Re: [PATCH] PE+: Remove the stdcall fixup machinery

Oleg Tolmatcev <[email protected]>
Newsgroups gmane.comp.gnu.binutils
Message-ID <CACcXsZgBHirUUQd-WjfOS5JqOWif4wKKBHt4hrxS-vqZ+htZgg@mail.gmail.com>
вт, 1 сент. 2026 г. в 10:49, Jan Beulich <[email protected]>:
>
> On 29.08.2026 19:05, Oleg Tolmatcev wrote:
> > Win64 has a single calling convention, so symbols never carry the @nn
> > stdcall decoration.  The stdcall fixup pass in pep.em can therefore
> > never find a match, and neither can --kill-at or --add-stdcall-alias,
> > both of which only act on names containing '@'.
> >
> > Remove the stdcall fixup pass.  Besides being dead code, it traversed
> > the whole link hash table once per undefined cdecl symbol, so it was
> > quadratic.
> >
> > The four affected options are still parsed, and now simply ignored, so
> > that command lines shared with i386 PE targets keep working.  They are
> > no longer listed in --help, and ld.texi records that they have no
> > effect on PE+ targets.
> >
> > ld/ChangeLog:
> >
> >       * emultempl/pep.em (pep_enable_stdcall_fixup, pep_undef_found_sym)
> >       (pep_undef_cdecl_match, set_decoration, pep_fixup_stdcalls):
> >       Remove.
> >       (gld${EMULATION_NAME}_list_options): Don't list --add-stdcall-alias,
> >       --disable-stdcall-fixup, --enable-stdcall-fixup or --kill-at.
> >       (gld${EMULATION_NAME}_handle_option): Accept and ignore
> >       OPTION_KILL_ATS, OPTION_STDCALL_ALIASES,
> >       OPTION_ENABLE_STDCALL_FIXUP and OPTION_DISABLE_STDCALL_FIXUP.
> >       (gld${EMULATION_NAME}_after_open): Don't call pep_fixup_stdcalls.
> >       * ld.texi (--add-stdcall-alias, --enable-stdcall-fixup)
> >       (--kill-at): Note that these have no effect on PE+ targets.
> >
> > Signed-off-by: Oleg Tolmatcev <[email protected]>
>
> Looks largely good to me, just one remark:
>
> > @@ -768,16 +763,10 @@ gld${EMULATION_NAME}_handle_option (int optc)
> >        pep_dll_add_excludes (optarg, EXCLUDEFORIMPLIB);
> >        break;
> >      case OPTION_KILL_ATS:
> > -      pep_dll_kill_ats = 1;
> > -      break;
> >      case OPTION_STDCALL_ALIASES:
> > -      pep_dll_stdcall_aliases = 1;
> > -      break;
> >      case OPTION_ENABLE_STDCALL_FIXUP:
> > -      pep_enable_stdcall_fixup = 1;
> > -      break;
> >      case OPTION_DISABLE_STDCALL_FIXUP:
> > -      pep_enable_stdcall_fixup = 0;
> > +      /* Ignored: stdcall and cdecl are unsupported on Win64.  */
> >        break;
>
> But Win64 isn't the only environment where PE32+ binaries can be used.
> I'd prefer if Windows wasn't mentioned here, or if at least this was
> generalized by e.g. saying "on platforms using Win64's ABI" (which
> would then include e.g. UEFI). I can adjust while committing, but of
> course only if you agree (and if you have preferred alternative
> wording, please also indicate that preference of yours).
>
> Jan

Thanks for the review. I didn't even know that, so I am of course OK
with any wording.

Oleg
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.