@@ -625,13 +625,28 @@ fn make_fake_pool_reloc(
625
625
let pool_reloc = resolve_relocation ( symbols, pool_reloc) ;
626
626
let offset_from_pool = pool_reloc. relocation . addend + offset as i64 ;
627
627
let target_address = pool_reloc. symbol . address . checked_add_signed ( offset_from_pool) ?;
628
- let section_index = pool_reloc. symbol . section ?;
629
- let target_symbol = symbols. iter ( ) . position ( |s| {
630
- s. section == Some ( section_index)
631
- && s. size > 0
632
- && ( s. address ..s. address + s. size ) . contains ( & target_address)
633
- } ) ?;
634
- let addend = target_address. checked_sub ( symbols[ target_symbol] . address ) ? as i64 ;
628
+ let target_symbol;
629
+ let addend;
630
+ if let Some ( section_index) = pool_reloc. symbol . section {
631
+ // Find the exact data symbol within the pool being accessed here based on the address.
632
+ target_symbol = symbols. iter ( ) . position ( |s| {
633
+ s. section == Some ( section_index)
634
+ && s. size > 0
635
+ && ( s. address ..s. address + s. size ) . contains ( & target_address)
636
+ } ) ?;
637
+ addend = target_address. checked_sub ( symbols[ target_symbol] . address ) ? as i64 ;
638
+ } else {
639
+ // If the target symbol is in a different object (extern), we simply copy the pool
640
+ // relocation's target. This is because it's not possible to locate the actual symbol if
641
+ // it's extern. And doing that for external symbols would also be unnecessary, because when
642
+ // the compiler generates an instruction that accesses an external "pool" plus some offset,
643
+ // that won't be a normal pool that contains other symbols within it that we want to
644
+ // display. It will be something like a vtable for a class with multiple inheritance (for
645
+ // example, dCcD_Cyl in The Wind Waker). So just showing that vtable symbol plus an addend
646
+ // to represent the offset into it works fine in this case.
647
+ target_symbol = pool_reloc. relocation . target_symbol ;
648
+ addend = pool_reloc. relocation . addend ;
649
+ }
635
650
Some ( Relocation {
636
651
flags : RelocationFlags :: Elf ( elf:: R_PPC_NONE ) ,
637
652
address : cur_addr as u64 ,
0 commit comments