From: Alan Cox Date: Fri, 13 Jul 2018 23:07:51 +0000 (+0100) Subject: tools: record and process source/dest banks to fix data reloc bug X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=2bb7b2231c3522703cd9c2759fe1f224a64e8b0d;p=FUZIX.git tools: record and process source/dest banks to fix data reloc bug Before if we had something like extern char foo[]; char *x = foo; and foo was banked the fixup code would try and write a code stub mashing x in the process. Now it treats data to data references as intentional. --- diff --git a/Kernel/tools/bankld/lkrloc3.c b/Kernel/tools/bankld/lkrloc3.c index c841790e..eae6d853 100644 --- a/Kernel/tools/bankld/lkrloc3.c +++ b/Kernel/tools/bankld/lkrloc3.c @@ -214,9 +214,9 @@ static void bankingstub(struct sym *s, struct areax *bx, int bmagic, int addr) fprintf(ofp, "; Banking Stub %s:%s(%s)\n", a->a_id, s->s_id, s->m_id); fprintf(ofp, "; From area %s\n", bx->a_bap->a_id); - fprintf(ofp, "B %02X %04X %02X %s\n", + fprintf(ofp, "B %02X %04X %02X %s %s\n", bxm, addr, - bmagic, bx->a_bap->a_id); + bmagic, bx->a_bap->a_id, a->a_id); } return; } diff --git a/Kernel/tools/binmunge.c b/Kernel/tools/binmunge.c index b2b26464..b898eda8 100644 --- a/Kernel/tools/binmunge.c +++ b/Kernel/tools/binmunge.c @@ -244,13 +244,19 @@ static void process_stub(char *p) { int b1, b2, addr; char name[65]; + char sname[65]; if (strlen(p) > 4 && !isspace(p[8])) fprintf(stderr, "Overflow: %s", p); - if (sscanf(p, "%02x %04x %02x %64s", &b1, &addr, &b2, name) != 4) { + if (sscanf(p, "%02x %04x %02x %64s %64s", &b1, &addr, &b2, name, sname) != 5) { fprintf(stderr, "Invalid relocation link %s\n", p); exit(1); } + /* A data relocation into another bank of data is treated as deliberate. + We can't do much else. It's not code so we can't patch it, and if it's + a data pointer (as it should be) then a relocation is nonsense! */ + if (!stub_code(sname) && !stub_code(name)) + return; /* If we are stubbing the lot then code is handled as data is */ if (stub_code(name) && !stub_all) code_reloc(b1, addr, b2);