r338682 | emaste | 2018-09-14 17:15:16 +0200 (Fri, 14 Sep 2018) | 16 lines lld: add -z interpose support -z interpose sets the DF_1_INTERPOSE flag, marking the object as an interposer. Committed upstream as LLVM r342239. PR: 230604 Reported by: jbeich Reviewed by: markj Approved by: re (kib) MFC after: 1 week Relnotes: Yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D17172 Index: tools/lld/ELF/Config.h =================================================================== --- tools/lld/ELF/Config.h (revision 338681) +++ tools/lld/ELF/Config.h (revision 338682) @@ -183,6 +183,7 @@ struct Configuration { bool ZHazardplt; bool ZIfuncnoplt; bool ZInitfirst; + bool ZInterpose; bool ZKeepTextSectionPrefix; bool ZNodelete; bool ZNodlopen; Index: tools/lld/ELF/Driver.cpp =================================================================== --- tools/lld/ELF/Driver.cpp (revision 338681) +++ tools/lld/ELF/Driver.cpp (revision 338682) @@ -339,7 +339,7 @@ static bool getZFlag(opt::InputArgList &Args, StringRe static bool isKnown(StringRef S) { return S == "combreloc" || S == "copyreloc" || S == "defs" || S == "execstack" || S == "hazardplt" || S == "ifunc-noplt" || - S == "initfirst" || + S == "initfirst" || S == "interpose" || S == "keep-text-section-prefix" || S == "lazy" || S == "muldefs" || S == "nocombreloc" || S == "nocopyreloc" || S == "nodelete" || S == "nodlopen" || S == "noexecstack" || @@ -846,6 +846,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args Config->ZHazardplt = hasZOption(Args, "hazardplt"); Config->ZIfuncnoplt = hasZOption(Args, "ifunc-noplt"); Config->ZInitfirst = hasZOption(Args, "initfirst"); + Config->ZInterpose = hasZOption(Args, "interpose"); Config->ZKeepTextSectionPrefix = getZFlag( Args, "keep-text-section-prefix", "nokeep-text-section-prefix", false); Config->ZNodelete = hasZOption(Args, "nodelete"); Index: tools/lld/ELF/SyntheticSections.cpp =================================================================== --- tools/lld/ELF/SyntheticSections.cpp (revision 338681) +++ tools/lld/ELF/SyntheticSections.cpp (revision 338682) @@ -1266,6 +1266,8 @@ template void DynamicSection::final DtFlags |= DF_SYMBOLIC; if (Config->ZInitfirst) DtFlags1 |= DF_1_INITFIRST; + if (Config->ZInterpose) + DtFlags1 |= DF_1_INTERPOSE; if (Config->ZNodelete) DtFlags1 |= DF_1_NODELETE; if (Config->ZNodlopen)