[PATCH] D30188: [ELF] - Do not segfault when using --gc-sections with linker script
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 21 07:46:36 PST 2017
> Index: test/ELF/linkerscript/sections-gc.s
> ===================================================================
> --- test/ELF/linkerscript/sections-gc.s
> +++ test/ELF/linkerscript/sections-gc.s
> @@ -0,0 +1,19 @@
> +# REQUIRES: x86
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
> +# RUN: echo "SECTIONS { .text : { *(.text*) } }" > %t.script
> +# RUN: ld.lld %t --gc-sections --script %t.script -o %t1
> +# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
> +
> +# CHECK: Sections:
> +# CHECK-NEXT: Name Size
> +# CHECK: .text 00000001
> +
> +.section .text.foo, "a"
> +.global foo
> +foo:
> + nop
> +
> +.section .text.bar
> +.global bar
> +bar:
> + nop
I am not sure I fully understand what is going on with this
testcase. Why do you need text.bar to be non-SHF_ALLOC? You just need a
section to not be live, right?
This testcase will produce an error without --gc-sections. It seems like
a small bug for --gc-sections to make it valid and we should not depend
on that.
Please change the test to
.section .text.foo, "ax"
.global _start
_start:
nop
.section .text.bar, "ax"
.global bar
bar:
nop
LGTM with that.
Cheers,
Rafael
More information about the llvm-commits
mailing list