diff options
Diffstat (limited to 'vendor/object/src/write/coff.rs')
-rw-r--r-- | vendor/object/src/write/coff.rs | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/vendor/object/src/write/coff.rs b/vendor/object/src/write/coff.rs index c7489d3d6..d2f7ccc64 100644 --- a/vendor/object/src/write/coff.rs +++ b/vendor/object/src/write/coff.rs @@ -37,29 +37,41 @@ impl<'a> Object<'a> { pub(crate) fn coff_section_info( &self, section: StandardSection, - ) -> (&'static [u8], &'static [u8], SectionKind) { + ) -> (&'static [u8], &'static [u8], SectionKind, SectionFlags) { match section { - StandardSection::Text => (&[], &b".text"[..], SectionKind::Text), - StandardSection::Data => (&[], &b".data"[..], SectionKind::Data), + StandardSection::Text => (&[], &b".text"[..], SectionKind::Text, SectionFlags::None), + StandardSection::Data => (&[], &b".data"[..], SectionKind::Data, SectionFlags::None), StandardSection::ReadOnlyData | StandardSection::ReadOnlyDataWithRel - | StandardSection::ReadOnlyString => (&[], &b".rdata"[..], SectionKind::ReadOnlyData), - StandardSection::UninitializedData => { - (&[], &b".bss"[..], SectionKind::UninitializedData) - } + | StandardSection::ReadOnlyString => ( + &[], + &b".rdata"[..], + SectionKind::ReadOnlyData, + SectionFlags::None, + ), + StandardSection::UninitializedData => ( + &[], + &b".bss"[..], + SectionKind::UninitializedData, + SectionFlags::None, + ), // TLS sections are data sections with a special name. - StandardSection::Tls => (&[], &b".tls$"[..], SectionKind::Data), + StandardSection::Tls => (&[], &b".tls$"[..], SectionKind::Data, SectionFlags::None), StandardSection::UninitializedTls => { // Unsupported section. - (&[], &[], SectionKind::UninitializedTls) + (&[], &[], SectionKind::UninitializedTls, SectionFlags::None) } StandardSection::TlsVariables => { // Unsupported section. - (&[], &[], SectionKind::TlsVariables) + (&[], &[], SectionKind::TlsVariables, SectionFlags::None) } StandardSection::Common => { // Unsupported section. - (&[], &[], SectionKind::Common) + (&[], &[], SectionKind::Common, SectionFlags::None) + } + StandardSection::GnuProperty => { + // Unsupported section. + (&[], &[], SectionKind::Note, SectionFlags::None) } } } @@ -265,7 +277,7 @@ impl<'a> Object<'a> { symtab_count += 1; match symbol.kind { SymbolKind::File => { - // Name goes in auxilary symbol records. + // Name goes in auxiliary symbol records. let aux_count = (symbol.name.len() + coff::IMAGE_SIZEOF_SYMBOL - 1) / coff::IMAGE_SIZEOF_SYMBOL; symbol_offsets[index].aux_count = aux_count as u8; @@ -355,7 +367,9 @@ impl<'a> Object<'a> { | coff::IMAGE_SCN_MEM_READ | coff::IMAGE_SCN_MEM_WRITE } - SectionKind::ReadOnlyData | SectionKind::ReadOnlyString => { + SectionKind::ReadOnlyData + | SectionKind::ReadOnlyDataWithRel + | SectionKind::ReadOnlyString => { coff::IMAGE_SCN_CNT_INITIALIZED_DATA | coff::IMAGE_SCN_MEM_READ } SectionKind::Debug | SectionKind::Other | SectionKind::OtherString => { @@ -573,11 +587,11 @@ impl<'a> Object<'a> { let section_number = match symbol.section { SymbolSection::None => { debug_assert_eq!(symbol.kind, SymbolKind::File); - coff::IMAGE_SYM_DEBUG + coff::IMAGE_SYM_DEBUG as u16 } - SymbolSection::Undefined => coff::IMAGE_SYM_UNDEFINED, - SymbolSection::Absolute => coff::IMAGE_SYM_ABSOLUTE, - SymbolSection::Common => coff::IMAGE_SYM_UNDEFINED, + SymbolSection::Undefined => coff::IMAGE_SYM_UNDEFINED as u16, + SymbolSection::Absolute => coff::IMAGE_SYM_ABSOLUTE as u16, + SymbolSection::Common => coff::IMAGE_SYM_UNDEFINED as u16, SymbolSection::Section(id) => id.0 as u16 + 1, }; let typ = if symbol.kind == SymbolKind::Text { @@ -587,7 +601,7 @@ impl<'a> Object<'a> { }; let storage_class = match symbol.kind { SymbolKind::File => { - // Name goes in auxilary symbol records. + // Name goes in auxiliary symbol records. name = b".file"; coff::IMAGE_SYM_CLASS_FILE } @@ -640,7 +654,7 @@ impl<'a> Object<'a> { let mut coff_symbol = coff::ImageSymbol { name: [0; 8], value: U32Bytes::new(LE, value), - section_number: U16Bytes::new(LE, section_number as u16), + section_number: U16Bytes::new(LE, section_number), typ: U16Bytes::new(LE, typ), storage_class, number_of_aux_symbols, |