]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld: Drop pep-dll-{aarch64,x86_64}.c
authorJon Turney <jon.turney@dronecode.org.uk>
Fri, 22 May 2026 12:43:15 +0000 (13:43 +0100)
committerJon Turney <jon.turney@dronecode.org.uk>
Thu, 4 Jun 2026 12:00:35 +0000 (13:00 +0100)
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 <evgeny.karpov@arm.com>
Fixes: c60b3806799a ("aarch64-pe support for LD, GAS and BFD")
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2026-05-29  Jon Turney  <jon.turney@dronecode.org.uk>

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

ld/Makefile.am
ld/Makefile.in
ld/configure.tgt
ld/pep-dll-aarch64.c [deleted file]
ld/pep-dll-x86_64.c [deleted file]

index 20d17c23f3327cd34c0267614b47d9299e40b76b..3ae3d7f14f62a33dccee05d24d9d8346bf49f2f4 100644 (file)
@@ -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 \
index ddc2732a03ff46644f050a5345ab858622a926e4..d879f04a17c70f540ffa577ce11da652df30d809 100644 (file)
@@ -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@
 
index 00c109e507997519af8e5e8520dfaa775ed24eed..32b1c45f8e3fbcdf63039fd82d8ae731e8b713b3 100644 (file)
@@ -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 (file)
index 16f748b..0000000
+++ /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 (file)
index a61ca3e..0000000
+++ /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"