2021-07-05 15:39:35 +08:00
|
|
|
# REQUIRES: x86
|
|
|
|
|
2021-07-05 13:13:30 +08:00
|
|
|
## This tests that we can handle relocations that are not sorted by address.
|
|
|
|
## llvm-mc isn't able to emit such a file, hence the use of yaml2obj. ld64
|
|
|
|
## may emit files with unsorted relocations in `-r` mode, so we need to support
|
|
|
|
## this.
|
|
|
|
|
|
|
|
# RUN: yaml2obj %s -o %t.o
|
|
|
|
# RUN: %lld -dylib -o %t %t.o
|
|
|
|
# RUN: llvm-objdump --macho -d %t | FileCheck %s
|
|
|
|
|
|
|
|
# CHECK: _foo:
|
|
|
|
# CHECK-NEXT: movq _bar(%rip), %rax
|
|
|
|
# CHECK-NEXT: _bar:
|
|
|
|
# CHECK-NEXT: movq _baz(%rip), %rax
|
|
|
|
# CHECK-NEXT: _baz:
|
|
|
|
# CHECK-NEXT: movq _foo(%rip), %rax
|
|
|
|
|
|
|
|
--- !mach-o
|
|
|
|
FileHeader:
|
|
|
|
magic: 0xFEEDFACF
|
|
|
|
cputype: 0x1000007
|
|
|
|
cpusubtype: 0x3
|
|
|
|
filetype: 0x1
|
|
|
|
ncmds: 2
|
|
|
|
sizeofcmds: 280
|
|
|
|
flags: 0x2000
|
|
|
|
reserved: 0x0
|
|
|
|
LoadCommands:
|
|
|
|
- cmd: LC_SEGMENT_64
|
|
|
|
cmdsize: 152
|
|
|
|
segname: ''
|
|
|
|
vmaddr: 0
|
|
|
|
vmsize: 21
|
|
|
|
fileoff: 312
|
|
|
|
filesize: 21
|
|
|
|
maxprot: 7
|
|
|
|
initprot: 7
|
|
|
|
nsects: 1
|
|
|
|
flags: 0
|
|
|
|
Sections:
|
|
|
|
- sectname: __text
|
|
|
|
segname: __TEXT
|
|
|
|
addr: 0x0
|
|
|
|
size: 21
|
|
|
|
offset: 0x138
|
|
|
|
align: 0
|
|
|
|
reloff: 0x150
|
|
|
|
nreloc: 3
|
|
|
|
flags: 0x80000400
|
|
|
|
reserved1: 0x0
|
|
|
|
reserved2: 0x0
|
|
|
|
reserved3: 0x0
|
|
|
|
content: 488B0500000000488B0500000000488B0500000000
|
|
|
|
relocations:
|
|
|
|
- address: 0x3
|
|
|
|
symbolnum: 1
|
|
|
|
pcrel: true
|
|
|
|
length: 2
|
|
|
|
extern: true
|
|
|
|
type: 1
|
|
|
|
scattered: false
|
|
|
|
value: 0
|
|
|
|
- address: 0x11
|
|
|
|
symbolnum: 0
|
|
|
|
pcrel: true
|
|
|
|
length: 2
|
|
|
|
extern: true
|
|
|
|
type: 1
|
|
|
|
scattered: false
|
|
|
|
value: 0
|
|
|
|
- address: 0xA
|
|
|
|
symbolnum: 2
|
|
|
|
pcrel: true
|
|
|
|
length: 2
|
|
|
|
extern: true
|
|
|
|
type: 1
|
|
|
|
scattered: false
|
|
|
|
value: 0
|
|
|
|
- cmd: LC_SYMTAB
|
|
|
|
cmdsize: 24
|
|
|
|
symoff: 360
|
|
|
|
nsyms: 3
|
|
|
|
stroff: 408
|
|
|
|
strsize: 16
|
|
|
|
LinkEditData:
|
|
|
|
NameList:
|
|
|
|
- n_strx: 11
|
|
|
|
n_type: 0xE
|
|
|
|
n_sect: 1
|
|
|
|
n_desc: 0
|
|
|
|
n_value: 0
|
|
|
|
- n_strx: 6
|
|
|
|
n_type: 0xE
|
|
|
|
n_sect: 1
|
|
|
|
n_desc: 0
|
|
|
|
n_value: 7
|
|
|
|
- n_strx: 1
|
|
|
|
n_type: 0xE
|
|
|
|
n_sect: 1
|
|
|
|
n_desc: 0
|
|
|
|
n_value: 14
|
|
|
|
StringTable:
|
|
|
|
- ''
|
|
|
|
- _baz
|
|
|
|
- _bar
|
|
|
|
- _foo
|
|
|
|
...
|