[lld] r250225 - [ELF2] Add support for -Bsymbolic.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 13 14:02:34 PDT 2015
Author: davide
Date: Tue Oct 13 16:02:34 2015
New Revision: 250225
URL: http://llvm.org/viewvc/llvm-project?rev=250225&view=rev
Log:
[ELF2] Add support for -Bsymbolic.
Added:
lld/trunk/test/elf2/dt_flags.s
- copied, changed from r250221, lld/trunk/test/elf2/now.s
Removed:
lld/trunk/test/elf2/now.s
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Options.td
lld/trunk/ELF/OutputSections.cpp
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=250225&r1=250224&r2=250225&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Tue Oct 13 16:02:34 2015
@@ -44,6 +44,7 @@ struct Configuration {
std::vector<llvm::StringRef> SearchPaths;
bool AllowMultipleDefinition;
bool AsNeeded = false;
+ bool Bsymbolic;
bool DiscardAll;
bool DiscardLocals;
bool DiscardNone;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=250225&r1=250224&r2=250225&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Oct 13 16:02:34 2015
@@ -136,6 +136,7 @@ void LinkerDriver::createFiles(opt::Inpu
}
Config->AllowMultipleDefinition = Args.hasArg(OPT_allow_multiple_definition);
+ Config->Bsymbolic = Args.hasArg(OPT_Bsymbolic);
Config->DiscardAll = Args.hasArg(OPT_discard_all);
Config->DiscardLocals = Args.hasArg(OPT_discard_locals);
Config->DiscardNone = Args.hasArg(OPT_discard_none);
Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=250225&r1=250224&r2=250225&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Tue Oct 13 16:02:34 2015
@@ -1,5 +1,8 @@
include "llvm/Option/OptParser.td"
+def Bsymbolic: Flag<["-"], "Bsymbolic">,
+ HelpText<"Bind defined symbols locally">;
+
def Bdynamic: Flag<["-"], "Bdynamic">,
HelpText<"Link against shared libraries">;
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=250225&r1=250224&r2=250225&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Tue Oct 13 16:02:34 2015
@@ -293,8 +293,10 @@ template <class ELFT> void DynamicSectio
++NumEntries; // DT_INIT
if (FiniSym)
++NumEntries; // DT_FINI
- if (Config->ZNow)
+ if (Config->ZNow || Config->Bsymbolic)
++NumEntries; // DT_FLAGS_1
+ if (Config->Bsymbolic)
+ ++NumEntries; // DT_SYMBOLIC
++NumEntries; // DT_NULL
@@ -366,8 +368,13 @@ template <class ELFT> void DynamicSectio
if (FiniSym)
WritePtr(DT_FINI, getSymVA<ELFT>(*FiniSym));
+ uint32_t Flags = 0;
+ if (Config->Bsymbolic)
+ Flags |= DF_SYMBOLIC;
if (Config->ZNow)
- WriteVal(DT_FLAGS_1, DF_1_NOW);
+ Flags |= DF_1_NOW;
+ if (Flags)
+ WriteVal(DT_FLAGS_1, Flags);
WriteVal(DT_NULL, 0);
}
Copied: lld/trunk/test/elf2/dt_flags.s (from r250221, lld/trunk/test/elf2/now.s)
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/dt_flags.s?p2=lld/trunk/test/elf2/dt_flags.s&p1=lld/trunk/test/elf2/now.s&r1=250221&r2=250225&rev=250225&view=diff
==============================================================================
--- lld/trunk/test/elf2/now.s (original)
+++ lld/trunk/test/elf2/dt_flags.s Tue Oct 13 16:02:34 2015
@@ -2,17 +2,17 @@
# 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 %t %t.so -o %t1
+# RUN: ld.lld2 -z now -Bsymbolic %t %t.so -o %t1
# RUN: ld.lld2 %t %t.so -o %t2
-# RUN: llvm-readobj -dynamic-table %t1 | FileCheck -check-prefix=NOW %s
+# RUN: llvm-readobj -dynamic-table %t1 | FileCheck -check-prefix=FLAGS %s
# RUN: llvm-readobj -dynamic-table %t2 | FileCheck %s
-# NOW: DynamicSection [
-# NOW: 0x000000006FFFFFFB FLAGS_1 NOW
-# NOW: ]
+# FLAGS: DynamicSection [
+# FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW GLOBAL
+# FLAGS: ]
# CHECK: DynamicSection [
-# CHECK-NOT: 0x000000006FFFFFFB FLAGS_1 NOW
+# CHECK-NOT: 0x000000006FFFFFFB FLAGS_1 NOW GLOBAL
# CHECK: ]
.globl _start
Removed: lld/trunk/test/elf2/now.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/now.s?rev=250224&view=auto
==============================================================================
--- lld/trunk/test/elf2/now.s (original)
+++ lld/trunk/test/elf2/now.s (removed)
@@ -1,19 +0,0 @@
-# REQUIRES: x86
-
-# 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 %t %t.so -o %t1
-# RUN: ld.lld2 %t %t.so -o %t2
-# RUN: llvm-readobj -dynamic-table %t1 | FileCheck -check-prefix=NOW %s
-# RUN: llvm-readobj -dynamic-table %t2 | FileCheck %s
-
-# NOW: DynamicSection [
-# NOW: 0x000000006FFFFFFB FLAGS_1 NOW
-# NOW: ]
-
-# CHECK: DynamicSection [
-# CHECK-NOT: 0x000000006FFFFFFB FLAGS_1 NOW
-# CHECK: ]
-
-.globl _start
-_start:
More information about the llvm-commits
mailing list