[lld] r335090 - [ELF] Support -z initfirst
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 19 19:06:01 PDT 2018
Author: maskray
Date: Tue Jun 19 19:06:01 2018
New Revision: 335090
URL: http://llvm.org/viewvc/llvm-project?rev=335090&view=rev
Log:
[ELF] Support -z initfirst
Summary:
glibc uses this option to link libpthread.so
glibc/nptl/Makefile:
LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst
Reviewers: ruiu, echristo, espindola
Subscribers: emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D48329
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/test/ELF/dt_flags.s
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=335090&r1=335089&r2=335090&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Tue Jun 19 19:06:01 2018
@@ -172,6 +172,7 @@ struct Configuration {
bool ZCopyreloc;
bool ZExecstack;
bool ZHazardplt;
+ bool ZInitfirst;
bool ZKeepTextSectionPrefix;
bool ZNodelete;
bool ZNodlopen;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=335090&r1=335089&r2=335090&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Jun 19 19:06:01 2018
@@ -784,6 +784,7 @@ void LinkerDriver::readConfigs(opt::Inpu
Config->ZCopyreloc = getZFlag(Args, "copyreloc", "nocopyreloc", true);
Config->ZExecstack = getZFlag(Args, "execstack", "noexecstack", false);
Config->ZHazardplt = hasZOption(Args, "hazardplt");
+ Config->ZInitfirst = hasZOption(Args, "initfirst");
Config->ZKeepTextSectionPrefix = getZFlag(
Args, "keep-text-section-prefix", "nokeep-text-section-prefix", false);
Config->ZNodelete = hasZOption(Args, "nodelete");
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=335090&r1=335089&r2=335090&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Tue Jun 19 19:06:01 2018
@@ -1239,6 +1239,8 @@ template <class ELFT> void DynamicSectio
uint32_t DtFlags1 = 0;
if (Config->Bsymbolic)
DtFlags |= DF_SYMBOLIC;
+ if (Config->ZInitfirst)
+ DtFlags1 |= DF_1_INITFIRST;
if (Config->ZNodelete)
DtFlags1 |= DF_1_NODELETE;
if (Config->ZNodlopen)
Modified: lld/trunk/test/ELF/dt_flags.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/dt_flags.s?rev=335090&r1=335089&r2=335090&view=diff
==============================================================================
--- lld/trunk/test/ELF/dt_flags.s (original)
+++ lld/trunk/test/ELF/dt_flags.s Tue Jun 19 19:06:01 2018
@@ -3,7 +3,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld -shared %t -o %t.so
-# RUN: ld.lld -z now -z nodelete -z nodlopen -z origin -Bsymbolic %t %t.so -o %t1
+# RUN: ld.lld -z initfirst -z now -z nodelete -z nodlopen -z origin -Bsymbolic %t %t.so -o %t1
# RUN: llvm-readobj -dynamic-table %t1 | FileCheck -check-prefix=FLAGS %s
# RUN: ld.lld %t %t.so -o %t2
@@ -14,12 +14,12 @@
# FLAGS: DynamicSection [
# FLAGS: 0x000000000000001E FLAGS ORIGIN SYMBOLIC BIND_NOW
-# FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE NOOPEN ORIGIN
+# FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE INITFIRST NOOPEN ORIGIN
# FLAGS: ]
# CHECK: DynamicSection [
-# CHECK-NOT: 0x000000000000001E FLAGS ORIGIN SYMBOLIC BIND_NOW
-# CHECK-NOT: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE NOOPEN ORIGIN
+# CHECK-NOT: FLAGS
+# CHECK-NOT: FLAGS_1
# CHECK: ]
.globl _start
More information about the llvm-commits
mailing list