# HG changeset patch # User Paul Boddie # Date 1461618344 -7200 # Node ID 8e7b3cc4a26848ad9505131792b613a1f35982b7 # Parent a1f3027033f2725e10f61d5395e1cc9bd10b445f Attempted to simplify region allocation by putting the object table copy in a completely separate location. diff -r a1f3027033f2 -r 8e7b3cc4a268 stage2/entry.S --- a/stage2/entry.S Mon Apr 25 21:56:49 2016 +0200 +++ b/stage2/entry.S Mon Apr 25 23:05:44 2016 +0200 @@ -21,7 +21,7 @@ .extern interrupt_handler .extern current_registers .extern current_stack_pointer -.extern _payload_end +.extern _shared_end .globl _tlb_entry .globl _exc_entry .globl _irq_entry @@ -43,10 +43,10 @@ beqz $k1, _tlb_entry_direct nop - /* For addresses beyond the relocated global object table... */ + /* For addresses beyond the program and data... */ - lui $k1, %hi(_payload_end - 0x80000000) - ori $k1, $k1, %lo(_payload_end - 0x80000000) + lui $k1, %hi(_shared_end - 0x80000000) + ori $k1, $k1, %lo(_shared_end - 0x80000000) sltu $k1, $k1, $k0 bnez $k1, _tlb_entry_direct nop diff -r a1f3027033f2 -r 8e7b3cc4a268 stage2/head2.S --- a/stage2/head2.S Mon Apr 25 21:56:49 2016 +0200 +++ b/stage2/head2.S Mon Apr 25 23:05:44 2016 +0200 @@ -30,7 +30,7 @@ .extern _end_entries .extern _got_start .extern _got_end -.extern _got_copy_start +.extern _payload_start .extern enter_task .globl _start .globl _enter_task @@ -89,10 +89,13 @@ /* Copy the offset table for user mode programs. */ + li $t3, 0x80000000 /* adjustment */ la $t0, _got_start /* start */ - la $t1, _got_copy_start + la $t1, _payload_start + subu $t1, $t0, $t1 + addiu $t1, $t1, 0x1000 + addu $t1, $t1, $t3 /* target = start - payload start + 0x80001000 */ la $t2, _got_end /* end */ - li $t3, 0x80000000 /* adjustment */ jal _copy_adjust nop diff -r a1f3027033f2 -r 8e7b3cc4a268 stage2/stage2.ld --- a/stage2/stage2.ld Mon Apr 25 21:56:49 2016 +0200 +++ b/stage2/stage2.ld Mon Apr 25 23:05:44 2016 +0200 @@ -21,33 +21,18 @@ . = ALIGN(4); .data : { *(.data*) *(.scommon*) *(.reginfo*) } - _shared_end = ABSOLUTE(.); - . = ALIGN(4); - - _bss_start = ABSOLUTE(.); - .sbss : { *(.sbss*) } .bss : { *(.bss*) } + . = ALIGN (4); - - _bss_end = ABSOLUTE(.); - - /* The global object table. */ + _shared_end = ABSOLUTE(.); .got : ALIGN(4096) { _gp = ALIGN(16); _got_start = ABSOLUTE(.); - *(.got*) + *(.got*) } _got_end = ABSOLUTE(.); - - /* The relocated copy of the global object table. */ - - .got_copy : ALIGN(4096) { - _got_copy_start = ABSOLUTE(.); - . += _got_end - _got_start - 1; - } - _got_copy_end = ABSOLUTE(.); _payload_end = ABSOLUTE(.); } diff -r a1f3027033f2 -r 8e7b3cc4a268 stage2/tasks.c --- a/stage2/tasks.c Mon Apr 25 21:56:49 2016 +0200 +++ b/stage2/tasks.c Mon Apr 25 23:05:44 2016 +0200 @@ -36,16 +36,13 @@ const u32 stack_size = 0x00002000; const u32 pagesize = 4 * 1024; -/* -References to the unrelocated symbol table and to the relocated version, both in -their original locations. -*/ +/* Reference to the unrelocated symbol table. */ -extern u32 _got_start, _got_copy_start; +extern u32 _got_start; /* Regions to be mapped directly. */ -extern u32 _shared_start, _shared_end; +extern u32 _payload_start, _shared_start, _shared_end; /* Task management functions. */ @@ -64,6 +61,7 @@ void start_task(unsigned short task, void (*function)(), u32 args[], u8 nargs) { u32 virtual, physical, address; + u32 _got_copy_start = (u32) &_got_start - (u32) &_payload_start + 0x1000; /* Each task employs a stack at a multiple of the given start address in