[llvm] cf7edb6 - [llvm-objcopy][MachO] Avoid accidental invalid relocations in tests
Alexander Shaposhnikov via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 27 15:33:38 PDT 2020
Author: Alexander Shaposhnikov
Date: 2020-04-27T15:33:17-07:00
New Revision: cf7edb6ea507949ce859510970698c9c11887d98
URL: https://github.com/llvm/llvm-project/commit/cf7edb6ea507949ce859510970698c9c11887d98
DIFF: https://github.com/llvm/llvm-project/commit/cf7edb6ea507949ce859510970698c9c11887d98.diff
LOG: [llvm-objcopy][MachO] Avoid accidental invalid relocations in tests
Until recently yaml2obj didn't properly support relocations for MachO.
This behavior resulted in binaries having invalid relocations.
In this diff we adjust the existing tests as follows:
for the tests which don't actually look at any relocations they are removed,
for the tests which essentially depend on relocations they are fixed.
Test plan: make check-all
Differential revision: https://reviews.llvm.org/D78898
Added:
Modified:
llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all-with-dwarf.yaml
llvm/test/tools/llvm-objcopy/MachO/basic-big-endian-32-copy.test
llvm/test/tools/llvm-objcopy/MachO/basic-big-endian-64-copy.test
llvm/test/tools/llvm-objcopy/MachO/basic-little-endian-32-copy.test
llvm/test/tools/llvm-objcopy/MachO/basic-little-endian-64-copy.test
llvm/test/tools/llvm-objcopy/MachO/strip-debug.test
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all-with-dwarf.yaml b/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all-with-dwarf.yaml
index 268cc2549e72..213d66fd4371 100644
--- a/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all-with-dwarf.yaml
+++ b/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all-with-dwarf.yaml
@@ -33,6 +33,23 @@ LoadCommands:
reserved1: 0x00000000
reserved2: 0x00000000
reserved3: 0x00000000
+ relocations:
+ - address: 0x0
+ symbolnum: 0
+ pcrel: false
+ length: 0
+ extern: true
+ type: 0
+ scattered: false
+ value: 0
+ - address: 0x0
+ symbolnum: 1
+ pcrel: false
+ length: 0
+ extern: true
+ type: 0
+ scattered: false
+ value: 0
- sectname: __data
segname: __DATA
addr: 0x0000000000000024
@@ -81,6 +98,39 @@ LoadCommands:
reserved1: 0x00000000
reserved2: 0x00000000
reserved3: 0x00000000
+ relocations:
+ - address: 0x0
+ symbolnum: 0
+ pcrel: false
+ length: 0
+ extern: true
+ type: 0
+ scattered: false
+ value: 0
+ - address: 0x0
+ symbolnum: 0
+ pcrel: false
+ length: 0
+ extern: true
+ type: 0
+ scattered: false
+ value: 0
+ - address: 0x0
+ symbolnum: 0
+ pcrel: false
+ length: 0
+ extern: true
+ type: 0
+ scattered: false
+ value: 0
+ - address: 0x0
+ symbolnum: 0
+ pcrel: false
+ length: 0
+ extern: true
+ type: 0
+ scattered: false
+ value: 0
- sectname: __debug_macinfo
segname: __DWARF
addr: 0x0000000000000166
@@ -153,6 +203,15 @@ LoadCommands:
reserved1: 0x00000000
reserved2: 0x00000000
reserved3: 0x00000000
+ relocations:
+ - address: 0x0
+ symbolnum: 0
+ pcrel: false
+ length: 0
+ extern: true
+ type: 0
+ scattered: false
+ value: 0
- sectname: __eh_frame
segname: __TEXT
addr: 0x0000000000000290
@@ -177,6 +236,15 @@ LoadCommands:
reserved1: 0x00000000
reserved2: 0x00000000
reserved3: 0x00000000
+ relocations:
+ - address: 0x0
+ symbolnum: 0
+ pcrel: false
+ length: 0
+ extern: true
+ type: 0
+ scattered: false
+ value: 0
- cmd: LC_BUILD_VERSION
cmdsize: 24
platform: 1
diff --git a/llvm/test/tools/llvm-objcopy/MachO/basic-big-endian-32-copy.test b/llvm/test/tools/llvm-objcopy/MachO/basic-big-endian-32-copy.test
index 083011badc3b..67e2be00eb92 100644
--- a/llvm/test/tools/llvm-objcopy/MachO/basic-big-endian-32-copy.test
+++ b/llvm/test/tools/llvm-objcopy/MachO/basic-big-endian-32-copy.test
@@ -31,8 +31,8 @@ LoadCommands:
size: 61
offset: 0x00000198
align: 4
- reloff: 0x00000250
- nreloc: 1
+ reloff: 0x0
+ nreloc: 0
flags: 0x80000400
reserved1: 0x00000000
reserved2: 0x00000000
@@ -43,8 +43,8 @@ LoadCommands:
size: 40
offset: 0x000001D8
align: 2
- reloff: 0x00000258
- nreloc: 2
+ reloff: 0x00000
+ nreloc: 0
flags: 0x02000000
reserved1: 0x00000000
reserved2: 0x00000000
@@ -67,9 +67,9 @@ LoadCommands:
sdk: 0
- cmd: LC_SYMTAB
cmdsize: 24
- symoff: 616
+ symoff: 592
nsyms: 2
- stroff: 640
+ stroff: 616
strsize: 16
- cmd: LC_DYSYMTAB
cmdsize: 80
diff --git a/llvm/test/tools/llvm-objcopy/MachO/basic-big-endian-64-copy.test b/llvm/test/tools/llvm-objcopy/MachO/basic-big-endian-64-copy.test
index ff8e4a0096bb..5963e57d1ce6 100644
--- a/llvm/test/tools/llvm-objcopy/MachO/basic-big-endian-64-copy.test
+++ b/llvm/test/tools/llvm-objcopy/MachO/basic-big-endian-64-copy.test
@@ -32,8 +32,8 @@ LoadCommands:
size: 93
offset: 0x00000220
align: 4
- reloff: 0x00000310
- nreloc: 3
+ reloff: 0x0
+ nreloc: 0
flags: 0x80000400
reserved1: 0x00000000
reserved2: 0x00000000
@@ -56,8 +56,8 @@ LoadCommands:
size: 32
offset: 0x000002B0
align: 3
- reloff: 0x00000328
- nreloc: 1
+ reloff: 0x0
+ nreloc: 0
flags: 0x02000000
reserved1: 0x00000000
reserved2: 0x00000000
@@ -80,9 +80,9 @@ LoadCommands:
sdk: 0
- cmd: LC_SYMTAB
cmdsize: 24
- symoff: 816
+ symoff: 784
nsyms: 2
- stroff: 848
+ stroff: 816
strsize: 36
- cmd: LC_DYSYMTAB
cmdsize: 80
diff --git a/llvm/test/tools/llvm-objcopy/MachO/basic-little-endian-32-copy.test b/llvm/test/tools/llvm-objcopy/MachO/basic-little-endian-32-copy.test
index 7e6663945179..54cb3193f714 100644
--- a/llvm/test/tools/llvm-objcopy/MachO/basic-little-endian-32-copy.test
+++ b/llvm/test/tools/llvm-objcopy/MachO/basic-little-endian-32-copy.test
@@ -31,8 +31,8 @@ LoadCommands:
size: 61
offset: 0x00000198
align: 4
- reloff: 0x00000250
- nreloc: 1
+ reloff: 0x0
+ nreloc: 0
flags: 0x80000400
reserved1: 0x00000000
reserved2: 0x00000000
@@ -43,8 +43,8 @@ LoadCommands:
size: 40
offset: 0x000001D8
align: 2
- reloff: 0x00000258
- nreloc: 2
+ reloff: 0x0
+ nreloc: 0
flags: 0x02000000
reserved1: 0x00000000
reserved2: 0x00000000
@@ -67,9 +67,9 @@ LoadCommands:
sdk: 0
- cmd: LC_SYMTAB
cmdsize: 24
- symoff: 616
+ symoff: 592
nsyms: 2
- stroff: 640
+ stroff: 616
strsize: 16
- cmd: LC_DYSYMTAB
cmdsize: 80
diff --git a/llvm/test/tools/llvm-objcopy/MachO/basic-little-endian-64-copy.test b/llvm/test/tools/llvm-objcopy/MachO/basic-little-endian-64-copy.test
index 18e3bbb997ea..8795602e51ad 100644
--- a/llvm/test/tools/llvm-objcopy/MachO/basic-little-endian-64-copy.test
+++ b/llvm/test/tools/llvm-objcopy/MachO/basic-little-endian-64-copy.test
@@ -32,8 +32,8 @@ LoadCommands:
size: 93
offset: 0x00000220
align: 4
- reloff: 0x00000310
- nreloc: 3
+ reloff: 0x0
+ nreloc: 0
flags: 0x80000400
reserved1: 0x00000000
reserved2: 0x00000000
@@ -56,8 +56,8 @@ LoadCommands:
size: 32
offset: 0x000002B0
align: 3
- reloff: 0x00000328
- nreloc: 1
+ reloff: 0x0
+ nreloc: 0
flags: 0x02000000
reserved1: 0x00000000
reserved2: 0x00000000
@@ -80,9 +80,9 @@ LoadCommands:
sdk: 0
- cmd: LC_SYMTAB
cmdsize: 24
- symoff: 816
+ symoff: 784
nsyms: 2
- stroff: 848
+ stroff: 816
strsize: 36
- cmd: LC_DYSYMTAB
cmdsize: 80
diff --git a/llvm/test/tools/llvm-objcopy/MachO/strip-debug.test b/llvm/test/tools/llvm-objcopy/MachO/strip-debug.test
index 817ca0ecb561..604f011d6035 100644
--- a/llvm/test/tools/llvm-objcopy/MachO/strip-debug.test
+++ b/llvm/test/tools/llvm-objcopy/MachO/strip-debug.test
@@ -23,19 +23,19 @@
# RELOC: Relocations [
# RELOC-NEXT: Section __text {
-# RELOC-NEXT: 0x0 0 0 0 X86_64_RELOC_UNSIGNED 0 -
-# RELOC-NEXT: 0x0 0 0 0 X86_64_RELOC_UNSIGNED 0 -
+# RELOC-NEXT: 0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
+# RELOC-NEXT: 0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _main
# RELOC-NEXT: }
# DEBUG: Section __debug_info {
-# DEBUG-NEXT: 0x0 0 0 0 X86_64_RELOC_UNSIGNED 0 -
-# DEBUG-NEXT: 0x0 0 0 0 X86_64_RELOC_UNSIGNED 0 -
-# DEBUG-NEXT: 0x0 0 0 0 X86_64_RELOC_UNSIGNED 0 -
-# DEBUG-NEXT: 0x0 0 0 0 X86_64_RELOC_UNSIGNED 0 -
+# DEBUG-NEXT: 0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
+# DEBUG-NEXT: 0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
+# DEBUG-NEXT: 0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
+# DEBUG-NEXT: 0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
# DEBUG-NEXT: }
# RELOC-NEXT: Section __compact_unwind {
-# RELOC-NEXT: 0x0 0 0 0 X86_64_RELOC_UNSIGNED 0 -
+# RELOC-NEXT: 0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
# RELOC-NEXT: }
# DEBUG-NEXT: Section __debug_line {
-# DEBUG-NEXT: 0x0 0 0 0 X86_64_RELOC_UNSIGNED 0 -
+# DEBUG-NEXT: 0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
# DEBUG-NEXT: }
# RELOC-NEXT: ]
More information about the llvm-commits
mailing list