[haiku-commits] haiku: hrev44159 - in src/system: ldscripts/arm boot/platform/raspberrypi_arm

  • From: kallisti5@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 15 May 2012 17:35:57 +0200 (CEST)

hrev44159 adds 2 changesets to branch 'master'
old head: 85c4ab42a10a5aae3c0b181e59d03d6c8772144b
new head: 27d3324651b3292fd076e18d33be8d44395f2e46

----------------------------------------------------------------------------

8d44fff: rpi: Raise exception on loader return

27d3324: 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.

                          [ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

3 files changed, 121 insertions(+), 47 deletions(-)
src/system/boot/platform/raspberrypi_arm/entry.S   |   15 +-
src/system/boot/platform/raspberrypi_arm/start.c   |   17 +-
.../ldscripts/arm/boot_loader_raspberrypi_arm.ld   |  136 +++++++++++-----

############################################################################

Commit:      8d44fff34a331e36d32db911f8ec96c69992619c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=8d44fff
Author:      Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date:        Tue May 15 14:14:14 2012 UTC

rpi: Raise exception on loader return

----------------------------------------------------------------------------

diff --git a/src/system/boot/platform/raspberrypi_arm/entry.S 
b/src/system/boot/platform/raspberrypi_arm/entry.S
index 2b2fe49..2980d6c 100644
--- a/src/system/boot/platform/raspberrypi_arm/entry.S
+++ b/src/system/boot/platform/raspberrypi_arm/entry.S
@@ -10,3 +10,6 @@ jmp_loader:
 
        /* Start Haiku loader */
        b pi_start
+
+       /* Cause exception if loader returns */
+       swi 0xFFFFFF

############################################################################

Revision:    hrev44159
Commit:      27d3324651b3292fd076e18d33be8d44395f2e46
URL:         http://cgit.haiku-os.org/haiku/commit/?id=27d3324
Author:      Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date:        Tue May 15 15:24:54 2012 UTC

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.

----------------------------------------------------------------------------

diff --git a/src/system/boot/platform/raspberrypi_arm/entry.S 
b/src/system/boot/platform/raspberrypi_arm/entry.S
index 2980d6c..7c668ff 100644
--- a/src/system/boot/platform/raspberrypi_arm/entry.S
+++ b/src/system/boot/platform/raspberrypi_arm/entry.S
@@ -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 */
diff --git a/src/system/boot/platform/raspberrypi_arm/start.c 
b/src/system/boot/platform/raspberrypi_arm/start.c
index 691952a8..bac1cee 100644
--- a/src/system/boot/platform/raspberrypi_arm/start.c
+++ b/src/system/boot/platform/raspberrypi_arm/start.c
@@ -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();
diff --git a/src/system/ldscripts/arm/boot_loader_raspberrypi_arm.ld 
b/src/system/ldscripts/arm/boot_loader_raspberrypi_arm.ld
index 70176e6..15eecff 100644
--- a/src/system/ldscripts/arm/boot_loader_raspberrypi_arm.ld
+++ b/src/system/ldscripts/arm/boot_loader_raspberrypi_arm.ld
@@ -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  .  */
 }


Other related posts:

  • » [haiku-commits] haiku: hrev44159 - in src/system: ldscripts/arm boot/platform/raspberrypi_arm - kallisti5