From: Vlad Lungu <vlad@comsys.ro>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] Off-by-two bug when relocating GOT
Date: Fri, 12 Oct 2007 01:06:40 +0300 [thread overview]
Message-ID: <470E9E70.7060508@comsys.ro> (raw)
In-Reply-To: <470E81C4.8080908@ruby.dti.ne.jp>
Shinya Kuribayashi wrote:
[snip]
> Here's my proposal for RFC. This patch fixes
>
> 1) __got_start and _GLOBAL_OFFSET_TABLE_ miss-alignment, and
>
> 2) duplicated .sdata declaration.
>
[snip]
>
> + .got : {
>
> + _gp = .;
>
> + __got_start = .;
>
> + *(.got)
>
> + __got_end = .;
>
> + }
[snip]
That doesn't look right. Don't put _gp inside .got section.
>
> I think this style is easier to understand than before.
>
> But I'm still wondering where _gp can be used?
>
> Any comments are welcome.
>
>
It should be loaded into the $gp register.
> got[0](=0x00000000) and got[1](=0x80000000) are always reserved by
>
> GNU ld. When updating the contents of GOT entries at in_ram:, leave
>
> first two entries as they are. This is the reason for skipping two
>
> entries. And as you know, this is nothing related with corrupting
>
> command table. That's caused by relocation itself, not by updating
>
> GOT entries.
>
>
.got it :-)
>> 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.
>
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.
I can also send you a patch with _gp != __got_start , and if you don't
load $gp with _gp but with __got_start, it will crash and
burn when doing
/* Initialize any external memory.
*/
la t9, lowlevel_init
jalr t9
It will actually jump to _serial_puts(), believe it or not.
Vlad
next prev parent reply other threads:[~2007-10-11 22:06 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 [this message]
2007-10-12 10:20 ` Vlad Lungu
2007-10-14 15:57 ` Shinya Kuribayashi
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=470E9E70.7060508@comsys.ro \
--to=vlad@comsys.ro \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox