barebox/arch/arm/include/asm/sections.h
Sascha Hauer 74d44e7b2a 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>
2013-03-07 10:56:37 +01:00

35 lines
597 B
C

#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 */