[llvm] r367202 - [llvm-objcopy] - Reimplement strip-dwo-groups.test to stop using the precompiled object.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 00:55:40 PDT 2019


Author: grimar
Date: Mon Jul 29 00:55:39 2019
New Revision: 367202

URL: http://llvm.org/viewvc/llvm-project?rev=367202&view=rev
Log:
[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

Removed:
    llvm/trunk/test/tools/llvm-objcopy/ELF/Inputs/groups.o
Modified:
    llvm/trunk/test/tools/llvm-objcopy/ELF/strip-dwo-groups.test

Removed: llvm/trunk/test/tools/llvm-objcopy/ELF/Inputs/groups.o
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/Inputs/groups.o?rev=367201&view=auto
==============================================================================
Binary file - no diff available.

Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/strip-dwo-groups.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/strip-dwo-groups.test?rev=367202&r1=367201&r2=367202&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/strip-dwo-groups.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/strip-dwo-groups.test Mon Jul 29 00:55:39 2019
@@ -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 <class T>
-// struct S {
-//    static constexpr T X = T(1);
-//    T getX() { return X; }
-// };
-// void f() {
-//  S<int> A;
-//  S<double> 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




More information about the llvm-commits mailing list