[PATCH] D36519: [ELF] - Add a test for --gc-sections --undefined=foo combination.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 9 16:06:06 PDT 2017


LGTM with the same nit as Rui.

Cheers,
Rafael

George Rimar via Phabricator <reviews at reviews.llvm.org> writes:

> grimar created this revision.
> Herald added a subscriber: emaste.
>
> GC code contains following logic uncovered by tests:
> (nothing fails if I remove these 2 lines)
>
>   for (StringRef S : Config->Undefined)
>     MarkSymbol(Symtab->find(S));
>
> As far I can tell we never had test for that before,
> patch fixes it.
>
>
> https://reviews.llvm.org/D36519
>
> Files:
>   test/ELF/gc-sections-undefined.s
>
>
> Index: test/ELF/gc-sections-undefined.s
> ===================================================================
> --- test/ELF/gc-sections-undefined.s
> +++ test/ELF/gc-sections-undefined.s
> @@ -0,0 +1,20 @@
> +# REQUIRES: x86
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
> +# RUN: ld.lld %t -o %t1 --gc-sections --undefined=foo --undefined=bar
> +# RUN: llvm-readobj -t %t1 | FileCheck %s
> +
> +# CHECK: bar
> +# CHECK: foo
> +
> +.section .foo,"ax"
> +.global foo
> +foo:
> +
> +.section .bar,"ax"
> +.global bar
> +bar:
> +
> +.section .text,"ax"
> +.globl _start
> +_start:
> + .quad foo
>
>
> Index: test/ELF/gc-sections-undefined.s
> ===================================================================
> --- test/ELF/gc-sections-undefined.s
> +++ test/ELF/gc-sections-undefined.s
> @@ -0,0 +1,20 @@
> +# REQUIRES: x86
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
> +# RUN: ld.lld %t -o %t1 --gc-sections --undefined=foo --undefined=bar
> +# RUN: llvm-readobj -t %t1 | FileCheck %s
> +
> +# CHECK: bar
> +# CHECK: foo
> +
> +.section .foo,"ax"
> +.global foo
> +foo:
> +
> +.section .bar,"ax"
> +.global bar
> +bar:
> +
> +.section .text,"ax"
> +.globl _start
> +_start:
> + .quad foo


More information about the llvm-commits mailing list