mirror of
https://github.com/encounter/object.git
synced 2026-07-10 12:18:39 -07:00
write/elf: improve .symtab_shndx writing (#906)
Write 0 if st_shndx is not `SHN_XINDEX`.
This commit is contained in:
@@ -858,9 +858,13 @@ impl<'a> Writer<'a> {
|
||||
}
|
||||
|
||||
if self.need_symtab_shndx {
|
||||
let section_index = sym.section.unwrap_or(SectionIndex(0));
|
||||
let section_index = if st_shndx == elf::SHN_XINDEX {
|
||||
sym.section.map_or(0, |s| s.0)
|
||||
} else {
|
||||
0
|
||||
};
|
||||
self.symtab_shndx_data
|
||||
.write_pod(&U32::new(self.endian, section_index.0));
|
||||
.write_pod(&U32::new(self.endian, section_index));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user