[binutils-gdb] ld: Drop pep-dll-{aarch64,x86_64}.c

Jon Turney via Binutils-cvs <[email protected]>
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fc7126f8630423ce0224f83e2688fd14fc01d2b7

commit fc7126f8630423ce0224f83e2688fd14fc01d2b7
Author: Jon Turney <[email protected]>
Date:   Fri May 22 13:43:15 2026 +0100

    ld: Drop pep-dll-{aarch64,x86_64}.c
    
    When configuring with
    '--enable-targets=x86_64-w64-mingw32,aarch64-w64-mingw32', many
    duplicate symbol errors are produced:
    
    > /usr/lib/gcc/x86_64-pc-cygwin/16/../../../../x86_64-pc-cygwin/bin/ld: pep-dll-aarch64.o: in function `pep_dll_id_target':
    > /wip/binutils-gdb/build/ld/../../ld/pe-dll.c:493: multiple definition of `pep_dll_id_target'; pep-dll.o:/wip/binutils-gdb/build/ld/../../ld/pe-dll.c:493: first defined here
    > /usr/lib/gcc/x86_64-pc-cygwin/16/../../../../x86_64-pc-cygwin/bin/ld: pep-dll-aarch64.o: in function `pep_dll_add_excludes':
    > /wip/binutils-gdb/build/ld/../../ld/pe-dll.c:586: multiple definition of `pep_dll_add_excludes'; pep-dll.o:/wip/binutils-gdb/build/ld/../../ld/pe-dll.c:586: first defined here
    > /usr/lib/gcc/x86_64-pc-cygwin/16/../../../../x86_64-pc-cygwin/bin/ld: pep-dll-aarch64.o: in function `pep_find_data_imports':
    > /wip/binutils-gdb/build/ld/../../ld/pe-dll.c:1444: multiple definition of `pep_find_data_imports'; pep-dll.o:/wip/binutils-gdb/build/ld/../../ld/pe-dll.c:1444: first defined here
    > /usr/lib/gcc/x86_64-pc-cygwin/16/../../../../x86_64-pc-cygwin/bin/ld: pep-dll-aarch64.o: in function `pep_dll_generate_def_file':
    > /wip/binutils-gdb/build/ld/../../ld/pe-dll.c:1877: multiple definition of `pep_dll_generate_def_file'; pep-dll.o:/wip/binutils-gdb/build/ld/../../ld/pe-dll.c:1877: first defined here
    > /usr/lib/gcc/x86_64-pc-cygwin/16/../../../../x86_64-pc-cygwin/bin/ld: pep-dll-aarch64.o: in function `pep_create_import_fixup':
    > etc.
    
    On investigation, this is unsurprising, since we're compiling the same code twice. In
    fact, configure.tgt has:
    
    > arch64-*-pe* | aarch64-*-mingw*)
    >                         targ_extra_ofiles="deffilep.o pep-dll-aarch64.o pe-dll.o pdb.o"
    > x86_64-*-pe | x86_64-*-pep) targ_emul=i386pep ;
    >                         targ_extra_ofiles="deffilep.o pdb.o pep-dll-x86_64.o pe-dll.o"
    > x86_64-*-cygwin)        targ_emul=i386pep ;
    >                         targ_extra_ofiles="deffilep.o pdb.o pep-dll.o pe-dll.o"
    > x86_64-*-mingw*)        targ_emul=i386pep ;
    >                         targ_extra_ofiles="deffilep.o pdb.o pep-dll.o pe-dll.o"
    
    ... so we're potentially including pep-dll.c compiled under three
    different names!
    
    I can't see anything in pe{,p}-dll.c which depends on the
    COFF_WITH_peAArch64 or COFF_WITH_pex64 defines, so just remove all this.
    
    (Neither pep-dll-aarch64.o or pep-dll-x86_64.o are listed in
    ALL_EMUL_EXTRA_OFILES, so this multiple definition problem doesn't show
    up when configured --enable-targets=all', but this seems like another
    source of subtle bugs if those defines did do anything here...)
    
    Cc'ed Evgeny (Hi!), because I think this crosses with not-yet-submitted
    patches of his which do add some code conditional on COFF_WITH_peAArch64.
    
    I imagine it's possible in code which *does* need to depend on the
    output target to replace build time checks of COFF_WITH_pe{AArch64,x64}
    with a runtime check of the output architecture (via
    pe_details->pe_arch?).
    
    Cc: Evgeny Karpov <[email protected]>
    Fixes: c60b3806799a ("aarch64-pe support for LD, GAS and BFD")
    Signed-off-by: Jon Turney <[email protected]>
    
    2026-05-29  Jon Turney  <[email protected]>
    
            * Makefile.am (EXTRA_ld_new_SOURCES): Update.
            * Makefile.in: Regenerate.
            * configure.tgt (tar_extra_ofiles): Update.
            * pep-dll-aarch64.c: Remove.
            * pep-dll-x86_64.c: Remove.

Diff:
---
 ld/Makefile.am       |  3 +--
 ld/Makefile.in       |  6 ++----
 ld/configure.tgt     |  4 ++--
 ld/pep-dll-aarch64.c | 23 -----------------------
 ld/pep-dll-x86_64.c  | 22 ----------------------
 5 files changed, 5 insertions(+), 53 deletions(-)

diff --git a/ld/Makefile.am b/ld/Makefile.am
index 20d17c23f33..3ae3d7f14f6 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -644,8 +644,7 @@ $(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES): $(GEN_DEPENDS)
 # We need this for automake to use YLWRAP.
 EXTRA_ld_new_SOURCES = deffilep.y ldlex.l
 # Allow dependency tracking to work for these files, too.
-EXTRA_ld_new_SOURCES += ldelf.c ldelfgen.c pdb.c pep-dll.c pe-dll.c \
-	 pep-dll-aarch64.c pep-dll-x86_64.c
+EXTRA_ld_new_SOURCES += ldelf.c ldelfgen.c pdb.c pep-dll.c pe-dll.c
 
 ld_new_SOURCES = ldgram.y ldlex-wrapper.c lexsup.c ldlang.c mri.c ldctor.c ldmain.c \
 	ldwrite.c ldexp.c ldemul.c ldver.c ldmisc.c ldfile.c ldcref.c plugin.c \
diff --git a/ld/Makefile.in b/ld/Makefile.in
index ddc2732a03f..d879f04a17c 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -1026,8 +1026,8 @@ GEN_DEPENDS = $(srcdir)/genscripts.sh ldscripts/stamp
 
 # Dependency tracking for the generated emulation files.
 EXTRA_ld_new_SOURCES = deffilep.y ldlex.l ldelf.c ldelfgen.c pdb.c \
-	pep-dll.c pe-dll.c pep-dll-aarch64.c pep-dll-x86_64.c \
-	$(ALL_EMULATION_SOURCES) $(ALL_64_EMULATION_SOURCES)
+	pep-dll.c pe-dll.c $(ALL_EMULATION_SOURCES) \
+	$(ALL_64_EMULATION_SOURCES)
 ld_new_SOURCES = ldgram.y ldlex-wrapper.c lexsup.c ldlang.c mri.c ldctor.c ldmain.c \
 	ldwrite.c ldexp.c ldemul.c ldver.c ldmisc.c ldfile.c ldcref.c plugin.c \
 	ldbuildid.c
@@ -1593,8 +1593,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mri.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdb.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pe-dll.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pep-dll-aarch64.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pep-dll-x86_64.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pep-dll.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin.Po@am__quote@
 
diff --git a/ld/configure.tgt b/ld/configure.tgt
index 00c109e5079..32b1c45f8e3 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -128,7 +128,7 @@ aarch64-*-nto*)		targ_emul=aarch64nto
 aarch64-*-pe* | aarch64-*-mingw*)
 			targ_emul=aarch64pe
 			targ_extra_emuls="arm64pe"
-			targ_extra_ofiles="deffilep.o pep-dll-aarch64.o pe-dll.o pdb.o"
+			targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o pdb.o"
 			;;
 alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
 			targ_emul=elf64alpha_fbsd
@@ -991,7 +991,7 @@ x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
 			;;
 x86_64-*-pe | x86_64-*-pep) targ_emul=i386pep ;
 			targ_extra_emuls=i386pe ;
-			targ_extra_ofiles="deffilep.o pdb.o pep-dll-x86_64.o pe-dll.o"
+			targ_extra_ofiles="deffilep.o pdb.o pep-dll.o pe-dll.o"
 			;;
 x86_64-*-cygwin)	targ_emul=i386pep ;
 			targ_extra_emuls=i386pe
diff --git a/ld/pep-dll-aarch64.c b/ld/pep-dll-aarch64.c
deleted file mode 100644
index 16f748b33fd..00000000000
--- a/ld/pep-dll-aarch64.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Tiny wrapper over pep-dll.c
-   Copyright (C) 2006-2026 Free Software Foundation, Inc.
-
-   This file is part of the GNU Binutils.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
-
-#define COFF_WITH_peAArch64
-
-#include "pep-dll.c"
diff --git a/ld/pep-dll-x86_64.c b/ld/pep-dll-x86_64.c
deleted file mode 100644
index a61ca3e8216..00000000000
--- a/ld/pep-dll-x86_64.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Tiny wrapper over pep-dll.c
-   Copyright (C) 2006-2026 Free Software Foundation, Inc.
-   This file is part of the GNU Binutils.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
-
-#define COFF_WITH_pex64
-
-#include "pep-dll.c"
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.