1、globe pointer($gp) define
1.1、It is the address in the middle of data sections.
1.2、Linker places scalar data around it so that they can be accessed efficiently by $gp-based load/store instructions and their addresses can be calculated efficiently by $gp-based add instructions.
2、$gp relative instruction
2.1、swi.gp Rt,[+(imm17s<<2)]
Rt = [imm17s<<2]
The (imm17s << 2) value covers a range of
512K byte region relative to the location pointed to by the GP register.
2.2、ADDI.gp Rt, imm19s
Rt = R29 + SE(imm19s)
The imm19s value covers a range of
512K byte region relative to the location pointed to by the GP register.
3、$gp example at assembly
3.1、Relax optimization
3.1.1、Default is on.
3.1.2、Trun off relax linker option : -mno-relax.
Attachment:
-mno-relax.png [ 326.47 KiB | Viewed 19458 times ]
ex:
example code
Attachment:
mem_test2.zip [58.29 KiB]
Downloaded 2086 times
Relax function
Attachment:
圖片1.jpg [ 10.49 KiB | Viewed 19458 times ]
No relax function
Attachment:
圖片2.jpg [ 14.43 KiB | Viewed 19458 times ]