more improvement on reGNUal

This commit is contained in:
NIIBE Yutaka
2013-03-15 16:06:42 +09:00
parent 13b9e7bcf3
commit 1ee99b30e4
2 changed files with 27 additions and 29 deletions

View File

@@ -23,18 +23,6 @@ SECTIONS
{ {
. = 0; . = 0;
.bss :
{
_bss_start = .;
*(.bss)
. = ALIGN(4);
*(.bss.*)
. = ALIGN(4);
*(COMMON)
. = ALIGN(4);
_bss_end = .;
} > ram0
.text : ALIGN(16) SUBALIGN(16) .text : ALIGN(16) SUBALIGN(16)
{ {
_text = .; _text = .;
@@ -97,6 +85,18 @@ SECTIONS
_edata = .; _edata = .;
} > ram1 } > ram1
.bss :
{
_bss_start = .;
*(.bss)
. = ALIGN(4);
*(.bss.*)
. = ALIGN(4);
*(COMMON)
. = ALIGN(4);
_bss_end = .;
} > ram1
PROVIDE(end = .); PROVIDE(end = .);
_end = .; _end = .;
} }

View File

@@ -13,36 +13,33 @@ static void none (void)
* Note: the address of this routine 'entry' will be in the vectors as * Note: the address of this routine 'entry' will be in the vectors as
* RESET, but this will be called from application. It's not RESET * RESET, but this will be called from application. It's not RESET
* state, then. * state, then.
*
* This routine doesn't change PSP and MSP. Application should
* prepare those stack pointers.
*/ */
static __attribute__ ((naked,section(".text.entry"))) static __attribute__ ((naked,section(".text.entry")))
void entry (void) void entry (void)
{ {
asm volatile ("mov r0, pc\n\t" asm volatile ("mov r0, pc\n\t"
"bic r0, r0, #255\n\t" /* R0 := vector_table address */ "bic r0, r0, #255\n\t" /* R0 := vector_table address */
"mov r1, #0x90\n" /* R1 := numbers of entries * 4 */ "mov r1, #0x90\n\t" /* R1 := numbers of entries * 4 */
"ldr r3, .L01\n" /* R3 := -0x20001400 fixed addr */
"0:\n\t" "0:\n\t"
"ldr r2, [r0, r1]\n\t" "ldr r2, [r0, r1]\n\t"
"add r2, r2, #-0x20000000\n\t" "add r2, r0\n\t" /* Relocate: R0 - 0x20001400 */
"sub r2, r2, #0x1400\n\t" "add r2, r3\n\t"
"add r2, r2, r0\n\t" /* Relocate: -0x20001400 + R0 */
"str r2, [r0, r1]\n\t" "str r2, [r0, r1]\n\t"
"subs r1, r1, #4\n\t" "subs r1, r1, #4\n\t"
"bne 0b\n\t" "bne 0b\n\t"
/* Relocation done. We don't care the first entry. */ /* Relocation done. */
"ldr r3, .L00\n" "ldr r3, .L00\n"
".LPIC00:\n\t" ".LPIC00:\n\t"
"add r3, pc\n\t" /* R3 := @_GLOBAL_OFFSET_TABLE_ */ "add r3, pc\n\t" /* R3 := @_GLOBAL_OFFSET_TABLE_ */
"ldr r4, .L00+4\n\t"
"ldr r0, [r3, r4]\n\t"
"ldr r4, .L00+8\n\t"
"ldr r1, [r3, r4]\n\t"
"sub r0, r0, r1\n\t"
"mov sp, r0\n\t"
/* Clear BSS. */ /* Clear BSS. */
"mov r0, #0\n\t" "mov r0, #0\n\t"
"ldr r4, .L00+12\n\t" "ldr r4, .L00+4\n\t"
"ldr r1, [r3, r4]\n\t" "ldr r1, [r3, r4]\n\t"
"ldr r4, .L00+16\n\t" "ldr r4, .L00+8\n\t"
"ldr r2, [r3, r4]\n" "ldr r2, [r3, r4]\n"
"0:\n\t" "0:\n\t"
"str r0, [r1], #4\n\t" "str r0, [r1], #4\n\t"
@@ -53,11 +50,12 @@ void entry (void)
"mov r1, r0\n\t" "mov r1, r0\n\t"
"bl main\n" "bl main\n"
"1:\n\t" "1:\n\t"
"b 1b\n" "b 1b\n\t"
".align 2\n"
".L01:\n\t"
".word -0x20001400\n"
".L00:\n\t" ".L00:\n\t"
".word _GLOBAL_OFFSET_TABLE_-(.LPIC00+4)\n\t" ".word _GLOBAL_OFFSET_TABLE_-(.LPIC00+4)\n\t"
".word __ram_end__(GOT)\n\t"
".word __main_stack_size__(GOT)\n\t"
".word _bss_start(GOT)\n\t" ".word _bss_start(GOT)\n\t"
".word _bss_end(GOT)" ".word _bss_end(GOT)"
: /* no output */ : /* no input */ : "memory"); : /* no output */ : /* no input */ : "memory");