1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
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 <class ELFT> void DynamicSection<ELFT>::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)
|