[haiku-commits] haiku: hrev49085 - in src/system: ldscripts/ppc boot boot/platform/openfirmware

  • From: revol@xxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 22 Apr 2015 02:44:10 +0200 (CEST)

hrev49085 adds 2 changesets to branch 'master'
old head: 853598431c6e1af65c66e32952ed5eee1455dc0e
new head: 5c2425a61e38d8fda5011d1e34519fb51fe2952a
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=5c2425a61e38+%5E853598431c6e

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

ade89bf38ea7: PPC: simplify the bootloader linker script

the OF 2.0 COFF loader skips sections other than
.text .data and .bss, so merge others into those three.

5c2425a61e38: PPC: fix COFF bootloader entry point

The concept of entry point in COFF is actually different than in ELF.

In COFF, the entry point is actually a "descriptor" (pointer) to the actual
start code. So we patch the entry point address when calling objcopy.

Now my old Performa 5400/180 actually starts the loader correctly \o/

[ François Revol <revol@xxxxxxx> ]

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

3 files changed, 27 insertions(+), 17 deletions(-)
src/system/boot/Jamfile | 8 ++++-
src/system/boot/platform/openfirmware/start.cpp | 4 +++
.../ldscripts/ppc/boot_loader_openfirmware.ld | 32 ++++++++++----------

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

Commit: ade89bf38ea7ad2d70438abdc5fecdedb829dedc
URL: http://cgit.haiku-os.org/haiku/commit/?id=ade89bf38ea7
Author: François Revol <revol@xxxxxxx>
Date: Wed Apr 22 00:37:44 2015 UTC

PPC: simplify the bootloader linker script

the OF 2.0 COFF loader skips sections other than
.text .data and .bss, so merge others into those three.

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

diff --git a/src/system/ldscripts/ppc/boot_loader_openfirmware.ld
b/src/system/ldscripts/ppc/boot_loader_openfirmware.ld
index 327e7c4..8bb5aa2 100644
--- a/src/system/ldscripts/ppc/boot_loader_openfirmware.ld
+++ b/src/system/ldscripts/ppc/boot_loader_openfirmware.ld
@@ -5,35 +5,35 @@ ENTRY(_start)

SECTIONS
{
- . = 0x102000 + SIZEOF_HEADERS;
+ . = 0x202000 + SIZEOF_HEADERS;

__text_begin = .;

/* text/read-only data */
- .text : { *(.text .text.* .gnu.linkonce.t.*) }
-
- .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
- .sdata2 : { *(.sdata2) }
+ .text : { *(.text .text.* .gnu.linkonce.t.*)
+ *(.rodata .rodata.* .gnu.linkonce.r.*)
+ *(.sdata2) }

/* writable data */
/* align to the same offset in the next page (for performance reasons
(not that it really matters in the boot loader)) */
. = ALIGN(0x1000) + 0x1000 + (. & (0x1000 - 1));

- __ctor_list = .;
- .ctors : { *(.ctors) }
- __ctor_end = .;
+ .data : {
+ __ctor_list = .;
+ *(.ctors)
+ __ctor_end = .;

- __data_start = .;
- .data : { *(.data .gnu.linkonce.d.*) }
- .data.rel.ro : { *(.data.rel.ro.local .data.rel.ro*) }
- .got : { *(.got .got2) }
- .sdata : { *(.sdata .sdata.* .gnu.linkonce.s.*) }
+ __data_start = .;
+ *(.data .gnu.linkonce.d.*)
+ *(.data.rel.ro.local .data.rel.ro*)
+ *(.got .got2)
+ *(.sdata .sdata.* .gnu.linkonce.s.* .fixup) }

/* uninitialized data (in same segment as writable data) */
__bss_start = .;
- .sbss : { *(.sbss .sbss.* .gnu.linkonce.sb.*) }
- .bss : {
+ .bss : { *(.sbss .sbss.* .gnu.linkonce.sb.*)
+
*(.bss .bss.* .gnu.linkonce.b.*)
. = ALIGN(0x1000);
}
@@ -41,5 +41,5 @@ SECTIONS
_end = . ;

/* Strip unnecessary stuff */
- /DISCARD/ : { *(.comment .note .eh_frame .dtors .debug_*) }
+ /DISCARD/ : { *(.comment .note .eh_frame .dtors .debug_*
.gnu.attributes) }
}

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

Revision: hrev49085
Commit: 5c2425a61e38d8fda5011d1e34519fb51fe2952a
URL: http://cgit.haiku-os.org/haiku/commit/?id=5c2425a61e38
Author: François Revol <revol@xxxxxxx>
Date: Wed Apr 22 00:40:05 2015 UTC

PPC: fix COFF bootloader entry point

The concept of entry point in COFF is actually different than in ELF.

In COFF, the entry point is actually a "descriptor" (pointer) to the actual
start code. So we patch the entry point address when calling objcopy.

Now my old Performa 5400/180 actually starts the loader correctly \o/

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

diff --git a/src/system/boot/Jamfile b/src/system/boot/Jamfile
index 4070d0e..e751743 100644
--- a/src/system/boot/Jamfile
+++ b/src/system/boot/Jamfile
@@ -93,8 +93,14 @@ rule BuildCoffLoader {

actions BuildCoffLoader bind HACK_COFF {
rm -f $(1)
- $(TARGET_OBJCOPY_$(TARGET_PACKAGING_ARCH)) -O $(COFF_FORMAT) $(2) $(1)
+ # get the address of the COFF entry
+ $(TARGET_OBJCOPY_$(TARGET_PACKAGING_ARCH)) -O symbolsrec $(2) $(2).syms
+ EP=`grep _coff_start $(2).syms | tr -d '\r' | cut -d'$' -f2`
+ rm -f $(2).syms
+ # copy to XCOFF format and patch the entry point
+ $(TARGET_OBJCOPY_$(TARGET_PACKAGING_ARCH)) -O $(COFF_FORMAT)
--set-start="0x${EP}" $(2) $(1)
#$(CP) $(2) $(1)
+ # fill-in some fields objcopy missed
$(HACK_COFF) $(1)
}

diff --git a/src/system/boot/platform/openfirmware/start.cpp
b/src/system/boot/platform/openfirmware/start.cpp
index de6dce1..2938db2 100644
--- a/src/system/boot/platform/openfirmware/start.cpp
+++ b/src/system/boot/platform/openfirmware/start.cpp
@@ -27,6 +27,10 @@ extern "C" void _start(uint32 _unused1, uint32 _unused2,
void *openFirmwareEntry);
extern "C" void start(void *openFirmwareEntry);

+// XCOFF "entry-point" is actually a pointer to the real code
+extern "C" void *_coff_start;
+void *_coff_start = (void *)&_start;
+
// GCC defined globals
extern void (*__ctor_list)(void);
extern void (*__ctor_end)(void);


Other related posts:

  • » [haiku-commits] haiku: hrev49085 - in src/system: ldscripts/ppc boot boot/platform/openfirmware - revol