Skip to content

Commit

Permalink
write/coff: Set checksum for BSS section symbols (#718)
Browse files Browse the repository at this point in the history
  • Loading branch information
OndrikB authored Aug 11, 2024
1 parent 48f6b29 commit 112417e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/write/coff/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,11 @@ impl<'a> Object<'a> {
length: section.size as u32,
number_of_relocations: section.relocations.len() as u32,
number_of_linenumbers: 0,
check_sum: checksum(section.data()),
check_sum: if section.is_bss() {
0
} else {
checksum(section.data())
},
number: section_offsets[section_index].associative_section,
selection: section_offsets[section_index].selection,
});
Expand Down
12 changes: 12 additions & 0 deletions tests/round_trip/bss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ fn coff_x86_64_bss() {

let section = object.section_id(write::StandardSection::UninitializedData);

let _bss_section_symbol = object.section_symbol(section);

let symbol = object.add_symbol(write::Symbol {
name: b"v1".to_vec(),
value: 0,
Expand Down Expand Up @@ -60,6 +62,16 @@ fn coff_x86_64_bss() {

let mut symbols = object.symbols();

let section_symbol = symbols.next().unwrap();
println!("{:?}", section_symbol);
assert_eq!(section_symbol.name(), Ok(".bss"));
assert_eq!(section_symbol.kind(), SymbolKind::Section);
assert_eq!(section_symbol.section_index(), Some(bss_index));
assert_eq!(section_symbol.scope(), SymbolScope::Compilation);
assert!(!section_symbol.is_weak());
assert!(!section_symbol.is_undefined());
assert_eq!(section_symbol.address(), 0);

let symbol = symbols.next().unwrap();
println!("{:?}", symbol);
assert_eq!(symbol.name(), Ok("v1"));
Expand Down

0 comments on commit 112417e

Please sign in to comment.