This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Hiding symbols in a static library
Erik de Castro Lopo <mle+tools@mega-nerd.com> writes:
> Ken Raeburn wrote:
>
>> Right, there's nothing to cause any of the objects to get pulled in
>> from the archive libraries; "--retain-symbols-file" is just about
>> trimming the symbol table. Add "-u symbol" options for specific
>> symbols, or "--whole-archive" to just suck in everything.
>
> Thanks, --whole-archive helps.
>
>> Hm, that ought to work, I think... Check closely -- is it exporting
>> them as global symbols, or retaining them after converting to local
>> symbols so that they can still be used in relocations within the
>> output file?
>
> I'm not sure, I've been looking at the output of
>
> nm -g whatever.o
>
> Is there a better way of figuring out what is being exported and what
> isn't?
It may be that --retain-symbols-file keeps symbol which have
relocations and does not convert them to local. I haven't checked.
You may need to follow it with a call to objcopy --localize-symbols.
Or just skip --retain-symbols-file, --localize-symbols should do the
job (on a single object file produced by ld -r --whole-archive).
Ian