diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-10-03 16:25:08 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-03-07 10:56:37 +0100 |
commit | 74d44e7b2a741b7a7b4e9480d5c97a57073ad375 (patch) | |
tree | 5fd26d499e5a83af4e1e668def128e177246c5ed /arch/arm/include | |
parent | ae59bd9fcaa8d117217d4641d3af0ad83a7c7dcd (diff) | |
download | barebox-74d44e7b2a741b7a7b4e9480d5c97a57073ad375.tar.gz barebox-74d44e7b2a741b7a7b4e9480d5c97a57073ad375.tar.xz |
ARM: provide accessor functions for linker variables
With relocatable binaries the linker is not able to supply absolute
addresses. These only get available when the relocation function is
being run. Since for early initialization we need some variables
before relocation, we supply them relatively to some known address
in the binary. This means that the variables have to be converted
to absolute addresses during runtime.
This patch adds a C macro and an assembly macro to calculate the
variables during runtime.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/include')
-rw-r--r-- | arch/arm/include/asm/sections.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/arch/arm/include/asm/sections.h b/arch/arm/include/asm/sections.h index 2b8c516038..8c7bc8cccc 100644 --- a/arch/arm/include/asm/sections.h +++ b/arch/arm/include/asm/sections.h @@ -1 +1,34 @@ +#ifndef __ASM_SECTIONS_H +#define __ASM_SECTIONS_H + +#ifndef __ASSEMBLY__ #include <asm-generic/sections.h> + +/* + * Access a linker supplied variable. Use this if your code might not be running + * at the address it is linked at. + */ +#define ld_var(name) ({ \ + unsigned long __ld_var_##name(void); \ + __ld_var_##name(); \ +}) + +#else + +/* + * Access a linker supplied variable, assembler macro version + */ +.macro ld_var name, reg, scratch + 1000: + ldr \reg, 1001f + ldr \scratch, =1000b + add \reg, \reg, \scratch + b 1002f + 1001: + .word \name - 1000b + 1002: +.endm + +#endif + +#endif /* __ASM_SECTIONS_H */ |