Skip to content

Commit 074af2d

Browse files
author
Alexander Shaposhnikov
committed
[llvm-objcopy][MachO] Add support for min os version load commands
Add support for min os version load commands. Test plan: make check-all Differential revision: https://reviews.llvm.org/D69419
1 parent d4303b3 commit 074af2d

File tree

6 files changed

+83
-0
lines changed

6 files changed

+83
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- !mach-o
2+
FileHeader:
3+
magic: 0xFEEDFACE
4+
cputype: 0x0000000C
5+
cpusubtype: 0x00000009
6+
filetype: 0x00000001
7+
ncmds: 1
8+
sizeofcmds: 16
9+
flags: 0x00002000
10+
LoadCommands:
11+
- cmd: LC_VERSION_MIN_IPHONEOS
12+
cmdsize: 16
13+
version: 327680
14+
sdk: 0
15+
...
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- !mach-o
2+
FileHeader:
3+
magic: 0xFEEDFACE
4+
cputype: 0x0000000C
5+
cpusubtype: 0x00000009
6+
filetype: 0x00000001
7+
ncmds: 1
8+
sizeofcmds: 16
9+
flags: 0x00002000
10+
LoadCommands:
11+
- cmd: LC_VERSION_MIN_MACOSX
12+
cmdsize: 16
13+
version: 327680
14+
sdk: 0
15+
...
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- !mach-o
2+
FileHeader:
3+
magic: 0xFEEDFACE
4+
cputype: 0x0000000C
5+
cpusubtype: 0x00000009
6+
filetype: 0x00000001
7+
ncmds: 1
8+
sizeofcmds: 16
9+
flags: 0x00002000
10+
LoadCommands:
11+
- cmd: LC_VERSION_MIN_TVOS
12+
cmdsize: 16
13+
version: 327680
14+
sdk: 0
15+
...
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- !mach-o
2+
FileHeader:
3+
magic: 0xFEEDFACE
4+
cputype: 0x0000000C
5+
cpusubtype: 0x00000009
6+
filetype: 0x00000001
7+
ncmds: 1
8+
sizeofcmds: 16
9+
flags: 0x00002000
10+
LoadCommands:
11+
- cmd: LC_VERSION_MIN_WATCHOS
12+
cmdsize: 16
13+
version: 327680
14+
sdk: 0
15+
...
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## This test verifies that llvm-objcopy correctly handles min os version load commands.
2+
## We use separate input files since one binary is not allowed to contain more than one
3+
## load command of this type (LC_VERSION_MIN_IPHONEOS, LC_VERSION_MIN_MACOSX,
4+
## LC_VERSION_MIN_TVOS, LC_VERSION_MIN_WATCHOS).
5+
6+
# RUN: yaml2obj %p/Inputs/min_iphoneos_version_lc.yaml > %t.iphoneos
7+
# RUN: llvm-objcopy %t.iphoneos %t.iphoneos.copy
8+
# RUN: cmp %t.iphoneos %t.iphoneos.copy
9+
10+
# RUN: yaml2obj %p/Inputs/min_macos_version_lc.yaml > %t.macos
11+
# RUN: llvm-objcopy %t.macos %t.macos.copy
12+
# RUN: cmp %t.macos %t.macos.copy
13+
14+
# RUN: yaml2obj %p/Inputs/min_tvos_version_lc.yaml > %t.tvos
15+
# RUN: llvm-objcopy %t.tvos %t.tvos.copy
16+
# RUN: cmp %t.tvos %t.tvos.copy
17+
18+
# RUN: yaml2obj %p/Inputs/min_watchos_version_lc.yaml > %t.watchos
19+
# RUN: llvm-objcopy %t.watchos %t.watchos.copy
20+
# RUN: cmp %t.watchos %t.watchos.copy

llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ Error MachOLayoutBuilder::layoutTail(uint64_t Offset) {
318318
case MachO::LC_SEGMENT:
319319
case MachO::LC_SEGMENT_64:
320320
case MachO::LC_VERSION_MIN_MACOSX:
321+
case MachO::LC_VERSION_MIN_IPHONEOS:
322+
case MachO::LC_VERSION_MIN_TVOS:
323+
case MachO::LC_VERSION_MIN_WATCHOS:
321324
case MachO::LC_BUILD_VERSION:
322325
case MachO::LC_ID_DYLIB:
323326
case MachO::LC_LOAD_DYLIB:

0 commit comments

Comments
 (0)