# HG changeset patch # User Paul Boddie # Date 1434239089 -7200 # Node ID f1960e25e2b31cdda30a5c04d1dec08bc855a354 # Parent 62ee61016b7554bf7cfffe43718f9e96e3557c70 Introduced initial support for non-PIC stage 2 payloads that do not need their objects relocating, tested to be bootable from MMC. diff -r 62ee61016b75 -r f1960e25e2b3 stage2/Makefile --- a/stage2/Makefile Sat Jun 13 00:06:18 2015 +0200 +++ b/stage2/Makefile Sun Jun 14 01:44:49 2015 +0200 @@ -31,9 +31,9 @@ CFLAGS = -O2 -Wall \ -fno-unit-at-a-time -fno-zero-initialized-in-bss \ -ffreestanding -fno-hosted -fno-builtin \ - -march=mips32 -fPIC \ + -march=mips32 \ -I../include -LDFLAGS = -nostdlib -EL -pie +LDFLAGS = -nostdlib -EL UIMAGE = uImage PAYLOAD = stage2.bin @@ -76,7 +76,7 @@ echo "Nothing else to clean." $(UIMAGE): $(PAYLOAD) - $(MKIMAGE) -A mips -O u-boot -T standalone -C none -a 0x80000000 -e 0x80000000 -n NanoPayload -d $(PAYLOAD) $(UIMAGE) + $(MKIMAGE) -A mips -O linux -T kernel -C none -a 0x80010000 -e 0x80010000 -n NanoPayload -d $(PAYLOAD) $(UIMAGE) $(PAYLOAD): $(TARGET) $(OBJCOPY) -O binary $(@:.bin=.elf) $@+ diff -r 62ee61016b75 -r f1960e25e2b3 stage2/head2.S --- a/stage2/head2.S Sat Jun 13 00:06:18 2015 +0200 +++ b/stage2/head2.S Sun Jun 14 01:44:49 2015 +0200 @@ -12,22 +12,7 @@ .globl _start .set noreorder _start: - b real_start - nop - .word 0x0 // its address == start address + 8 - .word 0x0 - .word 0x0 - .word 0x0 - .word 0x0 - .word 0x0 - .word 0x0 - .word 0x0 - -real_start: - /* setup stack, jump to C code */ add $29, $20, 0x3ffff0 // sp locate at start address offset 0x2ffff0 - add $25, $20, 0x40 // t9 = c_main() - j $25 - nop + j c_main .set reorder diff -r 62ee61016b75 -r f1960e25e2b3 stage2/stage2.c --- a/stage2/stage2.c Sat Jun 13 00:06:18 2015 +0200 +++ b/stage2/stage2.c Sun Jun 14 01:44:49 2015 +0200 @@ -28,36 +28,8 @@ void c_main(void) { - /* Relocate object locations. */ - - volatile unsigned int start_addr, got_start, got_end, addr, offset; volatile int started; - /* get absolute start address */ - __asm__ __volatile__( - "move %0, $20\n\t" - : "=r"(start_addr) - : - ); - - /* get related GOT address */ - __asm__ __volatile__( - "la $4, _GLOBAL_OFFSET_TABLE_\n\t" - "move %0, $4\n\t" - "la $5, _got_end\n\t" - "move %1, $5\n\t" - : "=r"(got_start),"=r"(got_end) - : - ); - - /* calculate offset and correct GOT*/ - offset = start_addr - 0x80000000; - got_start += offset; - got_end += offset; - - for ( addr = got_start + 8; addr < got_end; addr += 4 ) - *((volatile unsigned int *)(addr)) += offset; // add offset to correct all GOT - /* The actual work. */ started = is_started(); diff -r 62ee61016b75 -r f1960e25e2b3 stage2/stage2.ld --- a/stage2/stage2.ld Sat Jun 13 00:06:18 2015 +0200 +++ b/stage2/stage2.ld Sun Jun 14 01:44:49 2015 +0200 @@ -2,7 +2,7 @@ ENTRY(_start) MEMORY { - ram : ORIGIN = 0x80000000 , LENGTH = 3M + ram : ORIGIN = 0x80010000 , LENGTH = 3M } SECTIONS