conditional linkage ?

jim.cromie@gmail.com jim.cromie@gmail.com
Thu Mar 11 02:16:08 GMT 2021


On Fri, Mar 5, 2021 at 7:27 AM Nick Clifton <nickc@redhat.com> wrote:

> Hi Jim,
>
> > Id like to allow this linker script language:
> >
> >         KEEP( *(sectA_contents AND .gnu.linkonce.*.sectA_header) )
>
> I do not think that this is going to work.


I think I agree on several levels
1st, the specific $3 $1 ordering looks counter to what I thought,
 suggesting opposite semantics, like perls print if $expr;
2nd, when I tested
KEEP ( *(.gnulinkonce.*.sectA_header sectA_contents ) )
the linkage order didnt change.
I think if my inserted behavior were to work at all,
it would depend upon ordering.


> The nearest equivalent
> would be section groups where if both .sectA and .gnu.linkonce.sectA
> are in a group, then if .sectA is discarded (by linker garbage collection,
> because it is unused) then .gnu.linkonce.sectA will also be discarded.
>
>
that would be useful behavior -
I currently get headers for empty per-module tables
I re-read the man / info pages,
all group mentions seemed to be about archives

if groups exist to allow something like

{
._start_dyndbg = . ;
KEEP( __dyndbg)
._stop_dyndbg = . ;
._stop_dyndbg - .start_dynbg ? KEEP(__dyndbg_header) :
 }

then I missed all that.. (distracted by my need for interleaving)

I did try putting the "statements" (; terminated) inside the KEEP,
that failed hard.


But in general I do not think that the idea will work because this
> is not the sort of thing that the linker is built to do.  If you can
> break your table down into lots of small sections and then link them
> with garbage collection enabled you may achieve some of what you need.
> But I doubt if it will be a complete solution.  Sorry.


>
Cheers
>    Nick
>
> thank you Nick
Jim


More information about the Binutils mailing list