[Mingw-w64-public] [PATCH] ld: pep: Stop emitting reference to the pseudo-relocator function

Martin Storsjö martin@martin.st
Thu Jul 2 19:41:48 GMT 2026


On Thu, 2 Jul 2026, LIU Hao wrote:

> 在 2026-7-2 22:38, Jon Turney 写道:
>> 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.
>> 
>> (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.)
>> 
>> Cc'ed to mingw-w64-public list.
>> 
>> [1] 
>> https://cygwin.com/cgit/newlib-cygwin/tree/winsup/cygwin/lib/pseudo-reloc-dummy.c
>> [2] 
>> https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/crt/pseudo-reloc.c#l479
>> 
>> Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
>> Cc: mingw-w64-public@lists.sourceforge.net
>> 
> AFAICT there's no reason to keep it. Even the original MinGW.org code calls 
> it explicitly:

Yes, I think it should be safe to remove it as things stand right now.

As discussed on irc, I believe the reason why this was added in the first 
place, was to try to link in the pseudo relocation machinery only when the 
binary actually uses pseudo relocations.

With something like [1], the mingw-w64-crt runtime could stop calling it 
unconditionally, so it only would be included when necessary. (That 
wouldn't really save any notable amount of runtime, but it would save a 
little bit of binary size and avoid a couple of imports, maybe shrinking 
the minimal size of binaries.) But with how ld works right now, it fails 
to pull in the right object files and just fails with an undefined symbol.

(And if we'd do that in mingw-w64, we'd break compatibility with existing 
versions of ld, which we don't want to do lightly. And we'd have to do 
a matching change to lld as well.)

So as things stand right now, I think it should be fine to drop it.

// Martin

[1] https://github.com/mstorsjo/mingw-w64/commit/pseudo-reloc-ctor


More information about the Binutils mailing list