mirror of
https://github.com/encounter/decomp-toolkit.git
synced 2025-06-07 23:23:45 +00:00
write_rel: Skip setting reloc/imp offset with empty relocations
This commit is contained in:
parent
8659b56da4
commit
38c692650f
@ -932,6 +932,7 @@ where
|
|||||||
let imp_count = relocations.iter().map(|r| r.module_id).dedup().count();
|
let imp_count = relocations.iter().map(|r| r.module_id).dedup().count();
|
||||||
let mut imp_entries = Vec::<RelImport>::with_capacity(imp_count);
|
let mut imp_entries = Vec::<RelImport>::with_capacity(imp_count);
|
||||||
let mut raw_relocations = vec![];
|
let mut raw_relocations = vec![];
|
||||||
|
if !relocations.is_empty() {
|
||||||
if info.version < 3 {
|
if info.version < 3 {
|
||||||
// Version 1 and 2 RELs write relocations before the import table.
|
// Version 1 and 2 RELs write relocations before the import table.
|
||||||
header.rel_offset = offset;
|
header.rel_offset = offset;
|
||||||
@ -958,6 +959,7 @@ where
|
|||||||
&mut offset,
|
&mut offset,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for symbol in file.symbols().filter(|s| s.is_definition()) {
|
for symbol in file.symbols().filter(|s| s.is_definition()) {
|
||||||
let Some(symbol_section) = symbol.section_index() else {
|
let Some(symbol_section) = symbol.section_index() else {
|
||||||
@ -1035,6 +1037,7 @@ where
|
|||||||
}
|
}
|
||||||
w.write_all(§ion_data)?;
|
w.write_all(§ion_data)?;
|
||||||
}
|
}
|
||||||
|
if !relocations.is_empty() {
|
||||||
if info.version < 3 {
|
if info.version < 3 {
|
||||||
// Version 1 and 2 RELs write relocations before the import table.
|
// Version 1 and 2 RELs write relocations before the import table.
|
||||||
ensure!(w.stream_position()? as u32 == header.rel_offset);
|
ensure!(w.stream_position()? as u32 == header.rel_offset);
|
||||||
@ -1053,6 +1056,7 @@ where
|
|||||||
reloc.to_writer(w, Endian::Big)?;
|
reloc.to_writer(w, Endian::Big)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ensure!(w.stream_position()? as u32 == offset);
|
ensure!(w.stream_position()? as u32 == offset);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user