rpi: Rework linker script
* Add some missing stuff, be more exact with stack and fill with 0xBEBEBEBE * Ensure .init_array is called with .ctors to ensure static constructors are called.
This commit is contained in:
parent
8d44fff34a
commit
27d3324651
@ -4,11 +4,15 @@ _start:
|
||||
|
||||
.balign 0x8000, 0
|
||||
jmp_loader:
|
||||
/* Set up 1MB C Stack Space */
|
||||
mov sp, #0x100000
|
||||
mov r4, #0
|
||||
|
||||
/* Start Haiku loader */
|
||||
|
||||
/* For Thumb code? */
|
||||
/*
|
||||
ldr r12, =pi_start
|
||||
mov lr, pc
|
||||
bx r12
|
||||
*/
|
||||
|
||||
b pi_start
|
||||
|
||||
/* Cause exception if loader returns */
|
||||
|
@ -27,8 +27,12 @@
|
||||
// GCC defined globals
|
||||
extern void (*__ctor_list)(void);
|
||||
extern void (*__ctor_end)(void);
|
||||
extern void (*__dtor_list)(void);
|
||||
extern void (*__dtor_end)(void);
|
||||
extern uint8 __bss_start;
|
||||
extern uint8 _end;
|
||||
extern uint8 __bss_end;
|
||||
extern uint8 __stack_start;
|
||||
extern uint8 __stack_end;
|
||||
|
||||
extern int main(stage2_args *args);
|
||||
void _start(void);
|
||||
@ -37,14 +41,20 @@ void _start(void);
|
||||
static void
|
||||
clear_bss(void)
|
||||
{
|
||||
memset(&__bss_start, 0, &_end - &__bss_start);
|
||||
memset(&__bss_start, 0, &__bss_end - &__bss_start);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fill_stack(void)
|
||||
{
|
||||
memset(&__stack_start, 0xBEBEBEBE, &__stack_end - &__stack_start);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
call_ctors(void)
|
||||
{
|
||||
#warning BUG: constructors don't get called!
|
||||
void (**f)(void);
|
||||
|
||||
for (f = &__ctor_list; f < &__ctor_end; f++) {
|
||||
@ -92,6 +102,7 @@ pi_start(void)
|
||||
stage2_args args;
|
||||
|
||||
clear_bss();
|
||||
fill_stack();
|
||||
call_ctors();
|
||||
|
||||
cpu_init();
|
||||
|
@ -1,18 +1,40 @@
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
|
||||
ENTRY(_start)
|
||||
|
||||
C_STACK_SIZE = 1048576;
|
||||
IRQ_STACK_SIZE = 0;
|
||||
FIQ_STACK_SIZE = 0;
|
||||
SVC_STACK_SIZE = 0;
|
||||
ABT_STACK_SIZE = 0;
|
||||
UND_STACK_SIZE = 0;
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = BOARD_LOADER_BASE;
|
||||
|
||||
/* text/read-only data */
|
||||
.text : { *(.text .gnu.linkonce.t.*) }
|
||||
.text : {
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
*(.text .text.* .gnu.linkonce.t.*)
|
||||
*(.plt)
|
||||
*(.gnu.warning)
|
||||
}
|
||||
|
||||
. = ALIGN(0x4);
|
||||
__ctor_list = .;
|
||||
.ctors : { *(.ctors) }
|
||||
__ctor_end = .;
|
||||
.ctors : {
|
||||
__ctor_list = .;
|
||||
*(.init_array);
|
||||
*(.ctors);
|
||||
__ctor_end = .;
|
||||
}
|
||||
|
||||
.dtors : {
|
||||
__dtor_list = .;
|
||||
*(.fini_array);
|
||||
*(.dtors);
|
||||
__dtor_end = .;
|
||||
}
|
||||
|
||||
.rodata : { *(.rodata .rodata.*) }
|
||||
|
||||
@ -27,41 +49,75 @@ SECTIONS
|
||||
__exidx_end = .;
|
||||
|
||||
/* uninitialized data (in same segment as writable data) */
|
||||
__bss_start = .;
|
||||
.bss : { *(.bss) }
|
||||
.bss : {
|
||||
__bss_start = .;
|
||||
*(.shbss)
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(0x4);
|
||||
__bss_end = .;
|
||||
}
|
||||
|
||||
.stack : {
|
||||
__stack_start = .;
|
||||
|
||||
. += IRQ_STACK_SIZE;
|
||||
. = ALIGN(0x4);
|
||||
__irq_stack_top = .;
|
||||
|
||||
. += FIQ_STACK_SIZE;
|
||||
. = ALIGN(0x4);
|
||||
__fiq_stack_top = .;
|
||||
|
||||
. += SVC_STACK_SIZE;
|
||||
. = ALIGN(0x4);
|
||||
__svc_stack_top = .;
|
||||
|
||||
. += ABT_STACK_SIZE;
|
||||
. = ALIGN(0x4);
|
||||
__abt_stack_top = .;
|
||||
|
||||
. += UND_STACK_SIZE;
|
||||
. = ALIGN(0x4);
|
||||
__und_stack_top = .;
|
||||
|
||||
. += C_STACK_SIZE;
|
||||
. = ALIGN(0x4);
|
||||
__c_stack_top = .;
|
||||
|
||||
__stack_end = .;
|
||||
}
|
||||
|
||||
. = ALIGN(0x1000);
|
||||
_end = . ;
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
/* DWARF debug sections.
|
||||
Symbols in the DWARF debugging sections are relative to the beginning
|
||||
of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
/* These must appear regardless of . */
|
||||
|
||||
/* Strip unnecessary stuff */
|
||||
/* /DISCARD/ : { *(.comment .note .eh_frame .dtors .stab .stabstr .debug*) }*/
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
|
||||
/* DWARF debug sections.
|
||||
Symbols in the DWARF debugging sections are relative to the beginning
|
||||
of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
/* These must appear regardless of . */
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user