Add primitive relocation to i386 port
PATCH 7/7 Add primitive relocation to i386 port
Add basic relocation to i386 port
---
This patch provides relocation of the text (code) segment of the i386 binary (in addition to already relocated sections). However, as discussed previously on the mailing list, the relocation does not fix up references to read-only data which is still referenced into Flash. Full relocation is likely going to require some in-depth knowledge of ELF and the very mysterious 'Global Offset Table'
cpu/i386/interrupts.c | 4 ++-- cpu/i386/start.S | 41 +++++++++++++++++++++++++++++++++++++++++ include/configs/sc520_cdp.h | 2 ++ include/configs/sc520_spunk.h | 2 ++ lib_i386/board.c | 27 +++++++++++++++++++++++++++ lib_i386/interrupts.c | 4 ++-- lib_i386/timer.c | 2 +- 7 files changed, 77 insertions(+), 5 deletions(-)
cpu/i386/interrupts.c +2 -2
@@ -53,8 +53,8 @@ asm ("idt_ptr:\n"void set_vector (u8 intnum,void *routine) { - idt[intnum].base_high = (u16)((u32)(routine)>>16 ); - idt[intnum].base_low = (u16)((u32)(routine)&0xffff ); + idt[intnum].base_high = (u16)((u32)(routine + gd->reloc_off) >>16 ); + idt[intnum].base_low = (u16)((u32)(routine + gd->reloc_off) &0xffff ); }
cpu/i386/start.S +41 -0
55 lines not on this page · raw message
include/configs/sc520_cdp.h +2 -0
@@ -28,6 +28,8 @@#ifndef __CONFIG_H#define __CONFIG_H +#define CONFIG_SKIP_RELOCATE_UBOOT +#define GRUSS_TESTING /* * High Level Configuration Options
include/configs/sc520_spunk.h +2 -0
@@ -28,6 +28,8 @@#ifndef __CONFIG_H#define __CONFIG_H +#define CONFIG_SKIP_RELOCATE_UBOOT +/* * High Level Configuration Options * (easy to change)
lib_i386/board.c +27 -0
@@ -225,6 +225,9 @@ void start_i386boot (void)static bd_t bd_data;init_fnc_t **init_fnc_ptr; +#ifndef CONFIG_SKIP_RELOCATE_UBOOT +cmd_tbl_t *p; +#endif show_boot_progress (0x21 ); gd = &gd_data;
@@ -238,6 +241,10 @@ void start_i386boot (void) gd->baudrate =CONFIG_BAUDRATE ; +#ifndef CONFIG_SKIP_RELOCATE_UBOOT +/* Need to set relocation offset here for interrupt initialization */ + gd->reloc_off =CONFIG_SYS_BL_START_RAM -TEXT_BASE ; +#endif for (init_fnc_ptr = init_sequence, i=0 ; *init_fnc_ptr; ++init_fnc_ptr, i++) {show_boot_progress (0xa130 |i);
@@ -247,6 +254,26 @@ void start_i386boot (void) }show_boot_progress (0x23 ); +#ifndef CONFIG_SKIP_RELOCATE_UBOOT +for (p = &__u_boot_cmd_start; p != &__u_boot_cmd_end; p++) { +ulong addr; + addr = (ulong) (p->cmd) + gd->reloc_off; + p->cmd = (int (*)(struct cmd_tbl_s *,int ,int ,char *[]))addr; + addr = (ulong)(p->name) + gd->reloc_off; + p->name = (char *)addr; + +if (p->usage !=NULL ) { + addr = (ulong)(p->usage) + gd->reloc_off; + p->usage = (char *)addr; + } +#ifdef CONFIG_SYS_LONGHELP +if (p->help !=NULL ) { + addr = (ulong)(p->help) + gd->reloc_off; + p->help = (char *)addr; + } +#endif + } +#endif /* configure available FLASH banks */ size =flash_init ();display_flash_config (size);
lib_i386/interrupts.c +2 -2
@@ -70,12 +70,12 @@ void irq_install_handler(int irq, interrupt_handler_t *handler, void *arg)if (irq_handlers[irq].handler !=NULL )printf ("irq_install_handler: 0x%08lx replacing 0x%08lx\n" , - (ulong ) handler, + (ulong ) handler + gd->reloc_off, (ulong ) irq_handlers[irq].handler); status =disable_interrupts (); - irq_handlers[irq].handler = handler; + irq_handlers[irq].handler = handler + gd->reloc_off; irq_handlers[irq].arg = arg; irq_handlers[irq].count =0 ;
lib_i386/timer.c +1 -1
@@ -51,7 +51,7 @@ int register_timer_isr (timer_fnc_t *isr_func)if (new_func ==NULL )return 1 ; - new_func->isr_func = isr_func; + new_func->isr_func = isr_func + gd->reloc_off; new_func->next =NULL ;/*
Wolfgang Denk
AppliedPATCH 7/7 Add primitive relocation to i386 port
Dear Graeme Russ,
Quoted 11 lines · In message <[email protected]> you wrote:
Add basic relocation to i386 port
Signed-off-by Graeme Russ <[email protected]>---
This patch provides relocation of the text (code) segment of the i386 binary (in addition to already relocated sections). However, as discussed previously on the mailing list, the relocation does not fix up references to read-only data which is still referenced into Flash. Full relocation is likely going to require some in-depth knowledge of ELF and the very mysterious 'Global Offset Table'
Quoted 8 lines
cpu/i386/interrupts.c | 4 ++-- cpu/i386/start.S | 41 +++++++++++++++++++++++++++++++++++++++++ include/configs/sc520_cdp.h | 2 ++ include/configs/sc520_spunk.h | 2 ++ lib_i386/board.c | 27 +++++++++++++++++++++++++++ lib_i386/interrupts.c | 4 ++-- lib_i386/timer.c | 2 +- 7 files changed, 77 insertions(+), 5 deletions(-)
Applied to "next" branch. Thanks.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Der Dativ ist dem Genitiv sein Tod.