diff options
-rw-r--r-- | lld/ELF/Config.h | 1 | ||||
-rw-r--r-- | lld/ELF/Driver.cpp | 1 | ||||
-rw-r--r-- | lld/ELF/Writer.cpp | 2 | ||||
-rw-r--r-- | lld/test/ELF/zdefs.s | 7 |
4 files changed, 10 insertions, 1 deletions
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index ade684c1c17..120df312a80 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -89,6 +89,7 @@ struct Configuration { bool VersionScript = false; bool WarnCommon; bool ZCombreloc; + bool ZDefs; bool ZExecStack; bool ZNodelete; bool ZNow; diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index f23db3d5fcc..4b11472a688 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -353,6 +353,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { error("number of threads must be > 0"); Config->ZCombreloc = !hasZOption(Args, "nocombreloc"); + Config->ZDefs = hasZOption(Args, "defs"); Config->ZExecStack = hasZOption(Args, "execstack"); Config->ZNodelete = hasZOption(Args, "nodelete"); Config->ZNow = hasZOption(Args, "now"); diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 4c9be04e42a..e40a5ce8224 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -793,7 +793,7 @@ static void reportUndefined(SymbolTable<ELFT> &Symtab, SymbolBody *Sym) { if (!Config->NoUndefined) { if (Config->Relocatable) return; - if (Config->Shared) + if (Config->Shared && !Config->ZDefs) if (Sym->symbol()->Visibility == STV_DEFAULT) return; } diff --git a/lld/test/ELF/zdefs.s b/lld/test/ELF/zdefs.s new file mode 100644 index 00000000000..410da1812db --- /dev/null +++ b/lld/test/ELF/zdefs.s @@ -0,0 +1,7 @@ +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: ld.lld -shared %t.o -o %t1.so + +# RUN: not ld.lld -z defs -shared %t.o -o %t1.so 2>&1 | FileCheck -check-prefix=ERR %s +# ERR: undefined symbol: foo + +callq foo@PLT |