[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 reserved1: 0x00000000
reserved2: 0x00000000 reserved2: 0x00000000
reserved3: 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 - sectname: __data
segname: __DATA segname: __DATA
addr: 0x0000000000000024 addr: 0x0000000000000024
@ -81,6 +98,39 @@ LoadCommands:
reserved1: 0x00000000 reserved1: 0x00000000
reserved2: 0x00000000 reserved2: 0x00000000
reserved3: 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 - sectname: __debug_macinfo
segname: __DWARF segname: __DWARF
addr: 0x0000000000000166 addr: 0x0000000000000166
@ -153,6 +203,15 @@ LoadCommands:
reserved1: 0x00000000 reserved1: 0x00000000
reserved2: 0x00000000 reserved2: 0x00000000
reserved3: 0x00000000 reserved3: 0x00000000
relocations:
- address: 0x0
symbolnum: 0
pcrel: false
length: 0
extern: true
type: 0
scattered: false
value: 0
- sectname: __eh_frame - sectname: __eh_frame
segname: __TEXT segname: __TEXT
addr: 0x0000000000000290 addr: 0x0000000000000290
@ -177,6 +236,15 @@ LoadCommands:
reserved1: 0x00000000 reserved1: 0x00000000
reserved2: 0x00000000 reserved2: 0x00000000
reserved3: 0x00000000 reserved3: 0x00000000
relocations:
- address: 0x0
symbolnum: 0
pcrel: false
length: 0
extern: true
type: 0
scattered: false
value: 0
- cmd: LC_BUILD_VERSION - cmd: LC_BUILD_VERSION
cmdsize: 24 cmdsize: 24
platform: 1 platform: 1

View File

@ -31,8 +31,8 @@ LoadCommands:
size: 61 size: 61
offset: 0x00000198 offset: 0x00000198
align: 4 align: 4
reloff: 0x00000250 reloff: 0x0
nreloc: 1 nreloc: 0
flags: 0x80000400 flags: 0x80000400
reserved1: 0x00000000 reserved1: 0x00000000
reserved2: 0x00000000 reserved2: 0x00000000
@ -43,8 +43,8 @@ LoadCommands:
size: 40 size: 40
offset: 0x000001D8 offset: 0x000001D8
align: 2 align: 2
reloff: 0x00000258 reloff: 0x00000
nreloc: 2 nreloc: 0
flags: 0x02000000 flags: 0x02000000
reserved1: 0x00000000 reserved1: 0x00000000
reserved2: 0x00000000 reserved2: 0x00000000
@ -67,9 +67,9 @@ LoadCommands:
sdk: 0 sdk: 0
- cmd: LC_SYMTAB - cmd: LC_SYMTAB
cmdsize: 24 cmdsize: 24
symoff: 616 symoff: 592
nsyms: 2 nsyms: 2
stroff: 640 stroff: 616
strsize: 16 strsize: 16
- cmd: LC_DYSYMTAB - cmd: LC_DYSYMTAB
cmdsize: 80 cmdsize: 80

View File

@ -32,8 +32,8 @@ LoadCommands:
size: 93 size: 93
offset: 0x00000220 offset: 0x00000220
align: 4 align: 4
reloff: 0x00000310 reloff: 0x0
nreloc: 3 nreloc: 0
flags: 0x80000400 flags: 0x80000400
reserved1: 0x00000000 reserved1: 0x00000000
reserved2: 0x00000000 reserved2: 0x00000000
@ -56,8 +56,8 @@ LoadCommands:
size: 32 size: 32
offset: 0x000002B0 offset: 0x000002B0
align: 3 align: 3
reloff: 0x00000328 reloff: 0x0
nreloc: 1 nreloc: 0
flags: 0x02000000 flags: 0x02000000
reserved1: 0x00000000 reserved1: 0x00000000
reserved2: 0x00000000 reserved2: 0x00000000
@ -80,9 +80,9 @@ LoadCommands:
sdk: 0 sdk: 0
- cmd: LC_SYMTAB - cmd: LC_SYMTAB
cmdsize: 24 cmdsize: 24
symoff: 816 symoff: 784
nsyms: 2 nsyms: 2
stroff: 848 stroff: 816
strsize: 36 strsize: 36
- cmd: LC_DYSYMTAB - cmd: LC_DYSYMTAB
cmdsize: 80 cmdsize: 80

View File

@ -31,8 +31,8 @@ LoadCommands:
size: 61 size: 61
offset: 0x00000198 offset: 0x00000198
align: 4 align: 4
reloff: 0x00000250 reloff: 0x0
nreloc: 1 nreloc: 0
flags: 0x80000400 flags: 0x80000400
reserved1: 0x00000000 reserved1: 0x00000000
reserved2: 0x00000000 reserved2: 0x00000000
@ -43,8 +43,8 @@ LoadCommands:
size: 40 size: 40
offset: 0x000001D8 offset: 0x000001D8
align: 2 align: 2
reloff: 0x00000258 reloff: 0x0
nreloc: 2 nreloc: 0
flags: 0x02000000 flags: 0x02000000
reserved1: 0x00000000 reserved1: 0x00000000
reserved2: 0x00000000 reserved2: 0x00000000
@ -67,9 +67,9 @@ LoadCommands:
sdk: 0 sdk: 0
- cmd: LC_SYMTAB - cmd: LC_SYMTAB
cmdsize: 24 cmdsize: 24
symoff: 616 symoff: 592
nsyms: 2 nsyms: 2
stroff: 640 stroff: 616
strsize: 16 strsize: 16
- cmd: LC_DYSYMTAB - cmd: LC_DYSYMTAB
cmdsize: 80 cmdsize: 80

View File

@ -32,8 +32,8 @@ LoadCommands:
size: 93 size: 93
offset: 0x00000220 offset: 0x00000220
align: 4 align: 4
reloff: 0x00000310 reloff: 0x0
nreloc: 3 nreloc: 0
flags: 0x80000400 flags: 0x80000400
reserved1: 0x00000000 reserved1: 0x00000000
reserved2: 0x00000000 reserved2: 0x00000000
@ -56,8 +56,8 @@ LoadCommands:
size: 32 size: 32
offset: 0x000002B0 offset: 0x000002B0
align: 3 align: 3
reloff: 0x00000328 reloff: 0x0
nreloc: 1 nreloc: 0
flags: 0x02000000 flags: 0x02000000
reserved1: 0x00000000 reserved1: 0x00000000
reserved2: 0x00000000 reserved2: 0x00000000
@ -80,9 +80,9 @@ LoadCommands:
sdk: 0 sdk: 0
- cmd: LC_SYMTAB - cmd: LC_SYMTAB
cmdsize: 24 cmdsize: 24
symoff: 816 symoff: 784
nsyms: 2 nsyms: 2
stroff: 848 stroff: 816
strsize: 36 strsize: 36
- cmd: LC_DYSYMTAB - cmd: LC_DYSYMTAB
cmdsize: 80 cmdsize: 80

View File

@ -23,19 +23,19 @@
# RELOC: Relocations [ # RELOC: Relocations [
# RELOC-NEXT: Section __text { # RELOC-NEXT: Section __text {
# 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 0 X86_64_RELOC_UNSIGNED 0 - # RELOC-NEXT: 0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _main
# RELOC-NEXT: } # RELOC-NEXT: }
# DEBUG: Section __debug_info { # DEBUG: Section __debug_info {
# 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 0 X86_64_RELOC_UNSIGNED 0 - # DEBUG-NEXT: 0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
# 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 0 X86_64_RELOC_UNSIGNED 0 - # DEBUG-NEXT: 0x0 0 0 1 X86_64_RELOC_UNSIGNED 0 _bar
# DEBUG-NEXT: } # DEBUG-NEXT: }
# RELOC-NEXT: Section __compact_unwind { # 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: } # RELOC-NEXT: }
# DEBUG-NEXT: Section __debug_line { # 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: } # DEBUG-NEXT: }
# RELOC-NEXT: ] # RELOC-NEXT: ]