Skip to content

Commit

Permalink
[llvm-objcopy][MachO] Avoid accidental invalid relocations in tests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Alexander Shaposhnikov committed Apr 27, 2020
1 parent 15fcdac commit cf7edb6
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 32 deletions.
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions llvm/test/tools/llvm-objcopy/MachO/basic-big-endian-32-copy.test
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions llvm/test/tools/llvm-objcopy/MachO/basic-big-endian-64-copy.test
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions llvm/test/tools/llvm-objcopy/MachO/strip-debug.test
Expand Up @@ -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: ]

0 comments on commit cf7edb6

Please sign in to comment.