Commit 1c49abec authored by Kevin Hao's avatar Kevin Hao Committed by Scott Wood

powerpc: introduce macro LOAD_REG_ADDR_PIC

This is used to get the address of a variable when the kernel is not
running at the linked or relocated address.
Signed-off-by: default avatarKevin Hao <haokexin@gmail.com>
Signed-off-by: default avatarScott Wood <scottwood@freescale.com>
parent 99739611
...@@ -295,6 +295,11 @@ GLUE(.,name): ...@@ -295,6 +295,11 @@ GLUE(.,name):
* you want to access various offsets within it). On ppc32 this is * you want to access various offsets within it). On ppc32 this is
* identical to LOAD_REG_IMMEDIATE. * identical to LOAD_REG_IMMEDIATE.
* *
* LOAD_REG_ADDR_PIC(rn, name)
* Loads the address of label 'name' into register 'run'. Use this when
* the kernel doesn't run at the linked or relocated address. Please
* note that this macro will clobber the lr register.
*
* LOAD_REG_ADDRBASE(rn, name) * LOAD_REG_ADDRBASE(rn, name)
* ADDROFF(name) * ADDROFF(name)
* LOAD_REG_ADDRBASE loads part of the address of label 'name' into * LOAD_REG_ADDRBASE loads part of the address of label 'name' into
...@@ -305,6 +310,14 @@ GLUE(.,name): ...@@ -305,6 +310,14 @@ GLUE(.,name):
* LOAD_REG_ADDRBASE(rX, name) * LOAD_REG_ADDRBASE(rX, name)
* ld rY,ADDROFF(name)(rX) * ld rY,ADDROFF(name)(rX)
*/ */
/* Be careful, this will clobber the lr register. */
#define LOAD_REG_ADDR_PIC(reg, name) \
bl 0f; \
0: mflr reg; \
addis reg,reg,(name - 0b)@ha; \
addi reg,reg,(name - 0b)@l;
#ifdef __powerpc64__ #ifdef __powerpc64__
#define LOAD_REG_IMMEDIATE(reg,expr) \ #define LOAD_REG_IMMEDIATE(reg,expr) \
lis reg,(expr)@highest; \ lis reg,(expr)@highest; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment