@@ -133,7 +133,7 @@ fn map_symbol(
133133 if symbol. is_weak ( ) {
134134 flags |= SymbolFlag :: Weak ;
135135 }
136- if file. format ( ) == object:: BinaryFormat :: Elf
136+ if matches ! ( file. format( ) , object:: BinaryFormat :: Elf | object :: BinaryFormat :: MachO )
137137 && symbol. scope ( ) == object:: SymbolScope :: Linkage
138138 && ( file. architecture ( ) != Architecture :: Arm || !symbol. is_global ( ) )
139139 {
@@ -250,20 +250,22 @@ fn add_section_symbols(sections: &[Section], symbols: &mut Vec<Symbol>) {
250250
251251 // `section.size` can include extra padding, so instead prefer using the address that the
252252 // last symbol ends at when there are any symbols in the section.
253+ // Compute size as a section-relative offset (important for non-zero section.address, e.g. Mach-O).
253254 let size = symbols
254255 . iter ( )
255256 . filter ( |s| {
256257 s. section == Some ( section_idx) && s. kind == SymbolKind :: Object && s. size > 0
257258 } )
258259 . map ( |s| s. address + s. size )
259260 . max ( )
260- . unwrap_or ( section. size ) ;
261+ . unwrap_or ( section. address + section. size )
262+ . saturating_sub ( section. address ) ;
261263
262264 symbols. push ( Symbol {
263265 name,
264266 demangled_name : None ,
265267 normalized_name : None ,
266- address : 0 ,
268+ address : section . address ,
267269 size,
268270 kind : SymbolKind :: Section ,
269271 section : Some ( section_idx) ,
@@ -577,6 +579,9 @@ fn map_section_relocations(
577579 let flags = match reloc. flags ( ) {
578580 object:: RelocationFlags :: Elf { r_type } => RelocationFlags :: Elf ( r_type) ,
579581 object:: RelocationFlags :: Coff { typ } => RelocationFlags :: Coff ( typ) ,
582+ object:: RelocationFlags :: MachO { r_type, r_pcrel, r_length } => {
583+ RelocationFlags :: MachO { r_type, r_pcrel, r_length }
584+ }
580585 flags => bail ! ( "Unhandled relocation flags: {:?}" , flags) ,
581586 } ;
582587 let target_symbol = match symbol_indices. get ( symbol_index. 0 ) . copied ( ) {
0 commit comments