X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=07asjSBUPxHlJeJ6YMIqrUDmyLHxXyvKNFQBMfQzzIY=; b=SrtPBWrfxPpT2vtV9l7s9sPW0vGlXDDRxbC2SWOOMCy82pE3H73fGEKorNo7vs3i/t 6zxDnLrjaZ8LipGXbFtcTzoWGy7zlmjjlEg7hEEhZ/kD267rx685nbb9i8fX3Fr8g2Ne bTO9cuporBF/BrjEYkgdVtzd1VaBTRDalyoGf7cLPxZrneT9HiGubNbsIwMaoRgSf2EH X2heM3EtwycoYfc1jgoyNcQBq1RGAdlwACvxHigm1vEYgCEz93ogKFIg+wBKZsIBU3DC gt4A8PAeIzYwUrT/sdhHPqn9FK4VafEOcvo2yDOxS6YPi2wWoy/h/scUh8ii3YuBTd48 66tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=07asjSBUPxHlJeJ6YMIqrUDmyLHxXyvKNFQBMfQzzIY=; b=aLJky1i6+I37G4KrrEZLQfpSaALtu5IVGXKq2/aiVJN05RwvEGaIhNSigC88f8ijKM S2tgRUMp2vfyrNbDG08gjsUnYYQvrVOdpUS2BIU7IhmClFMj+LuQ0X13RmZXyib8Gp0P XeAw44Mek/RuF3bSn20szbYCnJkcySe1sVD2WQk25KCISbcDcsYXBphHaAL0hkik120d t50/j3vNeRLpcXepf0yabMRQWHdZYs/69PxfokfeMNZr3biwcbKsPisRbdso//yAkBIh ulr/1A/79UEGfbdDOQ3TtaEvPEWRO/TXZghGeLNcxPBuwDOYsF5N4e60CWkWUbZ87b++ DBkA== X-Gm-Message-State: AN3rC/5nXr1bR7ciSHvSK58CXOEjb3WR2jPJzAfMhmVJORg5IMPTHMb2 O4Xt+20h2MR+mp6UxeNcnty3Tb4sgyEP X-Received: by 10.237.51.226 with SMTP id v89mr3652758qtd.162.1493539701921; Sun, 30 Apr 2017 01:08:21 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <83d1bwmitb DOT fsf AT gnu DOT org> From: "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]" Date: Sun, 30 Apr 2017 11:08:21 +0300 Message-ID: Subject: Re: dxe3gen does not handle relocs > 65535 To: djgpp AT delorie DOT com Content-Type: text/plain; charset=UTF-8 Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 4/28/17, Ozkan Sezer wrote: > On 4/28/17, Eli Zaretskii (eliz AT gnu DOT org) [via djgpp AT delorie DOT com] > wrote: >>> From: "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]" >>> >>> Date: Fri, 28 Apr 2017 22:20:39 +0300 >>> >>> Here is a somewhat cleaned-up patch with a changelog entry: >> >> Thanks. Some minor comments: >> >>> + if (opt.verbose) >>> + printf("%s: real nrelocs: %lu\n", progname, (unsigned >>> long)real_nrelocs); >> >> is this printf really necessary? > > Not truly. I can comment it out. > >> >>> + } else { >>> + real_nrelocs = dh.nrelocs; >>> + } >> >> Please use the style adopted in the rest of the source, with regards >> to braces. > > OK. > >> >>> Should apply to CVS? >> >> If no one speaks up in a couple of days, please do. >> > > OK. Thanks. Applied the following to CVS. dxe3gen: handle extended relocations. bump version to 1.0.4. Index: src/docs/kb/wc206.txi =================================================================== RCS file: /cvs/djgpp/djgpp/src/docs/kb/wc206.txi,v retrieving revision 1.3 diff -u -p -r1.3 wc206.txi --- src/docs/kb/wc206.txi 26 Apr 2017 11:46:19 -0000 1.3 +++ src/docs/kb/wc206.txi 30 Apr 2017 08:03:04 -0000 @@ -3,6 +3,9 @@ Here is a list of changes from DJGPP V2.05 to DJGPP V2.06 +@cindex dxe3gen and extended coff relocations +dxe3gen now handles extended coff relocations (more than 65535 relocs.) + @cindex Update of DXE linker script The dxe linker script, dxe.ld, now handles @code{.gnu.linkonce.b.*} and @code{.bss.*} sections. Index: src/dxe/dxe3gen.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/dxe/dxe3gen.c,v retrieving revision 1.23 diff -u -p -r1.23 dxe3gen.c --- src/dxe/dxe3gen.c 4 Oct 2015 10:27:26 -0000 1.23 +++ src/dxe/dxe3gen.c 30 Apr 2017 08:03:04 -0000 @@ -193,7 +193,7 @@ #include "../../include/sys/dxe.h" #include "../../include/coff.h" -#define VERSION "1.0.3" +#define VERSION "1.0.4" #define TEMP_BASE "dxe_tmp" /* 7 chars, 1 char suffix */ #define TEMP_O_FILE TEMP_BASE".o" @@ -937,6 +937,7 @@ static int write_dxe(FILE *inf, FILE *ou char *strings; RELOC *relocs; unsigned int i, j, errcount; + ULONG32 real_nrelocs; size_t hdrsize; /* Exported symbols table */ @@ -985,9 +986,23 @@ static int write_dxe(FILE *inf, FILE *ou strings[0] = 0; /* Read the relocation table */ - relocs = (RELOC *)malloc(sc.s_nreloc * sizeof(RELOC)); fseek(inf, sc.s_relptr, SEEK_SET); - fread(relocs, RELSZ, sc.s_nreloc, inf); + if (sc.s_flags & STYP_NRELOC_OVFL) + { + fread(&real_nrelocs, 4, 1, inf); /* read r_vaddr */ + fseek(inf, RELSZ - 4, SEEK_CUR); /* skip the rest */ + dh.nrelocs = --real_nrelocs; +#if 0 + if (opt.verbose) + printf("%s: found extended relocations, nrelocs = %lu\n", progname, (unsigned long)real_nrelocs); +#endif + } + else + { + real_nrelocs = dh.nrelocs; + } + relocs = (RELOC *)malloc(real_nrelocs * sizeof(RELOC)); + fread(relocs, RELSZ, real_nrelocs, inf); /* Close input file */ fclose(inf); @@ -1042,7 +1057,7 @@ static int write_dxe(FILE *inf, FILE *ou int n_abs_relocs = 0, n_rel_relocs = 0; /* count the amount of relocations pointing to this symbol */ - for (j = 0; j < sc.s_nreloc; j++) + for (j = 0; j < real_nrelocs; j++) { if (relocs[j].r_symndx == i) { @@ -1101,7 +1116,7 @@ static int write_dxe(FILE *inf, FILE *ou unres_size = newsize; - for (j = 0; j < sc.s_nreloc; j++) + for (j = 0; j < real_nrelocs; j++) { if (relocs[j].r_symndx == i) { @@ -1202,7 +1217,7 @@ static int write_dxe(FILE *inf, FILE *ou /* Compute the amount of valid relocations */ DEBUG_PRINT_RELOCATION_DIRECTIVE_PROLOG(); - for (i = 0; i < sc.s_nreloc; i++) + for (i = 0; i < real_nrelocs; i++) { DEBUG_PRINT_RELOCATION_DIRECTIVE(i, relocs); if (!VALID_RELOC(relocs[i])) @@ -1278,7 +1293,7 @@ static int write_dxe(FILE *inf, FILE *ou free(data); /* Output the relocations */ - for (i = 0; i < sc.s_nreloc; i++) + for (i = 0; i < real_nrelocs; i++) { if (VALID_RELOC(relocs[i])) fwrite(&relocs[i].r_vaddr, 1, sizeof(relocs[0].r_vaddr), outf);