diff --git a/src/system/boot/Jamfile b/src/system/boot/Jamfile index 4070d0ef75..e751743336 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 de6dce172f..2938db2373 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);