[PATCH] D29273: [ELF] - Added partial support for --emit-relocs (no --gc-section case)
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 30 11:13:54 PST 2017
> Index: test/ELF/linkerscript/emit-reloc-discard.s
> ===================================================================
> --- test/ELF/linkerscript/emit-reloc-discard.s
> +++ test/ELF/linkerscript/emit-reloc-discard.s
> @@ -0,0 +1,15 @@
> +# REQUIRES: x86
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
> +# RUN: echo "SECTIONS { /DISCARD/ : { *(.debug*) } }" > %t.script
> +# RUN: ld.lld --emit-relocs --script %t.script %t.o -o %t1
> +# RUN: llvm-readobj -r %t1 | FileCheck %s
> +
> +# CHECK: Relocations [
> +# CHECK-NEXT: ]
> +
> +.section .debug_str,"MS", at progbits,1
> +.Linfo_string0:
> + .asciz "AAA"
> +
> +.section .debug_info,"", at progbits
> + .long .Linfo_string0
This is better handled along the followup patch that adds gc, no?
> Index: ELF/LinkerScript.cpp
> ===================================================================
> --- ELF/LinkerScript.cpp
> +++ ELF/LinkerScript.cpp
> @@ -262,6 +262,12 @@
> for (InputSectionBase<ELFT> *S : V) {
> S->Live = false;
> reportDiscarded(S);
> +
> + // If we discard a section, we also should discard a dependent section.
> + InputSection<ELFT> *IS = dyn_cast<InputSection<ELFT>>(S);
> + if (!IS || !IS->DependentSection || !IS->DependentSection->Live)
> + continue;
> + discard({IS->DependentSection});
> }
> }
And this.
Cheers,
Rafael
More information about the llvm-commits
mailing list