[U-Boot] [PATCH v4] x86: Don't relocate symbols which point to things that aren't relocated
Gabe Black
gabeblack at chromium.org
Sun Nov 13 03:34:48 CET 2011
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 at chromium.org>
---
Changes in v2:
Merge in a fix in a later patch which gets rid of some unintentional
pointer arithmetic.
Changes in v3:
Update x86 tag.
Changes in v4:
Rebase onto the x86 repository.
arch/x86/lib/bios_setup.c | 7 ++-----
arch/x86/lib/board.c | 5 ++++-
arch/x86/lib/realmode.c | 7 ++-----
3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/arch/x86/lib/bios_setup.c b/arch/x86/lib/bios_setup.c
index 0dfe4a1..265f7d6 100644
--- a/arch/x86/lib/bios_setup.c
+++ b/arch/x86/lib/bios_setup.c
@@ -78,11 +78,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;
diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
index 244a021..18e0ede 100644
--- a/arch/x86/lib/board.c
+++ b/arch/x86/lib/board.c
@@ -231,8 +231,11 @@ static int do_elf_reloc_fixups(void)
offset_ptr_ram = offset_ptr_rom + gd->reloc_off;
/* Check that the target points into .text */
- if (*offset_ptr_ram >= CONFIG_SYS_TEXT_BASE)
+ if (*offset_ptr_ram >= CONFIG_SYS_TEXT_BASE &&
+ *offset_ptr_ram <
+ (CONFIG_SYS_TEXT_BASE + size)) {
*offset_ptr_ram += gd->reloc_off;
+ }
}
} while (re_src++ < re_end);
diff --git a/arch/x86/lib/realmode.c b/arch/x86/lib/realmode.c
index bf0d0aa..75511b2 100644
--- a/arch/x86/lib/realmode.c
+++ b/arch/x86/lib/realmode.c
@@ -30,11 +30,8 @@
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
More information about the U-Boot
mailing list