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/
This commit is contained in:
François Revol
2015-04-22 02:43:35 +02:00
parent ade89bf38e
commit 5c2425a61e
2 changed files with 11 additions and 1 deletions
+7 -1
View File
@@ -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)
}
@@ -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);