]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld/PE: respect --enable-reloc-section even when .reloc isn't created by default
authorJan Beulich <jbeulich@suse.com>
Fri, 10 Oct 2025 14:00:04 +0000 (16:00 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 10 Oct 2025 14:00:04 +0000 (16:00 +0200)
Even when !DLL_SUPPORT, an executable may still want to have base
relocations created. Avoid doing so by default, though, to not alter
prior behavior.

With this, an xfail can (and actually should) go away (or else we end up
with an XPASS).

ld/emultempl/pe.em
ld/emultempl/pep.em
ld/pe-dll.c
ld/testsuite/ld-pe/reloc.d

index b522687c1d5b4e4fb1d3d998b6ee5f19232b264c..c66c75fb06de715c46382450579d8b743a42b75b 100644 (file)
@@ -228,6 +228,8 @@ fragment <<EOF
   link_info.pei386_auto_import = ${default_auto_import};
   /* Use by default version.  */
   link_info.pei386_runtime_pseudo_reloc = DEFAULT_PSEUDO_RELOC_VERSION;
+#else
+  pe_dll_enable_reloc_section = 0;
 #endif
 }
 \f
@@ -1594,6 +1596,9 @@ gld${EMULATION_NAME}_after_open (void)
   else
     pe_exe_build_sections (link_info.output_bfd, &link_info);
 #endif
+#else /* !DLL_SUPPORT */
+  if (!bfd_link_relocatable (&link_info))
+    pe_exe_build_sections (link_info.output_bfd, &link_info);
 #endif /* DLL_SUPPORT */
 
 #if defined(TARGET_IS_armpe) || defined(TARGET_IS_arm_wince_pe)
@@ -2104,6 +2109,9 @@ gld${EMULATION_NAME}_finish (void)
 
   if (pe_out_def_filename)
     pe_dll_generate_def_file (pe_out_def_filename);
+#else /* !DLL_SUPPORT */
+  if (!bfd_link_relocatable (&link_info))
+    pe_exe_fill_sections (link_info.output_bfd, &link_info);
 #endif /* DLL_SUPPORT */
 
   /* I don't know where .idata gets set as code, but it shouldn't be.  */
index 60a833947bd524d06241d9d54f5999f69594643d..0d059fb6400ea4cffba5daebb1603ef9e7c9c9a0 100644 (file)
@@ -246,6 +246,8 @@ gld${EMULATION_NAME}_before_parse (void)
   config.has_shared = 1;
   link_info.pei386_auto_import = 1;
   link_info.pei386_runtime_pseudo_reloc = 2; /* Use by default version 2.  */
+#else
+  pep_dll_enable_reloc_section = 0;
 #endif
 }
 \f
@@ -1602,6 +1604,9 @@ gld${EMULATION_NAME}_after_open (void)
   else
     pep_exe_build_sections (link_info.output_bfd, &link_info);
 #endif
+#else /* !DLL_SUPPORT */
+  if (!bfd_link_relocatable (&link_info))
+    pep_exe_build_sections (link_info.output_bfd, &link_info);
 #endif /* DLL_SUPPORT */
 
   {
@@ -1944,6 +1949,9 @@ gld${EMULATION_NAME}_finish (void)
 
   if (pep_out_def_filename)
     pep_dll_generate_def_file (pep_out_def_filename);
+#else /* !DLL_SUPPORT */
+  if (!bfd_link_relocatable (&link_info))
+    pep_exe_fill_sections (link_info.output_bfd, &link_info);
 #endif /* DLL_SUPPORT */
 
   /* I don't know where .idata gets set as code, but it shouldn't be.  */
index 6fb45f0d6aa8c1fdeea0c935069ad11203d44877..bbf16e713974b4c2cbc8cce025c1397b28d40fc2 100644 (file)
@@ -3738,8 +3738,11 @@ pe_exe_build_sections (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
   pe_dll_id_target (bfd_get_target (abfd));
   pe_output_file_set_long_section_names (abfd);
-  build_filler_bfd (0);
-  pe_output_file_set_long_section_names (filler_bfd);
+  if (pe_dll_enable_reloc_section)
+    {
+      build_filler_bfd (false);
+      pe_output_file_set_long_section_names (filler_bfd);
+    }
 }
 
 void
index eab8dfb9b026de40128077485be05d28a517b092..55888c3bdf122eb326c684324756439727b4eef3 100644 (file)
@@ -1,7 +1,6 @@
 #name: PE base relocations
 #ld: --enable-reloc-section
 #objdump: -p
-#xfail: mcore-*-*
 
 .*:     file format .*