public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Bradley A. Bosch <bbosch@iphase.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] PPC ROM relocation and GCC GOT
Date: Sat, 1 Feb 2003 23:02:49 -0600	[thread overview]
Message-ID: <15932.42617.767500.276543@lachman.com> (raw)

Greetings,

The firmware update strategy we are planning for a product I am
working on will work best if we can pre-build U-Boot images which can
be run from either of two locations in ROM.  A very small piece of
code at the reset vector would choose the correct version to run.

It seems that the method GCC (eldk 2.0) uses for global variable
reference does not lend itself to such relocation.  The effect of the
current GCC generated code is to reference the variables at the
original linked address.  This is in spite of the fact that the GOT
itself is properly located by relative addressing techniques.  The GOT
can't be updated at runtime because, of course, it is in ROM.

Aside from our particular application, such "install time" relocation
(including to ROM) would seem a useful capability to have in a boot
loader.  I've only been working with the PPC a few months, so please
enlighten me I am completely wrong, but I don't see any way to cause
GCC to generate code for full code relative or even simple global
register+offset access to global constants.

I guess I could set up the BAT registers earlier and relocate the ROM
image back to it's linked location.  Is there any reason that wouldn't
work, at least for the MPC8241?

If GCC were just a bit more flexible, this might be easier.  Has
anyone else solved (or even tried to solve) this problem?

BTW, the U-Boot documentation and code which imply that r30 is used by
GCC to point to the GOT seem misleading.  R30 is indeed used for
access thru the GOT within each function, but r30 appears to be set up
independently at the beginning of each function.  In particular, I
don't see the point in updating r30 in the following code from
/cpu/mpc824x/start.S since it doesn't return to a C function anyway.

        /*
         * Fix GOT pointer:
         *
         * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
         *
         * Offset:
         */
        sub     r15, r10, r4

        /* First our own GOT */
        add     r14, r14, r15
        /* the the one used by the C code */
        add     r30, r30, r15

Have I missed something obvious?  Thanks for any insight anyone can
provide.

--Brad Bosch

             reply	other threads:[~2003-02-02  5:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-02  5:02 Bradley A. Bosch [this message]
2003-02-02 14:49 ` [U-Boot-Users] PPC ROM relocation and GCC GOT Thomas Lange

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=15932.42617.767500.276543@lachman.com \
    --to=bbosch@iphase.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