[PATCH] D137492: [lld-macho] Ensure that chained fixups data comes first in __LINKEDIT
Daniel Bertalan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 7 14:53:28 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG79f9f1f8e335: [lld-macho] Ensure that chained fixups data comes first in __LINKEDIT (authored by BertalanD).
Changed prior to commit:
https://reviews.llvm.org/D137492?vs=473433&id=473801#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137492/new/
https://reviews.llvm.org/D137492
Files:
lld/MachO/OutputSegment.cpp
lld/test/MachO/linkedit-contiguity.s
Index: lld/test/MachO/linkedit-contiguity.s
===================================================================
--- lld/test/MachO/linkedit-contiguity.s
+++ lld/test/MachO/linkedit-contiguity.s
@@ -2,7 +2,7 @@
# RUN: rm -rf %t; split-file %s %t
## codesign requires that each section in __LINKEDIT ends where the next one
-## starts. This test enforces that invariant.
+## starts and that they follow a certain order. This test enforces that invariant.
## It also checks that the last section in __LINKEDIT covers the last byte of
## the segment.
@@ -10,9 +10,12 @@
# RUN: %lld %t/foo.o -dylib -o %t/libfoo.dylib
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
+
# RUN: %lld -lSystem -adhoc_codesign -o %t/test %t/libfoo.dylib %t/test.o
+# RUN: llvm-objdump --macho --all-headers %t/test | FileCheck --check-prefixes=CHECK,OPCODE %s
-# RUN: llvm-objdump --macho --all-headers %t/test | FileCheck %s
+# RUN: %lld -lSystem -adhoc_codesign -fixup_chains -o %t/chained_test %t/libfoo.dylib %t/test.o
+# RUN: llvm-objdump --macho --all-headers %t/chained_test | FileCheck --check-prefixes=CHECK,CHAINED %s
# CHECK: segname __LINKEDIT
# CHECK-NEXT: vmaddr
@@ -20,18 +23,28 @@
# CHECK-NEXT: fileoff [[#LINKEDIT_OFF:]]
# CHECK-NEXT: filesize [[#LINKEDIT_SIZE:]]
-# CHECK: cmd LC_DYLD_INFO_ONLY
-# CHECK-NEXT: cmdsize 48
-# CHECK-NEXT: rebase_off [[#REBASE_OFF:]]
-# CHECK-NEXT: rebase_size [[#REBASE_SIZE:]]
-# CHECK-NEXT: bind_off [[#BIND_OFF: REBASE_OFF + REBASE_SIZE]]
-# CHECK-NEXT: bind_size [[#BIND_SIZE:]]
-# CHECK-NEXT: weak_bind_off [[#WEAK_OFF: BIND_OFF + BIND_SIZE]]
-# CHECK-NEXT: weak_bind_size [[#WEAK_SIZE:]]
-# CHECK-NEXT: lazy_bind_off [[#LAZY_OFF: WEAK_OFF + WEAK_SIZE]]
-# CHECK-NEXT: lazy_bind_size [[#LAZY_SIZE:]]
-# CHECK-NEXT: export_off [[#EXPORT_OFF: LAZY_OFF + LAZY_SIZE]]
-# CHECK-NEXT: export_size [[#EXPORT_SIZE:]]
+# OPCODE: cmd LC_DYLD_INFO_ONLY
+# OPCODE-NEXT: cmdsize 48
+# OPCODE-NEXT: rebase_off [[#REBASE_OFF:]]
+# OPCODE-NEXT: rebase_size [[#REBASE_SIZE:]]
+# OPCODE-NEXT: bind_off [[#BIND_OFF: REBASE_OFF + REBASE_SIZE]]
+# OPCODE-NEXT: bind_size [[#BIND_SIZE:]]
+# OPCODE-NEXT: weak_bind_off [[#WEAK_OFF: BIND_OFF + BIND_SIZE]]
+# OPCODE-NEXT: weak_bind_size [[#WEAK_SIZE:]]
+# OPCODE-NEXT: lazy_bind_off [[#LAZY_OFF: WEAK_OFF + WEAK_SIZE]]
+# OPCODE-NEXT: lazy_bind_size [[#LAZY_SIZE:]]
+# OPCODE-NEXT: export_off [[#EXPORT_OFF: LAZY_OFF + LAZY_SIZE]]
+# OPCODE-NEXT: export_size [[#EXPORT_SIZE:]]
+
+# CHAINED: cmd LC_DYLD_CHAINED_FIXUPS
+# CHAINED-NEXT: cmdsize
+# CHAINED-NEXT: dataoff [[#FIXUPS_OFF: LINKEDIT_OFF]]
+# CHAINED-NEXT: datasize [[#FIXUPS_SIZE:]]
+
+# CHAINED: cmd LC_DYLD_EXPORTS_TRIE
+# CHAINED-NEXT: cmdsize
+# CHAINED-NEXT: dataoff [[#EXPORT_OFF: FIXUPS_OFF + FIXUPS_SIZE]]
+# CHAINED-NEXT: datasize [[#EXPORT_SIZE:]]
# CHECK: cmd LC_FUNCTION_STARTS
# CHECK-NEXT: cmdsize
Index: lld/MachO/OutputSegment.cpp
===================================================================
--- lld/MachO/OutputSegment.cpp
+++ lld/MachO/OutputSegment.cpp
@@ -125,6 +125,7 @@
}
} else if (segname == segment_names::linkEdit) {
return StringSwitch<int>(osec->name)
+ .Case(section_names::chainFixups, -11)
.Case(section_names::rebase, -10)
.Case(section_names::binding, -9)
.Case(section_names::weakBinding, -8)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137492.473801.patch
Type: text/x-patch
Size: 3382 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221107/7db6727c/attachment.bin>
More information about the llvm-commits
mailing list