[PATCH] D48329: [ELF] Support -z initfirst
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 19 11:15:02 PDT 2018
MaskRay created this revision.
MaskRay added reviewers: ruiu, echristo.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
glibc uses this option to link libpthread.so
glibc/nptl/Makefile:
LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D48329
Files:
ELF/Config.h
ELF/Driver.cpp
ELF/SyntheticSections.cpp
test/ELF/dt_flags.s
Index: test/ELF/dt_flags.s
===================================================================
--- test/ELF/dt_flags.s
+++ test/ELF/dt_flags.s
@@ -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
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -1239,6 +1239,8 @@
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)
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -784,6 +784,7 @@
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");
Index: ELF/Config.h
===================================================================
--- ELF/Config.h
+++ ELF/Config.h
@@ -172,6 +172,7 @@
bool ZCopyreloc;
bool ZExecstack;
bool ZHazardplt;
+ bool ZInitfirst;
bool ZKeepTextSectionPrefix;
bool ZNodelete;
bool ZNodlopen;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48329.151951.patch
Type: text/x-patch
Size: 2341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180619/6508fdc7/attachment.bin>
More information about the llvm-commits
mailing list