[llvm-dev] ThinLTO and linkonce_odr + unnamed_addr
Rafael Avila de Espindola via llvm-dev
llvm-dev at lists.llvm.org
Fri Feb 9 13:40:30 PST 2018
Steven Wu <stevenwu at apple.com> writes:
> Rafael, another question for you. IRLinker currently takes min visibility for the symbol (lib/Linker/LinkModules.cpp:120). Should it take the max visibility? At least that is what ld64 is doing and is somewhat related to this change because I want to make sure the behavior is consistent if we mark more stuff as hidden.
No, it should take the min visibility to be consistent with the ELF
spec. The spec says
If different visibility attributes are specified for distinct
references to or definitions of a symbol, the most constraining
visibility attribute must be propagated to the resolving symbol in the
linked object.
The reason the ELF spec mandates the minimum is that a .o having a
hidden symbol foo means that that file can access foo in a way that is
only valid under the assumption it is local. It not might change the pic
register before doing a call for example.
Cheers,
Rafael
More information about the llvm-dev
mailing list