[PATCH] D40878: Handle multiple "--version-script" options.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 6 17:27:04 PST 2017
LGTM
Igor Kudrin via Phabricator <reviews at reviews.llvm.org> writes:
> ikudrin created this revision.
> ikudrin added a project: lld.
> Herald added a subscriber: emaste.
>
> Both ld.bfd and ld.gold can handle them.
>
> In our case, several version script files are used to separate general and per-project settings.
>
>
> Repository:
> rLLD LLVM Linker
>
> https://reviews.llvm.org/D40878
>
> Files:
> ELF/Driver.cpp
> test/ELF/version-script.s
>
>
> Index: test/ELF/version-script.s
> ===================================================================
> --- test/ELF/version-script.s
> +++ test/ELF/version-script.s
> @@ -42,6 +42,12 @@
> # RUN: ld.lld --version-script %t.script --dynamic-list %t.list %t.o %t2.so -o %t2
> # RUN: llvm-readobj %t2 > /dev/null
>
> +## Check that we can handle multiple "--version-script" options.
> +# RUN: echo "VERSION_1.0 { global : foo1; local : *; };" > %t7a.script
> +# RUN: echo "VERSION_2.0 { global: foo3; local: *; };" > %t7b.script
> +# RUN: ld.lld --version-script %t7a.script --version-script %t7b.script -shared %t.o %t2.so -o %t7.so
> +# RUN: llvm-readobj -dyn-symbols %t7.so | FileCheck --check-prefix=VERDSO %s
> +
> # DSO: DynamicSymbols [
> # DSO-NEXT: Symbol {
> # DSO-NEXT: Name: @
> Index: ELF/Driver.cpp
> ===================================================================
> --- ELF/Driver.cpp
> +++ ELF/Driver.cpp
> @@ -774,7 +774,7 @@
> {Arg->getValue(), /*IsExternCpp*/ false, /*HasWildcard*/ false});
> }
>
> - if (auto *Arg = Args.getLastArg(OPT_version_script))
> + for (auto *Arg : Args.filtered(OPT_version_script))
> if (Optional<MemoryBufferRef> Buffer = readFile(Arg->getValue()))
> readVersionScript(*Buffer);
> }
>
>
> Index: test/ELF/version-script.s
> ===================================================================
> --- test/ELF/version-script.s
> +++ test/ELF/version-script.s
> @@ -42,6 +42,12 @@
> # RUN: ld.lld --version-script %t.script --dynamic-list %t.list %t.o %t2.so -o %t2
> # RUN: llvm-readobj %t2 > /dev/null
>
> +## Check that we can handle multiple "--version-script" options.
> +# RUN: echo "VERSION_1.0 { global : foo1; local : *; };" > %t7a.script
> +# RUN: echo "VERSION_2.0 { global: foo3; local: *; };" > %t7b.script
> +# RUN: ld.lld --version-script %t7a.script --version-script %t7b.script -shared %t.o %t2.so -o %t7.so
> +# RUN: llvm-readobj -dyn-symbols %t7.so | FileCheck --check-prefix=VERDSO %s
> +
> # DSO: DynamicSymbols [
> # DSO-NEXT: Symbol {
> # DSO-NEXT: Name: @
> Index: ELF/Driver.cpp
> ===================================================================
> --- ELF/Driver.cpp
> +++ ELF/Driver.cpp
> @@ -774,7 +774,7 @@
> {Arg->getValue(), /*IsExternCpp*/ false, /*HasWildcard*/ false});
> }
>
> - if (auto *Arg = Args.getLastArg(OPT_version_script))
> + for (auto *Arg : Args.filtered(OPT_version_script))
> if (Optional<MemoryBufferRef> Buffer = readFile(Arg->getValue()))
> readVersionScript(*Buffer);
> }
More information about the llvm-commits
mailing list