diff --git a/src/write/coff/object.rs b/src/write/coff/object.rs index f70465f3..77f1fbb4 100644 --- a/src/write/coff/object.rs +++ b/src/write/coff/object.rs @@ -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, }); diff --git a/tests/round_trip/bss.rs b/tests/round_trip/bss.rs index 02fca4cc..e13003d5 100644 --- a/tests/round_trip/bss.rs +++ b/tests/round_trip/bss.rs @@ -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, @@ -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"));