Files
clang-p2996/lld/test/MachO/invalid/invalid-relocation-pcrel.yaml
Jez Ng fd28f71872 [lld-macho] Have tests default to targeting macos 10.15
D101114 enforced proper version checks, which exposed a variety of version
mismatch issues in our tests. We previously changed the test inputs to
target 10.0, which was the simpler thing to do, but we should really
just have our lit.local.cfg default to targeting 10.15, which is what is done
here. We're not likely to ever have proper support for the older versions
anyway, as that would require more work for unclear benefit; for instance,
llvm-mc seems to generate a different compact unwind format for older macOS
versions, which would cause our compact-unwind.s test to fail.

Targeting 10.15 by default causes the following behavioral changes:
* `__mh_execute_header` is now a section symbol instead of an absolute symbol
* LC_BUILD_VERSION gets emitted instead of LC_VERSION_MIN_MACOSX. The former is
  32 bytes in size whereas the latter is 16 bytes, so a bunch of hardcoded
  address offsets in our tests had to be updated.
* >= 10.6 executables are PIE by default

Note that this diff was stacked atop of a local revert of most of the test
changes in rG8c17a875150f8e736e8f9061ddf084397f45f4c5, to make review easier.

Reviewed By: #lld-macho, oontvoo

Differential Revision: https://reviews.llvm.org/D101119
2021-04-23 09:25:08 -04:00

102 lines
2.6 KiB
YAML

# REQUIRES: x86
# RUN: rm -rf %t; mkdir %t
# RUN: yaml2obj %s -o %t/test.o
# RUN: llvm-ar rcs %t/test.a %t/test.o
# RUN: not %lld -o /dev/null %t/test.a 2>&1 | FileCheck %s
#
# CHECK: error: UNSIGNED relocation must not be PC-relative at offset 1 of __TEXT,__text in {{.*}}test.a(test.o)
!mach-o
FileHeader:
magic: 0xFEEDFACF
cputype: 0x01000007
cpusubtype: 0x00000003
filetype: 0x00000001
ncmds: 4
sizeofcmds: 280
flags: 0x00000000
reserved: 0x00000000
LoadCommands:
- cmd: LC_SEGMENT_64
cmdsize: 152
segname: ''
vmaddr: 0
vmsize: 9
fileoff: 312
filesize: 9
maxprot: 7
initprot: 7
nsects: 1
flags: 0
Sections:
- sectname: __text
segname: __TEXT
addr: 0x0000000000000000
size: 9
offset: 0x00000138
align: 0
reloff: 0x00000144
nreloc: 1
flags: 0x80000000
reserved1: 0x00000000
reserved2: 0x00000000
reserved3: 0x00000000
content: '000000000000000000'
relocations:
- address: 0x00000001
symbolnum: 1
pcrel: true
length: 3
extern: true
type: 0
scattered: false
value: 0
- cmd: LC_BUILD_VERSION
cmdsize: 24
platform: 1
minos: 659200
sdk: 0
ntools: 0
- cmd: LC_SYMTAB
cmdsize: 24
symoff: 332
nsyms: 2
stroff: 364
strsize: 12
- cmd: LC_DYSYMTAB
cmdsize: 80
ilocalsym: 0
nlocalsym: 0
iextdefsym: 0
nextdefsym: 2
iundefsym: 2
nundefsym: 0
tocoff: 0
ntoc: 0
modtaboff: 0
nmodtab: 0
extrefsymoff: 0
nextrefsyms: 0
indirectsymoff: 0
nindirectsyms: 0
extreloff: 0
nextrel: 0
locreloff: 0
nlocrel: 0
LinkEditData:
NameList:
- n_strx: 1
n_type: 0x0F
n_sect: 1
n_desc: 0
n_value: 1
- n_strx: 6
n_type: 0x0F
n_sect: 1
n_desc: 0
n_value: 9
StringTable:
- ''
- _foo
- _main