[BOLT][AArch64] Detect veneers with missing data markers (#142069)
The linker may omit data markers for long absolute veneers causing BOLT to treat data as code. Detect such veneers and introduce data markers artificially before BOLT's disassembler kicks in.
This commit is contained in:
parent
587d6fcbb6
commit
c9022a29b4
@ -1341,6 +1341,19 @@ void RewriteInstance::discoverFileObjects() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The linker may omit data markers for absolute long veneers. Introduce
|
||||||
|
// those markers artificially to assist the disassembler.
|
||||||
|
for (BinaryFunction &BF :
|
||||||
|
llvm::make_second_range(BC->getBinaryFunctions())) {
|
||||||
|
if (BF.getOneName().starts_with("__AArch64AbsLongThunk_") &&
|
||||||
|
BF.getSize() == 16 && !BF.getSizeOfDataInCodeAt(8)) {
|
||||||
|
BC->errs() << "BOLT-WARNING: missing data marker detected in veneer "
|
||||||
|
<< BF << '\n';
|
||||||
|
BF.markDataAtOffset(8);
|
||||||
|
BC->AddressToConstantIslandMap[BF.getAddress() + 8] = &BF;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BC->IsLinuxKernel) {
|
if (!BC->IsLinuxKernel) {
|
||||||
|
@ -6,10 +6,21 @@
|
|||||||
# RUN: -fuse-ld=lld -Wl,-q
|
# RUN: -fuse-ld=lld -Wl,-q
|
||||||
# RUN: llvm-objdump -d %t.exe | FileCheck --check-prefix=CHECK-INPUT %s
|
# RUN: llvm-objdump -d %t.exe | FileCheck --check-prefix=CHECK-INPUT %s
|
||||||
# RUN: llvm-objcopy --remove-section .rela.mytext %t.exe
|
# RUN: llvm-objcopy --remove-section .rela.mytext %t.exe
|
||||||
# RUN: llvm-bolt %t.exe -o %t.bolt --elim-link-veneers=true --lite=0
|
# RUN: llvm-bolt %t.exe -o %t.bolt
|
||||||
# RUN: llvm-objdump -d -j .text %t.bolt | \
|
# RUN: llvm-objdump -d -j .text %t.bolt | \
|
||||||
# RUN: FileCheck --check-prefix=CHECK-OUTPUT %s
|
# RUN: FileCheck --check-prefix=CHECK-OUTPUT %s
|
||||||
|
|
||||||
|
## Occasionally, we see the linker not generating $d symbols for long veneers
|
||||||
|
## causing BOLT to fail veneer elimination.
|
||||||
|
# RUN: llvm-objcopy --remove-symbol-prefix=\$d %t.exe %t.no-marker.exe
|
||||||
|
# RUN: llvm-bolt %t.no-marker.exe -o %t.no-marker.bolt \
|
||||||
|
# RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-BOLT
|
||||||
|
# RUN: llvm-objdump -d -j .text %t.no-marker.bolt | \
|
||||||
|
# RUN: FileCheck --check-prefix=CHECK-OUTPUT %s
|
||||||
|
|
||||||
|
# CHECK-BOLT-NOT: BOLT-WARNING: unable to disassemble instruction
|
||||||
|
# CHECK-BOLT: BOLT-WARNING: missing data marker detected in veneer __AArch64AbsLongThunk_far_function
|
||||||
|
|
||||||
.text
|
.text
|
||||||
.balign 4
|
.balign 4
|
||||||
.global far_function
|
.global far_function
|
||||||
|
Loading…
x
Reference in New Issue
Block a user