[lld] r250907 - [ELF2] Add support for -z origin.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 21 10:09:48 PDT 2015
Author: davide
Date: Wed Oct 21 12:09:47 2015
New Revision: 250907
URL: http://llvm.org/viewvc/llvm-project?rev=250907&view=rev
Log:
[ELF2] Add support for -z origin.
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/OutputSections.cpp
lld/trunk/test/elf2/dt_flags.s
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=250907&r1=250906&r2=250907&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Wed Oct 21 12:09:47 2015
@@ -59,6 +59,7 @@ struct Configuration {
bool Verbose;
bool ZNodelete = false;
bool ZNow = false;
+ bool ZOrigin = false;
ELFKind EKind = ELFNoneKind;
uint16_t EMachine = llvm::ELF::EM_NONE;
uint64_t EntryAddr = -1;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=250907&r1=250906&r2=250907&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Wed Oct 21 12:09:47 2015
@@ -163,6 +163,8 @@ void LinkerDriver::createFiles(opt::Inpu
Config->ZNodelete = true;
else if (Arg->getValue() == StringRef("now"))
Config->ZNow = true;
+ else if (Arg->getValue() == StringRef("origin"))
+ Config->ZOrigin = true;
}
for (auto *Arg : Args) {
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=250907&r1=250906&r2=250907&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Oct 21 12:09:47 2015
@@ -349,9 +349,9 @@ template <class ELFT> void DynamicSectio
++NumEntries; // DT_INIT
if (FiniSym)
++NumEntries; // DT_FINI
- if (Config->Bsymbolic || Config->ZNow)
+ if (Config->Bsymbolic || Config->ZNow || Config->ZOrigin)
++NumEntries; // DT_FLAGS
- if (Config->ZNodelete || Config->ZNow)
+ if (Config->ZNodelete || Config->ZNow || Config->ZOrigin)
++NumEntries; // DT_FLAGS_1
++NumEntries; // DT_NULL
@@ -434,6 +434,8 @@ template <class ELFT> void DynamicSectio
Flags |= DF_SYMBOLIC;
if (Config->ZNow)
Flags |= DF_BIND_NOW;
+ if (Config->ZOrigin)
+ Flags |= DF_ORIGIN;
if (Flags)
WriteVal(DT_FLAGS, Flags);
Flags = 0;
@@ -441,6 +443,8 @@ template <class ELFT> void DynamicSectio
Flags |= DF_1_NODELETE;
if (Config->ZNow)
Flags |= DF_1_NOW;
+ if (Config->ZOrigin)
+ Flags |= DF_1_ORIGIN;
if (Flags)
WriteVal(DT_FLAGS_1, Flags);
Modified: lld/trunk/test/elf2/dt_flags.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/dt_flags.s?rev=250907&r1=250906&r2=250907&view=diff
==============================================================================
--- lld/trunk/test/elf2/dt_flags.s (original)
+++ lld/trunk/test/elf2/dt_flags.s Wed Oct 21 12:09:47 2015
@@ -2,19 +2,19 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld2 -shared %t -o %t.so
-# RUN: ld.lld2 -z now -z nodelete -Bsymbolic %t %t.so -o %t1
+# RUN: ld.lld2 -z now -z nodelete -z origin -Bsymbolic %t %t.so -o %t1
# RUN: ld.lld2 %t %t.so -o %t2
# RUN: llvm-readobj -dynamic-table %t1 | FileCheck -check-prefix=FLAGS %s
# RUN: llvm-readobj -dynamic-table %t2 | FileCheck %s
# FLAGS: DynamicSection [
-# FLAGS: 0x000000000000001E FLAGS SYMBOLIC BIND_NOW
-# FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE
+# FLAGS: 0x000000000000001E FLAGS ORIGIN SYMBOLIC BIND_NOW
+# FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE ORIGIN
# FLAGS: ]
# CHECK: DynamicSection [
-# CHECK-NOT: 0x000000000000001E FLAGS SYMBOLIC BIND_NOW
-# CHECK-NOT: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE
+# CHECK-NOT: 0x000000000000001E FLAGS ORIGIN SYMBOLIC BIND_NOW
+# CHECK-NOT: 0x000000006FFFFFFB FLAGS_1 NOW NODELETE ORIGIN
# CHECK: ]
.globl _start
More information about the llvm-commits
mailing list