On Wed, Nov 4, 2020 at 3:00 PM Hans-Peter Nilsson <h...@bitrange.com> wrote:
>
> On Wed, 4 Nov 2020, H.J. Lu wrote:
> > On Wed, Nov 4, 2020 at 1:56 PM Hans-Peter Nilsson <h...@bitrange.com> wrote:
> > > On Wed, 4 Nov 2020, H.J. Lu wrote:
> > >
> > > > On Wed, Nov 4, 2020 at 1:03 PM Hans-Peter Nilsson <h...@bitrange.com> 
> > > > wrote:
> > > > >
> > > > > On Wed, 4 Nov 2020, H.J. Lu wrote:
> > > > > > On Wed, Nov 4, 2020 at 10:09 AM Hans-Peter Nilsson 
> > > > > > <h...@bitrange.com> wrote:
> > > > > > > I'm not much more than a random voice, but an assembly directive
> > > > > > > that specifies the symbol (IIUC your .retain directive) to
> > > > > >
> > > > > > But .retain directive DOES NOT adjust symbol attribute.
> > >
> > > I see I missed to point out that I was speaking about the *gcc
> > > symbol* attribute "used".
> >
> > There is no such corresponding symbol attribute in ELF.
>
> I have not missed that, nor that SHF_GNU_RETAIN is so new that
> it's not in binutils master.  I have also not missed that gcc
> caters to other object formats too.  A common symbol-specific
> directive such as .retain, would be better than messing with
> section attributes, for gcc.

This is totally irrelevant to SHF_GNU_RETAIN.

> > > It's cleaner to the compiler if it can pass on to the assembler
> > > the specific symbol that needs to be kept.
> > >
> >
> > SHF_GNU_RETAIN is for section and GCC should place the symbol,
> > which should be kept, in the SHF_GNU_RETAIN section directly, not
> > through .retain directive.
>
> This is where opinions differ.  Anyway, this is now repetition;
> I'm done.

.retain is ill-defined.   For example,

[hjl@gnu-cfl-2 gcc]$ cat /tmp/x.c
static int xyzzy __attribute__((__used__));
[hjl@gnu-cfl-2 gcc]$ ./xgcc -B./ -S /tmp/x.c -fcommon
[hjl@gnu-cfl-2 gcc]$ cat x.s
.file "x.c"
.text
.retain xyzzy  <<<<<<<<< What does it do?
.local xyzzy
.comm xyzzy,4,4
.ident "GCC: (GNU) 11.0.0 20201103 (experimental)"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-cfl-2 gcc]$

A symbol directive should operate on the symbol table.
With 'R' flag, we got

.file "x.c"
.text
.section .bss.xyzzy,"awR",@nobits
.align 4
.type xyzzy, @object
.size xyzzy, 4
xyzzy:
.zero 4
.ident "GCC: (GNU) 11.0.0 20201104 (experimental)"
.section .note.GNU-stack,"",@progbits

-- 
H.J.

Reply via email to