ld/PE: respect --enable-reloc-section even when .reloc isn't created by default

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).
This commit is contained in:
Jan Beulich
2025-10-10 16:00:04 +02:00
parent f72471128d
commit 2817be508d
4 changed files with 21 additions and 3 deletions

View 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
}
@@ -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. */

View 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
}
@@ -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. */

View 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);
if (pe_dll_enable_reloc_section)
{
build_filler_bfd (false);
pe_output_file_set_long_section_names (filler_bfd);
}
}
void

View File

@@ -1,7 +1,6 @@
#name: PE base relocations
#ld: --enable-reloc-section
#objdump: -p
#xfail: mcore-*-*
.*: file format .*