From 329936be006f5a35e07c4a0a476729abde8490d6 Mon Sep 17 00:00:00 2001 From: Max <34987259+mparisi20@users.noreply.github.com> Date: Mon, 1 Dec 2025 12:18:25 -0500 Subject: [PATCH] Fix .ctors splitting for RELs (#126) The ProDG hack in split_ctors_dtors caused the automated splitting of .ctors to be incorrect for RELs, by stripping relocatable function pointers out of the object. This patch checks for relocations, resolving both of the build failures observed in #125. --- src/util/split.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/util/split.rs b/src/util/split.rs index 6641fd1..6d6d7d4 100644 --- a/src/util/split.rs +++ b/src/util/split.rs @@ -10,11 +10,11 @@ use sanitise_file_name::sanitize_with_options; use tracing_attributes::instrument; use crate::{ - analysis::{cfa::SectionAddress, read_address, read_u32}, + analysis::{cfa::SectionAddress, read_address, read_u32, relocation_target_for}, obj::{ - ObjArchitecture, ObjInfo, ObjKind, ObjReloc, ObjRelocations, ObjSection, ObjSectionKind, - ObjSplit, ObjSymbol, ObjSymbolFlagSet, ObjSymbolFlags, ObjSymbolKind, ObjSymbolScope, - ObjUnit, SectionIndex, SymbolIndex, + ObjArchitecture, ObjInfo, ObjKind, ObjReloc, ObjRelocKind, ObjRelocations, ObjSection, + ObjSectionKind, ObjSplit, ObjSymbol, ObjSymbolFlagSet, ObjSymbolFlags, ObjSymbolKind, + ObjSymbolScope, ObjUnit, SectionIndex, SymbolIndex, }, util::{align_up, comment::MWComment, toposort::toposort}, }; @@ -33,7 +33,9 @@ fn split_ctors_dtors(obj: &mut ObjInfo, start: SectionAddress, end: SectionAddre while current_address < end { // ProDG hack when the end address is not known - if matches!(read_u32(ctors_section, current_address.address), Some(0)) { + if matches!(read_u32(ctors_section, current_address.address), Some(0)) + && relocation_target_for(obj, current_address, Some(ObjRelocKind::Absolute))?.is_none() + { while current_address < end { ensure!( matches!(read_u32(ctors_section, current_address.address), Some(0)),