public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] RFC: Let linker create phy array
Date: Fri, 10 Feb 2012 16:41:51 -0500	[thread overview]
Message-ID: <201202101641.53306.vapier@gentoo.org> (raw)
In-Reply-To: <4F3584CE.2010804@aribaud.net>

On Friday 10 February 2012 15:57:50 Albert ARIBAUD wrote:
> Le 10/02/2012 21:32, Mike Frysinger a ?crit :
> > On Friday 10 February 2012 14:39:12 Albert ARIBAUD wrote:
> >> Le 07/02/2012 16:20, Mike Frysinger a ?crit :
> >>> On Monday 06 February 2012 16:01:56 Albert ARIBAUD wrote:
> >>>> Le 06/02/2012 21:57, Mike Frysinger a ?crit :
> >>>>>> Is there a keep attribute like the linker has for sections?
> >>>>> 
> >>>>> yes, __attribute__((used))
> >>>> 
> >>>> What is the point in adding a 'static' qualifier and a ((used))
> >>>> attribute, when not adding them in the first place gives the same
> >>>> result?
> >>> 
> >>> to control the visibility
> >> 
> >> I don't understand what you mean with this. Can you please elaborate?
> > 
> > no static means it has global elf visibility (other .c files can "extern"
> > it, and you have to worry about symbol clashes):
> > $ gcc -x c -c - -o test.o<<<'int foo;'&&  readelf -s test.o | grep foo
> > 
> >       7: 0000000000000004     4 OBJECT  GLOBAL DEFAULT  COM foo
> > 
> > static means it has local elf visibility (other files don't get access,
> > and you don't have to worry about symbol clashes):
> > $ gcc -x c -c - -o test.o<<<'static int foo;'&&  readelf -s test.o | grep
> > foo
> > 
> >       5: 0000000000000000     4 OBJECT  LOCAL  DEFAULT    3 foo
> > 
> > imo, anything that should not be externally accessed should have
> > "static". this is just good programming practice.
> 
> I would agree 100% if the symbol was truly local, i.e. declared *and
> used* locally. Here, however, it is used globally, by being gathered in
> a global section to serve as an entry in a global array.

except access is now explicitly gated, and symbol collisions are still 
prevented

> The only interest of making the symbol static would indeed be to allow
> reusing the symbol name elsewhere, which I think is quite improbable
> considering the symbol was global so far.

one or two might be global, but for the most part, they were all local.  look 
at his patch ... he deletes the "static" keyword in many places.

this style i'm proposing has been used in the kernel in subsystems, and some 
of them end up using the same variable name in diff modules.  like crypto/ 
which uses "alg" as the name for all of its shash drivers.

> So we add the static qualifier despite the object actually not being
> static; and because the object is not actually static, that qualifier
> causes a legit diagnostic; and to eliminate that diagnostic, we add an
> 'unused' attribute. This I find less than good programming practice.

no, the unused attribute was added *after* removing "static".  i'm proposing 
adding "used" so gcc won't strip it regardless of what else happens while 
retaining all other benefits that "static" brings us.
-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/20120210/0130816d/attachment.pgp>

  reply	other threads:[~2012-02-10 21:41 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-05  3:02 [U-Boot] [PATCH 1/2] RFC: create u-boot-common.lds Troy Kisky
2012-02-05  3:02 ` [U-Boot] [PATCH 2/2] RFC: Let linker create phy array Troy Kisky
2012-02-05  3:38   ` Mike Frysinger
2012-02-05  6:16     ` Dirk Behme
2012-02-05 13:26     ` Albert ARIBAUD
2012-02-05 20:40       ` Mike Frysinger
2012-02-06 20:53         ` Albert ARIBAUD
2012-02-06 18:48     ` Troy Kisky
2012-02-06 19:07       ` Mike Frysinger
2012-02-06 20:17         ` Troy Kisky
2012-02-06 20:56           ` Albert ARIBAUD
2012-02-06 20:57           ` Mike Frysinger
2012-02-06 21:01             ` Albert ARIBAUD
2012-02-07 15:20               ` Mike Frysinger
2012-02-10 19:39                 ` Albert ARIBAUD
2012-02-10 20:32                   ` Mike Frysinger
2012-02-10 20:57                     ` Albert ARIBAUD
2012-02-10 21:41                       ` Mike Frysinger [this message]
2012-02-12 14:45                         ` Albert ARIBAUD
2012-02-06 21:44             ` Troy Kisky
2012-02-07 15:21               ` Mike Frysinger
2012-02-05 21:01 ` [U-Boot] [PATCH 1/2] RFC: create u-boot-common.lds Mike Frysinger
2012-02-05 22:07   ` Graeme Russ
2012-02-06  3:24     ` Mike Frysinger
2012-02-06  3:43       ` Graeme Russ
2012-02-06  4:27         ` Mike Frysinger
2012-02-06  4:34           ` Graeme Russ
2012-02-06  5:48             ` Mike Frysinger

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=201202101641.53306.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