summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-02-06 11:18:07 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-02-08 12:03:20 +0100
commit857f69ba8c66e3b4834bcaafd373a83043629326 (patch)
tree9f72ddcb01875d0ed9d46f74dc6c90e05ba50171 /arch
parentf7165017f41fab86c1dd97e40de2355fc64dde2f (diff)
downloadbarebox-857f69ba8c66e3b4834bcaafd373a83043629326.tar.gz
ARM: start: Fix image size calculation
In barebox_non_pbl_start() we do not run at the address we are linked at, so we must read linker variables using ld_var(). Since ld_var() current is not available on arm64 we create two zero sized arrays, one at the begin of the image and one at the end. The difference between both is the image size we are looking for. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/boards/avnet-zedboard/flash_header.c4
-rw-r--r--arch/arm/boards/friendlyarm-tiny210/lowlevel.c2
-rw-r--r--arch/arm/cpu/common.c3
-rw-r--r--arch/arm/include/asm/barebox-arm.h2
-rw-r--r--arch/arm/lib32/barebox.lds.S2
-rw-r--r--arch/arm/lib32/runtime-offset.S1
6 files changed, 10 insertions, 4 deletions
diff --git a/arch/arm/boards/avnet-zedboard/flash_header.c b/arch/arm/boards/avnet-zedboard/flash_header.c
index ea20524..d9eb35b 100644
--- a/arch/arm/boards/avnet-zedboard/flash_header.c
+++ b/arch/arm/boards/avnet-zedboard/flash_header.c
@@ -52,10 +52,10 @@ struct zynq_flash_header __flash_header_section flash_header = {
.enc_stat = 0x0,
.user = 0x0,
.flash_offset = 0x8c0,
- .length = barebox_image_size,
+ .length = (unsigned int)&_barebox_image_size,
.res0 = 0x0,
.start_of_exec = 0x0,
- .total_len = barebox_image_size,
+ .total_len = (unsigned int)&_barebox_image_size,
.res1 = 0x1,
.checksum = 0x0,
.res2 = 0x0,
diff --git a/arch/arm/boards/friendlyarm-tiny210/lowlevel.c b/arch/arm/boards/friendlyarm-tiny210/lowlevel.c
index 3ab8d66..fea00ef 100644
--- a/arch/arm/boards/friendlyarm-tiny210/lowlevel.c
+++ b/arch/arm/boards/friendlyarm-tiny210/lowlevel.c
@@ -97,7 +97,7 @@ void __bare_init barebox_arm_reset_vector(void)
debug_led(1, 1);
if (! load_stage2((void*)(ld_var(_text) - 16),
- ld_var(_barebox_image_size) + 16)) {
+ barebox_image_size + 16)) {
debug_led(3, 1);
while (1) { } /* hang */
}
diff --git a/arch/arm/cpu/common.c b/arch/arm/cpu/common.c
index 46ce942..dcd8f0b 100644
--- a/arch/arm/cpu/common.c
+++ b/arch/arm/cpu/common.c
@@ -78,3 +78,6 @@ int __pure cpu_architecture(void)
return __cpu_architecture;
}
#endif
+
+char __image_start[0] __attribute__((section(".__image_start")));
+char __image_end[0] __attribute__((section(".__image_end"))); \ No newline at end of file
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index e8dfd02..3aea2e0 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -179,4 +179,6 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
*/
#define MAX_BSS_SIZE SZ_1M
+#define barebox_image_size (__image_end - __image_start)
+
#endif /* _BAREBOX_ARM_H_ */
diff --git a/arch/arm/lib32/barebox.lds.S b/arch/arm/lib32/barebox.lds.S
index 6dc8bd2..5fd39dc 100644
--- a/arch/arm/lib32/barebox.lds.S
+++ b/arch/arm/lib32/barebox.lds.S
@@ -30,6 +30,7 @@ SECTIONS
#else
. = TEXT_BASE;
#endif
+ .image_start : { *(.__image_start) }
#ifndef CONFIG_PBL_IMAGE
PRE_IMAGE
@@ -116,6 +117,7 @@ SECTIONS
}
_edata = .;
+ .image_end : { *(.__image_end) }
. = ALIGN(4);
__bss_start = .;
diff --git a/arch/arm/lib32/runtime-offset.S b/arch/arm/lib32/runtime-offset.S
index f10c4c8..7375cb9 100644
--- a/arch/arm/lib32/runtime-offset.S
+++ b/arch/arm/lib32/runtime-offset.S
@@ -39,7 +39,6 @@ ld_var_entry __rel_dyn_start
ld_var_entry __rel_dyn_end
ld_var_entry __dynsym_start
ld_var_entry __dynsym_end
-ld_var_entry _barebox_image_size
ld_var_entry __bss_start
ld_var_entry __bss_stop
#ifdef __PBL__