mirror of
https://github.com/clang-retro/dos-sdk.git
synced 2026-11-28 21:29:28 -08:00
- The i386 builtins get __eprintf, which <assert.h> of the 10.4u SDK calls. - ld64 links the PowerPC crt1.o of the 10.4u SDK, which takes the addresses of stubs with hi16 and lo16. - build-runtime-macosx.sh: set the work directories of each step before the step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRSSz5czpTdGQpDYmAk
45 lines
2.5 KiB
Diff
45 lines
2.5 KiB
Diff
diff --git a/cctools/ld64/src/ld/parsers/macho_relocatable_file.cpp b/cctools/ld64/src/ld/parsers/macho_relocatable_file.cpp
|
|
index 561d2c1..26530aa 100644
|
|
--- a/cctools/ld64/src/ld/parsers/macho_relocatable_file.cpp
|
|
+++ b/cctools/ld64/src/ld/parsers/macho_relocatable_file.cpp
|
|
@@ -2596,7 +2596,9 @@ void Parser<A>::makeSections()
|
|
machOSects[count].sect = sect;
|
|
switch ( sect->flags() & SECTION_TYPE ) {
|
|
case S_SYMBOL_STUBS:
|
|
- if ( _stubsSectionNum == 0 ) {
|
|
+ // Old gcc objects (such as the 10.4 crt1.o) have several stub
|
|
+ // sections, the first ones empty: use the one with stubs in it.
|
|
+ if ( _stubsSectionNum == 0 || _stubsMachOSection->size() == 0 ) {
|
|
_stubsSectionNum = i+1;
|
|
_stubsMachOSection = sect;
|
|
}
|
|
diff --git a/cctools/ld64/src/ld/passes/stubs/stubs.cpp b/cctools/ld64/src/ld/passes/stubs/stubs.cpp
|
|
index a92ed69..80d37ad 100644
|
|
--- a/cctools/ld64/src/ld/passes/stubs/stubs.cpp
|
|
+++ b/cctools/ld64/src/ld/passes/stubs/stubs.cpp
|
|
@@ -117,6 +117,24 @@ const ld::Atom* Pass::stubableFixup(const ld::Fixup* fixup, ld::Internal& state)
|
|
{
|
|
if ( fixup->binding == ld::Fixup::bindingsIndirectlyBound ) {
|
|
const ld::Atom* target = state.indirectBindingTable[fixup->u.bindingIndex];
|
|
+ // PowerPC: old gcc code built with -mlong-branch (such as the 10.4
|
|
+ // crt1.o) takes a dylib function's address as "stub - picbase" and
|
|
+ // calls it through CTR. Point that difference at a stub of our own.
|
|
+ if ( (_architecture == CPU_TYPE_POWERPC) && (fixup->kind == ld::Fixup::kindSetTargetAddress)
|
|
+ && !fixup->lastInCluster() && ((fixup+1)->kind == ld::Fixup::kindSubtractTargetAddress)
|
|
+ && (target != NULL) && (target->definition() == ld::Atom::definitionProxy) )
|
|
+ return target;
|
|
+ // PowerPC: the 10.4u crt1.o, which is not PIC, takes the address of a
|
|
+ // stub with lis/ori (hi16 and lo16 of the stub). Point it at a stub
|
|
+ // of our own.
|
|
+ if ( (_architecture == CPU_TYPE_POWERPC) && (fixup->kind == ld::Fixup::kindSetTargetAddress)
|
|
+ && !fixup->lastInCluster()
|
|
+ && (((fixup+1)->kind == ld::Fixup::kindStorePPCAbsLow16)
|
|
+ || ((fixup+1)->kind == ld::Fixup::kindStorePPCAbsLow14)
|
|
+ || ((fixup+1)->kind == ld::Fixup::kindStorePPCAbsHigh16)
|
|
+ || ((fixup+1)->kind == ld::Fixup::kindStorePPCAbsHigh16AddLow))
|
|
+ && (target != NULL) && (target->definition() == ld::Atom::definitionProxy) )
|
|
+ return target;
|
|
switch ( fixup->kind ) {
|
|
case ld::Fixup::kindStoreTargetAddressPPCBranch24:
|
|
case ld::Fixup::kindStoreTargetAddressX86BranchPCRel32:
|