PREVAILING_DEF_IRONLY_EXP

Rafael Ávila de Espíndola respindola@mozilla.com
Fri Mar 18 05:15:00 GMT 2011


I am a bit confused about this new proposed resolution. The 
documentation says:

-----------------------
Any symbol marked PREVAILING_DEF must be defined in one object file 
added to the link after WPA is done, or an undefined symbol error will 
result. Any symbol marked PREVAILING_DEF_IRONLY may be left undefined 
(provided all references to the symbol have been removed), and the 
linker will not issue an error. Any symbol marked 
PREVAILING_DEF_IRONLY_EXP may be left undefined if the compiler 
determines that any dynamically-loaded shared object that would 
reference the symbol will provide its own definition of the symbol 
(e.g., the symbol is always defined in a COMDAT group).

---------------------------------

Why is PREVAILING_DEF_IRONLY_EXP needed? I think it can be solved with 
just PREVAILING_DEF if we say that the compiler can drop references to 
them if it knows they are provided in any DSO. The only case I can see 
where this would almost be a problem is something like

* file a.o is IL and has a symbol foo defined in a COMDAT
* file b.o is ELF and has both a use and a definition of foo

The linker decides to use the definition in a.o, gives the plugin a 
PREVAILING_DEF and the compiler drops it because it is COMDAT and it 
managed to optimize the uses.

The linker now has to satisfy the undefined reference is b.o with the 
definition in b.o. The definition is known to exist, since the compiler 
only drops symbols that are PREVAILING_DEF if they are available 
everywhere they are used.

Is there a case I am missing? Maybe a symbol that is defined in comdat 
in one file but can have an undefined reference without accompanying 
definition in another!?! If not, I would propose changing the text to

-----------------
Any symbol marked PREVAILING_DEF may be left undefined if the compiler 
determines that any object that would reference the symbol will provide 
its own definition of the symbol (e.g., the symbol is always defined in 
a COMDAT group). Any symbol marked PREVAILING_DEF_IRONLY may be left 
undefined (provided all references to the symbol have been removed), and 
the linker will not issue an error.
------------------

Cheers,
Rafael



More information about the Binutils mailing list