Specify section for whole .a static library

Jan Pohanka xhpohanka@gmail.com
Thu Apr 7 09:57:00 GMT 2011


Thank you for clarification,
I can't change the LDFLAGS position within my IDE but fortunately
including the .a files among other .o as input for linker solves the
problem. The only thing I have care for is to use exact the same and
relative paths of .a files in SECTION commads, because there is a
problem with absolute windows style paths interpretation.

regards
Jan

2011/4/7 Alan Modra <amodra@gmail.com>:
> On Thu, Apr 07, 2011 at 09:29:10AM +0200, Jan Pohanka wrote:
>> Ok. Next information.
>>
>> SECTIONS {
>>  .foo { slibrary.a(.text) }
>> }
>>
>> works when -Tskript.ld option is specified AFTER the input files eg.
>> gcc -o prog.exe a.o b.o -Tlinker.ld
>>
>> when it is before (gcc -Tlinker.ld -o prog.exe a.o b.o), symbols from
>> slibrary.a won't be found.
>>
>> If I specify the object files in linker scripts, e.g.
>>
>> SECTIONS {
>>  .foo { s*.o(.text) }
>> }
>>
>> linking works without regard to -T position on command line.
>>
>> The same situation occurs for INPUT, GROUP, ... commands.
>>
>> Is this expected behaviour?
>
> Yes, that't the way unix linkers work with static archives.  Files are
> extracted only when they satisfy some strong undefined symbol at the
> point where the linker searches the archive.
>
> --
> Alan Modra
> Australia Development Lab, IBM
>



More information about the Binutils mailing list