[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:
Maksim Panchenko
2025-05-29 19:24:34 -07:00
committed by GitHub
parent 587d6fcbb6
commit c9022a29b4
2 changed files with 25 additions and 1 deletions

View File

@@ -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) {