@@ -205,10 +205,18 @@ fn infer_symbol_sizes(symbols: &mut [Symbol], sections: &[Section]) {
205205 }
206206 iter_idx += 1 ;
207207 } ;
208- let next_address = next_symbol. map ( |s| s. address ) . unwrap_or_else ( || {
209- let section = & sections[ section_idx] ;
210- section. address + section. size
211- } ) ;
208+ let section = & sections[ section_idx] ;
209+ let mut next_address =
210+ next_symbol. map ( |s| s. address ) . unwrap_or_else ( || section. address + section. size ) ;
211+ if section. kind == SectionKind :: Code {
212+ // For functions, trim any trailing 4-byte zeroes from the end (padding, nops)
213+ while next_address > symbol. address + 4
214+ && let Some ( data) = section. data_range ( next_address - 4 , 4 )
215+ && data == [ 0u8 ; 4 ]
216+ {
217+ next_address -= 4 ;
218+ }
219+ }
212220 let new_size = next_address. saturating_sub ( symbol. address ) ;
213221 if new_size > 0 {
214222 let symbol = & mut symbols[ symbol_idx] ;
@@ -218,7 +226,7 @@ fn infer_symbol_sizes(symbols: &mut [Symbol], sections: &[Section]) {
218226 }
219227 // Set symbol kind if unknown and size is non-zero
220228 if symbol. kind == SymbolKind :: Unknown {
221- symbol. kind = match sections [ section_idx ] . kind {
229+ symbol. kind = match section . kind {
222230 SectionKind :: Code => SymbolKind :: Function ,
223231 SectionKind :: Data | SectionKind :: Bss => SymbolKind :: Object ,
224232 _ => SymbolKind :: Unknown ,
0 commit comments