From 99f73ebe5c96de340c3a148c4a99e4aca5d13b7a Mon Sep 17 00:00:00 2001 From: George Rimar Date: Mon, 29 Jul 2019 07:55:39 +0000 Subject: [PATCH] [llvm-objcopy] - Reimplement strip-dwo-groups.test to stop using the precompiled object. When llvm-copy removes .dwo sections the index of symbol table, the indices of the symbols and the indices of the sections which go after the removed ones changes. That affects on SHT_GROUP sections, which needs to be updated. Initially this test used a precompiled object, I rewrote it to use YAML and improved a bit. Differential revision: https://reviews.llvm.org/D65273 llvm-svn: 367202 --- llvm/test/tools/llvm-objcopy/ELF/Inputs/groups.o | Bin 5368 -> 0 bytes .../tools/llvm-objcopy/ELF/strip-dwo-groups.test | 106 ++++++++++++++------- 2 files changed, 71 insertions(+), 35 deletions(-) delete mode 100644 llvm/test/tools/llvm-objcopy/ELF/Inputs/groups.o diff --git a/llvm/test/tools/llvm-objcopy/ELF/Inputs/groups.o b/llvm/test/tools/llvm-objcopy/ELF/Inputs/groups.o deleted file mode 100644 index e92b98046a37999b039dd1db84ddeb74a81c997b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5368 zcmd5Ounk}s@SDgi~c23BC(YN=)RBC_f;#Ak$Q+xa6 znY{>e2ppk!BGxuCC;!6AiR(W8udn(oA6mubs=d0HUUwVK<=Sd`G?UBZ(zh&mUVS{9 ztyb4pGPTBHc5&Iu`i2=uX*YMIFyah3`HE96jTW5Y^3Yh`KAayND^%RWL-{eMRB&>m zm0LRpqNwRye#EXgL!R~b3mMyDnMMG=~OWnEOnU1Cbu zq9nYf<)%Nk2|V8d{{{Rm_yh1i!2bgO8~h*e7vRg_pTHrkRRkOb)4IjMJ>Vaq+g?o> z5g}g2kQI|M6b=_*Aj2|ZMP=kTWa}gzB1&SH=%OYTu_E33AcU+0T;kz#kY)IpfUX>i z#NqlBFl!SJ5hW3>)Wo_YvF*?;1B3pfSmJ>NqR$;UzS?VH$lAc-l<$kojvU;<|cCiWdext1kn2ZkX; zvk;)fIB$l8ao$KF5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m-objcopy/ELF/strip-dwo-groups.test index 6404bba..fe1770d 100644 --- a/llvm/test/tools/llvm-objcopy/ELF/strip-dwo-groups.test +++ b/llvm/test/tools/llvm-objcopy/ELF/strip-dwo-groups.test @@ -1,40 +1,76 @@ -# RUN: cp %p/Inputs/groups.o %t +# RUN: yaml2obj %s -o %t # RUN: llvm-objcopy --strip-dwo %t -# RUN: llvm-readobj --elf-section-groups %t | FileCheck %s +# RUN: llvm-readobj --symbols -S --elf-section-groups %t | FileCheck %s --implicit-check-not=debug_ -// Source code of groups.o: -// -// template -// struct S { -// static constexpr T X = T(1); -// T getX() { return X; } -// }; -// void f() { -// S A; -// S B; -// int a = A.getX(); -// int b = B.getX(); -// } -// -// clang -g -gsplit-dwarf -std=c++11 -c groups.cpp -o groups.o +## `llvm-objcopy --strip-dwo` strips out dwo sections, as a result, the index of +## the symbol table, the indices of the symbols and the indices of the sections +## which go after the removed ones will change. Consequently, the fields +## Link, Info and the content of .group need to be updated. -// `llvm-objcopy --strip-dwo` strips out dwo sections, as a result, the index of -// the symbol table, the indices of the symbols and the indices of the sections -// which go after the removed ones will change. Consequently, the fields -// Link, Info and the content of .group need to be updated. In the past -// `llvm-objcopy --strip-dwo` used to produce invalid binaries with -// broken .group section, this test verifies the correctness of -// Link, Info and the content of this section. +# CHECK: Groups { +# CHECK: Name: .group (1) +# CHECK-NEXT: Index: 1{{$}} +# CHECK-NEXT: Link: 6 +# CHECK-NEXT: Info: 2 +# CHECK-NEXT: Type: COMDAT (0x1) +# CHECK-NEXT: Signature: group1 +# CHECK-NEXT: Section(s) in group [ +# CHECK-NEXT: .text.group1 (3) +# CHECK-NEXT: ] -CHECK: Name: .group (179) -CHECK-NEXT: Index: 1{{$}} -CHECK-NEXT: Link: 19 -CHECK-NEXT: Info: 14 -CHECK: .text._ZN1SIiE4getXEv +# CHECK: Name: .group (1) +# CHECK-NEXT: Index: 2{{$}} +# CHECK-NEXT: Link: 6 +# CHECK-NEXT: Info: 1 +# CHECK-NEXT: Type: COMDAT (0x1) +# CHECK-NEXT: Signature: group2 +# CHECK-NEXT: Section(s) in group [ +# CHECK-NEXT: .text.group2 (4) +# CHECK-NEXT: .rela.text.group2 (5) +# CHECK-NEXT: ] -CHECK: Name: .group (179) -CHECK-NEXT: Index: 2{{$}} -CHECK-NEXT: Link: 19 -CHECK-NEXT: Info: 13 -CHECK: .text._ZN1SIdE4getXEv -CHECK-NEXT: .rela.text._ZN1SIdE4getXEv +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .debug_before.dwo + Type: SHT_PROGBITS + - Name: .group + Type: SHT_GROUP + Link: .symtab + Info: group1 + Members: + - SectionOrType: GRP_COMDAT + - SectionOrType: .text.group1 + - Name: .text.group1 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ] + - Name: '.group [1]' + Type: SHT_GROUP + Link: .symtab + Info: group2 + Members: + - SectionOrType: GRP_COMDAT + - SectionOrType: .text.group2 + - SectionOrType: .rela.text.group2 + - Name: .text.group2 + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ] + - Name: .rela.text.group2 + Type: SHT_RELA + Flags: [ SHF_GROUP ] + Info: .text.group2 + - Name: .debug_after.dwo + Type: SHT_PROGBITS +Symbols: + - Name: debug_before + Section: .debug_before.dwo + - Name: group2 + Section: .text.group2 + - Name: group1 + Section: .text.group1 + - Name: debug_after + Section: .debug_after.dwo -- 2.7.4