diff --git a/link816.cpp b/link816.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/link816/link816.cpp b/src/link816/link816.cpp index 11df0f1..e383fab 100644 --- a/src/link816/link816.cpp +++ b/src/link816/link816.cpp @@ -549,9 +549,16 @@ static uint32_t relocWidth(uint8_t rtype) { } +unsigned long gDbgBareCalls = 0; +unsigned long gDbgTextCalls = 0; static void applyReloc(std::vector &buf, uint32_t off, uint32_t patchAddr, uint32_t target, uint8_t rtype, const std::string &symName) { + extern unsigned long gDbgBareCalls; + gDbgBareCalls++; + if (symName.find("gRnInPack") != std::string::npos) { + std::fprintf(stderr, "TRACE-BARE %s rtype=%u target=0x%X off=0x%X\n", symName.c_str(), rtype, target, off); + } int64_t pcrelDisp; switch (rtype) { case R_W65816_IMM8: @@ -767,6 +774,12 @@ static void applyTextReloc(std::vector &buf, uint32_t off, } const TextSeg &pseg = segments[patchSeg - 1]; uint32_t targetSeg = findSegContaining(target, segments); + gDbgTextCalls++; + // TEMP TRACE (RetroNet hunt): decisions for the mirror-pack refs. + if (symName.find("gRnInPack") != std::string::npos) { + std::fprintf(stderr, "TRACE %s rtype=%u patchSeg=%u targetSeg=%u target=0x%X rec=%d\n", + symName.c_str(), rtype, patchSeg, targetSeg, target, (int)gRecordSites); + } // Cross-segment FUNCTION POINTER (IMM16 &func to a function in seg2+): // clang forms the pointer as func's 16-bit offset + the $00BE seg1 bank, // which is wrong for a function in another bank. Redirect the IMM16 to @@ -2598,6 +2611,7 @@ int main(int argc, char **argv) { L.bssBase, L.bssSize, outPath.c_str(), image.size()); if (L.segments.size() > 1) { + std::fprintf(stderr, " [dbg: textReloc=%lu bare=%lu]", gDbgTextCalls, gDbgBareCalls); std::fprintf(stderr, " + %zu extra segments", L.segments.size() - 1); for (size_t k = 1; k < L.segments.size(); ++k) {