From: Shinya Kuribayashi <skuribay@ruby.dti.ne.jp>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] Off-by-two bug when relocating GOT
Date: Mon, 15 Oct 2007 00:57:53 +0900 [thread overview]
Message-ID: <47123C81.6050902@ruby.dti.ne.jp> (raw)
In-Reply-To: <470E9E70.7060508@comsys.ro>
Vlad Lungu wrote:
>> + .got : {
>> + _gp = .;
>> + __got_start = .;
>> + *(.got)
>> + __got_end = .;
>> + }
> [snip]
> That doesn't look right. Don't put _gp inside .got section.
Agreed, will fix.
>>> One more point: loading $gp with _GLOBAL_OFFSET_TABLE_ is not a
>>> good idea, it should be loaded with _gp. The value
>>> is the same at the moment, but it's not guaranteed at all,
>>> someone could start playing with the link scripts and break this.
>>>
>> Hmm, I have to consider more.
Thanks for your comment. Now investigating further, so I need some time.
> Here's a good example:
>
> http://www.sourceware.org/ml/ecos-discuss/2004-02/msg00327.html
>
> There are some sections (.sdata/.sbss/.scommon) that contain objects
> referenced via $gp and not via GOT.
>
> Try nm -n -f sysv u-boot|grep scommon.
This is caused by lacking of -G0 in PLATFORM_LDFLAGS. I'm preparing a
patch as below, and will submit for review in the near future.
diff --git a/mips_config.mk b/mips_config.mk
index d8aa5fa..93324ad 100644
--- a/mips_config.mk
+++ b/mips_config.mk
@@ -22,3 +22,36 @@
#
PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__
+
+#
+# GCC uses -G 0 -mabicalls -fpic as default. We don't want PIC in the kernel
+# code since it only slows down the whole thing. At some point we might make
+# use of global pointer optimizations but their use of $28 conflicts with
+# the current pointer optimization.
+#
+# The DECStation requires an ECOFF kernel for remote booting, other MIPS
+# machines may also. Since BFD is incredibly buggy with respect to
+# crossformat linking we rely on the elf2ecoff tool for format conversion.
+#
+#cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
+#cflags-y += -msoft-float
+#LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
+#MODFLAGS += -mlong-calls
+#
+# But we U-Boot rely on PIC and need abicalls for now.
+#
+PLATFORM_CPPFLAGS += -G 0 -mabicalls -fpic -pipe
+PLATFORM_CPPFLAGS += -msoft-float
+PLATFORM_LDFLAGS += -G 0 -static -n -nostdlib
+
+PLATFORM_CPPFLAGS += -ffreestanding
+
According to mail archives of binutils, linux-mips, etc., GCC for MIPS
uses -G 0 as default, but ld does not. If calling ld directly, you need
to pass -G 0 explicitly like Linux. As a result, we'll get no small data.
That's all for now.
thanks,
Shinya
next prev parent reply other threads:[~2007-10-14 15:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-04 17:45 [U-Boot-Users] [PATCH] Off-by-two bug when relocating GOT Vlad Lungu
2007-10-05 3:58 ` Shinya Kuribayashi
2007-10-05 10:39 ` Vlad Lungu
2007-10-05 20:18 ` Thomas Lange
2007-10-05 22:31 ` Vlad Lungu
2007-10-06 0:20 ` Thomas Lange
2007-10-06 12:27 ` Vlad Lungu
2007-10-11 20:04 ` Shinya Kuribayashi
2007-10-11 22:06 ` Vlad Lungu
2007-10-12 10:20 ` Vlad Lungu
2007-10-14 15:57 ` Shinya Kuribayashi [this message]
2007-10-14 19:00 ` Vlad Lungu
2007-10-16 18:19 ` [U-Boot-Users] _gp in current u-boot.lds for MIPS ports Wolfgang Denk
2007-10-16 19:13 ` Vlad Lungu
2007-10-16 20:15 ` Andrew Dyer
2007-10-17 14:27 ` Shinya Kuribayashi
2007-10-17 14:23 ` Shinya Kuribayashi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47123C81.6050902@ruby.dti.ne.jp \
--to=skuribay@ruby.dti.ne.jp \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.