asm-differ
asm-differ copied to clipboard
Fix GPREL16 references emitted by PS2 GCC
PS2 GCC emits R_MIPS_GPREL16 relocations for data that can be referenced by gp. The compiler emits an addend to all instructions that have the R_MIPS_GPREL16 relocation. Replacing the relocation of .sbss+0x4000-addend to the symbol that it points to would improve the diff for PS2 GCC objects.
objdump output of the object:
00000008 <CBuffGetStr__Fi>:
8: 04800005 bltz a0,20 <CBuffGetStr__Fi+0x18>
c: 00000000 nop
10: 8f82c000 lw v0,-16384(gp)
10: R_MIPS_GPREL16 .sbss+0x4000
14: 0082102a slt v0,a0,v0
18: 54400003 bnezl v0,28 <CBuffGetStr__Fi+0x20>
1c: 8f82c004 lw v0,-16380(gp)
1c: R_MIPS_GPREL16 .sbss+0x4000
20: 03e00008 jr ra
24: 0000102d move v0,zero
28: 8f83c00c lw v1,-16372(gp)
28: R_MIPS_GPREL16 .sbss+0x4000
2c: 00441018 mult v0,v0,a0
30: 03e00008 jr ra
34: 00621021 addu v0,v1,v0
Relocations in the object:
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000010 R_MIPS_GPREL16 .sbss+0x00004000
0000001c R_MIPS_GPREL16 .sbss+0x00004000
00000028 R_MIPS_GPREL16 .sbss+0x00004000
Relevant symbols in the object:
00000000 l .sbss 00000000 CBuffNum
00000004 l .sbss 00000000 CBuffMaxLen
0000000c l .sbss 00000000 CBuffStr
00000008 l .sbss 00000000 CBuffMaxNum