public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] [x86] Don't relocate symbols which point to things that aren't relocated
@ 2011-11-08  6:58 Gabe Black
  2011-11-08  7:02 ` Gabe Black
  2011-11-08  7:08 ` [U-Boot] [PATCH v2] " Gabe Black
  0 siblings, 2 replies; 11+ messages in thread
From: Gabe Black @ 2011-11-08  6:58 UTC (permalink / raw)
  To: u-boot

This change adds an upper bound for symbols which are fixed up after u-boot
is relocated into RAM. This way portions that are left at their original
location can be referred to without having to manually fix up any pointers.

Signed-off-by: Gabe Black <gabeblack@chromium.org>
---
 arch/x86/lib/bios_setup.c |    7 ++-----
 arch/x86/lib/board.c      |   14 +++++++++++---
 arch/x86/lib/realmode.c   |    7 ++-----
 3 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/arch/x86/lib/bios_setup.c b/arch/x86/lib/bios_setup.c
index 6c6b0fe..8112f33 100644
--- a/arch/x86/lib/bios_setup.c
+++ b/arch/x86/lib/bios_setup.c
@@ -140,11 +140,8 @@ static void setvector(int vector, u16 segment, void *handler)
 
 int bios_setup(void)
 {
-	/*
-	 * The BIOS section is not relocated and still in the ROM. The
-	 * __bios_start symbol was adjusted, though, so adjust it back.
-	 */
-	ulong bios_start = (ulong)&__bios_start - gd->reloc_off;
+	/* The BIOS section is not relocated and still in the ROM. */
+	ulong bios_start = (ulong)&__bios_start;
 	ulong bios_size = (ulong)&__bios_size;
 
 	static int done=0;
diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
index 8963580..ac135b7 100644
--- a/arch/x86/lib/board.c
+++ b/arch/x86/lib/board.c
@@ -227,10 +227,18 @@ static int do_elf_reloc_fixups(void)
 	Elf32_Rel *re_src = (Elf32_Rel *)(&__rel_dyn_start);
 	Elf32_Rel *re_end = (Elf32_Rel *)(&__rel_dyn_end);
 
+	/* The size of the region of u-boot that runs out of RAM. */
+	uintptr_t size = &__bss_end - &__text_start;
+
 	do {
-		if (re_src->r_offset >= CONFIG_SYS_TEXT_BASE)
-			if (*(Elf32_Addr *)(re_src->r_offset + gd->reloc_off) >= CONFIG_SYS_TEXT_BASE)
-				*(Elf32_Addr *)(re_src->r_offset + gd->reloc_off) += gd->reloc_off;
+		if (re_src->r_offset >= CONFIG_SYS_TEXT_BASE) {
+			Elf32_Addr *addr = (Elf32_Addr *)
+				(re_src->r_offset + gd->reloc_off);
+			if (*addr >= CONFIG_SYS_TEXT_BASE &&
+				*addr < (CONFIG_SYS_TEXT_BASE + size)) {
+				*addr += gd->reloc_off;
+			}
+		}
 	} while (re_src++ < re_end);
 
 	return 0;
diff --git a/arch/x86/lib/realmode.c b/arch/x86/lib/realmode.c
index f8f2251..7637e2c 100644
--- a/arch/x86/lib/realmode.c
+++ b/arch/x86/lib/realmode.c
@@ -34,11 +34,8 @@ extern char realmode_enter;
 
 int realmode_setup(void)
 {
-	/*
-	 * The realmode section is not relocated and still in the ROM. The
-	 * __realmode_start symbol was adjusted, though, so adjust it back.
-	 */
-	ulong realmode_start = (ulong)&__realmode_start - gd->reloc_off;
+	/* The realmode section is not relocated and still in the ROM. */
+	ulong realmode_start = (ulong)&__realmode_start;
 	ulong realmode_size = (ulong)&__realmode_size;
 
 	/* copy the realmode switch code */
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-11-15  1:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-08  6:58 [U-Boot] [PATCH] [x86] Don't relocate symbols which point to things that aren't relocated Gabe Black
2011-11-08  7:02 ` Gabe Black
2011-11-08  7:08 ` [U-Boot] [PATCH v2] " Gabe Black
2011-11-08 13:46   ` Mike Frysinger
2011-11-08 21:04     ` Gabe Black
2011-11-08 21:58     ` Graeme Russ
2011-11-08 22:21   ` [U-Boot] [PATCH v3] x86: " Gabe Black
2011-11-12 10:20     ` Graeme Russ
2011-11-13  2:34       ` [U-Boot] [PATCH v4] " Gabe Black
2011-11-13 11:44         ` Graeme Russ
2011-11-15  1:51         ` Graeme Russ

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox