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:
PulkoMandy
2019-05-25 18:16:35 +00:00
committed by waddlesplash
parent 89b16bb4d2
commit 94ba4f6406
3 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ rule BuildAoutLoader {
actions BuildAoutLoader {
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);
extern "C" void start(void *openFirmwareEntry);
#ifdef __powerpc__
// XCOFF "entry-point" is actually a pointer to the real code
extern "C" void *_coff_start;
void *_coff_start = (void *)&_start;
#endif
// GCC defined globals
extern void (*__ctor_list)(void);
@@ -52,11 +54,13 @@ call_ctors(void)
}
#ifdef __powerpc__
static void
clear_bss(void)
{
memset(&__bss_start, 0, &_end - &__bss_start);
}
#endif
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)
{
// According to the PowerPC bindings, OpenFirmware should have created
// a stack of 32kB or higher for us at this point
#ifndef __sparc__
clear_bss();
#endif
call_ctors();
// call C++ constructors before doing anything else
@@ -5,12 +5,13 @@ ENTRY(_start)
SECTIONS
{
. = 0x202000 + SIZEOF_HEADERS;
. = 0x202000;
__text_begin = .;
/* 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.*)
*(.sdata2) }