Skip to content

Commit

Permalink
write/coff: handle undefined section symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc committed Nov 12, 2023
1 parent e8662af commit 1b2ba64
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/write/coff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl<'a> Object<'a> {
// Don't add name to strtab.
continue;
}
SymbolKind::Section => {
SymbolKind::Section if symbol.section.id().is_some() => {
symbol_offsets[index].aux_count = 1;
symtab_count += 1;
}
Expand Down Expand Up @@ -605,7 +605,13 @@ impl<'a> Object<'a> {
name = b".file";
coff::IMAGE_SYM_CLASS_FILE
}
SymbolKind::Section => coff::IMAGE_SYM_CLASS_STATIC,
SymbolKind::Section => {
if symbol.section.id().is_some() {
coff::IMAGE_SYM_CLASS_STATIC
} else {
coff::IMAGE_SYM_CLASS_SECTION
}
}
SymbolKind::Label => coff::IMAGE_SYM_CLASS_LABEL,
SymbolKind::Text | SymbolKind::Data | SymbolKind::Tls => {
match symbol.section {
Expand Down Expand Up @@ -676,7 +682,7 @@ impl<'a> Object<'a> {
buffer.write_bytes(&symbol.name);
buffer.resize(old_len + aux_len);
}
SymbolKind::Section => {
SymbolKind::Section if symbol.section.id().is_some() => {
debug_assert_eq!(number_of_aux_symbols, 1);
let section_index = symbol.section.id().unwrap().0;
let section = &self.sections[section_index];
Expand Down

0 comments on commit 1b2ba64

Please sign in to comment.