@@ -18,12 +18,12 @@ use crate::obj::{
1818 ObjSymbolFlagSet , ObjSymbolFlags ,
1919} ;
2020
21- fn to_obj_section_kind ( kind : SectionKind ) -> ObjSectionKind {
21+ fn to_obj_section_kind ( kind : SectionKind ) -> Option < ObjSectionKind > {
2222 match kind {
23- SectionKind :: Text => ObjSectionKind :: Code ,
24- SectionKind :: Data | SectionKind :: ReadOnlyData => ObjSectionKind :: Data ,
25- SectionKind :: UninitializedData => ObjSectionKind :: Bss ,
26- _ => panic ! ( "Unhandled section kind {kind:?}" ) ,
23+ SectionKind :: Text => Some ( ObjSectionKind :: Code ) ,
24+ SectionKind :: Data | SectionKind :: ReadOnlyData => Some ( ObjSectionKind :: Data ) ,
25+ SectionKind :: UninitializedData => Some ( ObjSectionKind :: Bss ) ,
26+ _ => None ,
2727 }
2828}
2929
@@ -74,18 +74,14 @@ fn filter_sections(obj_file: &File<'_>) -> Result<Vec<ObjSection>> {
7474 if section. size ( ) == 0 {
7575 continue ;
7676 }
77- if section. kind ( ) != SectionKind :: Text
78- && section. kind ( ) != SectionKind :: Data
79- && section. kind ( ) != SectionKind :: ReadOnlyData
80- && section. kind ( ) != SectionKind :: UninitializedData
81- {
77+ let Some ( kind) = to_obj_section_kind ( section. kind ( ) ) else {
8278 continue ;
83- }
79+ } ;
8480 let name = section. name ( ) . context ( "Failed to process section name" ) ?;
8581 let data = section. uncompressed_data ( ) . context ( "Failed to read section data" ) ?;
8682 result. push ( ObjSection {
8783 name : name. to_string ( ) ,
88- kind : to_obj_section_kind ( section . kind ( ) ) ,
84+ kind,
8985 address : section. address ( ) ,
9086 size : section. size ( ) ,
9187 data : data. to_vec ( ) ,
0 commit comments