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 mut imp_entries = Vec::<RelImport>::with_capacity(imp_count);
|
||||
let mut raw_relocations = vec![];
|
||||
if !relocations.is_empty() {
|
||||
if info.version < 3 {
|
||||
// Version 1 and 2 RELs write relocations before the import table.
|
||||
header.rel_offset = offset;
|
||||
|
@ -958,6 +959,7 @@ where
|
|||
&mut offset,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
for symbol in file.symbols().filter(|s| s.is_definition()) {
|
||||
let Some(symbol_section) = symbol.section_index() else {
|
||||
|
@ -1035,6 +1037,7 @@ where
|
|||
}
|
||||
w.write_all(§ion_data)?;
|
||||
}
|
||||
if !relocations.is_empty() {
|
||||
if info.version < 3 {
|
||||
// Version 1 and 2 RELs write relocations before the import table.
|
||||
ensure!(w.stream_position()? as u32 == header.rel_offset);
|
||||
|
@ -1053,6 +1056,7 @@ where
|
|||
reloc.to_writer(w, Endian::Big)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
ensure!(w.stream_position()? as u32 == offset);
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue