This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Reference to discarded section
>>>>> "Cary" == Cary Coutant <ccoutant@google.com> writes:
>> 1. What does this mean? 3. What causes a link-once section to be
>> discarded? There's nothing in ld.info that discusses that topic.
Cary> Linkonce sections (and the newer notion of comdat groups) are a
Cary> way for the compiler to emit template instantiations and
Cary> out-of-line inlined functions without worrying about lots of
Cary> duplicate copies in the linked output file. There may be a copy
Cary> of a given instantiated template function in many different
Cary> object files, but the linker will pick one and discard all the
Cary> others. In order for this to work, it's important that each
Cary> copy defines and references exactly the same set of
Cary> symbols. ...
Great. That would be nice material to have in the docs.
>> 2. How do I fix this?
Cary> Can you rearrange the object modules in the link to try to get
Cary> the linker to keep the section that defines the symbol you
Cary> need? Can you recompile the offending module with or without -g
Cary> (or see if you can match the compilation options with the the
Cary> other modules in your program)? Can you make sure that all the
Cary> modules are compiled with the same version of gcc? I'm not sure
Cary> if any of these will help, but they might.
That worked. I looked at the way the offending component was built
and noticed some extra GCC switches, including -fno-omit-frame-pointer
and some inlining controls. There wasn't a good reason for that
anyway so I took them out, and now the linker is happy.
Thanks much for the clear and helpful answer.
paul