1.1 --- a/stage2/Makefile Sat Jun 13 00:06:18 2015 +0200
1.2 +++ b/stage2/Makefile Sun Jun 14 01:44:49 2015 +0200
1.3 @@ -31,9 +31,9 @@
1.4 CFLAGS = -O2 -Wall \
1.5 -fno-unit-at-a-time -fno-zero-initialized-in-bss \
1.6 -ffreestanding -fno-hosted -fno-builtin \
1.7 - -march=mips32 -fPIC \
1.8 + -march=mips32 \
1.9 -I../include
1.10 -LDFLAGS = -nostdlib -EL -pie
1.11 +LDFLAGS = -nostdlib -EL
1.12
1.13 UIMAGE = uImage
1.14 PAYLOAD = stage2.bin
1.15 @@ -76,7 +76,7 @@
1.16 echo "Nothing else to clean."
1.17
1.18 $(UIMAGE): $(PAYLOAD)
1.19 - $(MKIMAGE) -A mips -O u-boot -T standalone -C none -a 0x80000000 -e 0x80000000 -n NanoPayload -d $(PAYLOAD) $(UIMAGE)
1.20 + $(MKIMAGE) -A mips -O linux -T kernel -C none -a 0x80010000 -e 0x80010000 -n NanoPayload -d $(PAYLOAD) $(UIMAGE)
1.21
1.22 $(PAYLOAD): $(TARGET)
1.23 $(OBJCOPY) -O binary $(@:.bin=.elf) $@+
2.1 --- a/stage2/head2.S Sat Jun 13 00:06:18 2015 +0200
2.2 +++ b/stage2/head2.S Sun Jun 14 01:44:49 2015 +0200
2.3 @@ -12,22 +12,7 @@
2.4 .globl _start
2.5 .set noreorder
2.6 _start:
2.7 - b real_start
2.8 - nop
2.9 - .word 0x0 // its address == start address + 8
2.10 - .word 0x0
2.11 - .word 0x0
2.12 - .word 0x0
2.13 - .word 0x0
2.14 - .word 0x0
2.15 - .word 0x0
2.16 - .word 0x0
2.17 -
2.18 -real_start:
2.19 - /* setup stack, jump to C code */
2.20 add $29, $20, 0x3ffff0 // sp locate at start address offset 0x2ffff0
2.21 - add $25, $20, 0x40 // t9 = c_main()
2.22 - j $25
2.23 - nop
2.24 + j c_main
2.25
2.26 .set reorder
3.1 --- a/stage2/stage2.c Sat Jun 13 00:06:18 2015 +0200
3.2 +++ b/stage2/stage2.c Sun Jun 14 01:44:49 2015 +0200
3.3 @@ -28,36 +28,8 @@
3.4
3.5 void c_main(void)
3.6 {
3.7 - /* Relocate object locations. */
3.8 -
3.9 - volatile unsigned int start_addr, got_start, got_end, addr, offset;
3.10 volatile int started;
3.11
3.12 - /* get absolute start address */
3.13 - __asm__ __volatile__(
3.14 - "move %0, $20\n\t"
3.15 - : "=r"(start_addr)
3.16 - :
3.17 - );
3.18 -
3.19 - /* get related GOT address */
3.20 - __asm__ __volatile__(
3.21 - "la $4, _GLOBAL_OFFSET_TABLE_\n\t"
3.22 - "move %0, $4\n\t"
3.23 - "la $5, _got_end\n\t"
3.24 - "move %1, $5\n\t"
3.25 - : "=r"(got_start),"=r"(got_end)
3.26 - :
3.27 - );
3.28 -
3.29 - /* calculate offset and correct GOT*/
3.30 - offset = start_addr - 0x80000000;
3.31 - got_start += offset;
3.32 - got_end += offset;
3.33 -
3.34 - for ( addr = got_start + 8; addr < got_end; addr += 4 )
3.35 - *((volatile unsigned int *)(addr)) += offset; // add offset to correct all GOT
3.36 -
3.37 /* The actual work. */
3.38
3.39 started = is_started();
4.1 --- a/stage2/stage2.ld Sat Jun 13 00:06:18 2015 +0200
4.2 +++ b/stage2/stage2.ld Sun Jun 14 01:44:49 2015 +0200
4.3 @@ -2,7 +2,7 @@
4.4 ENTRY(_start)
4.5 MEMORY
4.6 {
4.7 - ram : ORIGIN = 0x80000000 , LENGTH = 3M
4.8 + ram : ORIGIN = 0x80010000 , LENGTH = 3M
4.9 }
4.10
4.11 SECTIONS