[lld] 28be02f - [lld/mac] Don't assert on -dead_strip + arm64 range extension thunks
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 27 20:28:34 PDT 2021
Author: Nico Weber
Date: 2021-08-27T23:27:45-04:00
New Revision: 28be02f33493f924d92b74b374e4d0bd6d1aaa63
URL: https://github.com/llvm/llvm-project/commit/28be02f33493f924d92b74b374e4d0bd6d1aaa63
DIFF: https://github.com/llvm/llvm-project/commit/28be02f33493f924d92b74b374e4d0bd6d1aaa63.diff
LOG: [lld/mac] Don't assert on -dead_strip + arm64 range extension thunks
The assert is harmless and thinks worked fine in builds with asserts enabled,
but it's still nice to fix the assert.
Differential Revision: https://reviews.llvm.org/D108853
Added:
Modified:
lld/MachO/ConcatOutputSection.cpp
lld/test/MachO/arm64-thunks.s
Removed:
################################################################################
diff --git a/lld/MachO/ConcatOutputSection.cpp b/lld/MachO/ConcatOutputSection.cpp
index 78590cff2eef..b41495b4fc64 100644
--- a/lld/MachO/ConcatOutputSection.cpp
+++ b/lld/MachO/ConcatOutputSection.cpp
@@ -109,7 +109,7 @@ void ConcatOutputSection::addInput(ConcatInputSection *input) {
// thus, we place thunks at monotonically increasing addresses. Once a thunk
// is placed, it and all previous input-section addresses are final.
//
-// * MergedInputSection::finalize() and MergedInputSection::writeTo() merge
+// * ConcatInputSection::finalize() and ConcatInputSection::writeTo() merge
// the inputs and thunks vectors (both ordered by ascending address), which
// is simple and cheap.
@@ -295,6 +295,12 @@ void ConcatOutputSection::finalize() {
thunkInfo.isec =
make<ConcatInputSection>(isec->getSegName(), isec->getName());
thunkInfo.isec->parent = this;
+
+ // This code runs after dead code removal. Need to set the `live` bit
+ // on the thunk isec so that asserts that check that only live sections
+ // get written are happy.
+ thunkInfo.isec->live = true;
+
StringRef thunkName = saver.save(funcSym->getName() + ".thunk." +
std::to_string(thunkInfo.sequence++));
r.referent = thunkInfo.sym = symtab->addDefined(
diff --git a/lld/test/MachO/arm64-thunks.s b/lld/test/MachO/arm64-thunks.s
index a97c4d60db00..38e1f4ce3ccb 100644
--- a/lld/test/MachO/arm64-thunks.s
+++ b/lld/test/MachO/arm64-thunks.s
@@ -2,15 +2,17 @@
## Check for the following:
## (1) address match between thunk definitions and call destinations
-## (2) address match between thunk page+offset computations and function definitions
+## (2) address match between thunk page+offset computations and function
+## definitions
## (3) a second thunk is created when the first one goes out of range
-## (4) early calls to a dylib stub use a thunk, and later calls the stub directly
+## (4) early calls to a dylib stub use a thunk, and later calls the stub
+## directly
## Notes:
## 0x4000000 = 64 Mi = half the magnitude of the forward-branch range
# RUN: rm -rf %t; mkdir %t
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t/input.o
-# RUN: %lld -arch arm64 -lSystem -o %t/thunk %t/input.o
+# RUN: %lld -arch arm64 -dead_strip -lSystem -o %t/thunk %t/input.o
# RUN: llvm-objdump -d --no-show-raw-insn %t/thunk | FileCheck %s
# CHECK: Disassembly of section __TEXT,__text:
More information about the llvm-commits
mailing list