[lld] r324145 - Add --no-gnu-unique and --no-undefined-version for completeness.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 2 13:44:06 PST 2018
Author: ruiu
Date: Fri Feb 2 13:44:06 2018
New Revision: 324145
URL: http://llvm.org/viewvc/llvm-project?rev=324145&view=rev
Log:
Add --no-gnu-unique and --no-undefined-version for completeness.
Differential Revision: https://reviews.llvm.org/D42865
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Options.td
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/ELF/Symbols.cpp
lld/trunk/test/ELF/gnu-unique.s
lld/trunk/test/ELF/version-script-noundef.s
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=324145&r1=324144&r2=324145&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Fri Feb 2 13:44:06 2018
@@ -124,6 +124,7 @@ struct Configuration {
bool GcSections;
bool GdbIndex;
bool GnuHash = false;
+ bool GnuUnique;
bool HasDynamicList = false;
bool HasDynSymTab;
bool ICF;
@@ -131,8 +132,6 @@ struct Configuration {
bool IgnoreFunctionAddressEquality;
bool MergeArmExidx;
bool MipsN32Abi = false;
- bool NoGnuUnique;
- bool NoUndefinedVersion;
bool NoinhibitExec;
bool Nostdlib;
bool OFormatBinary;
@@ -149,6 +148,7 @@ struct Configuration {
bool SysvHash = false;
bool Target1Rel;
bool Trace;
+ bool UndefinedVersion;
bool Verbose;
bool WarnCommon;
bool WarnMissingEntry;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=324145&r1=324144&r2=324145&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Fri Feb 2 13:44:06 2018
@@ -621,6 +621,7 @@ void LinkerDriver::readConfigs(opt::Inpu
Config->Fini = Args.getLastArgValue(OPT_fini, "_fini");
Config->FixCortexA53Errata843419 = Args.hasArg(OPT_fix_cortex_a53_843419);
Config->GcSections = Args.hasFlag(OPT_gc_sections, OPT_no_gc_sections, false);
+ Config->GnuUnique = Args.hasFlag(OPT_gnu_unique, OPT_no_gnu_unique, true);
Config->GdbIndex = Args.hasFlag(OPT_gdb_index, OPT_no_gdb_index, false);
Config->ICF = Args.hasFlag(OPT_icf_all, OPT_icf_none, false);
Config->IgnoreDataAddressEquality =
@@ -633,10 +634,8 @@ void LinkerDriver::readConfigs(opt::Inpu
Config->LTOO = args::getInteger(Args, OPT_lto_O, 2);
Config->LTOPartitions = args::getInteger(Args, OPT_lto_partitions, 1);
Config->MapFile = Args.getLastArgValue(OPT_Map);
- Config->NoGnuUnique = Args.hasArg(OPT_no_gnu_unique);
Config->MergeArmExidx =
Args.hasFlag(OPT_merge_exidx_entries, OPT_no_merge_exidx_entries, true);
- Config->NoUndefinedVersion = Args.hasArg(OPT_no_undefined_version);
Config->NoinhibitExec = Args.hasArg(OPT_noinhibit_exec);
Config->Nostdlib = Args.hasArg(OPT_nostdlib);
Config->OFormatBinary = isOutputFormatBinary(Args);
@@ -672,6 +671,8 @@ void LinkerDriver::readConfigs(opt::Inpu
ThreadsEnabled = Args.hasFlag(OPT_threads, OPT_no_threads, true);
Config->Trace = Args.hasArg(OPT_trace);
Config->Undefined = args::getStrings(Args, OPT_undefined);
+ Config->UndefinedVersion =
+ Args.hasFlag(OPT_undefined_version, OPT_no_undefined_version, true);
Config->UnresolvedSymbols = getUnresolvedSymbolPolicy(Args);
Config->Verbose = Args.hasArg(OPT_verbose);
errorHandler().Verbose = Config->Verbose;
Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=324145&r1=324144&r2=324145&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Fri Feb 2 13:44:06 2018
@@ -150,6 +150,10 @@ defm gdb_index: B<"gdb-index",
"Generate .gdb_index section",
"Do not generate .gdb_index section">;
+defm gnu_unique: B<"gnu-unique",
+ "Enable STB_GNU_UNIQUE symbol binding",
+ "Disable STB_GNU_UNIQUE symbol binding">;
+
defm hash_style: Eq<"hash-style">,
HelpText<"Specify hash style (sysv, gnu or both)">;
@@ -193,9 +197,6 @@ def no_color_diagnostics: F<"no-color-di
def no_dynamic_linker: F<"no-dynamic-linker">,
HelpText<"Inhibit output of .interp section">;
-def no_gnu_unique: F<"no-gnu-unique">,
- HelpText<"Disable STB_GNU_UNIQUE symbol binding">;
-
def noinhibit_exec: F<"noinhibit-exec">,
HelpText<"Retain the executable output file whenever it is still usable">;
@@ -208,9 +209,6 @@ def no_rosegment: F<"no-rosegment">,
def no_undefined: F<"no-undefined">,
HelpText<"Report unresolved symbols even if the linker is creating a shared library">;
-def no_undefined_version: F<"no-undefined-version">,
- HelpText<"Report version scripts that refer undefined symbols">;
-
def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
HelpText<"Path to file to write output">;
@@ -298,6 +296,10 @@ defm undefined: Eq<"undefined">,
defm unresolved_symbols: Eq<"unresolved-symbols">,
HelpText<"Determine how to handle unresolved symbols">;
+defm undefined_version: B<"undefined-version",
+ "Allow unused version in version script",
+ "Report version scripts that refer undefined symbols">;
+
defm rsp_quoting: Eq<"rsp-quoting">,
HelpText<"Quoting style for response files. Values supported: windows|posix">;
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=324145&r1=324144&r2=324145&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Fri Feb 2 13:44:06 2018
@@ -700,7 +700,7 @@ void SymbolTable::assignExactVersion(Sym
// Get a list of symbols which we need to assign the version to.
std::vector<Symbol *> Syms = findByVersion(Ver);
if (Syms.empty()) {
- if (Config->NoUndefinedVersion)
+ if (!Config->UndefinedVersion)
error("version script assignment of '" + VersionName + "' to symbol '" +
Ver.Name + "' failed: symbol not defined");
return;
Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=324145&r1=324144&r2=324145&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Fri Feb 2 13:44:06 2018
@@ -241,7 +241,7 @@ uint8_t Symbol::computeBinding() const {
return STB_LOCAL;
if (VersionId == VER_NDX_LOCAL && isDefined())
return STB_LOCAL;
- if (Config->NoGnuUnique && Binding == STB_GNU_UNIQUE)
+ if (!Config->GnuUnique && Binding == STB_GNU_UNIQUE)
return STB_GLOBAL;
return Binding;
}
Modified: lld/trunk/test/ELF/gnu-unique.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gnu-unique.s?rev=324145&r1=324144&r2=324145&view=diff
==============================================================================
--- lld/trunk/test/ELF/gnu-unique.s (original)
+++ lld/trunk/test/ELF/gnu-unique.s Fri Feb 2 13:44:06 2018
@@ -3,6 +3,8 @@
//
// RUN: ld.lld %t -shared -o %tout.so
// RUN: llvm-readobj -dyn-symbols %tout.so | FileCheck -check-prefix=GNU %s
+// RUN: ld.lld %t -shared -o %tout.so --gnu-unique
+// 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
Modified: lld/trunk/test/ELF/version-script-noundef.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/version-script-noundef.s?rev=324145&r1=324144&r2=324145&view=diff
==============================================================================
--- lld/trunk/test/ELF/version-script-noundef.s (original)
+++ lld/trunk/test/ELF/version-script-noundef.s Fri Feb 2 13:44:06 2018
@@ -2,6 +2,8 @@
# RUN: echo "VERSION_1.0 { global: bar; };" > %t.script
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so
+# RUN: ld.lld --version-script %t.script -shared --undefined-version %t.o -o %t.so
# RUN: not ld.lld --version-script %t.script -shared --no-undefined-version \
# RUN: %t.o -o %t.so 2>&1 | FileCheck -check-prefix=ERR1 %s
# ERR1: version script assignment of 'VERSION_1.0' to symbol 'bar' failed: symbol not defined
More information about the llvm-commits
mailing list