[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
This commit is contained in:
Alexander Shaposhnikov 2020-04-26 23:46:49 -07:00
parent 15fcdac498
commit cf7edb6ea5
6 changed files with 100 additions and 32 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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: ]