summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanez Zemva2018-02-04 17:38:52 +0100
committerJanez Zemva2018-02-04 17:38:52 +0100
commit88c5d6e30f1e9d186d48d7ff2956373ef1394eae (patch)
tree1b69b50dfb11f20cd6cdc33ae0e6a30d5fee7e7f
parent730daf9b4131b485e990de78175c71af27d48dfe (diff)
downloadaur-88c5d6e30f1e9d186d48d7ff2956373ef1394eae.tar.gz
some fixes
-rw-r--r--.SRCINFO15
-rw-r--r--PKGBUILD27
-rw-r--r--binutils-bfd-djgpp.patch1007
-rw-r--r--binutils-djgpp.patch1329
-rw-r--r--lto-discard.patch29
-rw-r--r--xtors.patch30
6 files changed, 2369 insertions, 68 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 60af7e5667c7..f389e7a87b26 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = dosbox-binutils
pkgdesc = Binutils for the djgpp dosbox cross-compiler
- pkgver = 2.29
- pkgrel = 1
+ pkgver = 2.29.1
+ pkgrel = 2
url = http://www.gnu.org/software/binutils
arch = i686
arch = x86_64
@@ -10,13 +10,14 @@ pkgbase = dosbox-binutils
depends = zlib
options = !libtool
options = !emptydirs
- source = http://ftp.gnu.org/gnu/binutils/binutils-2.29.tar.xz
- source = xtors.patch
+ source = http://ftp.gnu.org/gnu/binutils/binutils-2.29.1.tar.xz
+ source = binutils-bfd-djgpp.patch
+ source = binutils-djgpp.patch
source = lto-discard.patch
validpgpkeys = EAF1C276A747E9ED86210CBAC3126D3B4AE55E93
sha256sums = SKIP
- sha256sums = a54efa3f29f14c938fedf29fb352d4f104e8c0ec065c74b0cd3f753fe3e9d4ef
- sha256sums = a7978c3110dbccde7290fb3517121f5cae427728c04e6fb76736f36857514ec9
+ sha256sums = SKIP
+ sha256sums = SKIP
+ sha256sums = SKIP
pkgname = dosbox-binutils
-
diff --git a/PKGBUILD b/PKGBUILD
index 9c7918519700..4a89b6c97490 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,8 +3,8 @@
# Contributor: janezz55
pkgname=dosbox-binutils
-pkgver=2.29
-pkgrel=1
+pkgver=2.29.1
+pkgrel=2
pkgdesc="binutils for the djgpp dosbox cross-compiler"
arch=('i686' 'x86_64')
url="http://www.gnu.org/software/binutils"
@@ -13,39 +13,38 @@ groups=('djgpp')
depends=('zlib')
options=('!libtool' '!emptydirs')
source=("http://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz"
- xtors.patch
- lto-discard.patch)
+ "binutils-bfd-djgpp.patch"
+ "binutils-djgpp.patch"
+ "lto-discard.patch")
sha256sums=('SKIP'
- 'a54efa3f29f14c938fedf29fb352d4f104e8c0ec065c74b0cd3f753fe3e9d4ef'
- 'a7978c3110dbccde7290fb3517121f5cae427728c04e6fb76736f36857514ec9')
+ 'SKIP'
+ 'SKIP'
+ 'SKIP')
validpgpkeys=('EAF1C276A747E9ED86210CBAC3126D3B4AE55E93') # Tristan Gingold <adacore dot com, gingold>
_target="i586-pc-msdosdjgpp"
prepare() {
cd binutils-$pkgver
- # do not install libiberty
- sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
-
# hack! - libiberty configure tests for header files break with FORTIFY_SOURCE
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" libiberty/configure
- # put .ctors and .dtors where they belong
- patch -Np1 < ../xtors.patch
-
- # discard LTO sections in coff-go32-exe files
- patch -Np1 < ../lto-discard.patch
+ patch -Np1 <${srcdir}/binutils-djgpp.patch
+ patch -Np1 <${srcdir}/binutils-bfd-djgpp.patch
+ patch -Np2 <${srcdir}/lto-discard.patch
}
build() {
mkdir -p binutils-$_target
+ export CPPFLAGS="$CPPFLAGS -Ofast"
cd binutils-$_target
../binutils-$pkgver/configure --prefix=/usr \
--target="$_target" \
--infodir="/usr/share/info/$_target" \
--datadir="/usr/$_target/share" \
--enable-lto --enable-plugins \
+ --disable-install-libiberty \
--disable-multilib --disable-nls \
--disable-werror
make
diff --git a/binutils-bfd-djgpp.patch b/binutils-bfd-djgpp.patch
new file mode 100644
index 000000000000..9aa926cbc4a2
--- /dev/null
+++ b/binutils-bfd-djgpp.patch
@@ -0,0 +1,1007 @@
+# DJGPP specific changes to libbfd and libiberty shared
+# by the DJGPP ports of binutils and gdb.
+
+
+2017-09-30 Juan Manuel Guerrero <juan.guerrero@gmx.de>
+
+ * bfd/bfd-in.h [__DJGPP__]: Provide the declaration of
+ coff_64k_relocation_enabled.
+
+ * bfd/cache.c (bfd_cache_max_open) [__DJGPP__]: Do not use getrlimit
+ to check for the amount of files that can be opened. Use a fixed value
+ of 16.
+
+ * bfd/coff-go32.c: Define COFF_GO32 macro.
+ Add _bfd_go32_mkobject prototype.
+ Define coff_mkobject macro to _bfd_go32_mkobject.
+ Define IMAGE_SCN_LNK_NRELOC_OVFL. Signals that relocation counter
+ has overflown.
+
+ * bfd/coff-stgo32.c: Add _bfd_go32_mkobject prototype.
+ Define coff_mkobject macro to _bfd_go32_mkobject.
+ Add _bfd_go32_mkobject definition.
+ Define IMAGE_SCN_LNK_NRELOC_OVFL. Signals that relocation counter
+ has overflown.
+ (_bfd_go32_mkobject): Set go32 flag to 1 or 0 according to the value
+ of coff_64k_relocation_enabled.
+
+ * bfd/coffcode.h [COFF_GO32_EXE, COFF_GO32, COFF_WITH_PE]: Define new
+ macro COFF_WITH_PE_OR_COFF_WITH_EXTENDED_RELOC_COUNTER.
+ (coff_write_relocs, coff_write_object_contents): Replace COFF_WITH_PE
+ with COFF_WITH_PE_OR_COFF_WITH_EXTENDED_RELOC_COUNTER where appropriate
+ and add obj_go32 to the check if relocation counter >= 0xFFFF.
+ (coff_set_alignment_hook): Implementation for DJGPP.
+ [COFF_GO32_EXE, COFF_GO32]: Define COFF_PAD_SECTION_HEADERS.
+ Taken from bnu219s2.zip.
+ (coff_set_alignment_hook) [COFF_GO32_EXE, COFF_GO32]: Use
+ coff_64k_relocation_enabled where appropriate to enable/disable the
+ coff 64k relocation support.
+
+ * bfd/cofflink.c (_bfd_coff_final_link): If it is an obj_go32 allow
+ relocations larger than 65535.
+
+ * bfd/coffswap.h (coff_swap_scnhdr_in) [COFF_GO32_EXE, COFF_GO32]:
+ Iff reading an executable file and iff it is the ".text" section
+ header calculate the number of lines from the 16 bit field of the
+ relocation counter and the 16 bit filed of the line counter.
+ (coff_swap_scnhdr_out) [COFF_GO32_EXE, COFF_GO32]:
+ Use the same Ansatz to identify a .text section of an executable like
+ in coff_swap_scnhdr_in.
+ - Iff building an executable file and iff it is the ".text" section
+ header store the upper 16 bits of the line counter in the relocation
+ counter.
+ - Iff not building an executabe file or iff building an executable file
+ but iff it is not the ".text" section header then:
+ 1) if the relocation counter is greater the 65534 set the relocation
+ counter to 65535 and set the IMAGE_SCN_LNK_NRELOC_OVFL bit.
+ The relocation counter overflow is handled elsewhere.
+ 2) if the line counter is greater than 65535 then abort.
+ (coff_swap_scnhdr_in, coff_swap_scnhdr_out) [COFF_GO32_EXE, COFF_GO32]:
+ Use coff_64k_relocation_enabled where appropriate to enable/disable the
+ coff 64k relocation support.
+
+ * bfd/config.in [__DJGPP__]: Added DJGPP specific macros definitions.
+ They are all NO-OPS for other OSes.
+
+ * bfd/init.c [__DJGPP__]: Define coff_64k_relocation_enabled.
+ (bfd_init): Read the environment variable DISABLE_64K_RELOC_SUPPORT
+ to set the value of coff_64k_relocation_enabled.
+
+ * bfd/libcoff-in.h: Define obj_go32 macro.
+ Add go32 flag to struct coff_tdata. 1 if DJGPP else 0.
+
+ * bfd/Makefile.in: Force the regenaration of bfd-in2.h to provide the
+ declaration of coff_64k_relocation_enabled. Force the regenaration of
+ libcoff.h to provide the definition of obj_go32.
+
+ * include/bfdlink.h: Pacify compiler.
+
+ * include/coff/internal.h: Pacify compiler.
+
+ * libiberty/config.in [__DJGPP__]: Added DJGPP specific macros definitions.
+ They are all NO-OPS for other OSes.
+
+ * libiberty/cp-demangle.c (d_demangle_callback, d_print_comp): Pacify
+ compiler.
+
+ * libiberty/make-relative-prefix.c: DJGPP specific adjustments.
+ Taken from bnu219s2.zip.
+
+ * libiberty/make-temp-file.c: DJGPP specific adjustments.
+ Taken from bnu219s2.zip.
+
+ * libiberty/pex-common.c (temp_file, pex_run_in_environment): Pacify
+ compiler.
+
+ * libiberty/stack-limit.c (stack_limit_increase): Pacify compiler.
+
+
+
+
+
+diff -aprNU5 binutils-2.29.1.orig/bfd/bfd-in.h binutils-2.29.1/bfd/bfd-in.h
+--- binutils-2.29.1.orig/bfd/bfd-in.h 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/bfd/bfd-in.h 2017-09-30 21:36:18 +0000
+@@ -1047,5 +1047,11 @@ extern bfd_boolean v850_elf_set_note
+ (bfd *, unsigned int, unsigned int);
+
+ /* MIPS ABI flags data access. For the disassembler. */
+ struct elf_internal_abiflags_v0;
+ extern struct elf_internal_abiflags_v0 *bfd_mips_elf_get_abiflags (bfd *);
++
++/* This controls if the coff 64k relocation support shall be disabled or not.
++ By default always enabled. */
++#if defined(__DJGPP__) || defined(COFF_GO32_EXE) || defined(COFF_GO32)
++extern bfd_boolean coff_64k_relocation_enabled;
++#endif
+diff -aprNU5 binutils-2.29.1.orig/bfd/cache.c binutils-2.29.1/bfd/cache.c
+--- binutils-2.29.1.orig/bfd/cache.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/bfd/cache.c 2017-09-30 21:36:18 +0000
+@@ -76,11 +76,11 @@ static int
+ bfd_cache_max_open (void)
+ {
+ if (max_open_files == 0)
+ {
+ int max;
+-#if defined(__sun) && !defined(__sparcv9) && !defined(__x86_64__)
++#if defined(__sun) && !defined(__sparcv9) && !defined(__x86_64__) || defined(__DJGPP__)
+ /* PR ld/19260: 32-bit Solaris has very inelegant handling of the 255
+ file descriptor limit. The problem is that setrlimit(2) can raise
+ RLIMIT_NOFILE to a value that is not supported by libc, resulting
+ in "Too many open files" errors. This can happen here even though
+ max_open_files is set to rlim.rlim_cur / 8. For example, if
+diff -aprNU5 binutils-2.29.1.orig/bfd/coff-go32.c binutils-2.29.1/bfd/coff-go32.c
+--- binutils-2.29.1.orig/bfd/coff-go32.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/bfd/coff-go32.c 2017-09-30 21:36:18 +0000
+@@ -20,10 +20,11 @@
+ MA 02110-1301, USA. */
+
+ #define TARGET_SYM i386_coff_go32_vec
+ #define TARGET_NAME "coff-go32"
+ #define TARGET_UNDERSCORE '_'
++#define COFF_GO32
+ #define COFF_LONG_SECTION_NAMES
+ #define COFF_SUPPORT_GNU_LINKONCE
+ #define COFF_LONG_FILENAMES
+
+ #define COFF_SECTION_ALIGNMENT_ENTRIES \
+@@ -40,6 +41,16 @@
+ { COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
+ { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
+
++/* Section contains extended relocations. */
++#define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
++
++#include "sysdep.h"
++#include "bfd.h"
++
++bfd_boolean _bfd_go32_mkobject (bfd *abfd);
++
++#define coff_mkobject _bfd_go32_mkobject
++
+ #include "coff-i386.c"
+diff -aprNU5 binutils-2.29.1.orig/bfd/coff-stgo32.c binutils-2.29.1/bfd/coff-stgo32.c
+--- binutils-2.29.1.orig/bfd/coff-stgo32.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/bfd/coff-stgo32.c 2017-09-30 21:36:18 +0000
+@@ -51,10 +51,13 @@
+ { COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
+ { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
+
++/* Section contains extended relocations. */
++#define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
++
+ #include "sysdep.h"
+ #include "bfd.h"
+
+ /* All that ..._PRE and ...POST functions are called from the corresponding
+ coff_swap... functions. The ...PRE functions are called at the beginning
+@@ -100,10 +103,14 @@ static const bfd_target *go32_check_form
+ static bfd_boolean
+ go32_stubbed_coff_bfd_copy_private_bfd_data (bfd *, bfd *);
+
+ #define coff_bfd_copy_private_bfd_data go32_stubbed_coff_bfd_copy_private_bfd_data
+
++bfd_boolean _bfd_go32_mkobject (bfd *abfd);
++
++#define coff_mkobject _bfd_go32_mkobject
++
+ #include "coff-i386.c"
+
+ /* This macro is used, because I cannot assume the endianness of the
+ host system. */
+ #define _H(index) (H_GET_16 (abfd, (header + index * 2)))
+@@ -420,5 +427,31 @@ go32_check_format (bfd *abfd)
+ if (bfd_seek (abfd, 0, SEEK_SET) != 0)
+ return NULL;
+
+ return coff_object_p (abfd);
+ }
++
++/* This function is not static because it is used
++ by both targets coff-go32 and coff-go32-exe. */
++
++bfd_boolean
++_bfd_go32_mkobject (bfd *abfd)
++{
++ coff_data_type *coff;
++ bfd_size_type amt = sizeof (coff_data_type);
++
++ abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
++ if (abfd->tdata.coff_obj_data == NULL)
++ return FALSE;
++ coff = coff_data (abfd);
++ coff->symbols = NULL;
++ coff->conversion_table = NULL;
++ coff->raw_syments = NULL;
++ coff->relocbase = 0;
++ coff->local_toc_sym_map = 0;
++
++ /* Setting go32 does not only identify a go32 bfd
++ but also that more than 64k relocations are supported. */
++ coff->go32 = coff_64k_relocation_enabled ? 1 : 0;
++
++ return TRUE;
++}
+diff -aprNU5 binutils-2.29.1.orig/bfd/coffcode.h binutils-2.29.1/bfd/coffcode.h
+--- binutils-2.29.1.orig/bfd/coffcode.h 2017-09-05 10:12:10 +0000
++++ binutils-2.29.1/bfd/coffcode.h 2017-09-30 21:36:18 +0000
+@@ -376,10 +376,14 @@ CODE_FRAGMENT
+ #define DOT_ZDEBUG ".zdebug"
+ #define GNU_LINKONCE_WI ".gnu.linkonce.wi."
+ #define GNU_LINKONCE_WT ".gnu.linkonce.wt."
+ #define DOT_RELOC ".reloc"
+
++#if defined(COFF_WITH_PE) || defined(COFF_GO32_EXE) || defined(COFF_GO32)
++# define COFF_WITH_PE_OR_COFF_WITH_EXTENDED_RELOC_COUNTER
++#endif
++
+ #if defined (COFF_LONG_SECTION_NAMES)
+ /* Needed to expand the inputs to BLANKOR1TOODD. */
+ #define COFFLONGSECTIONCATHELPER(x,y) x ## y
+ /* If the input macro Y is blank or '1', return an odd number; if it is
+ '0', return an even number. Result undefined in all other cases. */
+@@ -1988,13 +1992,53 @@ coff_set_alignment_hook (bfd *abfd, asec
+ }
+ }
+
+ #else /* ! RS6000COFF_C */
+
++#if defined (COFF_GO32_EXE) || defined (COFF_GO32)
++
++static void
++coff_set_alignment_hook (bfd * abfd ATTRIBUTE_UNUSED,
++ asection * section,
++ void * scnhdr)
++{
++ if (coff_64k_relocation_enabled)
++ {
++ struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
++
++ /* Check for extended relocs. */
++ if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
++ {
++ struct external_reloc dst;
++ struct internal_reloc n;
++ file_ptr oldpos = bfd_tell (abfd);
++ bfd_size_type relsz = bfd_coff_relsz (abfd);
++
++ if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0)
++ return;
++ if (bfd_bread (& dst, relsz, abfd) != relsz)
++ return;
++
++ coff_swap_reloc_in (abfd, &dst, &n);
++ if (bfd_seek (abfd, oldpos, 0) != 0)
++ return;
++ section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
++ section->rel_filepos += relsz;
++ }
++ else if (hdr->s_nreloc == 0xffff)
++ (*_bfd_error_handler)
++ ("%s: warning: claims to have 0xffff relocs, without overflow",
++ bfd_get_filename (abfd));
++ }
++}
++
++#else /* ! COFF_GO32_EXE && ! COFF_GO32 */
++
+ #define coff_set_alignment_hook \
+ ((void (*) (bfd *, asection *, void *)) bfd_void)
+
++#endif /* ! COFF_GO32_EXE && ! COFF_GO32 */
+ #endif /* ! RS6000COFF_C */
+ #endif /* ! COFF_WITH_PE */
+ #endif /* ! COFF_ALIGN_IN_SECTION_HEADER */
+
+ #ifndef coff_mkobject
+@@ -2703,12 +2747,12 @@ coff_write_relocs (bfd * abfd, int first
+ #endif
+
+ if (bfd_seek (abfd, s->rel_filepos, SEEK_SET) != 0)
+ return FALSE;
+
+-#ifdef COFF_WITH_PE
+- if (obj_pe (abfd) && s->reloc_count >= 0xffff)
++#ifdef COFF_WITH_PE_OR_COFF_WITH_EXTENDED_RELOC_COUNTER
++ if ((obj_pe (abfd) || obj_go32 (abfd)) && s->reloc_count >= 0xffff)
+ {
+ /* Encode real count here as first reloc. */
+ struct internal_reloc n;
+
+ memset (& n, 0, sizeof (n));
+@@ -3616,10 +3660,14 @@ coff_apply_checksum (bfd *abfd)
+ return TRUE;
+ }
+
+ #endif /* COFF_IMAGE_WITH_PE */
+
++#if defined (COFF_GO32_EXE) || defined (COFF_GO32)
++# define COFF_PAD_SECTION_HEADERS
++#endif
++
+ static bfd_boolean
+ coff_write_object_contents (bfd * abfd)
+ {
+ asection *current;
+ bfd_boolean hasrelocs = FALSE;
+@@ -3660,13 +3708,13 @@ coff_write_object_contents (bfd * abfd)
+ /* Work out the size of the reloc and linno areas. */
+
+ for (current = abfd->sections; current != NULL; current =
+ current->next)
+ {
+-#ifdef COFF_WITH_PE
++#ifdef COFF_WITH_PE_OR_COFF_WITH_EXTENDED_RELOC_COUNTER
+ /* We store the actual reloc count in the first reloc's addr. */
+- if (obj_pe (abfd) && current->reloc_count >= 0xffff)
++ if ((obj_pe (abfd) || obj_go32 (abfd)) && current->reloc_count >= 0xffff)
+ reloc_count ++;
+ #endif
+ reloc_count += current->reloc_count;
+ }
+
+@@ -3690,13 +3738,13 @@ coff_write_object_contents (bfd * abfd)
+
+ if (current->reloc_count)
+ {
+ current->rel_filepos = reloc_base;
+ reloc_base += current->reloc_count * bfd_coff_relsz (abfd);
+-#ifdef COFF_WITH_PE
++#ifdef COFF_WITH_PE_OR_COFF_WITH_EXTENDED_RELOC_COUNTER
+ /* Extra reloc to hold real count. */
+- if (obj_pe (abfd) && current->reloc_count >= 0xffff)
++ if ((obj_pe (abfd) || obj_go32 (abfd)) && current->reloc_count >= 0xffff)
+ reloc_base += bfd_coff_relsz (abfd);
+ #endif
+ }
+ else
+ current->rel_filepos = 0;
+@@ -4019,10 +4067,22 @@ coff_write_object_contents (bfd * abfd)
+ }
+ }
+ #endif
+ #endif
+
++#ifdef COFF_PAD_SECTION_HEADERS
++ if (abfd->flags & EXEC_P)
++ {
++ file_ptr cur_ptr = scn_base + abfd->section_count * bfd_coff_scnhsz(abfd);
++ long fill_size = (abfd->sections->filepos - cur_ptr);
++ bfd_byte *b = bfd_zmalloc(fill_size);
++ if (b)
++ bfd_bwrite ((PTR)b, fill_size, abfd);
++ free (b);
++ }
++#endif
++
+ /* OK, now set up the filehdr... */
+
+ /* Don't include the internal abs section in the section count */
+
+ /* We will NOT put a fucking timestamp in the header here. Every time you
+diff -aprNU5 binutils-2.29.1.orig/bfd/cofflink.c binutils-2.29.1/bfd/cofflink.c
+--- binutils-2.29.1.orig/bfd/cofflink.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/bfd/cofflink.c 2017-09-30 21:36:18 +0000
+@@ -679,11 +679,11 @@ _bfd_coff_final_link (bfd *abfd,
+ o->flags |= SEC_RELOC;
+ o->rel_filepos = rel_filepos;
+ rel_filepos += o->reloc_count * relsz;
+ /* In PE COFF, if there are at least 0xffff relocations an
+ extra relocation will be written out to encode the count. */
+- if (obj_pe (abfd) && o->reloc_count >= 0xffff)
++ if ((obj_pe (abfd) || obj_go32 (abfd)) && o->reloc_count >= 0xffff)
+ rel_filepos += relsz;
+ }
+
+ if (bfd_coff_long_section_names (abfd)
+ && strlen (o->name) > SCNNMLEN)
+@@ -1098,11 +1098,11 @@ _bfd_coff_final_link (bfd *abfd,
+ bfd_coff_swap_reloc_out (abfd, irel, erel);
+ }
+
+ if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0)
+ goto error_return;
+- if (obj_pe (abfd) && o->reloc_count >= 0xffff)
++ if ((obj_pe (abfd) || obj_go32 (abfd)) && o->reloc_count >= 0xffff)
+ {
+ /* In PE COFF, write the count of relocs as the first
+ reloc. The header overflow bit will be set
+ elsewhere. */
+ struct internal_reloc incount;
+diff -aprNU5 binutils-2.29.1.orig/bfd/coffswap.h binutils-2.29.1/bfd/coffswap.h
+--- binutils-2.29.1.orig/bfd/coffswap.h 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/bfd/coffswap.h 2017-09-30 21:36:18 +0000
+@@ -765,10 +765,23 @@ coff_swap_scnhdr_in (bfd * abfd, void *
+ scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr);
+ scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr);
+ scnhdr_int->s_flags = GET_SCNHDR_FLAGS (abfd, scnhdr_ext->s_flags);
+ scnhdr_int->s_nreloc = GET_SCNHDR_NRELOC (abfd, scnhdr_ext->s_nreloc);
+ scnhdr_int->s_nlnno = GET_SCNHDR_NLNNO (abfd, scnhdr_ext->s_nlnno);
++#if defined (COFF_GO32_EXE) || defined(COFF_GO32)
++ /* DJGPP follows the same strategy than PE COFF.
++ Iff the file is an executable then the higher 16 bits
++ of the line number have been stored in the relocation
++ counter field. */
++ if (coff_64k_relocation_enabled && abfd->flags & EXEC_P
++ && (strcmp(scnhdr_ext->s_name, ".text") == 0))
++ {
++ scnhdr_int->s_nlnno = (GET_SCNHDR_NRELOC(abfd, scnhdr_ext->s_nreloc) << 16)
++ + GET_SCNHDR_NLNNO(abfd, scnhdr_ext->s_nlnno);
++ scnhdr_int->s_nreloc = 0;
++ }
++#endif
+ #ifdef I960
+ scnhdr_int->s_align = GET_SCNHDR_ALIGN (abfd, scnhdr_ext->s_align);
+ #endif
+ #ifdef COFF_ADJUST_SCNHDR_IN_POST
+ COFF_ADJUST_SCNHDR_IN_POST (abfd, ext, in);
+@@ -796,10 +809,65 @@ coff_swap_scnhdr_out (bfd * abfd, void *
+ PUT_SCNHDR_FLAGS (abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
+ #if defined(M88)
+ H_PUT_32 (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
+ H_PUT_32 (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
+ #else
++#if defined (COFF_GO32_EXE) || defined(COFF_GO32)
++ if (coff_64k_relocation_enabled)
++ {
++ if (abfd->flags & EXEC_P
++ && (strcmp(scnhdr_int->s_name, ".text") == 0))
++ {
++ /* DJGPP follows the same strategy than PE COFF.
++ By inference from looking at MS output, the 32 bit field
++ which is the combination of the number_of_relocs and
++ number_of_linenos is used for the line number count in
++ executables. A 16-bit field won't do for cc1. The MS
++ document says that the number of relocs is zero for
++ executables, but the 17-th bit has been observed to be there.
++ Overflow is not an issue: a 4G-line program will overflow a
++ bunch of other fields long before this! */
++ PUT_SCNHDR_NLNNO (abfd, (scnhdr_int->s_nlnno & 0xffff), scnhdr_ext->s_nlnno);
++ PUT_SCNHDR_NRELOC (abfd, (scnhdr_int->s_nlnno >> 16), scnhdr_ext->s_nreloc);
++ }
++ else
++ {
++ /* DJGPP follows the same strategy than PE COFF. */
++ if (scnhdr_int->s_nlnno <= MAX_SCNHDR_NLNNO)
++ PUT_SCNHDR_NLNNO (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
++ else
++ {
++ char buf[sizeof (scnhdr_int->s_name) + 1];
++
++ memcpy (buf, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
++ buf[sizeof (scnhdr_int->s_name)] = '\0';
++ (*_bfd_error_handler)
++ (_("%s: %s: line number overflow: 0x%lx > 0xffff"),
++ bfd_get_filename (abfd),
++ buf, scnhdr_int->s_nlnno);
++ bfd_set_error (bfd_error_file_truncated);
++ PUT_SCNHDR_NLNNO (abfd, 0xffff, scnhdr_ext->s_nlnno);
++ ret = 0;
++ }
++
++ /* Although we could encode 0xffff relocs here, we do not, to be
++ consistent with other parts of bfd. Also it lets us warn, as
++ we should never see 0xffff here w/o having the overflow flag
++ set. */
++ if (scnhdr_int->s_nreloc < MAX_SCNHDR_NRELOC)
++ PUT_SCNHDR_NRELOC (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
++ else
++ {
++ /* DJGPP can deal with large #s of relocs, but not here. */
++ PUT_SCNHDR_NRELOC (abfd, 0xffff, scnhdr_ext->s_nreloc);
++ scnhdr_int->s_flags |= IMAGE_SCN_LNK_NRELOC_OVFL;
++ PUT_SCNHDR_FLAGS (abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
++ }
++ }
++ goto finalization;
++ }
++#endif
+ if (scnhdr_int->s_nlnno <= MAX_SCNHDR_NLNNO)
+ PUT_SCNHDR_NLNNO (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
+ else
+ {
+ char buf[sizeof (scnhdr_int->s_name) + 1];
+@@ -828,10 +896,13 @@ coff_swap_scnhdr_out (bfd * abfd, void *
+ PUT_SCNHDR_NRELOC (abfd, 0xffff, scnhdr_ext->s_nreloc);
+ ret = 0;
+ }
+ #endif
+
++#if defined (COFF_GO32_EXE) || defined(COFF_GO32)
++finalization:
++#endif
+ #ifdef I960
+ PUT_SCNHDR_ALIGN (abfd, scnhdr_int->s_align, scnhdr_ext->s_align);
+ #endif
+ #ifdef COFF_ADJUST_SCNHDR_OUT_POST
+ COFF_ADJUST_SCNHDR_OUT_POST (abfd, in, out);
+diff -aprNU5 binutils-2.29.1.orig/bfd/config.in binutils-2.29.1/bfd/config.in
+--- binutils-2.29.1.orig/bfd/config.in 2017-09-15 11:36:58 +0000
++++ binutils-2.29.1/bfd/config.in 2017-09-30 21:36:18 +0000
+@@ -396,5 +396,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.29.1.orig/bfd/init.c binutils-2.29.1/bfd/init.c
+--- binutils-2.29.1.orig/bfd/init.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/bfd/init.c 2017-09-30 21:36:18 +0000
+@@ -21,10 +21,16 @@
+
+ #include "sysdep.h"
+ #include "bfd.h"
+ #include "libbfd.h"
+
++/* This controls if the coff 64k support shall be disabled or not.
++ By default always enabled. */
++/* #if defined(__DJGPP__) || defined(COFF_GO32_EXE) || defined(COFF_GO32) */
++bfd_boolean coff_64k_relocation_enabled = TRUE;
++/* #endif */
++
+ /*
+ SECTION
+ Initialization
+
+ SUBSECTION
+@@ -49,6 +55,12 @@ DESCRIPTION
+ However, someday it may be needed, so keep it around. */
+
+ void
+ bfd_init (void)
+ {
++#if defined(__DJGPP__) || defined(COFF_GO32_EXE) || defined(COFF_GO32)
++ const char *disable_64k_reloc_support = getenv("DISABLE_64K_RELOC_SUPPORT");
++ coff_64k_relocation_enabled = !(disable_64k_reloc_support &&
++ (disable_64k_reloc_support[0] == 'y' || disable_64k_reloc_support[0] == 'Y') &&
++ disable_64k_reloc_support[1] == '\0') ? TRUE : FALSE;
++#endif
+ }
+diff -aprNU5 binutils-2.29.1.orig/bfd/libcoff-in.h binutils-2.29.1/bfd/libcoff-in.h
+--- binutils-2.29.1.orig/bfd/libcoff-in.h 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/bfd/libcoff-in.h 2017-09-30 21:36:18 +0000
+@@ -28,12 +28,13 @@ extern "C" {
+
+ /* Object file tdata; access macros. */
+
+ #define coff_data(bfd) ((bfd)->tdata.coff_obj_data)
+ #define obj_pe(bfd) (coff_data (bfd)->pe)
++#define obj_go32(bfd) (coff_data (bfd)->go32)
+ #define obj_symbols(bfd) (coff_data (bfd)->symbols)
+-#define obj_sym_filepos(bfd) (coff_data (bfd)->sym_filepos)
++#define obj_sym_filepos(bfd) (coff_data (bfd)->sym_filepos)
+ #define obj_relocbase(bfd) (coff_data (bfd)->relocbase)
+ #define obj_raw_syments(bfd) (coff_data (bfd)->raw_syments)
+ #define obj_raw_syment_count(bfd) (coff_data (bfd)->raw_syment_count)
+ #define obj_convert(bfd) (coff_data (bfd)->conversion_table)
+ #define obj_conv_table_size(bfd) (coff_data (bfd)->conv_table_size)
+@@ -109,10 +110,12 @@ typedef struct coff_tdata
+
+ /* Copy of some of the f_flags bits in the COFF filehdr structure,
+ used by ARM code. */
+ flagword flags;
+
++ /* Is this a GO32 coff file? */
++ int go32;
+ /* coff-stgo32 EXE stub header after BFD tdata has been allocated. Its data
+ is kept in internal_filehdr.go32stub beforehand. */
+ char *go32stub;
+ } coff_data_type;
+
+diff -aprNU5 binutils-2.29.1.orig/bfd/Makefile.in binutils-2.29.1/bfd/Makefile.in
+--- binutils-2.29.1.orig/bfd/Makefile.in 2017-09-15 11:36:54 +0000
++++ binutils-2.29.1/bfd/Makefile.in 2017-09-30 21:36:18 +0000
+@@ -2150,11 +2150,11 @@ host-aout.lo: Makefile
+ aout-params.h: gen-aout
+ ./gen-aout host > aout-params.h
+ gen-aout: $(srcdir)/gen-aout.c Makefile
+ $(CC) -o gen-aout $(CFLAGS) $(LFLAGS) $(srcdir)/gen-aout.c
+
+-$(BFD_H): stmp-bfd-h ; @true
++$(BFD_H): stmp-lcoff-h stmp-bfd-h ; @true
+
+ stmp-bfd-h: bfd-in3.h
+ rm -f bfd-tmp.h
+ cp bfd-in3.h bfd-tmp.h
+ $(SHELL) $(srcdir)/../move-if-change bfd-tmp.h $(BFD_H)
+@@ -2172,11 +2172,11 @@ headers:
+ $(SHELL) $(srcdir)/../move-if-change libcoff.h-new $(srcdir)/libcoff.h
+
+ # We only rebuild the header files automatically if we have been
+ # configured with --enable-maintainer-mode.
+
+-$(srcdir)/bfd-in2.h: @MAINT@ stmp-bin2-h ; @true
++$(srcdir)/bfd-in2.h: stmp-bin2-h ; @true
+ stmp-bin2-h: $(BFD_H_FILES) $(BFD64_H_FILES)
+ (cd $(bfddocdir); $(MAKE) $(FLAGS_TO_PASS) bfd.h)
+ cp $(bfddocdir)/bfd.h bfd-in2.h-new
+ $(SHELL) $(srcdir)/../move-if-change bfd-in2.h-new $(srcdir)/bfd-in2.h
+ touch stmp-bin2-h
+diff -aprNU5 binutils-2.29.1.orig/include/bfdlink.h binutils-2.29.1/include/bfdlink.h
+--- binutils-2.29.1.orig/include/bfdlink.h 2017-07-10 09:54:42 +0000
++++ binutils-2.29.1/include/bfdlink.h 2017-09-30 21:36:18 +0000
+@@ -291,11 +291,11 @@ struct bfd_elf_version_tree;
+ enum output_type
+ {
+ type_pde,
+ type_pie,
+ type_relocatable,
+- type_dll,
++ type_dll
+ };
+
+ #define bfd_link_pde(info) ((info)->type == type_pde)
+ #define bfd_link_dll(info) ((info)->type == type_dll)
+ #define bfd_link_relocatable(info) ((info)->type == type_relocatable)
+diff -aprNU5 binutils-2.29.1.orig/include/coff/internal.h binutils-2.29.1/include/coff/internal.h
+--- binutils-2.29.1.orig/include/coff/internal.h 2017-07-10 09:54:42 +0000
++++ binutils-2.29.1/include/coff/internal.h 2017-09-30 21:36:20 +0000
+@@ -165,11 +165,11 @@ typedef struct _CODEVIEW_INFO
+ {
+ unsigned long CVSignature;
+ char Signature[CV_INFO_SIGNATURE_LENGTH];
+ unsigned int SignatureLength;
+ unsigned long Age;
+- // char PdbFileName[];
++ /* char PdbFileName[]; */
+ } CODEVIEW_INFO;
+
+ /* Default image base for NT. */
+ #define NT_EXE_IMAGE_BASE 0x400000
+ #define NT_DLL_IMAGE_BASE 0x10000000
+diff -aprNU5 binutils-2.29.1.orig/libiberty/config.in binutils-2.29.1/libiberty/config.in
+--- binutils-2.29.1.orig/libiberty/config.in 2017-09-01 09:56:40 +0000
++++ binutils-2.29.1/libiberty/config.in 2017-09-30 21:36:20 +0000
+@@ -565,5 +565,39 @@
+ pointer, if such a type exists, and if the system does not define it. */
+ #undef uintptr_t
+
+ /* Define as `fork' if `vfork' does not work. */
+ #undef vfork
++#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.29.1.orig/libiberty/cp-demangle.c binutils-2.29.1/libiberty/cp-demangle.c
+--- binutils-2.29.1.orig/libiberty/cp-demangle.c 2017-09-01 09:56:40 +0000
++++ binutils-2.29.1/libiberty/cp-demangle.c 2017-09-30 21:36:20 +0000
+@@ -4605,11 +4605,11 @@ d_print_comp_inner (struct d_print_info
+ without needing to modify *dc. */
+ struct demangle_component *mod_inner = NULL;
+
+ /* Variable used to store the current templates while a previously
+ captured scope is used. */
+- struct d_print_template *saved_templates;
++ struct d_print_template *saved_templates = NULL;
+
+ /* Nonzero if templates have been stored in the above variable. */
+ int need_template_restore = 0;
+
+ if (dc == NULL)
+@@ -6188,11 +6188,11 @@ d_demangle_callback (const char *mangled
+ DCT_GLOBAL_CTORS,
+ DCT_GLOBAL_DTORS
+ }
+ type;
+ struct d_info di;
+- struct demangle_component *dc;
++ struct demangle_component *dc = NULL;
+ int status;
+
+ if (mangled[0] == '_' && mangled[1] == 'Z')
+ type = DCT_MANGLED;
+ else if (strncmp (mangled, "_GLOBAL_", 8) == 0
+diff -aprNU5 binutils-2.29.1.orig/libiberty/make-relative-prefix.c binutils-2.29.1/libiberty/make-relative-prefix.c
+--- binutils-2.29.1.orig/libiberty/make-relative-prefix.c 2017-09-01 09:56:40 +0000
++++ binutils-2.29.1/libiberty/make-relative-prefix.c 2017-09-30 21:36:20 +0000
+@@ -79,10 +79,11 @@ relative prefix can be found, return @co
+ #if defined (_WIN32) || defined (__MSDOS__) \
+ || defined (__DJGPP__) || defined (__OS2__)
+ # define HAVE_DOS_BASED_FILE_SYSTEM
+ # define HAVE_HOST_EXECUTABLE_SUFFIX
+ # define HOST_EXECUTABLE_SUFFIX ".exe"
++# define FILENAME_COMPARE strcasecmp
+ # ifndef DIR_SEPARATOR_2
+ # define DIR_SEPARATOR_2 '\\'
+ # endif
+ # define PATH_SEPARATOR ';'
+ #else
+@@ -94,10 +95,13 @@ relative prefix can be found, return @co
+ #else
+ # define IS_DIR_SEPARATOR(ch) \
+ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+ #endif
+
++#ifndef FILENAME_COMPARE
++# define FILENAME_COMPARE strcmp
++#endif
+ #define DIR_UP ".."
+
+ static char *save_string (const char *, int);
+ static char **split_directories (const char *, int *);
+ static void free_split_directories (char **);
+@@ -335,11 +339,11 @@ make_relative_prefix_1 (const char *prog
+ we can do. */
+ if (prog_num == bin_num)
+ {
+ for (i = 0; i < bin_num; i++)
+ {
+- if (strcmp (prog_dirs[i], bin_dirs[i]) != 0)
++ if (FILENAME_COMPARE (prog_dirs[i], bin_dirs[i]) != 0)
+ break;
+ }
+
+ if (prog_num <= 0 || i == bin_num)
+ goto bailout;
+@@ -351,11 +355,11 @@ make_relative_prefix_1 (const char *prog
+
+ /* Find how many directories are in common between bin_prefix & prefix. */
+ n = (prefix_num < bin_num) ? prefix_num : bin_num;
+ for (common = 0; common < n; common++)
+ {
+- if (strcmp (bin_dirs[common], prefix_dirs[common]) != 0)
++ if (FILENAME_COMPARE (bin_dirs[common], prefix_dirs[common]) != 0)
+ break;
+ }
+
+ /* If there are no common directories, there can be no relative prefix. */
+ if (common == 0)
+diff -aprNU5 binutils-2.29.1.orig/libiberty/make-temp-file.c binutils-2.29.1/libiberty/make-temp-file.c
+--- binutils-2.29.1.orig/libiberty/make-temp-file.c 2017-09-01 09:56:40 +0000
++++ binutils-2.29.1/libiberty/make-temp-file.c 2017-09-30 21:36:20 +0000
+@@ -52,16 +52,31 @@ extern int mkstemps (char *, int);
+ /* '/' works just fine on MS-DOS based systems. */
+ #ifndef DIR_SEPARATOR
+ #define DIR_SEPARATOR '/'
+ #endif
+
++#if defined (_WIN32) || defined (__MSDOS__) \
++ || defined (__DJGPP__) || defined (__OS2__)
++# define HAVE_DOS_BASED_FILE_SYSTEM
++# ifndef DIR_SEPARATOR_2
++# define DIR_SEPARATOR_2 '\\'
++# endif
++#endif
++
++#ifndef DIR_SEPARATOR_2
++# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
++#else
++# define IS_DIR_SEPARATOR(ch) \
++ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
++#endif
++
+ /* Name of temporary file.
+ mktemp requires 6 trailing X's. */
+ #define TEMP_FILE "ccXXXXXX"
+ #define TEMP_FILE_LEN (sizeof(TEMP_FILE) - 1)
+
+-#if !defined(_WIN32) || defined(__CYGWIN__)
++#if !defined(_WIN32) || defined(__CYGWIN__) || defined(__DJGPP__)
+
+ /* Subroutine of choose_tmpdir.
+ If BASE is non-NULL, return it.
+ Otherwise it checks if DIR is a usable directory.
+ If success, DIR is returned.
+@@ -104,11 +119,11 @@ files in.
+ const char *
+ choose_tmpdir (void)
+ {
+ if (!memoized_tmpdir)
+ {
+-#if !defined(_WIN32) || defined(__CYGWIN__)
++#if !defined(_WIN32) || defined(__CYGWIN__) || defined(__DJGPP__)
+ const char *base = 0;
+ char *tmpdir;
+ unsigned int len;
+
+ #ifdef VMS
+@@ -140,11 +155,12 @@ choose_tmpdir (void)
+ /* Append DIR_SEPARATOR to the directory we've chosen
+ and return it. */
+ len = strlen (base);
+ tmpdir = XNEWVEC (char, len + 2);
+ strcpy (tmpdir, base);
+- tmpdir[len] = DIR_SEPARATOR;
++ if (len > 0 && !IS_DIR_SEPARATOR(tmpdir[len - 1]))
++ tmpdir[len] = DIR_SEPARATOR;
+ tmpdir[len+1] = '\0';
+ memoized_tmpdir = tmpdir;
+ #else /* defined(_WIN32) && !defined(__CYGWIN__) */
+ DWORD len;
+
+diff -aprNU5 binutils-2.29.1.orig/libiberty/pex-common.c binutils-2.29.1/libiberty/pex-common.c
+--- binutils-2.29.1.orig/libiberty/pex-common.c 2017-09-01 09:56:40 +0000
++++ binutils-2.29.1/libiberty/pex-common.c 2017-09-30 21:36:20 +0000
+@@ -115,11 +115,11 @@ temp_file (struct pex_obj *obj, int flag
+
+ if (len >= 6
+ && strcmp (obj->tempbase + len - 6, "XXXXXX") == 0)
+ name = xstrdup (obj->tempbase);
+ else
+- name = concat (obj->tempbase, "XXXXXX", NULL);
++ name = concat (obj->tempbase, "XXXXXX", (char *)NULL);
+
+ out = mkstemps (name, 0);
+ if (out < 0)
+ {
+ free (name);
+@@ -136,11 +136,11 @@ temp_file (struct pex_obj *obj, int flag
+ else if ((flags & PEX_SUFFIX) != 0)
+ {
+ if (obj->tempbase == NULL)
+ name = make_temp_file (name);
+ else
+- name = concat (obj->tempbase, name, NULL);
++ name = concat (obj->tempbase, name, (char *)NULL);
+ }
+
+ return name;
+ }
+
+@@ -220,11 +220,11 @@ pex_run_in_environment (struct pex_obj *
+ {
+ if (outname == NULL)
+ out = STDOUT_FILE_NO;
+ else if ((flags & PEX_SUFFIX) != 0)
+ {
+- outname = concat (obj->tempbase, outname, NULL);
++ outname = concat (obj->tempbase, outname, (char *)NULL);
+ outname_allocated = 1;
+ }
+ obj->next_input = -1;
+ }
+ else if ((obj->flags & PEX_USE_PIPES) == 0)
+diff -aprNU5 binutils-2.29.1.orig/libiberty/stack-limit.c binutils-2.29.1/libiberty/stack-limit.c
+--- binutils-2.29.1.orig/libiberty/stack-limit.c 2017-09-01 09:56:40 +0000
++++ binutils-2.29.1/libiberty/stack-limit.c 2017-09-30 21:36:20 +0000
+@@ -49,11 +49,11 @@ stack_limit_increase (unsigned long pref
+ #if defined(HAVE_SETRLIMIT) && defined(HAVE_GETRLIMIT) \
+ && defined(RLIMIT_STACK) && defined(RLIM_INFINITY)
+ struct rlimit rlim;
+ if (getrlimit (RLIMIT_STACK, &rlim) == 0
+ && rlim.rlim_cur != RLIM_INFINITY
+- && rlim.rlim_cur < pref
++ && rlim.rlim_cur < (rlim_t) pref
+ && (rlim.rlim_max == RLIM_INFINITY || rlim.rlim_cur < rlim.rlim_max))
+ {
+ rlim.rlim_cur = pref;
+ if (rlim.rlim_max != RLIM_INFINITY && rlim.rlim_cur > rlim.rlim_max)
+ rlim.rlim_cur = rlim.rlim_max;
+
+
+
+
+2017-09-30 Juan Manuel Guerrero <juan.guerrero@gmx.de>
+
+ * bfd/bfd.c [__DJGPP__]: Rename _doprnt to __bfd_doprnt to avoid
+ collision with DJGPP's declaration of _doprnt from stdio.h.
+ [__DJGPP__]: New macro _bfd_doprnt defined either to __bfd_doprnt
+ or to _doprnt if not DJGPP.
+ Replace every _doprnt occurrence with _bfd_doprnt.
+
+
+
+
+
+
+diff -aprNU5 binutils-2.29.1.orig/bfd/bfd.c binutils-2.29.1/bfd/bfd.c
+--- binutils-2.29.1.orig/bfd/bfd.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/bfd/bfd.c 2017-09-30 22:19:04 +0000
+@@ -622,11 +622,15 @@ static const char *_bfd_error_program_na
+ TYPE value = va_arg (ap, TYPE); \
+ result = fprintf (stream, specifier, value); \
+ } while (0)
+
+ static int
++#ifdef __DJGPP__
++__bfd_doprnt (FILE *stream, const char *format, va_list ap)
++#else
+ _doprnt (FILE *stream, const char *format, va_list ap)
++#endif
+ {
+ const char *ptr = format;
+ char specifier[128];
+ int total_printed = 0;
+
+@@ -848,10 +852,20 @@ _doprnt (FILE *stream, const char *forma
+ total_printed += result;
+ }
+
+ return total_printed;
+ }
++/*
++ * _doprnt definition collides with DJGPP's
++ * _doprnt prototype provided by stdio.h
++ */
++#ifdef __DJGPP__
++# define _bfd_doprnt __bfd_doprnt
++#else
++# define _bfd_doprnt _doprnt
++#endif
++
+
+ /* This is the default routine to handle BFD error messages.
+ Like fprintf (stderr, ...), but also handles some extra format specifiers.
+
+ %A section name from section. For group components, print group name too.
+@@ -866,11 +880,11 @@ error_handler_internal (const char *fmt,
+ if (_bfd_error_program_name != NULL)
+ fprintf (stderr, "%s: ", _bfd_error_program_name);
+ else
+ fprintf (stderr, "BFD: ");
+
+- _doprnt (stderr, fmt, ap);
++ _bfd_doprnt (stderr, fmt, ap);
+
+ /* On AIX, putc is implemented as a macro that triggers a -Wunused-value
+ warning, so use the fputc function to avoid it. */
+ fputc ('\n', stderr);
+ fflush (stderr);
diff --git a/binutils-djgpp.patch b/binutils-djgpp.patch
new file mode 100644
index 000000000000..8c2ec1c39dea
--- /dev/null
+++ b/binutils-djgpp.patch
@@ -0,0 +1,1329 @@
+# DJGPP specific changes to binutils for the DJGPP port of binutils
+# excluding the changes specific to libbfd and libiberty.
+
+
+2017-09-30 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/nlmconv.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.
+
+
+
+
+
+
+
+diff -aprNU5 binutils-2.29.1.orig/binutils/ar.c binutils-2.29.1/binutils/ar.c
+--- binutils-2.29.1.orig/binutils/ar.c 2017-07-17 09:52:56 +0000
++++ binutils-2.29.1/binutils/ar.c 2017-09-30 22:49:40 +0000
+@@ -687,11 +687,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.29.1.orig/binutils/coffdump.c binutils-2.29.1/binutils/coffdump.c
+--- binutils-2.29.1.orig/binutils/coffdump.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/binutils/coffdump.c 2017-09-30 22:49:40 +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.29.1.orig/binutils/config.in binutils-2.29.1/binutils/config.in
+--- binutils-2.29.1.orig/binutils/config.in 2017-09-15 11:37:46 +0000
++++ binutils-2.29.1/binutils/config.in 2017-09-30 22:49:40 +0000
+@@ -283,5 +283,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.29.1.orig/binutils/cxxfilt.c binutils-2.29.1/binutils/cxxfilt.c
+--- binutils-2.29.1.orig/binutils/cxxfilt.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/binutils/cxxfilt.c 2017-09-30 22:49:40 +0000
+@@ -172,11 +172,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.29.1.orig/binutils/nlmconv.c binutils-2.29.1/binutils/nlmconv.c
+--- binutils-2.29.1.orig/binutils/nlmconv.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/binutils/nlmconv.c 2017-09-30 22:49:40 +0000
+@@ -207,11 +207,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);
+
+ expandargv (&argc, &argv);
+
+diff -aprNU5 binutils-2.29.1.orig/binutils/nm.c binutils-2.29.1/binutils/nm.c
+--- binutils-2.29.1.orig/binutils/nm.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/binutils/nm.c 2017-09-30 22:49:40 +0000
+@@ -1636,11 +1636,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.29.1.orig/binutils/objcopy.c binutils-2.29.1/binutils/objcopy.c
+--- binutils-2.29.1.orig/binutils/objcopy.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/binutils/objcopy.c 2017-09-30 22:49:40 +0000
+@@ -5353,11 +5353,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.29.1.orig/binutils/objdump.c binutils-2.29.1/binutils/objdump.c
+--- binutils-2.29.1.orig/binutils/objdump.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/binutils/objdump.c 2017-09-30 22:49:40 +0000
+@@ -3741,11 +3741,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.29.1.orig/binutils/readelf.c binutils-2.29.1/binutils/readelf.c
+--- binutils-2.29.1.orig/binutils/readelf.c 2017-09-05 14:03:14 +0000
++++ binutils-2.29.1/binutils/readelf.c 2017-09-30 22:49:40 +0000
+@@ -537,11 +537,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.29.1.orig/binutils/size.c binutils-2.29.1/binutils/size.c
+--- binutils-2.29.1.orig/binutils/size.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/binutils/size.c 2017-09-30 22:49:42 +0000
+@@ -129,11 +129,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.29.1.orig/binutils/srconv.c binutils-2.29.1/binutils/srconv.c
+--- binutils-2.29.1.orig/binutils/srconv.c 2017-07-12 08:57:48 +0000
++++ binutils-2.29.1/binutils/srconv.c 2017-09-30 22:49:42 +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.29.1.orig/binutils/strings.c binutils-2.29.1/binutils/strings.c
+--- binutils-2.29.1.orig/binutils/strings.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/binutils/strings.c 2017-09-30 22:49:42 +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.29.1.orig/binutils/sysdump.c binutils-2.29.1/binutils/sysdump.c
+--- binutils-2.29.1.orig/binutils/sysdump.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/binutils/sysdump.c 2017-09-30 22:49:42 +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.29.1.orig/config.sub binutils-2.29.1/config.sub
+--- binutils-2.29.1.orig/config.sub 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/config.sub 2017-09-30 22:49:42 +0000
+@@ -634,11 +634,19 @@ case $basic_machine in
+ dicos)
+ 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
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+diff -aprNU5 binutils-2.29.1.orig/djgpp/build.sh binutils-2.29.1/djgpp/build.sh
+--- binutils-2.29.1.orig/djgpp/build.sh 1970-01-01 00:00:00 +0000
++++ binutils-2.29.1/djgpp/build.sh 2017-09-30 22:49:42 +0000
+@@ -0,0 +1,318 @@
++# 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_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 -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
++ }
++}
++
++# 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/
++
++# 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]/
++}
++
++# 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_&/
++}
++EOF
++
++
++for file in ../ltmain.sh ../configure ../bfd/configure ../binutils/configure ../gas/configure ../gprof/configure ../ld/configure ../opcodes/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; 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 --disable-dependency-tracking ${NLS_SUPPORT} \
++ --with-mpc='/dev/env/DJDIR' --with-mpfr='/dev/env/DJDIR' --with-gmp='/dev/env/DJDIR' \
++ --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.29.1.orig/gas/as.c binutils-2.29.1/gas/as.c
+--- binutils-2.29.1.orig/gas/as.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/gas/as.c 2017-09-30 22:49:42 +0000
+@@ -1205,11 +1205,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.29.1.orig/gas/config/obj-coff-seh.c binutils-2.29.1/gas/config/obj-coff-seh.c
+--- binutils-2.29.1.orig/gas/config/obj-coff-seh.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/gas/config/obj-coff-seh.c 2017-09-30 22:49:42 +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.29.1.orig/gas/config.in binutils-2.29.1/gas/config.in
+--- binutils-2.29.1.orig/gas/config.in 2017-09-15 11:37:28 +0000
++++ binutils-2.29.1/gas/config.in 2017-09-30 22:49:42 +0000
+@@ -396,5 +396,42 @@
+ /* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+ #ifndef __cplusplus
+ #undef inline
+ #endif
++
++#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.29.1.orig/gas/dw2gencfi.c binutils-2.29.1/gas/dw2gencfi.c
+--- binutils-2.29.1.orig/gas/dw2gencfi.c 2017-07-10 09:54:40 +0000
++++ binutils-2.29.1/gas/dw2gencfi.c 2017-09-30 22:49:42 +0000
+@@ -255,11 +255,11 @@ get_debugseg_name (segT seg, const char
+ 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.29.1.orig/gold/config.in binutils-2.29.1/gold/config.in
+--- binutils-2.29.1.orig/gold/config.in 2017-09-15 11:38:28 +0000
++++ binutils-2.29.1/gold/config.in 2017-09-30 22:49:42 +0000
+@@ -279,5 +279,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.29.1.orig/gprof/gconfig.in binutils-2.29.1/gprof/gconfig.in
+--- binutils-2.29.1.orig/gprof/gconfig.in 2017-07-10 09:54:42 +0000
++++ binutils-2.29.1/gprof/gconfig.in 2017-09-30 22:49:42 +0000
+@@ -112,5 +112,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.29.1.orig/gprof/gprof.c binutils-2.29.1/gprof/gprof.c
+--- binutils-2.29.1.orig/gprof/gprof.c 2017-07-10 09:54:42 +0000
++++ binutils-2.29.1/gprof/gprof.c 2017-09-30 22:49:42 +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.29.1.orig/ld/config.in binutils-2.29.1/ld/config.in
+--- binutils-2.29.1.orig/ld/config.in 2017-09-15 11:38:10 +0000
++++ binutils-2.29.1/ld/config.in 2017-09-30 22:49:42 +0000
+@@ -237,5 +237,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.29.1.orig/ld/configure binutils-2.29.1/ld/configure
+--- binutils-2.29.1.orig/ld/configure 2017-09-15 11:38:08 +0000
++++ binutils-2.29.1/ld/configure 2017-09-30 22:49:42 +0000
+@@ -17282,10 +17282,19 @@ fi
+
+
+
+
+
++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.29.1.orig/ld/ldfile.c binutils-2.29.1/ld/ldfile.c
+--- binutils-2.29.1.orig/ld/ldfile.c 2017-07-10 09:54:42 +0000
++++ binutils-2.29.1/ld/ldfile.c 2017-09-30 22:49:42 +0000
+@@ -62,10 +62,128 @@ 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 an 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);
++ char line[128];
++ 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)
+@@ -122,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
+@@ -369,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.29.1.orig/ld/ldmain.c binutils-2.29.1/ld/ldmain.c
+--- binutils-2.29.1.orig/ld/ldmain.c 2017-07-10 09:54:42 +0000
++++ binutils-2.29.1/ld/ldmain.c 2017-09-30 22:49:42 +0000
+@@ -209,11 +209,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);
+@@ -976,10 +976,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.29.1.orig/ld/libnames.tab binutils-2.29.1/ld/libnames.tab
+--- binutils-2.29.1.orig/ld/libnames.tab 1970-01-01 00:00:00 +0000
++++ binutils-2.29.1/ld/libnames.tab 2017-09-30 22:49:42 +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.29.1.orig/ld/scripttempl/i386go32.sc binutils-2.29.1/ld/scripttempl/i386go32.sc
+--- binutils-2.29.1.orig/ld/scripttempl/i386go32.sc 2017-07-10 09:54:42 +0000
++++ binutils-2.29.1/ld/scripttempl/i386go32.sc 2017-09-30 22:49:42 +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.29.1.orig/opcodes/config.in binutils-2.29.1/opcodes/config.in
+--- binutils-2.29.1.orig/opcodes/config.in 2017-09-15 11:37:22 +0000
++++ binutils-2.29.1/opcodes/config.in 2017-09-30 22:49:42 +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
diff --git a/lto-discard.patch b/lto-discard.patch
index 931aa20e95ee..2194e39a050b 100644
--- a/lto-discard.patch
+++ b/lto-discard.patch
@@ -1,17 +1,12 @@
---- binutils-2.29/ld/scripttempl/i386go32.sc
-+++ binutils-2.29/ld/scripttempl/i386go32.sc
-@@ -19,6 +19,7 @@
- *(SORT(.dtors.*))
- *(.dtor) *(.dtors)
- }'
-+DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
-
- cat <<EOF
- /* Copyright (C) 2014-2017 Free Software Foundation, Inc.
-@@ -82,5 +83,6 @@
- . $srcdir/scripttempl/DWARF.sc
-
- cat <<EOF
-+ ${RELOCATING+${DISCARDED}}
- }
- EOF
+diff -ur src/binutils-2.29.1.orig/ld/scripttempl/i386go32.sc src/binutils-2.29.1/ld/scripttempl/i386go32.sc
+--- src/binutils-2.29.1.orig/ld/scripttempl/i386go32.sc 2017-12-28 16:44:53.887247994 +0200
++++ src/binutils-2.29.1/ld/scripttempl/i386go32.sc 2017-12-28 16:54:10.917217558 +0200
+@@ -84,7 +84,7 @@
+ ${RELOCATING+ . = ALIGN(${SEGMENT_SIZE});}
+ }
+ /* Discard LTO sections. */
+- /DISCARD/ : { *(gnu.lto_*) }
++ /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(gnu.lto_*) }
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
diff --git a/xtors.patch b/xtors.patch
deleted file mode 100644
index 87bab7371244..000000000000
--- a/xtors.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- binutils-2.29/ld/scripttempl/i386go32.sc
-+++ binutils-2.29/ld/scripttempl/i386go32.sc
-@@ -13,11 +13,11 @@
- # conditional expansion.
- CTOR='.ctor : {
- *(SORT(.ctors.*))
-- *(.ctor)
-+ *(.ctor) *(.ctors)
- }'
- DTOR='.dtor : {
- *(SORT(.dtors.*))
-- *(.dtor)
-+ *(.dtor) *(.dtors)
- }'
-
- cat <<EOF
-@@ -46,11 +46,11 @@
- .data ${RELOCATING+ ${DATA_ALIGNMENT}} : {
- ${RELOCATING+djgpp_first_ctor = . ;
- *(SORT(.ctors.*))
-- *(.ctor)
-+ *(.ctor) *(.ctors)
- djgpp_last_ctor = . ;}
- ${RELOCATING+djgpp_first_dtor = . ;
- *(SORT(.dtors.*))
-- *(.dtor)
-+ *(.dtor) *(.dtors)
- djgpp_last_dtor = . ;}
- *(.data)
- ${RELOCATING+*(.data.*)}