Re: [PATCH] ld: pep: Stop emitting reference to the pseudo-relocator function

Jan Beulich <[email protected]>
Newsgroups gmane.comp.gnu.binutils,gmane.comp.gnu.mingw.w64.general
Message-ID <[email protected]>
On 02.07.2026 16:38, Jon Turney wrote:
> The exported _pei386_runtime_relocator function currently only exists as
> a non-functional stub in the Cygwin runtime, merely to satisfy this
> reference synthesized in ld [1].
> 
> The function still has contents in the MinGW runtime [2], but is already
> referenced by being explcitly called at crt startup/dll load.
> 
> We'd like to drop the (slightly confusing) stub from the Cygwin runtime,
> especially in possible future architectures (e.g aarch64), where
> backwards compatibilty concerns don't exist.
> 
> So, for PE+ targets, stop explicitly emitting a reference to
> _pei386_runtime_relocator in the linker.

This PE+ dependency is puzzling me. In a code comment near the end you
mention (only) i386, but ...

> (The archeological record is unclear why this functionality exists in
> ld.
> 
> Since --enable-runtime-pseudo-reloc-v1 exists for 32-bit PE arches, and
> out of an abundance of caution, keep emitting it for those targets (i.e.
> i386) where it conceivably might still be needed or useful with an
> ancient runtime.)

... SH, MCore and Arm look to similarly retain the old behavior then. It's
really a distinction between 32-bit and 64-bit targets, and that doesn't
look like a valid criteria here.

The other aspect I'd like to understand a little better before (possibly)
ack-ing is why pseudo-relocations need producing in the first place. If
ld's generating of real relocations still isn't good enough, maybe that
wants fixing? Then the question of whether a reference to that function is
needed simply vanishes.

> @@ -2798,6 +2800,7 @@ make_runtime_pseudo_reloc (const char *name ATTRIBUTE_UNUSED,
>    return abfd;
>  }
>  
> +#ifndef pe_use_plus
>  /*	.section	.rdata
>  	.rva		__pei386_runtime_relocator  */

As an aside, the name of this symbol looks to be in conflict with the
logic also applying to other architectures.

Jan

> @@ -2894,11 +2898,15 @@ pe_create_import_fixup (arelent *rel, asection *s, bfd_vma addend, char *name,
>  				     link_info.output_bfd);
>        add_bfd_to_link (b, bfd_get_filename (b), &link_info);
>  
> +      /* We think this is entirely useless, but emit a reference to the
> +	 relocator on the i386 target, just in case. */
> +#ifndef pe_use_plus
>        if (runtime_pseudo_relocs_created++ == 0)
>  	{
>  	  b = pe_create_runtime_relocator_reference (link_info.output_bfd);
>  	  add_bfd_to_link (b, bfd_get_filename (b), &link_info);
>  	}
> +#endif
>      }
>  
>    else if (addend != 0)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.