[llvm] [BOLT] Skip out-of-range pending relocations (PR #116964)
Maksim Panchenko via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 3 11:57:59 PDT 2025
================
@@ -174,11 +175,30 @@ void BinarySection::flushPendingRelocations(raw_pwrite_stream &OS,
OS.pwrite(Patch.Bytes.data(), Patch.Bytes.size(),
SectionFileOffset + Patch.Offset);
+ uint64_t SkippedPendingRelocations = 0;
for (Relocation &Reloc : PendingRelocations) {
uint64_t Value = Reloc.Addend;
if (Reloc.Symbol)
Value += Resolver(Reloc.Symbol);
+ // Safely skip any optional pending relocation that cannot be encoded.
+ if (Reloc.isOptional() &&
+ !Relocation::canEncodeValue(Reloc.Type, Value,
+ SectionAddress + Reloc.Offset)) {
+
+ // A successful run of 'scanExternalRefs' means that all pending
+ // relocations are flushed. Otherwise, PatchEntries should run.
+ if (!opts::ForcePatch) {
+ BC.errs()
+ << "BOLT-ERROR: Cannot encode relocation for symbol "
----------------
maksfb wrote:
nit:
```suggestion
<< "BOLT-ERROR: cannot encode relocation for symbol "
```
https://github.com/llvm/llvm-project/pull/116964
More information about the llvm-commits
mailing list