From: J. William Campbell <jwilliamcampbell@comcast.net>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] Changing u-boot relocation scheme
Date: Fri, 25 Jul 2008 12:57:33 -0700 [thread overview]
Message-ID: <488A302D.1020408@comcast.net> (raw)
In-Reply-To: <20080725203517.2b940103@siona.local>
Haavard Skinnemoen wrote:
> On Fri, 25 Jul 2008 19:28:48 +0200
> kenneth johansson <kenneth@southpole.se> wrote:
>
>
>> I was afraid that what was needed was more or less a complete linker but
>> it looks like if one generate the dynamic reloc table a much simpler
>> linker(relocation function) is needed. Still probably a lot more complex
>> than the GOT and fixup code that is just a loop over a table. We may
>> need a case also ;-)
>>
>
>
First of all, you are correct that "fully linked" executables contain no
relocation information unless the user does something like
--emit-relocs. I was wrong about that.
> Hmm...looks like linking with -pie (or --pic-executable) does
> something vaguely resembling the trick. But I don't know what vintage
> of ld you need for this to be available and actually work...
>
> hskinnemoen at siona:~/work/u-boot/master$ avr32-linux-readelf -d u-boot
>
> Dynamic section at offset 0x1b8f0 contains 12 entries:
> Tag Type Name/Value
> 0x00000004 (HASH) 0x182ac
> 0x00000005 (STRTAB) 0x18260
> 0x00000006 (SYMTAB) 0x18150
> 0x0000000a (STRSZ) 74 (bytes)
> 0x0000000b (SYMENT) 16 (bytes)
> 0x00000003 (PLTGOT) 0x1ae70
> 0x70000001 (Processor Specific: 70000001) 0xe6c
> 0x00000015 (DEBUG) 0x0
> 0x00000007 (RELA) 0x1833c
> 0x00000008 (RELASZ) 6996 (bytes)
> 0x00000009 (RELAENT) 12 (bytes)
> 0x00000000 (NULL) 0x0
>
> The dynamic relocation section became surprisingly large. I wonder if
> we actually manage to manually relocate all those buggers...I checked a
> couple of them and in both cases it looked like something that needed
> to be relocated, but I couldn't find any code that actually did it.
>
> One example from common/cmd_itest.c:
>
> op_tbl_t op_table [] = {
> { "-lt", LT },
> { "<" , LT },
> { "-gt", GT },
> { ">" , GT },
> { "-eq", EQ },
> { "==" , EQ },
> { "-ne", NE },
> { "!=" , NE },
> { "<>" , NE },
> { "-ge", GE },
> { ">=" , GE },
> { "-le", LE },
> { "<=" , LE },
> };
>
> Does this really work without any relocation? Or is it being relocated
> and I'm just too blind to see it?
>
Is your u-boot built with -fPIC on all the C compiles? If so, op_table
references may work without any actual relocation if the distance from
the code segment to the segment containing op_table is not changed when
u-boot is "relocated" to the new address. If you look at the assembly
code for op_table being used, it may be done via an offset from the
start of the code + a register pointing to the start of the code. The
offset will not change when the code is moved, and the register will
contain the correct start of code address, so it works. If it is not
-fPIC, and it is not being executed at the address for which it was
linked, I have no idea how it would work without a "loader" relocating
all the references. There are "only" 583 relocation entries specified!
I think you are correct that the --pic-executable switch is the
"generic" way to get the relocation addresses. I expect it is much
better supported than the PPC specific compiler switches, because ld
needs to have the relocation data on all platforms. The only additional
requirement is for ld to actually output this data. It seems pretty
likely that this is implemented on all platforms, because at least a
subset of it is required for shared libraries and dynamically linked
executables.
Best Regards,
Bill Campbell
> The symbol tables can probably be made smaller with some careful
> ldscript tweaking.
>
> Haavard
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> U-Boot-Users mailing list
> U-Boot-Users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/u-boot-users
>
>
>
next prev parent reply other threads:[~2008-07-25 19:57 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-23 17:39 [U-Boot-Users] Changing u-boot relocation scheme vb
2008-07-23 21:46 ` Jerry Van Baren
2008-07-23 22:46 ` vb
2008-07-24 3:18 ` Wolfgang Denk
2008-07-24 6:45 ` vb
2008-07-24 9:58 ` Haavard Skinnemoen
2008-07-24 13:47 ` vb
2008-07-24 12:23 ` Jerry Van Baren
2008-07-24 12:47 ` Kenneth Johansson
2008-07-24 13:50 ` vb
2008-07-24 13:01 ` Wolfgang Denk
2008-07-24 13:17 ` Kenneth Johansson
2008-07-24 16:57 ` Haavard Skinnemoen
2008-07-24 17:12 ` Kenneth Johansson
2008-07-25 9:16 ` Haavard Skinnemoen
2008-07-24 17:37 ` vb
2008-07-24 18:09 ` Kenneth Johansson
2008-07-24 18:26 ` vb
2008-07-24 18:32 ` Joakim Tjernlund
2008-07-24 18:41 ` Kenneth Johansson
2008-07-25 4:28 ` Wolfgang Denk
2008-07-26 5:48 ` Grant Likely
2008-07-26 7:53 ` kenneth johansson
2008-07-26 12:48 ` Grant Likely
2008-07-25 4:28 ` Wolfgang Denk
2008-07-25 9:10 ` Haavard Skinnemoen
2008-07-25 11:55 ` kenneth johansson
2008-07-25 12:19 ` Haavard Skinnemoen
2008-07-25 13:30 ` Joakim Tjernlund
2008-07-26 5:36 ` Wolfgang Denk
2008-07-25 14:33 ` kenneth johansson
2008-07-25 14:51 ` vb
2008-07-25 15:21 ` Jerry Van Baren
2008-07-25 18:50 ` Haavard Skinnemoen
2008-07-25 19:03 ` Jerry Van Baren
2008-07-26 5:36 ` Wolfgang Denk
2008-07-26 16:09 ` Haavard Skinnemoen
2008-07-26 6:06 ` Grant Likely
2008-07-26 6:11 ` Grant Likely
2008-07-26 12:49 ` Wolfgang Denk
2008-07-26 5:36 ` Wolfgang Denk
2008-07-26 5:51 ` vb
2008-07-25 15:23 ` Haavard Skinnemoen
2008-07-25 16:31 ` kenneth johansson
2008-07-25 17:02 ` Jerry Van Baren
2008-07-25 17:28 ` kenneth johansson
2008-07-25 18:35 ` Haavard Skinnemoen
2008-07-25 19:57 ` J. William Campbell [this message]
2008-07-25 20:51 ` kenneth johansson
2008-07-26 15:54 ` Haavard Skinnemoen
2008-07-26 21:29 ` J. William Campbell
2008-07-26 21:58 ` Haavard Skinnemoen
2008-07-27 0:15 ` J. William Campbell
2008-07-26 5:36 ` Wolfgang Denk
2008-07-26 7:41 ` kenneth johansson
2008-07-26 12:49 ` Wolfgang Denk
2008-07-26 5:57 ` Grant Likely
2008-07-26 14:03 ` Jean-Christophe PLAGNIOL-VILLARD
2008-07-26 14:29 ` Joakim Tjernlund
2008-07-25 16:48 ` J. William Campbell
2008-07-25 4:28 ` Wolfgang Denk
2008-07-24 13:45 ` Jon Loeliger
2008-07-24 13:52 ` vb
2008-07-26 5:43 ` Grant Likely
2008-07-26 5:54 ` vb
2008-07-26 6:20 ` Grant Likely
2008-07-24 3:18 ` Wolfgang Denk
2008-07-24 6:20 ` Robert Schwebel
2008-09-15 14:56 ` [U-Boot] " vb
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=488A302D.1020408@comcast.net \
--to=jwilliamcampbell@comcast.net \
--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