From 0c53ac58079a05cf177550684112d72489d8b97e Mon Sep 17 00:00:00 2001 Message-Id: <0c53ac58079a05cf177550684112d72489d8b97e.1716400958.git.mdw@distorted.org.uk> From: Mark Wooding Date: Thu, 26 May 2016 09:26:09 +0100 Subject: [PATCH] base/asm-common.h: Introduce simpler PIC data reference macro. Organization: Straylight/Edgeware From: Mark Wooding Using the `GOT_PREL' relocation type means that we don't need to burn a register for the GOT. --- base/asm-common.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 ///-------------------------------------------------------------------------- -- [mdw]