[lld] r265717 - ELF: Add --no-gnu-unique option.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 7 13:41:41 PDT 2016
Author: ruiu
Date: Thu Apr 7 15:41:41 2016
New Revision: 265717
URL: http://llvm.org/viewvc/llvm-project?rev=265717&view=rev
Log:
ELF: Add --no-gnu-unique option.
When the option is specified, then all STB_GNU_UNIQUE symbols are
converted to STB_GLOBAL symbols.
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Options.td
lld/trunk/ELF/OutputSections.cpp
lld/trunk/test/ELF/gnu-unique.s
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=265717&r1=265716&r2=265717&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Thu Apr 7 15:41:41 2016
@@ -67,6 +67,7 @@ struct Configuration {
bool GnuHash = false;
bool ICF;
bool Mips64EL = false;
+ bool NoGnuUnique;
bool NoUndefined;
bool NoinhibitExec;
bool Pic;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=265717&r1=265716&r2=265717&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Thu Apr 7 15:41:41 2016
@@ -282,6 +282,7 @@ void LinkerDriver::readConfigs(opt::Inpu
Config->ExportDynamic = Args.hasArg(OPT_export_dynamic);
Config->GcSections = Args.hasArg(OPT_gc_sections);
Config->ICF = Args.hasArg(OPT_icf);
+ Config->NoGnuUnique = Args.hasArg(OPT_no_gnu_unique);
Config->NoUndefined = Args.hasArg(OPT_no_undefined);
Config->NoinhibitExec = Args.hasArg(OPT_noinhibit_exec);
Config->Pie = Args.hasArg(OPT_pie);
Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=265717&r1=265716&r2=265717&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Thu Apr 7 15:41:41 2016
@@ -91,6 +91,9 @@ def no_as_needed : Flag<["--"], "no-as-n
def no_demangle: Flag<["--"], "no-demangle">,
HelpText<"Do not demangle symbol names">;
+def no_gnu_unique : Flag<["--"], "no-gnu-unique">,
+ HelpText<"Disable STB_GNU_UNIQUE symbol binding">;
+
def no_whole_archive : Flag<["--", "-"], "no-whole-archive">,
HelpText<"Restores the default behavior of loading archive members">;
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=265717&r1=265716&r2=265717&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Thu Apr 7 15:41:41 2016
@@ -1515,6 +1515,8 @@ uint8_t SymbolTableSection<ELFT>::getSym
uint8_t Visibility = Body->getVisibility();
if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED)
return STB_LOCAL;
+ if (Config->NoGnuUnique && Body->Binding == STB_GNU_UNIQUE)
+ return STB_GLOBAL;
return Body->Binding;
}
Modified: lld/trunk/test/ELF/gnu-unique.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gnu-unique.s?rev=265717&r1=265716&r2=265717&view=diff
==============================================================================
--- lld/trunk/test/ELF/gnu-unique.s (original)
+++ lld/trunk/test/ELF/gnu-unique.s Thu Apr 7 15:41:41 2016
@@ -1,7 +1,11 @@
+// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
+//
// RUN: ld.lld %t -shared -o %tout.so
-// RUN: llvm-readobj -dyn-symbols %tout.so | FileCheck %s
-// REQUIRES: x86
+// RUN: llvm-readobj -dyn-symbols %tout.so | FileCheck -check-prefix=GNU %s
+//
+// RUN: ld.lld %t -shared -o %tout.so --no-gnu-unique
+// RUN: llvm-readobj -dyn-symbols %tout.so | FileCheck -check-prefix=NO %s
// Check that STB_GNU_UNIQUE is treated as a global and ends up in the dynamic
// symbol table as STB_GNU_UNIQUE.
@@ -14,11 +18,20 @@ _start:
.type symb, @gnu_unique_object
symb:
-# CHECK: Name: symb@
-# CHECK-NEXT: Value:
-# CHECK-NEXT: Size: 0
-# CHECK-NEXT: Binding: Unique
-# CHECK-NEXT: Type: Object
-# CHECK-NEXT: Other: 0
-# CHECK-NEXT: Section: .data
-# CHECK-NEXT: }
+# GNU: Name: symb@
+# GNU-NEXT: Value:
+# GNU-NEXT: Size: 0
+# GNU-NEXT: Binding: Unique
+# GNU-NEXT: Type: Object
+# GNU-NEXT: Other: 0
+# GNU-NEXT: Section: .data
+# GNU-NEXT: }
+
+# NO: Name: symb@
+# NO-NEXT: Value:
+# NO-NEXT: Size: 0
+# NO-NEXT: Binding: Global
+# NO-NEXT: Type: Object
+# NO-NEXT: Other: 0
+# NO-NEXT: Section: .data
+# NO-NEXT: }
More information about the llvm-commits
mailing list