From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/4] Use LINK_OFF to access global data
Date: Fri, 1 Jan 2010 01:18:44 -0500 [thread overview]
Message-ID: <201001010118.45061.vapier@gentoo.org> (raw)
In-Reply-To: <OF7EEC72D7.43E7C3B7-ONC125769E.00078331-C125769E.0009144C@transmode.se>
On Thursday 31 December 2009 20:39:10 Joakim Tjernlund wrote:
> Mike Frysinger <vapier@gentoo.org> wrote on 31/12/2009 19:44:40:
> > On Wednesday 30 December 2009 10:08:30 Joakim Tjernlund wrote:
> > > --- a/common/cmd_nvedit.c
> > > +++ b/common/cmd_nvedit.c
> > > @@ -512,6 +512,7 @@ char *getenv (char *name)
> > > {
> > > int i, nxt;
> > >
> > > + name = LINK_OFF(name);
> > > WATCHDOG_RESET();
> > >
> > > for (i=0; env_get_char(i) != '\0'; i=nxt+1) {
> > > @@ -534,6 +535,7 @@ int getenv_r (char *name, char *buf, unsigned len)
> > > {
> > > int i, nxt;
> > >
> > > + name = LINK_OFF(name);
> > > for (i=0; env_get_char(i) != '\0'; i=nxt+1) {
> > > int val, n;
> >
> > you have no guarantee that getenv() is called with a const string which
> > is in the .rodata section. there's code that generates the env name in a
> > buffer on the stack and gives that to getenv(). does LINK_OFF() still
> > work then ?
>
> True. LINK_OFF will not work iff link addr != load addr and name isn't a
> const string. Basically if you want to use the LINK_OFF feature you have
> to use a const string.
some of the other functions in these patch sets fall into the same issue ...
like the output functions
> > > --- a/common/console.c
> > > +++ b/common/console.c
> > > @@ -346,7 +346,7 @@ void putc(const char c)
> > > }
> > > }
> > >
> > > -void puts(const char *s)
> > > +static void printf_puts(const char *s)
> > > {
> > > #ifdef CONFIG_SILENT_CONSOLE
> > > if (gd->flags & GD_FLG_SILENT)
> > > @@ -367,12 +367,18 @@ void puts(const char *s)
> > > }
> > > }
> > >
> > > +void puts(const char *s)
> > > +{
> > > + printf_puts(LINK_OFF(s));
> > > +}
> >
> > and if CONFIG_LINK_OFF isnt defined, does gcc correctly inline this ? if
> > not, i think there needs to be #ifdef CONFIG_LINK_OFF handling here.
>
> Possibly, however LINK_OFF is is a NOP if CONFIG_LINK_OFF isn't defined.
yes, but that doesnt mean gcc takes care of inlining all of printf_puts() into
the puts() and all the new call sites go to puts()
> > > --- a/lib_generic/crc32.c
> > > +++ b/lib_generic/crc32.c
> > > @@ -156,6 +156,11 @@
> > > */ uint32_t ZEXPORT crc32 (uint32_t crc, const Bytef *buf, uInt len) {
> > > +#ifdef LINK_OFF
> > > + const uint32_t *crc_tab = LINK_OFF(crc_table);
> > > +#else
> > > + const uint32_t *crc_tab = crc_table;
> > > +#endif
> >
> > the patch 1/4 you posted always defines LINK_OFF. it's CONFIG_LINK_OFF
> > which is dynamic.
>
> Yes, but LINK_OFF will work too. I can change this though, it looks better.
my point is that it should either be checking CONFIG_LINK_OFF or always using
LINK_OFF (since it nops when the config is off as you point out)
> The bigger question is if the LINN_OFF changes in general are acceptable to
> u-boot. Any board/arch that doesn't want this functionality should not
> notice I think.
i dont have any plans on wanting this, and it seems pretty invasive ... and
easy to introduce new code that breaks PIC people but no one else really
notices ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100101/53c5c142/attachment.pgp
next prev parent reply other threads:[~2010-01-01 6:18 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-30 15:08 [U-Boot] [PATCH 0/4] Make u-boot true PIC for ppc Joakim Tjernlund
2009-12-30 15:08 ` [U-Boot] [PATCH 1/4] ppc: Add const void *link_off(const void *addr) Joakim Tjernlund
2009-12-30 15:08 ` [U-Boot] [PATCH 2/4] Use LINK_OFF to access global data Joakim Tjernlund
2009-12-30 15:08 ` [U-Boot] [PATCH 3/4] Use LINK_OFF in enviroment too Joakim Tjernlund
2009-12-30 15:08 ` [U-Boot] [PATCH 4/4] ppc: Make mpc83xx start.S relative Joakim Tjernlund
2009-12-31 18:44 ` [U-Boot] [PATCH 2/4] Use LINK_OFF to access global data Mike Frysinger
2010-01-01 1:39 ` Joakim Tjernlund
2010-01-01 6:18 ` Mike Frysinger [this message]
2010-01-01 16:29 ` Joakim Tjernlund
2010-01-02 3:14 ` Mike Frysinger
2010-01-02 18:17 ` Wolfgang Denk
2010-01-03 10:48 ` Joakim Tjernlund
2010-01-02 18:13 ` Wolfgang Denk
2010-01-03 10:33 ` Joakim Tjernlund
2010-01-03 19:51 ` Wolfgang Denk
2010-01-03 20:06 ` Albert ARIBAUD
2010-01-03 20:17 ` Wolfgang Denk
2010-01-03 20:41 ` Albert ARIBAUD
2010-01-03 21:07 ` Wolfgang Denk
2010-01-04 6:54 ` Albert ARIBAUD
2010-01-03 22:29 ` Graeme Russ
2010-01-05 20:20 ` Scott Wood
2010-01-05 22:11 ` Joakim Tjernlund
2010-01-06 21:02 ` Scott Wood
2010-01-04 1:08 ` Joakim Tjernlund
2010-01-05 0:40 ` Mike Frysinger
-- strict thread matches above, loose matches on Subject: below --
2009-11-02 18:01 [U-Boot] [PATCH 0/4] Make u-boot true PIC for ppc Joakim Tjernlund
2009-11-02 18:01 ` [U-Boot] [PATCH 1/4] ppc: Add const void *link_off(const void *addr) Joakim Tjernlund
2009-11-02 18:01 ` [U-Boot] [PATCH 2/4] Use LINK_OFF to access global data Joakim Tjernlund
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=201001010118.45061.vapier@gentoo.org \
--to=vapier@gentoo.org \
--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