summarylogtreecommitdiffstats
path: root/binutils-djgpp.patch
blob: 91f2fe1064c93434d37f6f997869fae3780e0d96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
#  DJGPP specific changes to binutils for the DJGPP port of binutils
#  excluding the changes specific to libbfd and libiberty.


2020-03-01 Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* binutils/addr2line.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.

	* binutils/ar.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.

	* binutils/coffdump.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.

	* binutils/config.in [__DJGPP__]:  Added DJGPP specific macros definitions.
	They are all NO-OPS for other OSes.

	* binutils/cxxfilt.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.

	* binutils/nm.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.

	* binutils/objcopy.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.

	* binutils/objdump.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.

	* binutils/readelf.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.
	(print_symbol) [__DJGPP__]:  Use mbtowc instead of mbrtowc.

	* binutils/size.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.

	* binutils/srconv.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.

	* binutils/strings.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.

	* binutils/sysdump.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.

	* config.sub:  Use uname result to set basic_machine value instead of
	hardcoded one.

	* djgpp/build.sh:  DJGPP specific shell script to adjust, configure and
	compile progs and libs.  To support the build of a binutils version used
	by a cross-compiler, the sed scripts that modified bfd/Makefile.in and
	config.in files have been removed.  This change is now part of the patch.

	* gas/as.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.

	* gas/config/obj-coff-seh.c (get_pxdata_name):  Pacify compiler.

	* gas/config.in [__DJGPP__]:  Added DJGPP specific macros definitions.
	They are all NO-OPS for other OSes.

	* gas/dw2gencfi.c (get_debugseg_name):  Pacify compiler.

	* gold/config.in [__DJGPP__]:  Added DJGPP specific macros definitions.
	They are all NO-OPS for other OSes.

	* gprof/gconfig.in [__DJGPP__]:  Added DJGPP specific macros definitions.
	They are all NO-OPS for other OSes.

	* gprof/gprof.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.
	(main) [COFF_GO32_EXE, COFF_GO32]:  Call bfd_init to check to enable/disable
	the coff 64k relocation support.

	* ld/config.in [__DJGPP__]:  Added DJGPP specific macros definitions.
	They are all NO-OPS for other OSes.
	[__DJGPP__]:  For DJGPP versions greather than 2.03 enable support to
	resolve multiple symbol definitions due to the use of DXE3 modules by
	defining the HAVE_DXE3_SUPPORT macro.

	* ld/configure:  Set HAVE_DXE3_SUPPORT to 1 if using DJGPP as taget OS.

	* ld/ldfile.c [__DJGPP__]:  New function map_LFN_to_SFN.
	Maps a library long filename to a short filename according to a table
	defined in /dev/env/DJDIR/lib/libnames.tab.
	(ldfile_try_open_bfd) [__DJGPP__]:  If library is not found by its
	original name try the mapped SFN one.

	* ld/ldmain.c (main):  Use STRIP_FULL_PATH_AND_EXTENSION to adjust file name.
	(multiple_definition) [HAVE_DXE3_SUPPORT]:  If the linker is compiled
	for DX3 module support, it will be able to resolve multiple symbol definitions.
	This is usually the case when different DXE3 import libraries provide the same
	wrapper function to call certain function from the DXE3 module.  If the symbol
	is defined in a static library and in an import library, the import library
	definition takes always precedence over the static library.  This is to
	guarantee that all aplications linked with the same DXE3 module use the same
	functionality and not the one from the static library.  The DXE3 module
	provides functions ported to DJGPP, the functions from the static library
	may not be ported to DJGPP and may behave differently.
	(multiple_definition) [HAVE_DXE3_SUPPORT]:  Allow also the older file name
	$$dxe$$.o as identifier of import libraries generated by dxe3gen.exe.

	* ld/libnames.tab:  New file providing the mapping table between the
        library's LFN to SFN.  LFN to SFN mapping for PCRE2 libraries added.

	* ld/scripttempl/i386go32.sc:  DJGPP specific adjustments to the linker
	script.  Taken from djcross-binutils-2.19.1-10ap.src.rpm.
	Added discard .gnu.lto_* sections command to linker script.
	Fixed w/out relocation (-r) and w/out relocation and do ctor (-Ur) linker
	scripts.

	* opcodes/config.in [__DJGPP__]:  Added DJGPP specific macros definitions.
	They are all NO-OPS for other OSes.

	* libctf/config.h.in [__DJGPP__]:  Added DJGPP specific macros definitions.
	Define HAVE_TSL_SUPPORT if the gcc version is greather equal than 4.3.0.

	* libctf/swap.h [__DJGPP__]:  bswap_identity_64, bswap_16, bswap_32 and
	bswap_64 reimplemented as macros to avoid issues with the inline versions
	of those functions with different gcc versions.

	* libctf/ctf-archive.c [HAVE_TSL_SUPPORT]: Do not use __thread if not supported
	by gcc.





diff -aprNU5 binutils-2.34.orig/binutils/ar.c binutils-2.34/binutils/ar.c
--- binutils-2.34.orig/binutils/ar.c	2020-01-18 13:55:46 +0000
+++ binutils-2.34/binutils/ar.c	2020-03-01 19:35:24 +0000
@@ -719,11 +719,11 @@ main (int argc, char **argv)
   setlocale (LC_CTYPE, "");
 #endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  program_name = argv[0];
+  program_name = STRIP_FULL_PATH_AND_EXTENSION(argv[0]);
   xmalloc_set_program_name (program_name);
   bfd_set_error_program_name (program_name);
 #if BFD_SUPPORTS_PLUGINS
   bfd_plugin_set_program_name (program_name);
 #endif
diff -aprNU5 binutils-2.34.orig/binutils/coffdump.c binutils-2.34/binutils/coffdump.c
--- binutils-2.34.orig/binutils/coffdump.c	2020-01-18 13:55:46 +0000
+++ binutils-2.34/binutils/coffdump.c	2020-03-01 19:35:24 +0000
@@ -497,11 +497,11 @@ main (int ac, char **av)
   setlocale (LC_CTYPE, "");
 #endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  program_name = av[0];
+  program_name = STRIP_FULL_PATH_AND_EXTENSION(av[0]);
   xmalloc_set_program_name (program_name);
   bfd_set_error_program_name (program_name);
 
   expandargv (&ac, &av);
 
diff -aprNU5 binutils-2.34.orig/binutils/config.in binutils-2.34/binutils/config.in
--- binutils-2.34.orig/binutils/config.in	2020-02-01 11:50:08 +0000
+++ binutils-2.34/binutils/config.in	2020-03-01 19:35:24 +0000
@@ -300,5 +300,40 @@
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
 
 /* Define to `unsigned int' if <sys/types.h> does not define. */
 #undef size_t
+
+#ifdef __DJGPP__
+# if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#  define __gnuc_extension__  __extension__
+# else
+#  define __gnuc_extension__
+# endif
+
+# undef  IS_SLASH
+# define IS_SLASH(c)                ((c) == '/' || (c) == '\\')
+# undef  IS_DIRECTORY_SEPARATOR
+# define IS_DIRECTORY_SEPARATOR(c)  (IS_SLASH(c) || (c) == ':')
+
+# include <libc/unconst.h>
+# define STRIP_FULL_PATH_AND_EXTENSION(file_name)   \
+  (__gnuc_extension__                               \
+    ({                                              \
+       char *_dst, *_src;                           \
+       _dst = _src = unconst((file_name), char *);  \
+       while (*_src++)                              \
+         ;                                          \
+       while ((_src - _dst) && (*--_src != '.'))    \
+         ;                                          \
+       for (*_src = '\0'; (_src - _dst); _src--)    \
+         if (IS_DIRECTORY_SEPARATOR(*_src))         \
+           break;                                   \
+       if (_src - _dst)                             \
+         while ((*_dst++ = *++_src))                \
+           ;                                        \
+       (file_name);                                 \
+    })                                              \
+  )
+#else
+# define STRIP_FULL_PATH_AND_EXTENSION(file_name)  (file_name)
+#endif
diff -aprNU5 binutils-2.34.orig/binutils/cxxfilt.c binutils-2.34/binutils/cxxfilt.c
--- binutils-2.34.orig/binutils/cxxfilt.c	2020-01-18 13:55:46 +0000
+++ binutils-2.34/binutils/cxxfilt.c	2020-03-01 19:35:24 +0000
@@ -142,11 +142,11 @@ main (int argc, char **argv)
 {
   int c;
   const char *valid_symbols;
   enum demangling_styles style = auto_demangling;
 
-  program_name = argv[0];
+  program_name = STRIP_FULL_PATH_AND_EXTENSION(argv[0]);
   xmalloc_set_program_name (program_name);
   bfd_set_error_program_name (program_name);
 
   expandargv (&argc, &argv);
 
diff -aprNU5 binutils-2.34.orig/binutils/nm.c binutils-2.34/binutils/nm.c
--- binutils-2.34.orig/binutils/nm.c	2020-01-18 13:55:46 +0000
+++ binutils-2.34/binutils/nm.c	2020-03-01 19:35:24 +0000
@@ -1695,11 +1695,11 @@ main (int argc, char **argv)
   setlocale (LC_COLLATE, "");
 #endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  program_name = *argv;
+  program_name = STRIP_FULL_PATH_AND_EXTENSION(argv[0]);
   xmalloc_set_program_name (program_name);
   bfd_set_error_program_name (program_name);
 #if BFD_SUPPORTS_PLUGINS
   bfd_plugin_set_program_name (program_name);
 #endif
diff -aprNU5 binutils-2.34.orig/binutils/objcopy.c binutils-2.34/binutils/objcopy.c
--- binutils-2.34.orig/binutils/objcopy.c	2020-01-28 09:32:00 +0000
+++ binutils-2.34/binutils/objcopy.c	2020-03-01 19:35:24 +0000
@@ -5935,11 +5935,11 @@ main (int argc, char *argv[])
   setlocale (LC_CTYPE, "");
 #endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  program_name = argv[0];
+  program_name = STRIP_FULL_PATH_AND_EXTENSION(argv[0]);
   xmalloc_set_program_name (program_name);
 
   START_PROGRESS (program_name, 0);
 
   expandargv (&argc, &argv);
diff -aprNU5 binutils-2.34.orig/binutils/objdump.c binutils-2.34/binutils/objdump.c
--- binutils-2.34.orig/binutils/objdump.c	2020-01-18 13:55:46 +0000
+++ binutils-2.34/binutils/objdump.c	2020-03-01 19:35:24 +0000
@@ -5031,11 +5031,11 @@ main (int argc, char **argv)
 #endif
 
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  program_name = *argv;
+  program_name = STRIP_FULL_PATH_AND_EXTENSION(argv[0]);
   xmalloc_set_program_name (program_name);
   bfd_set_error_program_name (program_name);
 
   START_PROGRESS (program_name, 0);
 
diff -aprNU5 binutils-2.34.orig/binutils/readelf.c binutils-2.34/binutils/readelf.c
--- binutils-2.34.orig/binutils/readelf.c	2020-01-18 13:55:46 +0000
+++ binutils-2.34/binutils/readelf.c	2020-03-01 19:35:24 +0000
@@ -584,11 +584,16 @@ print_symbol (signed int width, const ch
 
 #ifdef HAVE_MBSTATE_T
 	  /* Try to find out how many bytes made up the character that was
 	     just printed.  Advance the symbol pointer past the bytes that
 	     were displayed.  */
+#ifdef __DJGPP__
+	  /* DJGPP does not provide mbrtowc.  */
+	  n = mbtowc (& w, symbol - 1, MB_CUR_MAX);
+#else
 	  n = mbrtowc (& w, symbol - 1, MB_CUR_MAX, & state);
+#endif
 #else
 	  n = 1;
 #endif
 	  if (n != (size_t) -1 && n != (size_t) -2 && n > 0)
 	    symbol += (n - 1);
diff -aprNU5 binutils-2.34.orig/binutils/size.c binutils-2.34/binutils/size.c
--- binutils-2.34.orig/binutils/size.c	2020-01-18 13:55:46 +0000
+++ binutils-2.34/binutils/size.c	2020-03-01 19:35:24 +0000
@@ -141,11 +141,11 @@ main (int argc, char **argv)
   setlocale (LC_CTYPE, "");
 #endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  program_name = *argv;
+  program_name = STRIP_FULL_PATH_AND_EXTENSION(argv[0]);
   xmalloc_set_program_name (program_name);
   bfd_set_error_program_name (program_name);
 
   expandargv (&argc, &argv);
 
diff -aprNU5 binutils-2.34.orig/binutils/srconv.c binutils-2.34/binutils/srconv.c
--- binutils-2.34.orig/binutils/srconv.c	2020-01-18 13:55:46 +0000
+++ binutils-2.34/binutils/srconv.c	2020-03-01 19:35:24 +0000
@@ -1731,11 +1731,11 @@ main (int ac, char **av)
   setlocale (LC_CTYPE, "");
 #endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  program_name = av[0];
+  program_name = STRIP_FULL_PATH_AND_EXTENSION(av[0]);
   xmalloc_set_program_name (program_name);
   bfd_set_error_program_name (program_name);
 
   expandargv (&ac, &av);
 
diff -aprNU5 binutils-2.34.orig/binutils/strings.c binutils-2.34/binutils/strings.c
--- binutils-2.34.orig/binutils/strings.c	2020-01-18 13:55:46 +0000
+++ binutils-2.34/binutils/strings.c	2020-03-01 19:35:24 +0000
@@ -153,11 +153,11 @@ main (int argc, char **argv)
   setlocale (LC_ALL, "");
 #endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  program_name = argv[0];
+  program_name = STRIP_FULL_PATH_AND_EXTENSION(argv[0]);
   xmalloc_set_program_name (program_name);
   bfd_set_error_program_name (program_name);
 
   expandargv (&argc, &argv);
 
diff -aprNU5 binutils-2.34.orig/binutils/sysdump.c binutils-2.34/binutils/sysdump.c
--- binutils-2.34.orig/binutils/sysdump.c	2020-01-18 13:55:46 +0000
+++ binutils-2.34/binutils/sysdump.c	2020-03-01 19:35:24 +0000
@@ -668,11 +668,11 @@ main (int ac, char **av)
   setlocale (LC_CTYPE, "");
 #endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  program_name = av[0];
+  program_name = STRIP_FULL_PATH_AND_EXTENSION(av[0]);
   xmalloc_set_program_name (program_name);
   bfd_set_error_program_name (program_name);
 
   expandargv (&ac, &av);
 
diff -aprNU5 binutils-2.34.orig/config.sub binutils-2.34/config.sub
--- binutils-2.34.orig/config.sub	2020-01-18 13:55:46 +0000
+++ binutils-2.34/config.sub	2020-03-01 19:35:24 +0000
@@ -301,10 +301,19 @@ case $1 in
 				basic_machine=i686-pc
 				os=dicos
 				;;
 			djgpp)
 				basic_machine=i586-pc
+				UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+				case $UNAME_MACHINE in
+					*386*) basic_machine=i386-pc;;
+					*486*) basic_machine=i486-pc;;
+					*586*) basic_machine=i586-pc;;
+					*686*) basic_machine=i686-pc;;
+					*786*) basic_machine=i786-pc;;
+					*)     basic_machine=i586-pc;;
+				esac
 				os=msdosdjgpp
 				;;
 			ebmon29k)
 				basic_machine=a29k-amd
 				os=ebmon
diff -aprNU5 binutils-2.34.orig/djgpp/build.sh binutils-2.34/djgpp/build.sh
--- binutils-2.34.orig/djgpp/build.sh	1970-01-01 00:00:00 +0000
+++ binutils-2.34/djgpp/build.sh	2020-03-01 19:35:24 +0000
@@ -0,0 +1,490 @@
+#  This script only works in the ./djgpp directory.
+
+export HOME=.
+export PATH_SEPARATOR=:
+export PATH_EXPAND=y
+export TEST_FINDS_EXE=y
+export LD=ld
+export NM=nm
+export LN_S="cp -p"
+export GMSGFMT=${GMSGFMT='/dev/env/DJDIR/bin/msgfmt'}
+export MSGFMT=${MSGFMT='/dev/env/DJDIR/bin/msgfmt'}
+export MSGMERGE=${MSGMERGE='/dev/env/DJDIR/bin/msgmerge'}
+export XGETTEXT=${XGETTEXT='/dev/env/DJDIR/bin/xgettext'}
+export ac_cv_path_AWK=${AWK='/dev/env/DJDIR/bin/gawk'}
+export ac_cv_path_EMACS=${EMACS='/dev/env/DJDIR/gnu/emacs/bin/emacs'}
+export ac_cv_path_M4=${M4='/dev/env/DJDIR/bin/m4'}
+export ac_cv_path_GREP=${GREP='/dev/env/DJDIR/bin/grep'}
+export ac_cv_path_EGREP=${EGREP='/dev/env/DJDIR/bin/egrep'}
+export ac_cv_path_FGREP=${FGREP='/dev/env/DJDIR/bin/fgrep'}
+export ac_cv_path_SED=${SED='/dev/env/DJDIR/bin/sed'}
+export ac_cv_path_MAKEINFO=${MAKEINFO='/dev/env/DJDIR/bin/makeinfo'}
+export ac_cv_path_INSTALL_INFO=${INSTALL_INFO='/dev/env/DJDIR/bin/install-info'}
+export ac_cv_path_ROFF=${ROFF='/dev/env/DJDIR/bin/groff'}
+export ac_cv_path_GROFF=${GROFF='/dev/env/DJDIR/bin/groff'}
+export ac_cv_path_NROFF=${NROFF='/dev/env/DJDIR/bin/nroff'}
+export ac_cv_path_PERL=${PERL='/dev/env/DJDIR/bin/perl'}
+export ac_cv_path_mkdir=${MKDIR_P='/dev/env/DJDIR/bin/mkdir -p'}
+export ac_cv_path_RM=${RM='/dev/env/DJDIR/bin/rm'}
+export ac_cv_path_MV=${MV='/dev/env/DJDIR/bin/mv'}
+export ac_cv_path_TAR=${TAR='/dev/env/DJDIR/bin/tar'}
+export ac_cv_path_PR_PROGRAM=${PR='/dev/env/DJDIR/bin/pr'}
+export ac_cv_path_ed_PROGRAM=${ED='/dev/env/DJDIR/bin/ed'}
+export ac_cv_path_TEXI2DVI=${TEXI2DVI='texi2dvi'}
+export ac_cv_path_TEXI2PDF=${TEXI2PDF='texi2pdf'}
+export ac_cv_path_DVIPS=${DVIPS='dvips'}
+export ac_cv_path_PS2PDF=${PS2PDF='ps2pdf'}
+export ac_cv_path_TEST_SHELL=${TEST_SHELL='/dev/env/DJDIR/bin/bash'}
+export ac_cv_path_MKTEMP=${MKTEMP='/dev/env/DJDIR/bin/mktemp'}
+export ac_cv_prog_LN_S="cp -p"
+export ac_cv_prog_AWK=${AWK='/dev/env/DJDIR/bin/gawk'}
+export ac_cv_prog_EMACS=${EMACS='/dev/env/DJDIR/gnu/emacs/bin/emacs'}
+export ac_cv_prog_M4=${M4='/dev/env/DJDIR/bin/m4'}
+export ac_cv_prog_GREP=${GREP='/dev/env/DJDIR/bin/grep'}
+export ac_cv_prog_EGREP=${EGREP='/dev/env/DJDIR/bin/egrep'}
+export ac_cv_prog_FGREP=${FGREP='/dev/env/DJDIR/bin/fgrep'}
+export ac_cv_prog_SED=${SED='/dev/env/DJDIR/bin/sed'}
+export ac_cv_prog_MAKEINFO=${MAKEINFO='/dev/env/DJDIR/bin/makeinfo'}
+export ac_cv_prog_INSTALL_INFO=${INSTALL_INFO='/dev/env/DJDIR/bin/install-info'}
+export ac_cv_prog_ROFF=${ROFF='/dev/env/DJDIR/bin/groff'}
+export ac_cv_prog_GROFF=${GROFF='/dev/env/DJDIR/bin/groff'}
+export ac_cv_prog_NROFF=${NROFF='/dev/env/DJDIR/bin/nroff'}
+export ac_cv_prog_PERL=${PERL='/dev/env/DJDIR/bin/perl'}
+export ac_cv_prog_mkdir=${MKDIR_P='/dev/env/DJDIR/bin/mkdir -p'}
+export ac_cv_prog_RM=${RM='/dev/env/DJDIR/bin/rm'}
+export ac_cv_prog_MV=${MV='/dev/env/DJDIR/bin/mv'}
+export ac_cv_prog_CAT=${CAT='/dev/env/DJDIR/bin/cat'}
+export ac_cv_prog_SORT=${SORT='/dev/env/DJDIR/bin/sort'}
+export ac_cv_prog_TAR=${TAR='/dev/env/DJDIR/bin/tar'}
+export ac_cv_prog_PR_PROGRAM=${PR='/dev/env/DJDIR/bin/pr'}
+export ac_cv_prog_ed_PROGRAM=${ED='/dev/env/DJDIR/bin/ed'}
+export ac_cv_prog_TEXI2DVI=${TEXI2DVI='texi2dvi'}
+export ac_cv_prog_TEXI2PDF=${TEXI2PDF='texi2pdf'}
+export ac_cv_prog_DVIPS=${DVIPS='dvips'}
+export ac_cv_prog_PS2PDF=${PS2PDF='ps2pdf'}
+export ac_cv_prog_TEST_SHELL=${TEST_SHELL='/dev/env/DJDIR/bin/bash'}
+export ac_cv_prog_MKTEMP=${MKTEMP='/dev/env/DJDIR/bin/mktemp'}
+export ac_cv_func_fork=no
+export ac_cv_func_mkfifo=no
+export ac_cv_func_mknod=no
+export ac_cv_func_mmap=no
+export ac_cv_func_vfork=no
+
+# Do not allow that the BFD's configure script determine the
+# host dependant file_ptr a.k.a. off_t type as BFD_HOST_64_BIT.
+# This is the case if ftello64 and fseeko64 are found.  But DJGPP
+# does not provide the full set of 64 bit file functions required
+# for a working 64 bit BFD.
+export ac_cv_func_fseeko64=${ac_cv_func_fseeko64=no}
+export ac_cv_func_ftello64=${ac_cv_func_ftello64=no}
+export ac_cv_have_decl_fseeko64=${ac_cv_have_decl_fseeko64=no}
+export ac_cv_have_decl_ftello64=${ac_cv_have_decl_ftello64=no}
+
+# Ensure that always old GNU extern inline semantics is used
+# (aka -fgnu89-inline) even if ISO C99 semantics has been specified.
+case $(gcc --version 2>/dev/null | sed "/^.* \([1-9]\+\.[0-9]\+[.0-9]*\).*$/!d;s/^.* \([1-9]\+\.[0-9]\+[.0-9]*\).*$/\1/") in
+[1-3].*|4.[0-1][.0-9]* )  export CFLAGS=${CFLAGS='-g2 -O2 -std=gnu99 -march=i386 -mtune=i586'};;
+* )                       export CFLAGS=${CFLAGS='-g2 -O2 -fgnu89-inline -march=i386 -mtune=i586'};;
+esac
+
+# DJGPP's implementation of printf survives out-of-memory conditions.
+export gl_cv_func_printf_enomem='yes'
+
+# Enable libiberty installation.
+# Passing --enable-install-libiberty to the toplovel configure seems not to be enough.
+export enable_install_libiberty=yes
+
+# Select NLS support.
+# NLS_SUPPORT='--enable-nls'
+ NLS_SUPPORT='--disable-nls'
+
+if [ "x${NLS_SUPPORT}" = "x--enable-nls" ]; then
+  rm -vf ../bfd/po/*gmo
+  rm -vf ../bfd/po/*pot
+  rm -vf ../binutils/po/*gmo
+  rm -vf ../binutils/po/*pot
+  rm -vf ../gas/po/*gmo
+  rm -vf ../gas/po/*pot
+  rm -vf ../gold/po/*gmo
+  rm -vf ../gold/po/*pot
+  rm -vf ../gprof/po/*gmo
+  rm -vf ../gprof/po/*pot
+  rm -vf ../ld/po/*gmo
+  rm -vf ../ld/po/*pot
+  rm -vf ../opcodes/po/*gmo
+  rm -vf ../opcodes/po/*pot
+  rm -vf ../bfd/po/*gmo
+  rm -vf ../bfd/po/*pot
+fi
+
+
+#
+#  1: Adjust the configure scripts.
+#
+
+cat > script.sed << EOF
+# For some reason the function does not work with bash 2.05b.
+/^func_lalib_p/,/^}$/ {
+  /test/ i\\
+    case \$1 in\\
+    *.la | *.lo)
+  /GREP/ {
+    s/$/;;/
+    a\\
+    *) false;;\\
+    esac
+  }
+}
+
+# Use func_lalib_p instead of func_lalib_unsafe_p.
+/func_lalib_unsafe_p[ 	][^(]/ s/_unsafe//
+
+# Adjust temp directory.
+/{TMPDIR-\/tmp}/ s|{TMPDIR-/tmp}|{TMPDIR-\${TMP-\${TEMP-.}}}|
+
+# Remove -lc reference from the dependency_libs= line in .la files.
+# This is unnecessary when linking with static  labraries and causes
+# multiple symbol definitions that cannot be resolved when using DXE3 modules.
+/^# Libraries that this one depends upon.$/,/^# Directory that this library needs to be installed in:$/ {
+  /^# Directory that this library needs to be installed in:$/ {
+    n
+    a\\
+	  sed "/^dependency_libs=/ s|[ 	]\\\\{1,\\\\}-lc| |"  \$output > fixed.sed && cp -vf fixed.sed \$output
+  }
+}
+
+# Supress makeinfo test.  DJGPP does not provide any other port than 4.13.
+/# For an installed makeinfo, we require it to be from texinfo 4.7 or/,/;;/ {
+  /MAKEINFO.*makeinfo/ s/MAKEINFO/IGNORE_&/
+}
+
+# We always use _deps and _libs instead of .deps and .libs, because
+# the latter is an invalid name on 8+3 MS-DOS filesystem.  This makes
+# the generated Makefiles good for every DJGPP installation, not only
+# the one where the package was configured (which could happen to be
+# a Windows box, where leading dots in file names are allowed).
+s,\.deps,_deps,g
+s,\.libs,_libs,g
+/^rmdir[ 	]*\.tst/ i\\
+am__leading_dot=_
+
+# Autoconf 2.63b produces if clauses that are enclosed in \`
+# so we cannot use \` to replace parenthesized commands.
+# This case must be treated before the parenthesized commands
+# are replaced by \`.
+/.*\`if[ 	](/ {
+  s/(/"/
+  s/)/"/
+}
+
+# Replace (command) > /dev/null with \`command > /dev/null\`, since
+# parenthesized commands always return zero status in the ported Bash,
+# even if the named command doesn't exist
+/if ([^|;\`]*null/{
+  s,(,\`,
+  s,\\([^ 	)]\\)),\\1,
+  /null[ 	]*2>&1/ s,2>&1,&\`,
+  /null.*null/ s,null.*null,&\`,
+  /null.*null/ !{
+    /null[ 	]*2>&1/ !s,null,&\`,
+  }
+}
+
+# DOS-style absolute file names should be supported as well
+/\*) top_srcdir=/s,/\*,[\\\\\\\\/]* | ?:[\\\\\\\\/]*,
+
+# The following two items are changes needed for configuring
+# and compiling across partitions.
+# 1) The given srcdir value is always translated from the
+#    "x:" syntax into "/dev/x" syntax while we run configure.
+/^[ 	]*-srcdir=\\*.*$/ a\\
+    ac_optarg=\`echo "\$ac_optarg" | sed "s,^\\\\([A-Za-z]\\\\):,/dev/\\\\1,"\`
+/set X \`ls -Lt \\\$srcdir/ i\\
+   if \`echo \$srcdir | grep "^/dev/" - > /dev/null\`; then\\
+     srcdir=\`echo "\$srcdir" | sed -e "s%^/dev/%%" -e "s%/%:/%"\`\\
+   fi
+
+# Autoconf 2.52e generated configure scripts
+# write absolute paths into Makefiles making
+# them useless for DJGPP installations for which
+# the package has not been configured for.
+/am_missing_run=/,/^$/ {
+  /^fi$/ a\\
+am_missing_run=\`echo "\$am_missing_run" | sed 's%/dev.*/@FILE_NAME@[-_0-9]\\\\{1,1\\\\}[-.0-9A-z+]*%\${top_srcdir}%;s%.:.*/@FILE_NAME@[-_0-9]\\\\{1,1\\\\}[-.0-9A-z+]*%\${top_srcdir}%'\`
+}
+/^[	 ]*install_sh=/,/^$/ {
+  /^fi$/ a\\
+install_sh=\`echo "\$install_sh" | sed 's%/dev.*/@FILE_NAME@[-_0-9]\\\\{1,1\\\\}[-.0-9A-z+]*%\${top_srcdir}%;s%.:.*/@FILE_NAME@[-_0-9]\\\\{1,1\\\\}[-.0-9A-z+]*%\${top_srcdir}%'\`
+}
+
+# Only if both builddir and srcdir are on the same
+# partition the absolute paths are converted to
+# relative paths so that the produced makefiles are
+# good for all installations but not only for the one
+# where it was configured.
+/^# If the template does not know about datarootdir, expand it.$/ i\\
+# DJGPP specific.\\
+# Autoconf generated configure scripts write\\
+# absolute paths into Makefiles making them\\
+# useless for DJGPP installations for which\\
+# the package has not been configured for.\\
+djgpp_ac_abs_top_builddir_drive=\\\$(echo \${ac_abs_top_builddir} | sed -e 's%:[/\\\\\\\\]*.*$%%;s%^/dev/\\\\([A-z]\\\\)/.*$%\\\\1%')\\
+djgpp_ac_abs_top_srcdir_drive=\\\$(echo \${ac_abs_top_srcdir} | sed -e 's%:[/\\\\\\\\]*.*$%%;s%^/dev/\\\\([A-z]\\\\)/.*$%\\\\1%')\\
+if [ "x\\\${ac_abs_top_srcdir}" == "x\\\${ac_top_srcdir}" ]; then\\
+  paths_are_absolute=yes\\
+else\\
+  paths_are_absolute=no\\
+fi\\
+\\
+if [ "x\\\${djgpp_ac_abs_top_builddir_drive}" == "x\\\${djgpp_ac_abs_top_srcdir_drive}" ]; then\\
+  # builddir and srcdir are on the same partition.\\
+\\
+  # Convert absolute buildir paths to relative ones.\\
+  paths_to_be_adjusted="ac_abs_builddir ac_abs_top_builddir"\\
+  for path in \\\${paths_to_be_adjusted}; do\\
+    eval _path=\\\\\\\${\$path}\\
+    eval djgpp_\\\${path}=\$(echo \\\${_path} | sed -e "s%\\\${ac_abs_top_builddir}%\\\${ac_builddir}%")\\
+  done\\
+\\
+  if [ "x\\\${paths_are_absolute}" == "xyes" ]; then\\
+    # Convert absolute srcdir paths to relative ones.\\
+    djgpp_relative_prefix=\$(echo \\\${ac_abs_builddir} | sed -e 's%^[A-z]:%%;s%^/dev/[A-z]%%;s%^%.%;s%[/\\\\\\\\][A-z0-9._+-]\\\\+%/..%g;s%[/\\\\\\\\]$%%')\\
+    paths_to_be_adjusted="ac_srcdir ac_abs_srcdir ac_top_srcdir ac_abs_top_srcdir"\\
+    for path in \\\${paths_to_be_adjusted}; do\\
+      eval _path=\\\\\\\${\$path}\\
+      eval djgpp_\\\${path}=\$(echo \\\${_path} | sed -e "s%^[A-z]:%%;s%^/dev/[A-z]%%;s%^%\\\${djgpp_relative_prefix}%")\\
+    done\\
+  else\\
+    djgpp_ac_srcdir="\\\${ac_srcdir}"\\
+    djgpp_ac_abs_srcdir="\\\${ac_srcdir}"\\
+    djgpp_ac_top_srcdir="\\\${ac_top_srcdir}"\\
+    djgpp_ac_abs_top_srcdir="\\\${ac_top_srcdir}"\\
+  fi\\
+else\\
+  # builddir and srcdir are on different partitions.\\
+\\
+  paths_to_be_adjusted="ac_abs_builddir ac_abs_top_builddir"\\
+  for path in \\\${paths_to_be_adjusted}; do\\
+    eval djgpp_\\\${path}=\\\\\\\${\$path}\\
+  done\\
+\\
+  paths_to_be_adjusted="ac_srcdir ac_abs_srcdir ac_top_srcdir ac_abs_top_srcdir"\\
+  for path in \\\${paths_to_be_adjusted}; do\\
+    eval djgpp_\\\${path}=\\\\\\\${\$path}\\
+  done\\
+fi\\
+
+
+/^s|@configure_input@|\\\$ac_sed_conf_input|;t t$/,/^\\\$ac_datarootdir_hack$/ {
+  s/\\\$ac_srcdir/\\\$djgpp_ac_srcdir/
+  s/\\\$ac_abs_srcdir/\\\$djgpp_ac_abs_srcdir/
+  s/\\\$ac_top_srcdir/\\\$djgpp_ac_top_srcdir/
+  s/\\\$ac_abs_top_srcdir/\\\$djgpp_ac_abs_top_srcdir/
+  s/\\\$ac_abs_builddir/\\\$djgpp_ac_abs_builddir/
+  s/\\\$ac_abs_top_builddir/\\\$djgpp_ac_abs_top_builddir/
+}
+
+# Add DJGPP version information.
+/^#define VERSION/ s/\\\$VERSION/&  (DJGPP port (r1))/
+
+# We need makeinfo to make the html formated docs.
+/\\\$am_missing_run[ 	]*makeinfo/ s,\\\$am_missing_run,,
+
+# The path to the FORTRAN compiler and libraries
+# shall contain no absolute path reference so it
+# will be good for all djgpp installations.
+/^FLIBS="\\\$ac_cv_flibs"/ i\\
+ac_djgpp_path=\`echo "\$DJDIR" | sed 's%\\\\\\\\\\\\%/%g' | tr \$as_cr_LETTERS \$as_cr_letters\`\\
+ac_cv_flibs=\`echo "\$ac_cv_flibs" | sed "s%-L$ac_djgpp_path%-L/dev/env/DJDIR%g"\`
+
+# Do not split info output.
+/^MAKEINFO=.*$/s:=.*$:&" --no-split":
+
+# The CR test for awk does not work for DJGPP.
+/^ac_cs_awk_cr=/,/^$/ {
+  /^fi$/ a\\
+ac_cs_awk_cr=\$ac_cr
+}
+
+# AWK program above erroneously prepends '/' to C:/dos/paths
+/# AWK program above erroneously prepends/,/esac/ {
+  s/mingw/*djgpp* | mingw/
+}
+
+# Force the test for 'ln -s' to report 'cp -pf'.
+/as_ln_s='ln -s'/ s/ln -s/cp -pf/
+
+##LIBTOOL="\${CONFIG_SHELL-\$SHELL} "'\$(top_builddir)/libtool'
+# Set the right shell for libtool
+/^LIBTOOL=.*libtool'$/ s/".*"/'\$(SHELL) '/
+
+# Adjust the config.site path for the case
+# of recursive called configure scripts
+/^if test "\$no_recursion" != yes; then/ a\\
+  djgpp_config_site=\$CONFIG_SITE
+/case \$srcdir in/,/esac/ {
+  / # Relative name.$/ a\\
+export CONFIG_SITE=\$ac_top_build_prefix\$djgpp_config_site
+}
+
+# DJGPP specific adjustments of the compile-time system search path for libraries.
+/^[ 	]*lt_search_path_spec=.*-print-search-dirs/ s,\`\$, -e \\"s%[A-z]:[\\\\\\\\/]djgpp-[0-9].[0-9][0-9][\\\\\\\\/]%/dev/env/DJDIR/%g\\"&,
+
+# Fix realpath check.  DJGPP always prepends a drive letter.
+/checking whether realpath works/,/^_ACEOF$/ {
+  /name && \\*name == '\\/'/ s/\\*name/name[2]/
+}
+
+# This works around a bug in DJGPP port of Bash 2.0x.
+s|return \$ac_retval|(&)|g
+
+# DJGPP port of Bash 2.04 doesn't like this redirection of stdin
+/exec 7</s|7<&0 </dev/null||
+
+# Remove LINGUAS from dependecy list in ./po/Makefile
+/POMAKEFILEDEPS=/ s/POMAKEFILEDEPS LINGUAS/POMAKEFILEDEPS #LINGUAS/
+
+# The dup2 check of autoconf will fail with SIGABRT due to implementations issues in DJGPP's version of dup2.
+# To avoid this, it will not be allowed to use file descriptors greather than 255.
+# This will be removed as soon as a fixed versions of DJGPP is released.
+/checking whether dup2 works/,/^_ACEOF$/ {
+  /dup2.*256);/d
+}
+
+# Convert am_aux_dir and abs_aux_dir into relative paths.
+/^# Expand \$ac_aux_dir to an absolute path./ {
+n
+a\\
+am_aux_dir=\${ac_aux_dir}
+}
+
+/abs_aux_dir=/ a\\
+abs_aux_dir=\${ac_aux_dir}
+EOF
+
+
+for file in ../ltmain.sh ../configure ../bfd/configure ../binutils/configure ../gas/configure ../gprof/configure ../ld/configure ../opcodes/configure ../zlib/configure ../libctf/configure; do
+  if test ! -f ${file}.orig; then
+    cp -vf ${file} ${file}.orig
+    touch ${file}.orig -r ${file}
+  fi
+  sed -f ./script.sed ${file}.orig > ./file.out
+  update ./file.out ${file}
+  touch ${file} -r ${file}.orig
+done
+rm -vf ./file.out ./script.sed
+
+
+
+#
+#  2: Adjust the Makefile.ins and other files.
+#
+
+cat > script.sed << EOF
+# For html docs.
+/^MAKEINFOHTML[ 	]*=/ s/$/ --no-split/
+s/--split-size=5000000/--no-split/g
+
+# Fixes for ./libiberty/Makefile.in
+# ps support for libiberty docs.
+/dvi-subdir[ 	]\\{1,\\}pdf-subdir/ s/dvi-subdir[ 	]\\{1,\\}pdf-subdir/& ps-subdir/
+
+/^LIBIBERTY_PDFFILES[ 	]*=/ i\\
+LIBIBERTY_PSFILES = libiberty.ps\\
+\\
+ps: \\\$(LIBIBERTY_PSFILES) ps-subdir\\
+
+
+/^libiberty.pdf[ 	]*:/ i\\
+libiberty.ps : ./libiberty.dvi \\\$(srcdir)/libiberty.texi \\\$(TEXISRC)\\
+	dvips -o ./libiberty.ps ./libiberty.dvi\\
+
+# Enable libiberty installation.
+# Passing --enable-install-libiberty to the toplovel configure seems not to be enough.
+s/@target_header_dir@/libiberty/
+
+# Fixes for ./etc/Makefile.in.
+/^HTMLFILES =.*configure.html$/ i\\
+PSFILES = standards.ps configure.ps
+/epstopdf/ s/[ 	]\\{1,\\}-outfile/ --outfile/
+
+# Fixes for ./ld/Makefile.in.
+/^install-exec-local[	 ]*:.*ld-new.*$/ {
+  s/$/ install-data-local-djgpp/
+i\\
+install-data-local-djgpp:\\
+	\\\$(mkinstalldirs) \\\$(DESTDIR)\\\$(scriptdir)\\
+	for f in libnames.tab; do \\\\\\
+	  \\\$(INSTALL_DATA) \\\$(top_srcdir)/\\\$\\\$f \\\$(DESTDIR)\\\$(scriptdir)/\\\$\\\$f ; \\\\\\
+	done\\
+
+}
+EOF
+
+
+for file in ./../bfd/Makefile.in ./../bfd/doc/Makefile.in ./../binutils/doc/Makefile.in ./../etc/Makefile.in ./../gas/doc/Makefile.in ./../gprof/Makefile.in ./../ld/Makefile.in ./../libiberty/Makefile.in ./../libctf/Makefile.in; do
+  if test ! -f ${file}.orig; then
+    cp -vf ${file} ${file}.orig
+    touch ${file}.orig -r ${file}
+  fi
+  sed -f ./script.sed ${file}.orig > ./file.out
+  update ./file.out ${file}
+  touch ${file} -r ${file}.orig
+done
+rm -vf ./file.out ./script.sed
+
+dtou ../ld/configure.ac
+touch ../ld/configure.ac -r ../ld/configure.tgt
+
+
+#
+#  3: Configure and build the libs and programs.
+#
+
+touch start_build.txt
+
+echo
+echo Configuring the progs and libs.
+echo See build_log.txt file for output.
+
+
+echo Using: > build_log.txt
+gcc --version >> build_log.txt
+as --version >> build_log.txt
+echo >> build_log.txt
+ld --version >> build_log.txt
+echo >> build_log.txt
+echo >> build_log.txt
+echo >> build_log.txt
+
+echo Configuring the progs and libs for DJGPP. >> build_log.txt
+echo >> build_log.txt
+
+../configure  --prefix='/dev/env/DJDIR' --disable-dependency-tracking ${NLS_SUPPORT} \
+              --with-mpc-include='/dev/env/DJDIR/include' --with-mpc-lib='/dev/env/DJDIR/lib' \
+              --with-mpfr-include='/dev/env/DJDIR/include' --with-mpfr-lib='/dev/env/DJDIR/lib' \
+              --with-gmp-include='/dev/env/DJDIR/include' --with-gmp-lib='/dev/env/DJDIR/lib' \
+              --with-isl-include='/dev/env/DJDIR/include' --with-isl-lib='/dev/env/DJDIR/lib' \
+              --enable-install-bfd --enable-install-libiberty \
+              --enable-build-warnings=-Wimplicit,-Wcomment,-Wformat,-Wparentheses,-Wpointer-arith >> build_log.txt  2>&1
+
+echo >> build_log.txt
+echo ################################################################################ >> build_log.txt
+echo >> build_log.txt
+
+
+# Remove target alias from tooldir and scriptdir paths so
+# that the linker scripts and binaries are installed in
+# their DJGPP specific canonical places.
+sed "/^.*tooldir = /s|/.*$||" ./Makefile > file.out
+mv -vf ./file.out ./Makefile
+
+
+echo
+echo Building the progs and libs.
+echo See build_log.txt file for output.
+echo Building the progs and libs for DJGPP. >> build_log.txt
+echo >> build_log.txt
+make >> build_log.txt  2>&1
+
+touch stop_build.txt
diff -aprNU5 binutils-2.34.orig/gas/as.c binutils-2.34/gas/as.c
--- binutils-2.34.orig/gas/as.c	2020-01-18 13:55:46 +0000
+++ binutils-2.34/gas/as.c	2020-03-01 19:35:24 +0000
@@ -1240,11 +1240,11 @@ main (int argc, char ** argv)
 
 #ifdef HOST_SPECIAL_INIT
   HOST_SPECIAL_INIT (argc, argv);
 #endif
 
-  myname = argv[0];
+  myname = STRIP_FULL_PATH_AND_EXTENSION(argv[0]);
   xmalloc_set_program_name (myname);
 
   expandargv (&argc, &argv);
 
   START_PROGRESS (myname, 0);
diff -aprNU5 binutils-2.34.orig/gas/config/obj-coff-seh.c binutils-2.34/gas/config/obj-coff-seh.c
--- binutils-2.34.orig/gas/config/obj-coff-seh.c	2020-01-18 13:55:46 +0000
+++ binutils-2.34/gas/config/obj-coff-seh.c	2020-03-01 19:35:24 +0000
@@ -62,11 +62,11 @@ get_pxdata_name (segT seg, const char *b
   else if (dot < dollar)
     name = dot;
   else
     name = dollar;
 
-  sname = concat (base_name, name, NULL);
+  sname = concat (base_name, name, (char *)NULL);
 
   return sname;
 }
 
 /* Allocate a seh_seg_list structure.  */
diff -aprNU5 binutils-2.34.orig/gas/config.in binutils-2.34/gas/config.in
--- binutils-2.34.orig/gas/config.in	2020-02-01 11:49:54 +0000
+++ binutils-2.34/gas/config.in	2020-03-01 19:35:24 +0000
@@ -412,5 +412,42 @@
 #undef inline
 #endif
 
 /* Define to `unsigned int' if <sys/types.h> does not define. */
 #undef size_t
+
+#ifdef __DJGPP__
+# include <sys/version.h>
+
+# if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#  define __gnuc_extension__  __extension__
+# else
+#  define __gnuc_extension__
+# endif
+
+# undef  IS_SLASH
+# define IS_SLASH(c)                ((c) == '/' || (c) == '\\')
+# undef  IS_DIRECTORY_SEPARATOR
+# define IS_DIRECTORY_SEPARATOR(c)  (IS_SLASH(c) || (c) == ':')
+
+# include <libc/unconst.h>
+# define STRIP_FULL_PATH_AND_EXTENSION(file_name)   \
+  (__gnuc_extension__                               \
+    ({                                              \
+       char *_dst, *_src;                           \
+       _dst = _src = unconst((file_name), char *);  \
+       while (*_src++)                              \
+         ;                                          \
+       while ((_src - _dst) && (*--_src != '.'))    \
+         ;                                          \
+       for (*_src = '\0'; (_src - _dst); _src--)    \
+         if (IS_DIRECTORY_SEPARATOR(*_src))         \
+           break;                                   \
+       if (_src - _dst)                             \
+         while ((*_dst++ = *++_src))                \
+           ;                                        \
+       (file_name);                                 \
+    })                                              \
+  )
+#else
+# define STRIP_FULL_PATH_AND_EXTENSION(file_name)  (file_name)
+#endif
diff -aprNU5 binutils-2.34.orig/gas/dw2gencfi.c binutils-2.34/gas/dw2gencfi.c
--- binutils-2.34.orig/gas/dw2gencfi.c	2020-01-18 13:55:46 +0000
+++ binutils-2.34/gas/dw2gencfi.c	2020-03-01 19:35:24 +0000
@@ -255,11 +255,11 @@ get_debugseg_name (segT seg, const char
   else if (dot < dollar)
     name = dot;
   else
     name = dollar;
 
-  return concat (base_name, name, NULL);
+  return concat (base_name, name, (char *)NULL);
 }
 
 /* Allocate a dwcfi_seg_list structure.  */
 
 static struct dwcfi_seg_list *
diff -aprNU5 binutils-2.34.orig/gold/config.in binutils-2.34/gold/config.in
--- binutils-2.34.orig/gold/config.in	2020-01-18 14:04:34 +0000
+++ binutils-2.34/gold/config.in	2020-03-01 19:35:24 +0000
@@ -295,5 +295,39 @@
    this defined. */
 #undef _POSIX_1_SOURCE
 
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
+#ifdef __DJGPP__
+# if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#  define __gnuc_extension__  __extension__
+# else
+#  define __gnuc_extension__
+# endif
+
+# undef  IS_SLASH
+# define IS_SLASH(c)                ((c) == '/' || (c) == '\\')
+# undef  IS_DIRECTORY_SEPARATOR
+# define IS_DIRECTORY_SEPARATOR(c)  (IS_SLASH(c) || (c) == ':')
+
+# include <libc/unconst.h>
+# define STRIP_FULL_PATH_AND_EXTENSION(file_name)   \
+  (__gnuc_extension__                               \
+    ({                                              \
+       char *_dst, *_src;                           \
+       _dst = _src = unconst((file_name), char *);  \
+       while (*_src++)                              \
+         ;                                          \
+       while ((_src - _dst) && (*--_src != '.'))    \
+         ;                                          \
+       for (*_src = '\0'; (_src - _dst); _src--)    \
+         if (IS_DIRECTORY_SEPARATOR(*_src))         \
+           break;                                   \
+       if (_src - _dst)                             \
+         while ((*_dst++ = *++_src))                \
+           ;                                        \
+       (file_name);                                 \
+    })                                              \
+  )
+#else
+# define STRIP_FULL_PATH_AND_EXTENSION(file_name)  (file_name)
+#endif
diff -aprNU5 binutils-2.34.orig/gprof/gconfig.in binutils-2.34/gprof/gconfig.in
--- binutils-2.34.orig/gprof/gconfig.in	2020-02-01 11:52:24 +0000
+++ binutils-2.34/gprof/gconfig.in	2020-03-01 19:35:24 +0000
@@ -117,5 +117,42 @@
    this defined. */
 #undef _POSIX_1_SOURCE
 
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
+
+#ifdef __DJGPP__
+# include <sys/version.h>
+
+# if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#  define __gnuc_extension__  __extension__
+# else
+#  define __gnuc_extension__
+# endif
+
+# undef  IS_SLASH
+# define IS_SLASH(c)                ((c) == '/' || (c) == '\\')
+# undef  IS_DIRECTORY_SEPARATOR
+# define IS_DIRECTORY_SEPARATOR(c)  (IS_SLASH(c) || (c) == ':')
+
+# include <libc/unconst.h>
+# define STRIP_FULL_PATH_AND_EXTENSION(file_name)   \
+  (__gnuc_extension__                               \
+    ({                                              \
+       char *_dst, *_src;                           \
+       _dst = _src = unconst((file_name), char *);  \
+       while (*_src++)                              \
+         ;                                          \
+       while ((_src - _dst) && (*--_src != '.'))    \
+         ;                                          \
+       for (*_src = '\0'; (_src - _dst); _src--)    \
+         if (IS_DIRECTORY_SEPARATOR(*_src))         \
+           break;                                   \
+       if (_src - _dst)                             \
+         while ((*_dst++ = *++_src))                \
+           ;                                        \
+       (file_name);                                 \
+    })                                              \
+  )
+#else
+# define STRIP_FULL_PATH_AND_EXTENSION(file_name)  (file_name)
+#endif
diff -aprNU5 binutils-2.34.orig/gprof/gprof.c binutils-2.34/gprof/gprof.c
--- binutils-2.34.orig/gprof/gprof.c	2020-01-18 13:55:48 +0000
+++ binutils-2.34/gprof/gprof.c	2020-03-01 19:35:24 +0000
@@ -196,11 +196,17 @@ main (int argc, char **argv)
 #ifdef ENABLE_NLS
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 #endif
 
-  whoami = argv[0];
+#if defined (COFF_GO32_EXE) || defined (COFF_GO32)
+  /*  This call is necessary to check if coff
+      64k relocation support shall be enabled or not.  */
+  bfd_init ();
+#endif
+
+  whoami = STRIP_FULL_PATH_AND_EXTENSION(argv[0]);
   xmalloc_set_program_name (whoami);
 
   expandargv (&argc, &argv);
 
   while ((ch = getopt_long (argc, argv,
diff -aprNU5 binutils-2.34.orig/ld/config.in binutils-2.34/ld/config.in
--- binutils-2.34.orig/ld/config.in	2020-02-01 11:50:28 +0000
+++ binutils-2.34/ld/config.in	2020-03-01 19:35:24 +0000
@@ -252,5 +252,52 @@
    this defined. */
 #undef _POSIX_1_SOURCE
 
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
+
+
+
+/*
+ * DJGPP specific stuff.
+ */
+
+/* DJGPP, DXE3 support: Enable resolution of multiple symbol definition
+   introduced by the import libraries by the linker. */
+#undef HAVE_DXE3_SUPPORT
+
+#ifdef __DJGPP__
+# include <sys/version.h>
+
+# if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#  define __gnuc_extension__  __extension__
+# else
+#  define __gnuc_extension__
+# endif
+
+# undef  IS_SLASH
+# define IS_SLASH(c)                ((c) == '/' || (c) == '\\')
+# undef  IS_DIRECTORY_SEPARATOR
+# define IS_DIRECTORY_SEPARATOR(c)  (IS_SLASH(c) || (c) == ':')
+
+# include <libc/unconst.h>
+# define STRIP_FULL_PATH_AND_EXTENSION(file_name)   \
+  (__gnuc_extension__                               \
+    ({                                              \
+       char *_dst, *_src;                           \
+       _dst = _src = unconst((file_name), char *);  \
+       while (*_src++)                              \
+         ;                                          \
+       while ((_src - _dst) && (*--_src != '.'))    \
+         ;                                          \
+       for (*_src = '\0'; (_src - _dst); _src--)    \
+         if (IS_DIRECTORY_SEPARATOR(*_src))         \
+           break;                                   \
+       if (_src - _dst)                             \
+         while ((*_dst++ = *++_src))                \
+           ;                                        \
+       (file_name);                                 \
+    })                                              \
+  )
+#else
+# define STRIP_FULL_PATH_AND_EXTENSION(file_name)  (file_name)
+#endif
diff -aprNU5 binutils-2.34.orig/ld/configure binutils-2.34/ld/configure
--- binutils-2.34.orig/ld/configure	2020-02-01 11:50:24 +0000
+++ binutils-2.34/ld/configure	2020-03-01 19:35:24 +0000
@@ -17700,10 +17700,19 @@ ac_config_commands="$ac_config_commands
 
 
 
 
 
+case "$target_os" in
+  *djgpp)
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DXE3_SUPPORT 1
+_ACEOF
+ ;;
+esac
+
+
 ac_config_files="$ac_config_files Makefile po/Makefile.in:po/Make-in"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
diff -aprNU5 binutils-2.34.orig/ld/ldfile.c binutils-2.34/ld/ldfile.c
--- binutils-2.34.orig/ld/ldfile.c	2020-01-18 13:55:48 +0000
+++ binutils-2.34/ld/ldfile.c	2020-03-01 19:35:24 +0000
@@ -63,10 +63,127 @@ typedef struct search_arch
 
 static search_dirs_type **search_tail_ptr = &search_head;
 static search_arch_type *search_arch_head;
 static search_arch_type **search_arch_tail_ptr = &search_arch_head;
 
+
+#ifdef __DJGPP__
+/*  Map library long filename to a library short filename according
+    to the filename table stored in /dev/env/DJDIR/lib/libnames.tab.  */
+
+static bfd_boolean
+map_LFN_to_SFN (const char **filename)
+{
+  static char **table = NULL;
+  static int last_index = 0;
+
+
+  /*
+   *  Initialize library name table from libnames.tab content.
+   */
+  if (!table)
+  {
+    FILE *map = fopen ("/dev/env/DJDIR/lib/libnames.tab", "r");
+
+    if (map)
+    {
+      char line[128];
+      int i = 0;
+
+      while (fscanf(map, "%[^\n]\n", line) != EOF)
+      {
+        if (line[0] == '#')
+          continue;
+        else
+          i++;
+      }
+
+      if (i)
+      {
+        last_index = 2 * i;
+        table = xmalloc(last_index * sizeof(char *));
+
+        i = 0;
+        rewind(map);
+        while (fscanf(map, "%[^\n]\n", line) != EOF)
+        {
+          if (line[0] != '#')
+          {
+            char long_name[FILENAME_MAX + 1], short_name[FILENAME_MAX + 1];
+
+            sscanf(line, "%s %s", long_name, short_name);
+            table[i++] = concat(long_name, (const char *) NULL);
+            table[i++] = concat(short_name, (const char *) NULL);
+          }
+        }
+      }
+
+      fclose(map);
+    }
+    else if (verbose)
+      info_msg(_("cannot find \"/dev/env/DJDIR/lib/libnames.tab\"\n"));
+  }
+
+
+  /*
+   *  Map library LFN to SFN using the table read from libnames.tab content.
+   */
+  if (table)
+  {
+    char *extension, *libname, *prefix = concat(*filename, (const char *)NULL);
+    int i;
+
+    /*  Strip library prefix and suffix.  */
+    for (libname = prefix, i = 0; libname[i]; i++)
+      ;
+
+#define IS_DOT_A_SUFFIX(filename)  ((filename)[--i] == 'a' && (filename)[--i] == '.')
+#define IS_LIB_PREFIX(filename)    ((filename)[--i] == 'b' && (filename)[--i] == 'i' && (filename)[--i] == 'l')
+    while (i)
+      if (IS_DOT_A_SUFFIX(libname))
+      {
+        libname[i] = '\0';
+        extension = libname + i;
+        break;
+      }
+    while (i)
+      if (IS_LIB_PREFIX(libname))
+      {
+        if (i == 0)
+        {
+          libname += 3;
+          break;
+        }
+        if (libname[--i] == '/')
+        {
+          libname += i + 4;
+          break;
+        }
+      }
+#undef IS_DOT_A_SUFFIX
+#undef IS_LIB_PREFIX
+
+    for (i = 0; i < last_index; i++)
+      if (strcmp(libname, table[i++]) == 0)
+      {
+        /*  Create a short filename for the library.  */
+        *libname = '\0';
+        *extension = '.';
+        *filename = concat(prefix, table[i], extension, (const char *)NULL);
+        if (verbose)
+          info_msg(_("mapped \"%s\" to \"%s\"\n"), table[i - 1], table[i]);
+
+        return TRUE;
+      }
+
+    free(prefix);
+  }
+
+  return FALSE;
+}
+#endif  /* __DJGPP__ */
+
 /* Test whether a pathname, after canonicalization, is the same or a
    sub-directory of the sysroot directory.  */
 
 static bfd_boolean
 is_sysrooted_pathname (const char *name)
@@ -123,12 +240,23 @@ ldfile_add_library_path (const char *nam
 
 bfd_boolean
 ldfile_try_open_bfd (const char *attempt,
 		     lang_input_statement_type *entry)
 {
+#ifdef __DJGPP__
+  bfd_boolean already_tried_SFN = FALSE;
+
+again:
+#endif  /* __DJGPP__ */
+
   entry->the_bfd = bfd_openr (attempt, entry->target);
 
+#ifdef __DJGPP__
+  if (!entry->the_bfd && !already_tried_SFN && (already_tried_SFN = map_LFN_to_SFN(&attempt)))
+    goto again;
+#endif  /* __DJGPP__ */
+
   if (verbose)
     {
       if (entry->the_bfd == NULL)
 	info_msg (_("attempt to open %s failed\n"), attempt);
       else
@@ -370,11 +498,11 @@ ldfile_open_file_search (const char *arc
       if (entry->flags.maybe_archive && !entry->flags.full_name_provided)
 	string = concat (search->name, slash, lib, entry->filename,
 			 arch, suffix, (const char *) NULL);
       else
 	string = concat (search->name, slash, entry->filename,
-			 (const char *) 0);
+			 (const char *) NULL);
 
       if (ldfile_try_open_bfd (string, entry))
 	{
 	  entry->filename = string;
 	  return TRUE;
diff -aprNU5 binutils-2.34.orig/ld/ldmain.c binutils-2.34/ld/ldmain.c
--- binutils-2.34.orig/ld/ldmain.c	2020-01-18 13:55:48 +0000
+++ binutils-2.34/ld/ldmain.c	2020-03-01 19:35:24 +0000
@@ -203,11 +203,11 @@ main (int argc, char **argv)
   setlocale (LC_CTYPE, "");
 #endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  program_name = argv[0];
+  program_name = STRIP_FULL_PATH_AND_EXTENSION(argv[0]);
   xmalloc_set_program_name (program_name);
 
   START_PROGRESS (program_name, 0);
 
   expandargv (&argc, &argv);
@@ -992,10 +992,34 @@ multiple_definition (struct bfd_link_inf
 	  || (nsec->output_section != NULL
 	      && !bfd_is_abs_section (nsec)
 	      && bfd_is_abs_section (nsec->output_section))))
     return;
 
+#if defined(HAVE_DXE3_SUPPORT) && HAVE_DXE3_SUPPORT == 1
+  /*  DJGPP specific resolution of multiple symbol definitions.
+      A symbol defined in an object file or in an static library
+      and at the same time in an import library belonging to a
+      DXE3 module will be replaced by the symbol provided by the
+      import library.  If more than one import library provides
+      the same symbol the first one will be used and all other
+      ones will be ignored.
+      A symbol from an import library is identified by its "dxe_tmp.o"
+      or "$$dxe$$.o" file name.  */
+
+#define IS_IMPORT_LIBRARY_SYMBOL(name)  (((name)[0] == 'd' && (name)[1] == 'x' && (name)[2] == 'e' && (name)[3] == '_' && \
+                                          (name)[4] == 't' && (name)[5] == 'm' && (name)[6] == 'p' && (name)[7] == '.' && \
+                                          (name)[8] == 'o') ||                                                            \
+                                         ((name)[0] == '$' && (name)[1] == '$' && (name)[2] == 'd' && (name)[3] == 'x' && \
+                                          (name)[4] == 'e' && (name)[5] == '$' && (name)[6] == '$' && (name)[7] == '.' && \
+                                          (name)[8] == 'o'))
+
+    if (h->type == bfd_link_hash_defined && IS_IMPORT_LIBRARY_SYMBOL(nsec->owner->filename))
+      return;
+
+#undef IS_IMPORT_LIBRARY_SYMBOL
+#endif /*  HAVE_DXE3_SUPPORT  */
+
   name = h->root.string;
   if (nbfd == NULL)
     {
       nbfd = obfd;
       nsec = osec;
diff -aprNU5 binutils-2.34.orig/ld/libnames.tab binutils-2.34/ld/libnames.tab
--- binutils-2.34.orig/ld/libnames.tab	1970-01-01 00:00:00 +0000
+++ binutils-2.34/ld/libnames.tab	2020-03-01 19:35:24 +0000
@@ -0,0 +1,31 @@
+#
+#  Table to map libraries long file name to short file names.
+#  The entry is:
+#    LFN   SFN
+#  The library name is the name stripped from its directory name,
+#  stripped from its "lib" prefix and its ".a" suffix.
+#
+#
+#  E.g.: for the library
+#
+#    /dev/env/DJDIR/lib/foobar-1.2.3/libverylongname-1.2.3.a
+#
+#  the mapping entry will look like this:
+#
+#    verylongname-1.2.3   vln123
+#
+
+
+#  LFN           SFN
+
+#  Map for GNU gettext libraries.
+gettextlib     gtxtlib
+gettextpo      gtxtpo
+gettextsrc     gtxtsrc
+
+
+#  Map for perl compatible regular expressions libraries with API 2 (aka PCRE2).
+pcre2-8        pcr28
+pcre2-16       pcr216
+pcre2-32       pcr232
+pcre2-posix    pcr2posix
diff -aprNU5 binutils-2.34.orig/ld/scripttempl/i386go32.sc binutils-2.34/ld/scripttempl/i386go32.sc
--- binutils-2.34.orig/ld/scripttempl/i386go32.sc	2020-01-18 13:55:48 +0000
+++ binutils-2.34/ld/scripttempl/i386go32.sc	2020-03-01 19:35:24 +0000
@@ -45,18 +45,27 @@ SECTIONS
   }
   .data ${RELOCATING+ ${DATA_ALIGNMENT}} : {
     ${RELOCATING+djgpp_first_ctor = . ;
     *(SORT(.ctors.*))
     *(.ctor)
+    *(.ctors)
     djgpp_last_ctor = . ;}
     ${RELOCATING+djgpp_first_dtor = . ;
     *(SORT(.dtors.*))
     *(.dtor)
+    *(.dtors)
     djgpp_last_dtor = . ;}
+    __environ = . ;
+    PROVIDE(_environ = .) ;
+    LONG(0) ;
     *(.data)
     ${RELOCATING+*(.data.*)}
 
+    /* Ugly workaround to prevent entire .bss to have attribute CONTENT */
+    /* for C++ executables. */
+    *(.bss.*)
+
     ${RELOCATING+*(.gcc_exc*)}
     ${RELOCATING+___EH_FRAME_BEGIN__ = . ;}
     ${RELOCATING+*(.eh_fram*)}
     ${RELOCATING+___EH_FRAME_END__ = . ;}
     ${RELOCATING+LONG(0);}
@@ -67,15 +76,17 @@ SECTIONS
   }
   ${CONSTRUCTING+${RELOCATING-$CTOR}}
   ${CONSTRUCTING+${RELOCATING-$DTOR}}
   .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} :
   {
-    *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
+    *(.bss${RELOCATING+ .gnu.linkonce.b.*})
     *(COMMON)
     ${RELOCATING+ end = . ; PROVIDE(_end = .) ;}
     ${RELOCATING+ . = ALIGN(${SEGMENT_SIZE});}
   }
+  /* Discard LTO sections.  */
+  /DISCARD/ : { *(gnu.lto_*) } 
   /* Stabs debugging sections.  */
   .stab 0 : { *(.stab) }
   .stabstr 0 : { *(.stabstr) }
 EOF
 
diff -aprNU5 binutils-2.34.orig/libctf/config.h.in binutils-2.34/libctf/config.h.in
--- binutils-2.34.orig/libctf/config.h.in	2020-01-18 14:02:32 +0000
+++ binutils-2.34/libctf/config.h.in	2020-03-01 19:35:24 +0000
@@ -153,5 +153,35 @@
    this defined. */
 #undef _POSIX_1_SOURCE
 
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
+
+#ifdef __DJGPP__
+/*  gcc no longer includes this by default.  */
+# include <sys/version.h>
+
+/*
+ *  (ENOTSUP and EOPNOTSUPP have the same value on Linux,
+ *  but according to POSIX.1 these error values should be
+ *  distinct.)
+ */
+
+# if !defined(ENOTSUP) && defined(EOPNOTSUPP)
+#  define ENOTSUP  EOPNOTSUPP
+# endif
+
+/* Values taken from FreeBSD.  */
+# ifndef ENOTSUP
+#  define ENOTSUP  9926  /* Operation not supported (POSIX.1-2001).  */
+# endif
+
+# undef  DJGPP_GCC_VERSION
+# define DJGPP_GCC_VERSION  ((__GNUC__) * 10000 + (__GNUC_MINOR__) * 100 + (__GNUC_PATCHLEVEL__))
+# if DJGPP_GCC_VERSION < 40300
+#  define HAVE_TSL_SUPPORT  0
+# else
+#  define HAVE_TSL_SUPPORT  1
+# endif  /* DJGPP_GCC_VERSION */
+# undef DJGPP_GCC_VERSION
+
+#endif  /* __DJGPP__ */
diff -aprNU5 binutils-2.34.orig/libctf/ctf-archive.c binutils-2.34/libctf/ctf-archive.c
--- binutils-2.34.orig/libctf/ctf-archive.c	2020-01-18 13:55:48 +0000
+++ binutils-2.34/libctf/ctf-archive.c	2020-03-01 19:58:00 +0000
@@ -43,11 +43,15 @@ static void *arc_mmap_file (int fd, size
 static int arc_mmap_writeout (int fd, void *header, size_t headersz,
 			      const char **errmsg);
 static int arc_mmap_unmap (void *header, size_t headersz, const char **errmsg);
 
 /* bsearch() internal state.  */
+#if (HAVE_TSL_SUPPORT - 1) == 0
 static __thread char *search_nametbl;
+#else
+static char *search_nametbl;
+#endif
 
 /* Write out a CTF archive to the start of the file referenced by the passed-in
    fd.  The entries in CTF_FILES are referenced by name: the names are passed in
    the names array, which must have CTF_FILES entries.
 
diff -aprNU5 binutils-2.34.orig/libctf/swap.h binutils-2.34/libctf/swap.h
--- binutils-2.34.orig/libctf/swap.h	2020-01-18 13:55:48 +0000
+++ binutils-2.34/libctf/swap.h	2020-03-01 19:59:52 +0000
@@ -25,10 +25,11 @@
 
 #ifdef HAVE_BYTESWAP_H
 #include <byteswap.h>
 #else
 
+#ifndef __DJGPP__
 /* Provide our own versions of the byteswap functions.  */
 static inline uint16_t
 bswap_16 (uint16_t v)
 {
   return ((v >> 8) & 0xff) | ((v & 0xff) << 8);
@@ -59,8 +60,64 @@ bswap_64 (uint64_t v)
 	  | ((v & 0x00000000ff000000ULL) <<  8)
 	  | ((v & 0x0000000000ff0000ULL) << 24)
 	  | ((v & 0x000000000000ff00ULL) << 40)
 	  | ((v & 0x00000000000000ffULL) << 56));
 }
+#else  /* __DJGPP__ */
+
+/*  The inline functions make trouble with diferent versions of gcc thus use macros.  */
+# if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#  define __gnuc_extension__  __extension__
+# else
+#  define __gnuc_extension__
+# endif
+
+# define bswap_identity_64(v)                                      \
+  (__gnuc_extension__                                              \
+    ({                                                             \
+       uint64_t value = (v);                                       \
+       value;                                                      \
+    })                                                             \
+  )
+
+# define bswap_16(v)                                               \
+  (__gnuc_extension__                                              \
+    ({                                                             \
+       uint16_t _v = (v);                                          \
+       uint16_t value = (  ((_v >> 8) & 0xFF)                      \
+                         | ((_v & 0xFF) << 8));                    \
+       value;                                                      \
+    })                                                             \
+  )
+
+# define bswap_32(v)                                               \
+  (__gnuc_extension__                                              \
+    ({                                                             \
+       uint32_t _v = (v);                                          \
+       uint32_t value = (  ((_v & 0xFF000000) >> 24)               \
+                         | ((_v & 0x00FF0000) >>  8)               \
+                         | ((_v & 0x0000FF00) <<  8)               \
+                         | ((_v & 0x000000FF) << 24));             \
+       value;                                                      \
+    })                                                             \
+  )
+
+# define bswap_64(v)                                               \
+  (__gnuc_extension__                                              \
+    ({                                                             \
+       uint64_t _v = (v);                                          \
+       uint64_t value = (  ((_v & 0xFF00000000000000ULL) >> 56)    \
+                         | ((_v & 0x00FF000000000000ULL) >> 40)    \
+                         | ((_v & 0x0000FF0000000000ULL) >> 24)    \
+                         | ((_v & 0x000000FF00000000ULL) >>  8)    \
+                         | ((_v & 0x00000000FF000000ULL) <<  8)    \
+                         | ((_v & 0x0000000000FF0000ULL) << 24)    \
+                         | ((_v & 0x000000000000FF00ULL) << 40)    \
+                         | ((_v & 0x00000000000000FFULL) << 56));  \
+       value;                                                      \
+    })                                                             \
+  )
+#endif /* __DJGPP__ */
+
 #endif /* !defined(HAVE_BYTESWAP_H) */
 
 #endif /* !defined(_CTF_SWAP_H) */
diff -aprNU5 binutils-2.34.orig/opcodes/config.in binutils-2.34/opcodes/config.in
--- binutils-2.34.orig/opcodes/config.in	2020-02-01 11:49:44 +0000
+++ binutils-2.34/opcodes/config.in	2020-03-01 19:35:24 +0000
@@ -118,5 +118,42 @@
    this defined. */
 #undef _POSIX_1_SOURCE
 
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
+
+#ifdef __DJGPP__
+# include <sys/version.h>
+
+# if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#  define __gnuc_extension__  __extension__
+# else
+#  define __gnuc_extension__
+# endif
+
+# undef  IS_SLASH
+# define IS_SLASH(c)                ((c) == '/' || (c) == '\\')
+# undef  IS_DIRECTORY_SEPARATOR
+# define IS_DIRECTORY_SEPARATOR(c)  (IS_SLASH(c) || (c) == ':')
+
+# include <libc/unconst.h>
+# define STRIP_FULL_PATH_AND_EXTENSION(file_name)   \
+  (__gnuc_extension__                               \
+    ({                                              \
+       char *_dst, *_src;                           \
+       _dst = _src = unconst((file_name), char *);  \
+       while (*_src++)                              \
+         ;                                          \
+       while ((_src - _dst) && (*--_src != '.'))    \
+         ;                                          \
+       for (*_src = '\0'; (_src - _dst); _src--)    \
+         if (IS_DIRECTORY_SEPARATOR(*_src))         \
+           break;                                   \
+       if (_src - _dst)                             \
+         while ((*_dst++ = *++_src))                \
+           ;                                        \
+       (file_name);                                 \
+    })                                              \
+  )
+#else
+# define STRIP_FULL_PATH_AND_EXTENSION(file_name)  (file_name)
+#endif







2020-03-16 Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* ld/scripttempl/i386go32.sc:  Added missing leading dot to the
	gnu.lto_ symbol.





diff -aprNU5 binutils-2.34.orig/ld/scripttempl/i386go32.sc binutils-2.34/ld/scripttempl/i386go32.sc
--- binutils-2.34.orig/ld/scripttempl/i386go32.sc	2020-03-16 20:51:36 +0000
+++ binutils-2.34/ld/scripttempl/i386go32.sc	2020-03-16 20:58:40 +0000
@@ -82,11 +82,11 @@ SECTIONS
     *(COMMON)
     ${RELOCATING+ end = . ; PROVIDE(_end = .) ;}
     ${RELOCATING+ . = ALIGN(${SEGMENT_SIZE});}
   }
   /* Discard LTO sections.  */
-  /DISCARD/ : { *(gnu.lto_*) } 
+  /DISCARD/ : { *(.gnu.lto_*) } 
   /* Stabs debugging sections.  */
   .stab 0 : { *(.stab) }
   .stabstr 0 : { *(.stabstr) }
 EOF