From: Mark Wooding Date: Thu, 26 May 2016 08:26:09 +0000 (+0100) Subject: base/asm-common.h: Introduce simpler PIC data reference macro. X-Git-Tag: 2.2.4~24 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb/commitdiff_plain/0c53ac58079a05cf177550684112d72489d8b97e?ds=sidebyside base/asm-common.h: Introduce simpler PIC data reference macro. Using the `GOT_PREL' relocation type means that we don't need to burn a register for the GOT. --- diff --git a/base/asm-common.h b/base/asm-common.h index 32c05430..9c2dfb30 100644 --- a/base/asm-common.h +++ b/base/asm-common.h @@ -210,6 +210,22 @@ _where_am_i.\got : #endif .endm +// Load address of external symbol ADDR into REG directly. + .macro leaextq reg, addr, cond= +#if WANT_PIC + ldr\cond \reg, .L$_leaextq$\@ +.L$_leaextq_pc$\@: + ldr\cond \reg, [pc, \reg] + _LIT + .balign 4 +.L$_leaextq$\@: + .word \addr(GOT_PREL) + (. - .L$_leaextq_pc$\@ - 8) + _ENDLIT +#else + ldr\cond \reg, =\addr +#endif + .endm + #endif ///--------------------------------------------------------------------------