[PATCH] D20169: [ELF] implemented -z defs option
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Wed May 11 06:50:19 PDT 2016
LGTM. Thanks!
On 11 May 2016 at 09:49, George Rimar <grimar at accesssoftek.com> wrote:
> grimar created this revision.
> grimar added reviewers: ruiu, rafael.
> grimar added subscribers: grimar, llvm-commits.
>
> Just do not allow to link shared library if there are
> undefined symbols.
>
> This fixes PR27447
>
> http://reviews.llvm.org/D20169
>
> Files:
> ELF/Config.h
> ELF/Driver.cpp
> ELF/Writer.cpp
> test/ELF/zdefs.s
>
> Index: test/ELF/zdefs.s
> ===================================================================
> --- test/ELF/zdefs.s
> +++ 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 at PLT
> Index: ELF/Writer.cpp
> ===================================================================
> --- ELF/Writer.cpp
> +++ ELF/Writer.cpp
> @@ -793,7 +793,7 @@
> if (!Config->NoUndefined) {
> if (Config->Relocatable)
> return;
> - if (Config->Shared)
> + if (Config->Shared && !Config->ZDefs)
> if (Sym->symbol()->Visibility == STV_DEFAULT)
> return;
> }
> Index: ELF/Driver.cpp
> ===================================================================
> --- ELF/Driver.cpp
> +++ ELF/Driver.cpp
> @@ -353,6 +353,7 @@
> 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");
> Index: ELF/Config.h
> ===================================================================
> --- ELF/Config.h
> +++ ELF/Config.h
> @@ -89,6 +89,7 @@
> bool VersionScript = false;
> bool WarnCommon;
> bool ZCombreloc;
> + bool ZDefs;
> bool ZExecStack;
> bool ZNodelete;
> bool ZNow;
>
>
More information about the llvm-commits
mailing list