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
This commit is contained in:
emaste 2018-09-14 15:15:16 +00:00
parent b523ca8bfc
commit b60a07595c
4 changed files with 11 additions and 1 deletions

View File

@ -156,6 +156,7 @@ struct Configuration {
bool ZExecstack;
bool ZHazardplt;
bool ZIfuncnoplt;
bool ZInterpose;
bool ZNocopyreloc;
bool ZNodelete;
bool ZNodlopen;

View File

@ -670,6 +670,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
Config->ZExecstack = hasZOption(Args, "execstack");
Config->ZHazardplt = hasZOption(Args, "hazardplt");
Config->ZIfuncnoplt = hasZOption(Args, "ifunc-noplt");
Config->ZInterpose = hasZOption(Args, "interpose");
Config->ZNocopyreloc = hasZOption(Args, "nocopyreloc");
Config->ZNodelete = hasZOption(Args, "nodelete");
Config->ZNodlopen = hasZOption(Args, "nodlopen");

View File

@ -1034,6 +1034,8 @@ template <class ELFT> void DynamicSection<ELFT>::finalizeContents() {
uint32_t DtFlags1 = 0;
if (Config->Bsymbolic)
DtFlags |= DF_SYMBOLIC;
if (Config->ZInterpose)
DtFlags1 |= DF_1_INTERPOSE;
if (Config->ZNodelete)
DtFlags1 |= DF_1_NODELETE;
if (Config->ZNodlopen)

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 22, 2018
.Dd September 14, 2018
.Dt LD.LLD 1
.Os
.Sh NAME
@ -450,6 +450,12 @@ be applied by a run-time loader.
Note that this feature requires special loader support and will
generally result in application crashes when used outside of freestanding
environments.
.It Cm interpose
Set the
.Dv DF_1_INTERPOSE
flag to indicate that the object is an interposer.
Runtime linkers perform symbol resolution by first searching the application,
followed by interposers, and then any other dependencies.
.It Cm muldefs
Do not error if a symbol is defined multiple times.
The first definition will be used.