The R_MIPS_GPREL16 / R_MIPS_GPREL32 relocations use the following expressions for calculations:
local symbol: S + A + GP0 - GP global symbol: S + A - GP GP - Represents the final gp value, i.e. _gp symbol GP0 - Represents the gp value used to create the relocatable object
The GP0 value is taken from the .reginfo data section defined by an object file. To implement that I keep a reference to MipsReginfoInputSection
in the ObjectFile class. This reference is used by the ObjectFile::getMipsGp0 method to return the GP0 value.