diff mbox

[U-Boot,46/82] x86: Do relocation before clearing BSS

Message ID 1474860866-16406-47-git-send-email-sjg@chromium.org
State Accepted
Commit 6bda55a38ce4d9c5fcab5a5011e06469662954b3
Delegated to: Bin Meng
Headers show

Commit Message

Simon Glass Sept. 26, 2016, 3:33 a.m. UTC
The BSS region may overlap with relocations. If we clear BSS we will
overwrite the start of the relocation area. This doesn't matter when running
from SPI flash, since it is read-only. But when relocating 64-bit U-Boot
from one place in RAM to another, relocation will fail because some of its
relocations have been zeroed.

To fix this, put the ELF fixup call before the BSS clearing call.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/board_f.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/common/board_f.c b/common/board_f.c
index 28a63a6..a06578c 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -1040,8 +1040,8 @@  static init_fnc_t init_sequence_f[] = {
 	setup_reloc,
 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
 	copy_uboot_to_ram,
-	clear_bss,
 	do_elf_reloc_fixups,
+	clear_bss,
 #endif
 #if defined(CONFIG_XTENSA)
 	clear_bss,