Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / pe-x86_64.c
index 5b734442e3b48f029868d0f3f9f56e6300a9187c..5a777bbf4c87af12eaf7e548a1736670a68fe136 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "sysdep.h"
 #include "bfd.h"
+#include "coff/internal.h"
+#include "libcoff.h"
 
 #define TARGET_SYM             x86_64_pe_vec
 #define TARGET_NAME            "pe-x86-64"
@@ -30,7 +32,7 @@
 #define COFF_WITH_PE
 #define COFF_WITH_pex64
 #define COFF_WITH_PE_BIGOBJ
-#define PCRELOFFSET            TRUE
+#define PCRELOFFSET            true
 #if defined (USE_MINGW64_LEADING_UNDERSCORES)
 #define TARGET_UNDERSCORE      '_'
 #else
 
 /* The function pex64_bfd_print_pdata is implemented in pei-x86_64.c
    source, but has be extended to also handle pe objects.  */
-extern bfd_boolean pex64_bfd_print_pdata (bfd *, void *);
+extern bool pex64_bfd_print_pdata (bfd *, void *);
 
 #define bfd_pe_print_pdata   pex64_bfd_print_pdata
 
-#include "coff-x86_64.c"
+static bool
+pex64_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
+{
+  if (bfd_link_pde (info)
+      && bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour)
+    {
+      /* NB: When linking Windows x86-64 relocatable object files to
+        generate ELF executable, create an indirect reference to
+        __executable_start for __ImageBase to support R_AMD64_IMAGEBASE
+        relocation which is relative to __ImageBase.  */
+      struct bfd_link_hash_entry *h, *hi;
+      hi = bfd_link_hash_lookup (info->hash, "__ImageBase", true, false,
+                                false);
+      if (hi->type == bfd_link_hash_new
+         || hi->type == bfd_link_hash_undefined
+         || hi->type == bfd_link_hash_undefweak)
+       {
+         h = bfd_link_hash_lookup (info->hash, "__executable_start",
+                                   true, false, true);
+         hi->type = bfd_link_hash_indirect;
+         hi->u.i.link = h;
+       }
+    }
+
+  return _bfd_coff_link_add_symbols (abfd, info);
+}
 
+#define coff_bfd_link_add_symbols pex64_link_add_symbols
+
+#include "coff-x86_64.c"
This page took 0.024384 seconds and 4 git commands to generate.