Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MIPS $gp register

Tags:

mips

Is there a danger in using the $gp register to store a value? I guess my question is what is the true functionality of $gp and is it invoked behind-the-scenes somehow so that if I were to use it, things could go very very wrong?

like image 261
Hristo Avatar asked Apr 11 '10 21:04

Hristo


1 Answers

Well, $gp register points to the global area. Convention indicates that you should store it when you write a function (see .cprestore).

If you need to use it (honestly, cant see why), remeber these things:

1)Always store it in the Saved Register Area of your stack.

2)Always load that value into the $gp when destroying the stack.

3) Dont use it. (i.e dont access global scope)

Also, i'm not sure, but you can forget about PIC code.

like image 148
Tom Avatar answered Sep 23 '22 04:09

Tom