public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Kenneth Johansson <kenneth@southpole.se>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] Changing u-boot relocation scheme
Date: Thu, 24 Jul 2008 14:47:59 +0200	[thread overview]
Message-ID: <1216903679.27201.25.camel@localhost.localdomain> (raw)
In-Reply-To: <f608b67d0807232345r482792b6lbc9bd6804f48e597@mail.gmail.com>


On Wed, 2008-07-23 at 23:45 -0700, vb wrote:
> Wolfgang, thank you for your reply, let me try to explain myself a bit clearer:
> 
> On Wed, Jul 23, 2008 at 8:18 PM, Wolfgang Denk <wd@denx.de> wrote:
> > In message <f608b67d0807231039i434e96dbvda86590776db2cb0@mail.gmail.com> you wrote:
> >
> >> 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.
> >
> > I don't understand what you mean. Either you link statically with the
> > U-Boot image, or you use standalone programs. In both situations no
> > such problem as described by you exists.
> >
> 
> we talk here about modules statically linked into the u-boot image.
> Allow me to illustrate the problem I am trying to solve. Consider
> adding this code to a u-boot source file on a ppc460gt platform:
> 
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> 87a88,105
> >
> > int do_ptrt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
> >
> > int  (*pf)(struct cmd_tbl_s *, int, int, char *[]) = do_ptrt;
> >
> > int do_ptrt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
> > {
> >       printf ("pointer is %p\n", pf);
> >       printf ("function is %p\n", do_ptrt);
> >       return 0;
> > }
> >
> > U_BOOT_CMD(
> >       ptrt, CFG_MAXARGS, 1,   do_ptrt,
> >       "ptrt\n",
> >       ""
> > );
> >
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> And this is what happens when this command is invoked:
> 
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> => ptrt
> pointer is fffb2754
> function is 0ffb7754
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> So, the value of 'pf' is equal to the address of do_ptrt() *before*
> relocation. The fact that there is a GOT and a sophisticated linker
> script did not prevent this from happening.


This is due to a u-boot on powerpc not doing the right things when it is
relocating itself. The code to do the right things exist but is
currently disabled.  

What is missing right now is that to properly fix function pointers
stored in data section we have to compile with -mrelocatable flag to get
gcc to create a fixup table so we later at runtime can just go over that
table and correct all function pointers. 

This is currently not done as there was some problems with it that
people thought was due to toolchain issue. I'm not so sure it is, the
code to generate this fixup has been in gcc since mid 90's and has not
seen many changes and the linker should not have to know about it as
it's just a normal relocataion for it. My take is that some targets did
something special with trying to fixup some pointers themselves and fail
when it's done correctly.

this is the only issue I'm aware of regarding relocation and if you
enable this for your board all your problems goes away. 

  parent reply	other threads:[~2008-07-24 12:47 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 [this message]
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=1216903679.27201.25.camel@localhost.localdomain \
    --to=kenneth@southpole.se \
    --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