[llvm-objcopy] Fix SHT_GROUP ordering.
Summary:
When llvm-objcopy sorts sections during finalization, it only sorts based on the offset, which can cause the group section to come after the sections it contains. This causes link failures when using gold to link objects created by llvm-objcopy.
Fix this for now by copying GNU objcopy's behavior of placing SHT_GROUP sections first. In the future, we may want to remove this sorting entirely to more closely preserve the input file layout.
This fixes https://bugs.llvm.org/show_bug.cgi?id=42052.
Reviewers: jakehehrlich, jhenderson, MaskRay, espindola, alexshap
Reviewed By: MaskRay
Subscribers: phuongtrang148993, emaste, arichardson, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62620
llvm-svn: 362973
diff --git a/llvm/test/tools/llvm-objcopy/ELF/compress-debug-sections-zlib-gnu.test b/llvm/test/tools/llvm-objcopy/ELF/compress-debug-sections-zlib-gnu.test
index 2abd22e..d2811b9 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/compress-debug-sections-zlib-gnu.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/compress-debug-sections-zlib-gnu.test
@@ -14,8 +14,7 @@
# CHECK: .debug_foo:
# CHECK-NEXT: 0000 00000000 00000000
-# CHECK-HEADER: Index: 1
-# CHECK-HEADER-NEXT: Name: .debug_foo
+# CHECK-HEADER: Name: .debug_foo
# CHECK-HEADER-NEXT: Type: SHT_PROGBITS
# CHECK-HEADER-NEXT: Flags [
# CHECK-HEADER-NEXT: ]
@@ -27,9 +26,8 @@
# CHECK-COMPRESSED: ZLIB
# CHECK-COMPRESSED: .notdebug_foo:
-# CHECK-FLAGS-NOT: Name: .debug_foo
-# CHECK-FLAGS: Index: 1
-# CHECK-FLAGS-NEXT: Name: .zdebug_foo
+# CHECK-FLAGS-NOT: Name: .debug_foo
+# CHECK-FLAGS: Name: .zdebug_foo
# CHECK-FLAGS-NEXT: Type: SHT_PROGBITS
# CHECK-FLAGS-NEXT: Flags [
# CHECK-FLAGS-NEXT: ]
@@ -49,11 +47,6 @@
# CHECK-FLAGS-NEXT: Type: SHT_RELA
# CHECK-FLAGS-NEXT: Flags [
# CHECK-FLAGS-NEXT: ]
-# CHECK-FLAGS-NEXT: Address:
-# CHECK-FLAGS-NEXT: Offset:
-# CHECK-FLAGS-NEXT: Size:
-# CHECK-FLAGS-NEXT: Link:
-# CHECK-FLAGS-NEXT: Info: 1
# CHECK-FLAGS: Relocations [
# CHECK-FLAGS-NEXT: .rela.debug_foo {