From: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] Changing u-boot relocation scheme
Date: Fri, 25 Jul 2008 17:23:34 +0200 [thread overview]
Message-ID: <20080725172334.13ee6301@siona.local> (raw)
In-Reply-To: <1216996436.7972.14.camel@duo>
On Fri, 25 Jul 2008 16:33:56 +0200
kenneth johansson <kenneth@southpole.se> wrote:
> On Fri, 2008-07-25 at 14:19 +0200, Haavard Skinnemoen wrote:
> > On Fri, 25 Jul 2008 13:55:58 +0200
> > kenneth johansson <kenneth@southpole.se> wrote:
> >
> > > > An ELF shared library has the dynamic relocations we need. So if we
> > > > build u-boot as an .so file, it should work in theory on most
> > > > architectures.
> > >
> > > well the elf binary of u-boot obviously has everything we need
> > > regardless of what options it was compiled with. If we had a full linker
> > > at runtime we could just do a relink to whatever address we wanted.
> >
> > No we couldn't if we don't have any relocation information. Just as you
> > can't relink just any ELF binary to run at a different location after
> > it's been through a final link, no matter how "full" the linker is.
>
> Take time and READ what people write. I wrote compiler option and you go
> on about some final link that removes the relocation information. My
> point was that it is irrelevant if you use pic shared whatever if you
> are going to use the elf relocation information anyway granted you have
> less work to do if the object was compiled as PIC.
Oh, you're talking about some hypothetical u-boot binary that hasn't
been through the linker? How exactly do you generate it?
Besides, I talked about compiler options too (in the paragraph you cut
out). If you don't compile the code with -fPIC, most linkers won't be
able to make the result relocatable no matter what options you specify.
> > > It sounds a bit easier to just loop over a list of pointers and change
> > > the values than to implement a complete linker but maybe that is just
> > > me.
> >
> > The question remains how should that list of pointers be generated? One
> > possible answer is to let the linker do it (as dynamic relocations).
>
> Since I have not done a linker I probably miss some information on what
> makes the dynamic relocations so special ??
Yes, you probably do. Dynamic relocations are quite special as they are
intended for the _runtime_ system, not the linker. Therefore, they are
included in a loadable segment so that the program itself or the
dynamic loader can go through them and perform fixups at runtime.
Also, most platforms only allow a small handful of relocation types to
be used as dynamic relocations. This makes the job of the dynamic
loader much easier than that of the linker.
> And could you outline how the last step in generating the binary image
> would work.
That's basically the question I've been trying to ask for some time. On
PowerPC, I assume -mrelocatable does the trick. On other platforms, I
just don't know.
> now it works as follows. One final static link with all the .a files and
> a specified start address for TEXT. result is a elf file with al symbols
> resolved adn it can be relinked to another address if one wants but we
> use objcopy to make a binary.
Have you ever _tried_ to relink the final u-boot ELF file to another
address? How do you do that?
> here is a patch to generate dynamic relocations in the elf file. What is
> the next step? objcopy -j .rela.dyn -O binary u-boot dyn_reloc_table ??
Might actually work, though we might need more linker options as well.
At least -Bsymbolic comes to mind. And I'm not sure if -Bstatic goes
well along with -shared...
In any case, there's no next step. The dynamic relocations are included
in a loadable segment, so they will end up in the .bin file after the
last objcopy step.
There will obviously be a fair amount of arch-specific code required to
make the actual relocation work though.
Haavard
next prev parent reply other threads:[~2008-07-25 15:23 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 [this message]
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
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=20080725172334.13ee6301@siona.local \
--to=haavard.skinnemoen@atmel.com \
--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