sparc: fix bootloader executable format
- The entry point has to be at the start of the text section
- Use the correct formqt ("impure") for the a.out file
- Strip all symbols (the bootloader isn't relocatable)
Change-Id: I2b973c39eaf1416f874bf1b2668b1e3090eb5f7b
Reviewed-on: https://review.haiku-os.org/c/1468
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
@@ -38,7 +38,7 @@ rule BuildAoutLoader {
|
|||||||
|
|
||||||
actions BuildAoutLoader {
|
actions BuildAoutLoader {
|
||||||
rm -f $(1)
|
rm -f $(1)
|
||||||
$(TARGET_OBJCOPY_$(TARGET_PACKAGING_ARCH)) -O $(AOUT_FORMAT) $(2) $(1)
|
$(TARGET_OBJCOPY_$(TARGET_PACKAGING_ARCH)) -O $(AOUT_FORMAT) --impure -S $(2) $(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,11 @@ extern "C" void _start(uint32 _unused1, uint32 _unused2,
|
|||||||
void *openFirmwareEntry);
|
void *openFirmwareEntry);
|
||||||
extern "C" void start(void *openFirmwareEntry);
|
extern "C" void start(void *openFirmwareEntry);
|
||||||
|
|
||||||
|
#ifdef __powerpc__
|
||||||
// XCOFF "entry-point" is actually a pointer to the real code
|
// XCOFF "entry-point" is actually a pointer to the real code
|
||||||
extern "C" void *_coff_start;
|
extern "C" void *_coff_start;
|
||||||
void *_coff_start = (void *)&_start;
|
void *_coff_start = (void *)&_start;
|
||||||
|
#endif
|
||||||
|
|
||||||
// GCC defined globals
|
// GCC defined globals
|
||||||
extern void (*__ctor_list)(void);
|
extern void (*__ctor_list)(void);
|
||||||
@@ -52,11 +54,13 @@ call_ctors(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __powerpc__
|
||||||
static void
|
static void
|
||||||
clear_bss(void)
|
clear_bss(void)
|
||||||
{
|
{
|
||||||
memset(&__bss_start, 0, &_end - &__bss_start);
|
memset(&__bss_start, 0, &_end - &__bss_start);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -134,13 +138,15 @@ platform_boot_options(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void __attribute__((section(".text.start")))
|
||||||
_start(uint32 _unused1, uint32 _unused3, void *openFirmwareEntry)
|
_start(uint32 _unused1, uint32 _unused3, void *openFirmwareEntry)
|
||||||
{
|
{
|
||||||
// According to the PowerPC bindings, OpenFirmware should have created
|
// According to the PowerPC bindings, OpenFirmware should have created
|
||||||
// a stack of 32kB or higher for us at this point
|
// a stack of 32kB or higher for us at this point
|
||||||
|
|
||||||
|
#ifndef __sparc__
|
||||||
clear_bss();
|
clear_bss();
|
||||||
|
#endif
|
||||||
call_ctors();
|
call_ctors();
|
||||||
// call C++ constructors before doing anything else
|
// call C++ constructors before doing anything else
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,13 @@ ENTRY(_start)
|
|||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
. = 0x202000 + SIZEOF_HEADERS;
|
. = 0x202000;
|
||||||
|
|
||||||
__text_begin = .;
|
__text_begin = .;
|
||||||
|
|
||||||
/* text/read-only data */
|
/* text/read-only data */
|
||||||
.text : { *(.text .text.* .gnu.linkonce.t.*)
|
.text : { *(.text.start) /* Make sure entry point is at start of file */
|
||||||
|
*(.text .text.* .gnu.linkonce.t.*)
|
||||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||||
*(.sdata2) }
|
*(.sdata2) }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user