This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Reference to discarded section


> 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.

Linkonce sections (and the newer notion of comdat groups) are a way
for the compiler to emit template instantiations and out-of-line
inlined functions without worrying about lots of duplicate copies in
the linked output file. There may be a copy of a given instantiated
template function in many different object files, but the linker will
pick one and discard all the others. In order for this to work, it's
important that each copy defines and references exactly the same set
of symbols. That's where the note about buggy old versions of gcc
comes in -- sometimes extra symbols are defined when different
compilation options are used (e.g., -g) or the set of symbols has
changed from one version of gcc to the next. What may be happening in
your case is that there's a reference from a non-linkonce section to a
symbol that's defined in some but not all copies of a particular
linkonce section. If the linker happens to discard the one with that
symbol and keep the one without that symbol, you get this error. I've
seen this for debug info sections, so ignoring the message might be
fairly benign.

> 2. How do I fix this?

Can you rearrange the object modules in the link to try to get the
linker to keep the section that defines the symbol you need? Can you
recompile the offending module with or without -g (or see if you can
match the compilation options with the the other modules in your
program)? Can you make sure that all the modules are compiled with the
same version of gcc? I'm not sure if any of these will help, but they
might.

-cary


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]