Skip to content

Commit 23851c3

Browse files
committed
Add patch for "dxe3gen does not handle relocs > 65535"
See : #14 (comment) https://groups.google.com/forum/#!topic/comp.os.msdos.djgpp/VOyJcUMYqOE
1 parent 4a67ac8 commit 23851c3

File tree

1 file changed

+83
-6
lines changed

1 file changed

+83
-6
lines changed

patch/patch-djlsr205.txt

Lines changed: 83 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,83 @@
1+
diff -ur djlsr205-orig/src/dxe/dxe3gen.c djlsr205/src/dxe/dxe3gen.c
2+
--- djlsr205-orig/src/dxe/dxe3gen.c 2017-04-29 14:32:47.000000000 +0800
3+
+++ djlsr205/src/dxe/dxe3gen.c 2017-04-29 14:33:27.000000000 +0800
4+
@@ -193,7 +193,7 @@
5+
#include "../../include/sys/dxe.h"
6+
#include "../../include/coff.h"
7+
8+
-#define VERSION "1.0.3"
9+
+#define VERSION "1.0.4"
10+
11+
#define TEMP_BASE "dxe_tmp" /* 7 chars, 1 char suffix */
12+
#define TEMP_O_FILE TEMP_BASE".o"
13+
@@ -937,6 +937,7 @@
14+
char *strings;
15+
RELOC *relocs;
16+
unsigned int i, j, errcount;
17+
+ ULONG32 real_nrelocs;
18+
size_t hdrsize;
19+
20+
/* Exported symbols table */
21+
@@ -985,9 +986,18 @@
22+
strings[0] = 0;
23+
24+
/* Read the relocation table */
25+
- relocs = (RELOC *)malloc(sc.s_nreloc * sizeof(RELOC));
26+
fseek(inf, sc.s_relptr, SEEK_SET);
27+
- fread(relocs, RELSZ, sc.s_nreloc, inf);
28+
+ if (sc.s_flags & STYP_NRELOC_OVFL) {
29+
+ fread(&real_nrelocs, 4, 1, inf); /* read r_vaddr */
30+
+ fseek(inf, RELSZ - 4, SEEK_CUR); /* skip the rest */
31+
+ dh.nrelocs = --real_nrelocs; /* lose the '+1' */
32+
+ if (opt.verbose)
33+
+ printf("%s: real nrelocs: %lu\n", progname, (unsigned long)real_nrelocs);
34+
+ } else {
35+
+ real_nrelocs = dh.nrelocs;
36+
+ }
37+
+ relocs = (RELOC *)malloc(real_nrelocs * sizeof(RELOC));
38+
+ fread(relocs, RELSZ, real_nrelocs, inf);
39+
40+
/* Close input file */
41+
fclose(inf);
42+
@@ -1042,7 +1052,7 @@
43+
int n_abs_relocs = 0, n_rel_relocs = 0;
44+
45+
/* count the amount of relocations pointing to this symbol */
46+
- for (j = 0; j < sc.s_nreloc; j++)
47+
+ for (j = 0; j < real_nrelocs; j++)
48+
{
49+
if (relocs[j].r_symndx == i)
50+
{
51+
@@ -1101,7 +1111,7 @@
52+
53+
unres_size = newsize;
54+
55+
- for (j = 0; j < sc.s_nreloc; j++)
56+
+ for (j = 0; j < real_nrelocs; j++)
57+
{
58+
if (relocs[j].r_symndx == i)
59+
{
60+
@@ -1202,7 +1212,7 @@
61+
62+
/* Compute the amount of valid relocations */
63+
DEBUG_PRINT_RELOCATION_DIRECTIVE_PROLOG();
64+
- for (i = 0; i < sc.s_nreloc; i++)
65+
+ for (i = 0; i < real_nrelocs; i++)
66+
{
67+
DEBUG_PRINT_RELOCATION_DIRECTIVE(i, relocs);
68+
if (!VALID_RELOC(relocs[i]))
69+
@@ -1278,7 +1288,7 @@
70+
free(data);
71+
72+
/* Output the relocations */
73+
- for (i = 0; i < sc.s_nreloc; i++)
74+
+ for (i = 0; i < real_nrelocs; i++)
75+
{
76+
if (VALID_RELOC(relocs[i]))
77+
fwrite(&relocs[i].r_vaddr, 1, sizeof(relocs[0].r_vaddr), outf);
178
diff -ur djlsr205-orig/src/makefile djlsr205/src/makefile
2-
--- djlsr205-orig/src/makefile 2017-04-24 19:00:19.000000000 +0800
3-
+++ djlsr205/src/makefile 2017-04-25 13:35:37.000000000 +0800
79+
--- djlsr205-orig/src/makefile 2017-04-29 14:32:47.000000000 +0800
80+
+++ djlsr205/src/makefile 2017-04-29 14:32:57.000000000 +0800
481
@@ -40,17 +40,18 @@
582
$(MAKE) -C stub native
683
$(MAKE) -C utils native
@@ -32,8 +109,8 @@ diff -ur djlsr205-orig/src/makefile djlsr205/src/makefile
32109

33110
.PHONY : clean
34111
diff -ur djlsr205-orig/src/misc.c djlsr205/src/misc.c
35-
--- djlsr205-orig/src/misc.c 2017-04-24 19:00:19.000000000 +0800
36-
+++ djlsr205/src/misc.c 2017-04-25 13:35:37.000000000 +0800
112+
--- djlsr205-orig/src/misc.c 2017-04-29 14:32:47.000000000 +0800
113+
+++ djlsr205/src/misc.c 2017-04-29 14:32:57.000000000 +0800
37114
@@ -14,7 +14,11 @@
38115
{
39116
/* MS-DOS uses \, unix uses / */
@@ -47,8 +124,8 @@ diff -ur djlsr205-orig/src/misc.c djlsr205/src/misc.c
47124
/* redirection and long command lines don't always
48125
mix well under MS-DOS */
49126
diff -ur djlsr205-orig/src/stub/exe2coff.c djlsr205/src/stub/exe2coff.c
50-
--- djlsr205-orig/src/stub/exe2coff.c 2017-04-24 19:00:19.000000000 +0800
51-
+++ djlsr205/src/stub/exe2coff.c 2017-04-25 13:36:19.000000000 +0800
127+
--- djlsr205-orig/src/stub/exe2coff.c 2017-04-29 14:32:47.000000000 +0800
128+
+++ djlsr205/src/stub/exe2coff.c 2017-04-29 14:32:57.000000000 +0800
52129
@@ -5,10 +5,12 @@
53130
#include <fcntl.h>
54131
#include <sys/stat.h>

0 commit comments

Comments
 (0)