Index: lld/trunk/ELF/Config.h =================================================================== --- lld/trunk/ELF/Config.h +++ lld/trunk/ELF/Config.h @@ -172,6 +172,7 @@ bool ZCopyreloc; bool ZExecstack; bool ZHazardplt; + bool ZInitfirst; bool ZKeepTextSectionPrefix; bool ZNodelete; bool ZNodlopen; Index: lld/trunk/ELF/Driver.cpp =================================================================== --- lld/trunk/ELF/Driver.cpp +++ lld/trunk/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: lld/trunk/ELF/SyntheticSections.cpp =================================================================== --- lld/trunk/ELF/SyntheticSections.cpp +++ lld/trunk/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: lld/trunk/test/ELF/dt_flags.s =================================================================== --- lld/trunk/test/ELF/dt_flags.s +++ lld/trunk/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