mirror of
https://github.com/encounter/decomp-toolkit.git
synced 2025-12-10 14:08:07 +00:00
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.
This commit is contained in:
@@ -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)),
|
||||
|
||||
Reference in New Issue
Block a user