public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jerry Van Baren <gerald.vanbaren@ge.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] Changing u-boot relocation scheme
Date: Wed, 23 Jul 2008 17:46:55 -0400	[thread overview]
Message-ID: <4887A6CF.9090404@ge.com> (raw)
In-Reply-To: <f608b67d0807231039i434e96dbvda86590776db2cb0@mail.gmail.com>

vb wrote:
> Wolfgang,
> 
> I wonder if you would consider (and accept a patch) changing the
> u-boot architecture as described below.
> 
> As we all are well aware u-boot is a great software package which
> speeds up bringing up new hardware immensely, its popularity is
> obviously growing very fast. One thing which (IMO anyway) slows down
> its acceptance is the way it handles relocating of itself into an
> arbitrary DRAM area. (Arbitrary meaning that it depends on many
> factors and the exact address can't be assigned ahead of time).

One thing (IMO anyway) that allows u-boot to Just Work[tm] is that it 
relocates itself to the best location available, automatically adjusting 
to the probed memory configuration.

There.  Fixed that.  ;-)

> While this relocation is seamless for u-boot in its released form, it
> becomes a pain each time a module needs to be added (not necessarily
> for following release to the Open Source community, for instance used
> for inhouse installations which include tens of thousand units for
> some companies). If these added modules were not written in position
> independent manner (namely, using structures with multiple stage
> indirect pointers interleaved with data), the effort to make these
> modules work in u-boot is very exhausting.

You lost me here.

What is a module?
How does a it relate to u-boot?
Why does it need to be relocated?
Why isn't it written in position independent manner?
How is your relocation methodology going to fixup a module's data 
structures?
What pointers are in your data structures?  Why do they need to be 
relocated?

> Here is the suggested alternative. I will talk about recent PPC
> platforms, but it could be done very similar for most of the other
> platforms I believe.
> 
> In general the PPC u-boot image consists of three parts: the bulk of
> code and data, the startup page (the top 4k mapped out of reset), and
> the reset vector (the top four bytes in the address space). The bulk
> is usually aligned at a certain address matching the bootprom size,
> and there is a gap between the bulk and the startup page.
> 
> Now, let's say we link and purge the bulk section twice, once locating
> it at offset 0 and once at the normal u-boot TEXT_BASE, building two
> binary images (not including the top 4k in both cases).
> 
> Then we compare the two images and identify all locations which are
> different. All these locations are 4 byte aligned, and all differ by
> the same amount - equal TEXT_BASE. Now we can build a table of offsets
> which need to be changed when the program is moved into a different
> location, include this table in the resulting image between the bulk
> and the startup page, and use this table when relocating code.


Gcc supports "proper" relocation, if only we knew how to make it work 
for all "reasonable" versions of gcc (and Grant's conclusion is that 
many versions of gcc in use today do *not* support the relocation).
   <http://article.gmane.org/gmane.comp.boot-loaders.u-boot/36343/>

Grant Likely created a patch that did this in the 1.3.0 timeframe, but 
ended up reverting it due to toolset problems - it was a patch before 
its time.

To read up on the history, follow this search:
<http://search.gmane.org/?query=relocation&author=grant+likely&group=gmane.comp.boot-loaders.u-boot&sort=date&DEFAULTOP=and&xP=Zreloc%09Zchang%09Zgrant%09Zlike&xFILTERS=Gcomp.boot-loaders.u-boot---A>

> Basically, this implements a poor man's loader, and it will be
> sufficient in case the image we are dealing with is a flat binary
> (which is of course the case with u-boot). This will allow to add any
> code to u-boot without much worries about being able to relocate it
> properly. We would do away with storing certain structures in certain
> sections, dealing with GOT, etc.
> 
> I made some experiments, and this seems feasible, this could be done
> as a local customization, but I would much prefer to release it to the
> u-boot community and make it part of mainline - will you consider such
> a patch?
> 
> Thank you for reading this far, please let me know what you think,

On one hand, your proposal sounds fairly simple and independent of the 
gcc version.  The primary cost would be extra build steps
1) Link at TEXT_BASE
2) Link at address 0
3) Binary diff the two to find addresses that need relocation
4) Rebuild with the diff table (compile the diff table and relink)

On the other hand, the skeptic in me says it ain't that easy.  Go ahead, 
prove me wrong.  ;-)

> Vadim

Best regards,
gvb

  reply	other threads:[~2008-07-23 21:46 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 [this message]
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
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=4887A6CF.9090404@ge.com \
    --to=gerald.vanbaren@ge.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