Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru --new-file a/bfd/midipix.h b/bfd/midipix.h
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/bfd/midipix.h	1969-12-31 19:00:00.000000000 -0500
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/bfd/midipix.h	2015-03-11 17:23:18.492453732 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -0,0 +1,10 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#ifndef MIDIPIX_H
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#define MIDIPIX_H
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#define PE_TARGET_MIDIPIX
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#define PE_DSO_SUFFIX		".so"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#define PE_DSOLIB_SUFFIX	".dso.a"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#define PE_IMPLIB_SUFFIX	".lib.a"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#endif
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/ld/configure	2014-07-03 01:37:48.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/ld/configure	2015-03-11 20:01:08.888756786 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -19773,3 +19773,23 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 fi
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+sed -i -e 's/@pe_executable_name@/'$PE_EXECUTABLE_NAME'/g' Makefile
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+sed -i -e 's/@pe_crt_section@/'$PE_CRT_SECTION'/g' Makefile
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+sed -i -e 's/@pe_cygwin_fork_support@/'$PE_CYGWIN_FORK_SUPPORT'/g' Makefile
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#PE custom import library support
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+if [ -f peimplib.h ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	echo 'build directory is not clean (peimplib.h already exists)'
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	exit 2
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+fi
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+touch peimplib.h || exit 2
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+case $target_os in
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	*midipix*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		cat >> peimplib.h << EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+/* midipix supersystem support */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#include "midipix.h"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+esac
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru --new-file a/ld/emultempl/pe.em b/ld/emultempl/pe.em
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/ld/emultempl/pe.em	2014-07-03 01:37:48.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/ld/emultempl/pe.em	2015-11-25 09:02:09.729144140 -0500
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -35,6 +35,18 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
    only determine if the subsystem is console or windows in order to select
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
    the correct entry point by default. */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#include "peimplib.h"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#ifndef PE_IMPLIB_SUFFIX
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#define PE_IMPLIB_SUFFIX	".dll.a"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#endif
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#ifndef PE_DSO_SUFFIX
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#define PE_DSO_SUFFIX		".dll"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#endif
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #define TARGET_IS_${EMULATION_NAME}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 /* Do this before including bfd.h, so we prototype the right functions.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -132,7 +144,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 static char * thumb_entry_symbol = NULL;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 static lang_assignment_statement_type *image_base_statement = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 static unsigned short pe_dll_characteristics = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-static bfd_boolean insert_timestamp = TRUE;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+static bfd_boolean insert_timestamp = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 static const char *emit_build_id;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #ifdef DLL_SUPPORT
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -471,8 +483,8 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
                                        specifically set with --image-base\n"));
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   fprintf (file, _("  --disable-auto-image-base          Do not auto-choose image base. (default)\n"));
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   fprintf (file, _("  --dll-search-prefix=<string>       When linking dynamically to a dll without\n\
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-                                       an importlib, use <string><basename>.dll\n\
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-                                       in preference to lib<basename>.dll \n"));
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+                                       an importlib, use <string><basename>"PE_DSO_SUFFIX"\n\
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+                                       in preference to lib<basename>"PE_DSO_SUFFIX" \n"));
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   fprintf (file, _("  --enable-auto-import               Do sophisticated linking of _sym to\n\
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
                                        __imp_sym for DATA references\n"));
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   fprintf (file, _("  --disable-auto-import              Do not auto-import DATA items from DLLs\n"));
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -1698,7 +1710,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		       extension, and use that for the remainder of the
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		       comparisons.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		    pnt = strrchr (is3->the_bfd->filename, '.');
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-		    if (pnt != NULL && filename_cmp (pnt, ".dll") == 0)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		    if (pnt != NULL && filename_cmp (pnt, PE_DSO_SUFFIX) == 0)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		      break;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		  }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -1733,7 +1745,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	       then leave the filename alone.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	    pnt = strrchr (is->the_bfd->filename, '.');
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-	    if (is_ms_arch && (filename_cmp (pnt, ".dll") == 0))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	    if (is_ms_arch && (filename_cmp (pnt, PE_DSO_SUFFIX) == 0))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	      {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		int idata2 = 0, reloc_count=0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		asection *sec;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -2298,10 +2310,14 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   libname_fmt [] =
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      /* optionally support ldso-specific import libraries */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      #ifdef PE_DSOLIB_SUFFIX
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      { "lib%s"PE_DSOLIB_SUFFIX, FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      #endif
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* Preferred explicit import library for dll's.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      { "lib%s.dll.a", FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      { "lib%s"PE_IMPLIB_SUFFIX, FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* Alternate explicit import library for dll's.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      { "%s.dll.a", FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      { "%s"PE_IMPLIB_SUFFIX, FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* "libfoo.a" could be either an import lib or a static lib.
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
           For backwards compatibility, libfoo.a needs to precede
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
           libfoo.dll and foo.dll in the search.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -2310,10 +2326,10 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       { "%s.lib", FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #ifdef DLL_SUPPORT
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* Try "<prefix>foo.dll" (preferred dll name, if specified).  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      {	"%s%s.dll", TRUE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      {	"%s%s"PE_DSO_SUFFIX, TRUE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #endif
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* Try "libfoo.dll" (default preferred dll name).  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      {	"lib%s.dll", FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      {	"lib%s"PE_DSO_SUFFIX, FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* Finally try 'native' dll name "foo.dll".  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       {  "%s.dll", FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* Note: If adding more formats to this table, make sure to check to
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru --new-file a/ld/emultempl/pep.em b/ld/emultempl/pep.em
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/ld/emultempl/pep.em	2014-07-03 01:37:48.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/ld/emultempl/pep.em	2015-11-25 09:02:21.153143987 -0500
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -42,6 +42,18 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 /* For WINDOWS_XP64 and higher */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 /* Based on pe.em, but modified for 64 bit support.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#include "peimplib.h"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#ifndef PE_IMPLIB_SUFFIX
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#define PE_IMPLIB_SUFFIX	".dll.a"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#endif
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#ifndef PE_DSO_SUFFIX
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#define PE_DSO_SUFFIX		".dll"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#endif
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #define TARGET_IS_${EMULATION_NAME}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #define COFF_IMAGE_WITH_PE
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -147,7 +159,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 static int support_old_code = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 static lang_assignment_statement_type *image_base_statement = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 static unsigned short pe_dll_characteristics = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-static bfd_boolean insert_timestamp = TRUE;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+static bfd_boolean insert_timestamp = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 static const char *emit_build_id;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #ifdef DLL_SUPPORT
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -434,8 +446,8 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
                                        unless user specifies one\n"));
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   fprintf (file, _("  --disable-auto-image-base          Do not auto-choose image base. (default)\n"));
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   fprintf (file, _("  --dll-search-prefix=<string>       When linking dynamically to a dll without\n\
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-                                       an importlib, use <string><basename>.dll\n\
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-                                       in preference to lib<basename>.dll \n"));
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+                                       an importlib, use <string><basename>"PE_DSO_SUFFIX"\n\
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+                                       in preference to lib<basename>"PE_DSO_SUFFIX" \n"));
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   fprintf (file, _("  --enable-auto-import               Do sophisticated linking of _sym to\n\
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
                                        __imp_sym for DATA references\n"));
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   fprintf (file, _("  --disable-auto-import              Do not auto-import DATA items from DLLs\n"));
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -1635,7 +1647,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		       extension, and use that for the remainder of the
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		       comparisons.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		    pnt = strrchr (is3->the_bfd->filename, '.');
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-		    if (pnt != NULL && filename_cmp (pnt, ".dll") == 0)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		    if (pnt != NULL && filename_cmp (pnt, PE_DSO_SUFFIX) == 0)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		      break;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		  }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -1670,7 +1682,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	       then leave the filename alone.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	    pnt = strrchr (is->the_bfd->filename, '.');
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-	    if (is_ms_arch && (filename_cmp (pnt, ".dll") == 0))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	    if (is_ms_arch && (filename_cmp (pnt, PE_DSO_SUFFIX) == 0))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	      {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		int idata2 = 0, reloc_count=0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		asection *sec;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -2062,10 +2074,14 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   libname_fmt [] =
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      /* optionally support ldso-specific import libraries */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      #ifdef PE_DSOLIB_SUFFIX
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      { "lib%s"PE_DSOLIB_SUFFIX, FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      #endif
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* Preferred explicit import library for dll's.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      { "lib%s.dll.a", FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      { "lib%s"PE_IMPLIB_SUFFIX, FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* Alternate explicit import library for dll's.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      { "%s.dll.a", FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      { "%s"PE_IMPLIB_SUFFIX, FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* "libfoo.a" could be either an import lib or a static lib.
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
           For backwards compatibility, libfoo.a needs to precede
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
           libfoo.dll and foo.dll in the search.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -2074,10 +2090,10 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       { "%s.lib", FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #ifdef DLL_SUPPORT
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* Try "<prefix>foo.dll" (preferred dll name, if specified).  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      {	"%s%s.dll", TRUE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      {	"%s%s"PE_DSO_SUFFIX, TRUE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #endif
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* Try "libfoo.dll" (default preferred dll name).  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      {	"lib%s.dll", FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      {	"lib%s"PE_DSO_SUFFIX, FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* Finally try 'native' dll name "foo.dll".  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       {  "%s.dll", FALSE },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* Note: If adding more formats to this table, make sure to check to
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru --new-file a/ld/configure.tgt b/ld/configure.tgt
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/ld/configure.tgt	2014-07-03 01:37:48.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/ld/configure.tgt	2015-03-11 20:09:20.564772519 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -319,6 +319,11 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 			test "$targ" != "$host" && LIB_PATH='${tooldir}/lib/w32api' ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 i[3-7]86-*-mingw32*)	targ_emul=i386pe ;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 			targ_extra_ofiles="deffilep.o pe-dll.o" ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+i[3-7]86-*-midipix*)	targ_emul=i386pe ;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			targ_extra_ofiles="deffilep.o pe-dll.o" ;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			PE_EXECUTABLE_NAME=a.out ;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			PE_CRT_SECTION=no ;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			PE_CYGWIN_FORK_SUPPORT=no ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 x86_64-*-pe | x86_64-*-pep) targ_emul=i386pep ;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 			targ_extra_emuls=i386pe ;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 			targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o" ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -329,7 +333,13 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 x86_64-*-mingw*)	targ_emul=i386pep ;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 			targ_extra_emuls=i386pe
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 			targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o" ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-i[3-7]86-*-interix*)	targ_emul=i386pe_posix;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+x86_64-*-midipix*)	targ_emul=i386pep ;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			targ_extra_emuls=i386pe ;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o" ;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			PE_EXECUTABLE_NAME=a.out ;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			PE_CRT_SECTION=no ;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			PE_CYGWIN_FORK_SUPPORT=no ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+i[3-7]86-*-interix*)	targ_emul=i386pe_posix ;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
  			targ_extra_ofiles="deffilep.o pe-dll.o" ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 i[3-7]86-*-beospe*)	targ_emul=i386beos ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 i[3-7]86-*-beos*)	targ_emul=elf_i386_be ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru --new-file a/ld/Makefile.in b/ld/Makefile.in
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/ld/Makefile.in	2014-07-03 01:37:48.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/ld/Makefile.in	2015-03-11 20:09:38.972773108 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -54,6 +54,9 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 host_triplet = @host@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 target_triplet = @target@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 bin_PROGRAMS = ld-new$(EXEEXT)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+PE_EXECUTABLE_NAME = @pe_executable_name@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+PE_CRT_SECTION = @pe_crt_section@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+PE_CYGWIN_FORK_SUPPORT = @pe_cygwin_fork_support@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 # Automake 1.9 will only build info files in the objdir if they are
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 # mentioned in DISTCLEANFILES.  It doesn't have to be unconditional,
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -831,7 +833,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 POTFILES = $(CFILES) $(HFILES) $(EMULATION_FILES)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 # These all start with e so 'make clean' can find them.
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-GENSCRIPTS = LIB_PATH='${LIB_PATH}' $(SHELL) $(srcdir)/genscripts.sh "${srcdir}" "${libdir}" "${prefix}" "${exec_prefix}" @host@ @target@ @target_alias@ "@EMULATION_LIBPATH@" "@NATIVE_LIB_DIRS@" @use_sysroot@ @enable_initfini_array@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+GENSCRIPTS = EXECUTABLE_NAME='${PE_EXECUTABLE_NAME}' PE_CRT_SECTION='${PE_CRT_SECTION}' PE_CYGWIN_FORK_SUPPORT='${PE_CYGWIN_FORK_SUPPORT}' LIB_PATH='${LIB_PATH}' $(SHELL) $(srcdir)/genscripts.sh "${srcdir}" "${libdir}" "${prefix}" "${exec_prefix}" @host@ @target@ @target_alias@ "@EMULATION_LIBPATH@" "@NATIVE_LIB_DIRS@" @use_sysroot@ @enable_initfini_array@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 GEN_DEPENDS = $(srcdir)/genscripts.sh stringify.sed
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 ELF_DEPS = $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/elf-generic.em $(srcdir)/scripttempl/DWARF.sc
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 ELF_GEN_DEPS = $(srcdir)/emultempl/generic.em $(srcdir)/emultempl/elf-generic.em $(srcdir)/emultempl/genelf.em $(srcdir)/scripttempl/DWARF.sc
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru --new-file a/ld/scripttempl/pep.sc b/ld/scripttempl/pep.sc
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/ld/scripttempl/pep.sc	2014-07-03 01:37:48.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/ld/scripttempl/pep.sc	2015-03-11 20:10:05.324773952 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -92,12 +92,17 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${RELOCATING+ *(.gcc_except_table)}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+if [ x"$PE_CYGWIN_FORK_SUPPORT" != xno ]; then cat << EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   /* The Cygwin32 library uses a section to avoid copying certain data
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
      on fork.  This used to be named ".data$nocopy".  The linker used
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
      to include this between __data_start__ and __data_end__, but that
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
      breaks building the cygwin32 dll.  Instead, we name the section
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
      ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+fi
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+cat << EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   .data ${RELOCATING+BLOCK(__section_alignment__)} :
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${RELOCATING+__data_start__ = . ;}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -106,7 +111,12 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${R_DATA}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     *(.jcr)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${RELOCATING+__data_end__ = . ;}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+if [ x"$PE_CYGWIN_FORK_SUPPORT" != xno ]; then cat << EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${RELOCATING+*(.data_cygwin_nocopy)}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+fi
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+cat << EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -170,6 +180,8 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${RELOCATING+__IAT_end__ = .;}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${R_IDATA67}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+if [ x"$PE_CRT_SECTION" != xno ]; then cat << EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   { 					
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${RELOCATING+___crt_xc_start__ = . ;}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -188,6 +200,9 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${R_CRT_XT}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${RELOCATING+___crt_xt_end__ = . ;}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+fi
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+cat << EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
      at the end of the .tls section.  This is important because _tls_start MUST
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru --new-file a/ld/scripttempl/pe.sc b/ld/scripttempl/pe.sc
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/ld/scripttempl/pe.sc	2014-07-03 01:37:48.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/ld/scripttempl/pe.sc	2015-03-11 20:10:10.036774102 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -92,12 +92,17 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${RELOCATING+ *(.gcc_except_table)}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+if [ x"$PE_CYGWIN_FORK_SUPPORT" != xno ]; then cat << EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   /* The Cygwin32 library uses a section to avoid copying certain data
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
      on fork.  This used to be named ".data$nocopy".  The linker used
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
      to include this between __data_start__ and __data_end__, but that
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
      breaks building the cygwin32 dll.  Instead, we name the section
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
      ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+fi
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+cat << EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   .data ${RELOCATING+BLOCK(__section_alignment__)} :
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${RELOCATING+__data_start__ = . ;}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -106,7 +111,12 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${R_DATA}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     *(.jcr)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${RELOCATING+__data_end__ = . ;}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+if [ x"$PE_CYGWIN_FORK_SUPPORT" != xno ]; then cat << EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${RELOCATING+*(.data_cygwin_nocopy)}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+fi
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+cat << EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -165,6 +175,8 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${RELOCATING+__IAT_end__ = .;}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${R_IDATA67}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+if [ x"$PE_CRT_SECTION" != xno ]; then cat << EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   { 					
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${RELOCATING+___crt_xc_start__ = . ;}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -183,6 +195,9 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${R_CRT_XT}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ${RELOCATING+___crt_xt_end__ = . ;}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+fi
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+cat << EOF
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
      at the end of section.  This is important because _tls_start MUST
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru --new-file a/binutils/winduni.c b/binutils/winduni.c
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/binutils/winduni.c	2014-07-03 01:37:23.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/binutils/winduni.c	2015-02-14 11:18:32.987163288 -0500
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -57,7 +57,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 /* Codepages mapped.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 static local_iconv_map codepages[] =
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-  { 0, "MS-ANSI" },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  { 0, "cp1252" },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   { 1, "WINDOWS-1252" },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   { 437, "MS-ANSI" },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   { 737, "MS-GREEK" },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru a/ld/pe-dll.c b/ld/pe-dll.c
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/ld/pe-dll.c	2014-07-03 01:37:48.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/ld/pe-dll.c	2015-06-13 20:08:00.160401506 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -40,6 +40,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #include "coff/internal.h"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #include "../bfd/libcoff.h"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #include "deffile.h"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+#include "peimplib.h"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #ifdef pe_use_x86_64
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -234,7 +235,11 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   { STRING_COMMA_LEN ("impure_ptr") },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   { STRING_COMMA_LEN ("_impure_ptr") },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   { STRING_COMMA_LEN ("_fmode") },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  #ifdef PE_TARGET_MIDIPIX
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  /* (default) excluded symbols are defined by the caller (specs, etc.) */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  #else
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   { STRING_COMMA_LEN ("environ") },
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  #endif
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   { NULL, 0 }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 };
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -644,10 +649,13 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   int i, j;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   struct bfd_link_hash_entry *blhe;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  struct bfd_link_hash_entry *blhew;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   bfd *b;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   struct bfd_section *s;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   def_file_export *e = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   bfd_boolean resort_needed;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  char *weaksym;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  char *objsym;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   if (!pe_def_file)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     pe_def_file = def_file_empty ();
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -737,6 +745,16 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		    if (is_import (sn))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 			  continue;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		    if (!strncmp (sn, ".weak.", 6) && strchr (sn + 6, '.'))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		      {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		        objsym = strdup (sn);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		        weaksym = strdup (sn + 6);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		        *(strchr (weaksym, '.')) = '\0';
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		        sn = weaksym;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		      }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		    else
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		      weaksym = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		    name = xmalloc (strlen ("__imp_") + strlen (sn) + 1);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		    sprintf (name, "%s%s", "__imp_", sn);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -745,7 +763,8 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		    free (name);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		    if (blhe && blhe->type == bfd_link_hash_defined)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-		      continue;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		      if (strncmp (blhe->u.def.section->name, ".got$", 5))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			continue;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		  }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		  if (pe_details->underscored && *sn == '_')
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -761,7 +780,20 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		      /* Fill data flag properly, from dlltool.c.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		      if (!is_dup)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		        p->flag_data = !(symbols[j]->flags & BSF_FUNCTION);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		      if (weaksym)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		      {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			blhew = bfd_link_hash_lookup (info->hash, weaksym,
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+						 FALSE, FALSE, FALSE);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			if (blhew->type != bfd_link_hash_defined)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			  {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			    free (p->internal_name);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			    p->internal_name = objsym;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+			  }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		      }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		    }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		    if (weaksym)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		      free (weaksym);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	    }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -910,6 +942,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       if (blhe
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  && (blhe->type == bfd_link_hash_defined
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	      || (blhe->type == bfd_link_hash_defweak)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	      || (blhe->type == bfd_link_hash_common)))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	{
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  count_exported++;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -919,7 +952,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  /* Only fill in the sections. The actual offsets are computed
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	     in fill_exported_offsets() after common symbols are laid
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	     out.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-	  if (blhe->type == bfd_link_hash_defined)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	  if ((blhe->type == bfd_link_hash_defined) || (blhe->type == bfd_link_hash_defweak))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	    exported_symbol_sections[i] = blhe->u.def.section;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  else
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	    exported_symbol_sections[i] = blhe->u.c.p->section;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru --new-file a/bfd/config.bfd b/bfd/config.bfd
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/bfd/config.bfd	2014-07-03 01:37:20.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/bfd/config.bfd	2015-02-14 11:27:08.199179775 -0500
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -679,7 +679,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     targ_archs="$targ_archs bfd_arm_arch"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     want64=true
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-  x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin | x86_64-*-midipix*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     targ_defvec=x86_64_pe_vec
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     targ_selvecs="x86_64_pe_vec x86_64_pei_vec x86_64_pe_be_vec x86_64_elf64_vec l1om_elf64_vec k1om_elf64_vec i386_pe_vec i386_pei_vec i386_elf32_vec"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     want64=true
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -731,7 +731,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     targ_defvec=i386_elf32_vec
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     targ_selvecs=i386_coff_vec
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-  i[3-7]86-*-mingw32* | i[3-7]86-*-cygwin* | i[3-7]86-*-winnt | i[3-7]86-*-pe)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  i[3-7]86-*-mingw32* | i[3-7]86-*-cygwin* | i[3-7]86-*-winnt | i[3-7]86-*-pe | i[3-7]86-*-midipix*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     targ_defvec=i386_pe_vec
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     targ_selvecs="i386_pe_vec i386_pei_vec i386_elf32_vec"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     targ_underscore=yes
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru --new-file a/binutils/configure b/binutils/configure
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/binutils/configure	2014-07-03 01:37:22.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/binutils/configure	2015-09-13 21:35:09.738957435 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -14015,7 +14015,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-	x86_64-*-mingw* | x86_64-*-cygwin*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	x86_64-*-mingw* | x86_64-*-midipix* | x86_64-*-cygwin*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   	  BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  if test -z "$DLLTOOL_DEFAULT"; then
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	    DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_MX86_64"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -14025,7 +14025,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  BUILD_DLLWRAP='$(DLLWRAP_PROG)$(EXEEXT)'
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-	i[3-7]86-*-pe* | i[3-7]86-*-cygwin* | i[3-7]86-*-mingw32** | i[3-7]86-*-netbsdpe*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	i[3-7]86-*-pe* | i[3-7]86-*-cygwin* | i[3-7]86-*-midipix* | i[3-7]86-*-mingw32** | i[3-7]86-*-netbsdpe*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   	  BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  if test -z "$DLLTOOL_DEFAULT"; then
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	    DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_I386"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru --new-file a/configure b/configure
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/configure	2014-07-03 01:37:23.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/configure	2015-03-11 17:07:15.820422926 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -3428,6 +3428,9 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   x86_64-*-mingw*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     noconfigdirs="$noconfigdirs ${libgcj}"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  *-midipix*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+    noconfigdirs="$noconfigdirs ${libgcj}"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+    ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   mmix-*-*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     noconfigdirs="$noconfigdirs target-libffi target-boehm-gc"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -3549,6 +3552,9 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   *-*-mingw*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  *-*-midipix*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+    noconfigdirs="$noconfigdirs target-newlib target-libgloss"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+    ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   *-*-netbsd*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -6257,7 +6263,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 target_elf=no
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 case $target in
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-  *-darwin* | *-aix* | *-cygwin* | *-mingw* | *-aout* | *-*coff* | \
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  *-darwin* | *-aix* | *-cygwin* | *-mingw* | *-midipix* | *-aout* | *-*coff* | \
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   *-msdosdjgpp* | *-vms* | *-wince* | *-*-pe* | \
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   alpha*-dec-osf* | *-interix* | hppa[12]*-*-hpux*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     target_elf=no
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru --new-file a/gas/configure.tgt b/gas/configure.tgt
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/gas/configure.tgt	2014-07-03 01:37:25.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/gas/configure.tgt	2015-02-14 11:27:08.223179776 -0500
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -262,7 +262,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
      i*)				fmt=coff em=pe ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
    esac ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   i386-*-interix*)			fmt=coff em=interix ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-  i386-*-mingw*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  i386-*-mingw* | i386-*-midipix*)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     case ${cpu} in
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       x86_64*)				fmt=coff em=pep ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       i*)				fmt=coff em=pe ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru a/bfd/cofflink.c b/bfd/cofflink.c
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/bfd/cofflink.c	2014-07-03 01:37:20.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/bfd/cofflink.c	2015-06-13 20:22:46.000389638 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -202,6 +202,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   bfd_size_type symesz;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   bfd_byte *esym;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   bfd_byte *esym_end;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  char *weaksym;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   *pneeded = FALSE;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -236,6 +237,16 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	      && CONST_STRNEQ (name, "__imp_"))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	    h = bfd_link_hash_lookup (info->hash, name + 6, FALSE, FALSE, TRUE);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	  if (!h && !strncmp (name, ".weak.", 6) && strchr (name + 6, '.'))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	    {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	      weaksym = strdup (name + 6);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	      *(strchr (weaksym, '.')) = '\0';
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	      h = bfd_link_hash_lookup (info->hash, weaksym, FALSE, FALSE, TRUE);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	      name = weaksym;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	    }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	  else
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	    weaksym = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  /* We are only interested in symbols that are currently
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	     undefined.  If a symbol is currently known to be common,
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	     COFF linkers do not bring in an object file which defines
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -249,6 +260,9 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	      *pneeded = TRUE;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	      return TRUE;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	    }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	  if (weaksym)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	    free (weaksym);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       esym += (sym.n_numaux + 1) * symesz;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -320,6 +334,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   bfd_byte *esym;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   bfd_byte *esym_end;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   bfd_size_type amt;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  char *weaksym;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   symcount = obj_raw_syment_count (abfd);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -476,6 +491,20 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 		addit = FALSE;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	    }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	  if (!strncmp (name, ".weak.", 6) && strchr (name + 6, '.'))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	    {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	      if (! (bfd_coff_link_add_one_symbol
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		     (info, abfd, name, flags, section, value,
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		      (const char *) NULL, copy, FALSE,
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		      (struct bfd_link_hash_entry **) sym_hash)))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+		goto error_return;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	      weaksym = strdup (name + 6);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	      *(strchr(weaksym, '.')) = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	      name = weaksym;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	      flags |= BSF_WEAK;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	    }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  if (addit)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	    {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	      if (! (bfd_coff_link_add_one_symbol
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru a/bfd/linker.c b/bfd/linker.c
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/bfd/linker.c	2014-07-03 01:37:21.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/bfd/linker.c	2015-06-06 17:51:24.148275212 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -1050,6 +1050,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   struct archive_hash_table arsym_hash;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   unsigned int indx;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   struct bfd_link_hash_entry **pundef;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+  char *weaksym;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   if (! bfd_has_map (abfd))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -1073,6 +1074,13 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       struct archive_hash_entry *arh;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       struct archive_list *l, **pp;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      if (!strncmp (arsym->name, ".weak.", 6) && strchr (arsym->name + 6, '.'))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	{
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	  weaksym = strdup (arsym->name + 6);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	  *(strchr (weaksym, '.')) = '\0';
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	  arsym->name = weaksym;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	}
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       arh = archive_hash_lookup (&arsym_hash, arsym->name, TRUE, FALSE);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       if (arh == NULL)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	goto error_return;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
diff -ru a/gas/config/tc-i386.c b/gas/config/tc-i386.c
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/gas/config/tc-i386.c	2014-07-03 01:37:25.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/gas/config/tc-i386.c	2015-06-12 22:40:37.100250091 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -9148,25 +9148,6 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	value += md_pcrel_from (fixP);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #endif
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-#if defined (OBJ_COFF) && defined (TE_PE)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-  if (fixP->fx_addsy != NULL
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      && S_IS_WEAK (fixP->fx_addsy)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      /* PR 16858: Do not modify weak function references.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      && ! fixP->fx_pcrel)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-    {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-#if !defined (TE_PEP)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      /* For x86 PE weak function symbols are neither PC-relative
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-	 nor do they set S_IS_FUNCTION.  So the only reliable way
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-	 to detect them is to check the flags of their containing
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-	 section.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      if (S_GET_SEGMENT (fixP->fx_addsy) != NULL
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-	  && S_GET_SEGMENT (fixP->fx_addsy)->flags & SEC_CODE)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-	;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      else
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-#endif
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      value -= S_GET_VALUE (fixP->fx_addsy);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-    }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-#endif
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   /* Fix a few things - the dynamic linker expects certain values here,
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
      and we must not disappoint it.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -9237,8 +9218,11 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       fixP->fx_done = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       /* Remember value for tc_gen_reloc.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       fixP->fx_addnumber = value;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      /* Clear out the frag for now.  */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      value = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      /* for data symbols, cancel the effect of the relocation */
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      if (!((S_GET_SEGMENT (fixP->fx_addsy)->flags) & SEC_CODE))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+        value = -S_GET_VALUE (fixP->fx_addsy);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      else
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+        value = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     }
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 #endif
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
   else if (use_rela_relocations)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
--- a/binutils/rename.c	2014-07-03 01:37:22.000000000 -0400
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+++ b/binutils/rename.c	2015-11-25 23:13:38.086948592 -0500
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
@@ -167,7 +167,10 @@
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  && s.st_nlink == 1)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       )
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
     {
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
-      ret = rename (from, to);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+      if ((ret = rename (from, to)))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	if (!(ret = simple_copy (from, to)))
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+	  unlink (from);
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
+
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
       if (ret == 0)
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	{
Lucio Andrés Illanes Albornoz (arab, vxp) cddeef
 	  if (exists)
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
--- binutils-2.24.51/intl/libgnuintl.h.orig	2014-07-03 05:37:48.000000000 +0000
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
+++ binutils-2.24.51/intl/libgnuintl.h	2016-05-30 19:56:21.701967351 +0000
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
@@ -105,7 +105,7 @@
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
 #endif
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
 /* Auxiliary macros.  */
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
 #ifdef _INTL_REDIRECT_ASM
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
-# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
+# define _INTL_ASM(cname) __asm__ (#cname)
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
 # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
 # define _INTL_STRINGIFY(prefix) #prefix
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
 #else