[llvm-branch-commits] [llvm] [BOLT] Skip out-of-range pending relocations (PR #116964)

Paschalis Mpeis via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jan 20 08:34:35 PST 2025


================
@@ -165,11 +165,17 @@ 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);
 
+    if (!Relocation::canEncodeValue(Reloc.Type, Value,
----------------
paschalis-mpeis wrote:

`addPendingRelocation` now becomes the only way now to add a pending relocation (Parent PR #123635). If it comes from the `scanExternalRefs` optimization, then it is marked as optional. Finally, those relocations can be safely skipped when it's time to flush them.

https://github.com/llvm/llvm-project/pull/116964


More information about the llvm-branch-commits mailing list