From: Alan Modra Date: Thu, 22 Dec 2022 01:19:09 +0000 (+1030) Subject: pdb build fixes X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f27d07a1c208701de6f2c11d43b4a7d89a44180f;p=binutils-gdb.git pdb build fixes Enable compilation of ld/pdb.c just for x86, as is done for bfd/pdb.c. This reduces the size of ld and is necessary with the following patches that call a COFF-only bfd function from ld/pdb.c. Without it we'd break every non-COFF target build. --- diff --git a/ld/Makefile.am b/ld/Makefile.am index 65fef4e1690..a1ef4ad8c24 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -466,6 +466,7 @@ ALL_64_EMULATIONS = $(ALL_64_EMULATION_SOURCES:.c=.@OBJEXT@) ALL_EMUL_EXTRA_OFILES = \ deffilep.@OBJEXT@ \ + pdb.@OBJEXT@ \ pe-dll.@OBJEXT@ \ ldelf.@OBJEXT@ \ ldelfgen.@OBJEXT@ @@ -496,7 +497,7 @@ OFILES = ldgram.@OBJEXT@ ldlex-wrapper.@OBJEXT@ lexsup.@OBJEXT@ ldlang.@OBJEXT@ mri.@OBJEXT@ ldctor.@OBJEXT@ ldmain.@OBJEXT@ plugin.@OBJEXT@ \ ldwrite.@OBJEXT@ ldexp.@OBJEXT@ ldemul.@OBJEXT@ ldver.@OBJEXT@ ldmisc.@OBJEXT@ \ ldfile.@OBJEXT@ ldcref.@OBJEXT@ ${EMULATION_OFILES} ${EMUL_EXTRA_OFILES} \ - ldbuildid.@OBJEXT@ pdb.@OBJEXT@ + ldbuildid.@OBJEXT@ STAGESTUFF = *.@OBJEXT@ ldscripts/* e*.c @@ -956,11 +957,11 @@ $(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 += pep-dll.c pe-dll.c ldelf.c ldelfgen.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 \ - ldbuildid.c pdb.c + ldbuildid.c ld_new_DEPENDENCIES = $(EMULATION_OFILES) $(EMUL_EXTRA_OFILES) \ $(BFDLIB) $(LIBCTF) $(LIBIBERTY) $(LIBINTL_DEP) $(JANSSON_LIBS) ld_new_LDADD = $(EMULATION_OFILES) $(EMUL_EXTRA_OFILES) $(BFDLIB) $(LIBCTF) \ diff --git a/ld/Makefile.in b/ld/Makefile.in index ff4c916c27b..10b63629e2f 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -212,7 +212,7 @@ am_ld_new_OBJECTS = ldgram.$(OBJEXT) ldlex-wrapper.$(OBJEXT) \ ldctor.$(OBJEXT) ldmain.$(OBJEXT) ldwrite.$(OBJEXT) \ ldexp.$(OBJEXT) ldemul.$(OBJEXT) ldver.$(OBJEXT) \ ldmisc.$(OBJEXT) ldfile.$(OBJEXT) ldcref.$(OBJEXT) \ - plugin.$(OBJEXT) ldbuildid.$(OBJEXT) pdb.$(OBJEXT) + plugin.$(OBJEXT) ldbuildid.$(OBJEXT) ld_new_OBJECTS = $(am_ld_new_OBJECTS) am__DEPENDENCIES_1 = @ENABLE_LIBCTF_TRUE@am__DEPENDENCIES_2 = ../libctf/libctf.la @@ -965,6 +965,7 @@ ALL_64_EMULATION_SOURCES = \ ALL_64_EMULATIONS = $(ALL_64_EMULATION_SOURCES:.c=.@OBJEXT@) ALL_EMUL_EXTRA_OFILES = \ deffilep.@OBJEXT@ \ + pdb.@OBJEXT@ \ pe-dll.@OBJEXT@ \ ldelf.@OBJEXT@ \ ldelfgen.@OBJEXT@ @@ -994,7 +995,7 @@ OFILES = ldgram.@OBJEXT@ ldlex-wrapper.@OBJEXT@ lexsup.@OBJEXT@ ldlang.@OBJEXT@ mri.@OBJEXT@ ldctor.@OBJEXT@ ldmain.@OBJEXT@ plugin.@OBJEXT@ \ ldwrite.@OBJEXT@ ldexp.@OBJEXT@ ldemul.@OBJEXT@ ldver.@OBJEXT@ ldmisc.@OBJEXT@ \ ldfile.@OBJEXT@ ldcref.@OBJEXT@ ${EMULATION_OFILES} ${EMUL_EXTRA_OFILES} \ - ldbuildid.@OBJEXT@ pdb.@OBJEXT@ + ldbuildid.@OBJEXT@ STAGESTUFF = *.@OBJEXT@ ldscripts/* e*.c SRC_POTFILES = $(CFILES) $(HFILES) @@ -1008,12 +1009,12 @@ GEN_DEPENDS = $(srcdir)/genscripts.sh stringify.sed # Allow dependency tracking to work for these files, too. # Dependency tracking for the generated emulation files. -EXTRA_ld_new_SOURCES = deffilep.y ldlex.l pep-dll.c pe-dll.c ldelf.c \ - ldelfgen.c $(ALL_EMULATION_SOURCES) \ +EXTRA_ld_new_SOURCES = deffilep.y ldlex.l ldelf.c ldelfgen.c pdb.c \ + 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 pdb.c + ldbuildid.c ld_new_DEPENDENCIES = $(EMULATION_OFILES) $(EMUL_EXTRA_OFILES) \ $(BFDLIB) $(LIBCTF) $(LIBIBERTY) $(LIBINTL_DEP) $(JANSSON_LIBS) diff --git a/ld/configure.tgt b/ld/configure.tgt index 741b246f67e..5971866fb61 100644 --- a/ld/configure.tgt +++ b/ld/configure.tgt @@ -423,17 +423,17 @@ i[3-7]86-*-moss*) targ_emul=i386moss targ_extra_emuls=i386msdos ;; i[3-7]86-*-winnt*) targ_emul=i386pe ; - targ_extra_ofiles="deffilep.o pe-dll.o" + targ_extra_ofiles="deffilep.o pdb.o pe-dll.o" ;; i[3-7]86-*-pe) targ_emul=i386pe ; - targ_extra_ofiles="deffilep.o pe-dll.o" + targ_extra_ofiles="deffilep.o pdb.o pe-dll.o" ;; i[3-7]86-*-cygwin*) targ_emul=i386pe ; - targ_extra_ofiles="deffilep.o pe-dll.o" ; + targ_extra_ofiles="deffilep.o pdb.o pe-dll.o" ; test "$targ" != "$host" && LIB_PATH='${tooldir}/lib/w32api' ;; i[3-7]86-*-mingw32*) targ_emul=i386pe ; - targ_extra_ofiles="deffilep.o pe-dll.o" + targ_extra_ofiles="deffilep.o pdb.o pe-dll.o" ;; i[3-7]86-*-interix*) targ_emul=i386pe_posix; targ_extra_ofiles="deffilep.o pe-dll.o" @@ -1047,16 +1047,16 @@ 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 pep-dll-x86_64.o pe-dll.o" + targ_extra_ofiles="deffilep.o pdb.o pep-dll-x86_64.o pe-dll.o" ;; x86_64-*-cygwin) targ_emul=i386pep ; targ_extra_emuls=i386pe - targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o" + targ_extra_ofiles="deffilep.o pdb.o pep-dll.o pe-dll.o" test "$targ" != "$host" && LIB_PATH='${tooldir}/lib/w32api' ;; x86_64-*-mingw*) targ_emul=i386pep ; targ_extra_emuls=i386pe - targ_extra_ofiles="deffilep.o pep-dll.o pe-dll.o" + targ_extra_ofiles="deffilep.o pdb.o pep-dll.o pe-dll.o" ;; xgate-*-*) targ_emul=xgateelf targ_extra_ofiles=ldelfgen.o diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 1e0e23df043..cd4634180e7 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -15,6 +15,13 @@ case ${target} in ;; esac +case ${target} in + x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin | \ + i[3-7]86-*-mingw32* | i[3-7]86-*-cygwin* | i[3-7]86-*-winnt | i[3-7]86-*-pe) + pdb_support=" ";; + *) +esac + rm -f e${EMULATION_NAME}.c (echo;echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-) fragment <pe_opthdr.ImageBase; +#ifdef PDB_H if (pdb_name) pdb_base_name = lbasename (pdb_name); +#endif /* Construct a debug directory entry which points to an immediately following CodeView record. */ struct internal_IMAGE_DEBUG_DIRECTORY idd; @@ -1336,7 +1350,11 @@ write_build_id (bfd *abfd) idd.MajorVersion = 0; idd.MinorVersion = 0; idd.Type = PE_IMAGE_DEBUG_TYPE_CODEVIEW; - idd.SizeOfData = sizeof (CV_INFO_PDB70) + (pdb_base_name ? strlen (pdb_base_name) : 0) + 1; + idd.SizeOfData = (sizeof (CV_INFO_PDB70) +#ifdef PDB_H + + (pdb_base_name ? strlen (pdb_base_name) : 0) +#endif + + 1); idd.AddressOfRawData = asec->vma - ib + link_order->offset + sizeof (struct external_IMAGE_DEBUG_DIRECTORY); idd.PointerToRawData = asec->filepos + link_order->offset @@ -1352,11 +1370,13 @@ write_build_id (bfd *abfd) if (bfd_bwrite (contents, sizeof (*ext), abfd) != sizeof (*ext)) return 0; +#ifdef PDB_H if (pdb) { if (!create_pdb_file (abfd, pdb_name, build_id)) return 0; } +#endif /* Construct the CodeView record. */ CODEVIEW_INFO cvinfo; @@ -1414,9 +1434,10 @@ setup_build_id (bfd *ibfd) s->size = sizeof (struct external_IMAGE_DEBUG_DIRECTORY) + sizeof (CV_INFO_PDB70) + 1; +#ifdef PDB_H if (pdb_name) s->size += strlen (lbasename (pdb_name)); - +#endif return true; } @@ -1447,6 +1468,7 @@ gld${EMULATION_NAME}_after_open (void) } #endif +#ifdef PDB_H if (pdb && !pdb_name) { const char *base = lbasename (bfd_get_filename (link_info.output_bfd)); @@ -1465,6 +1487,7 @@ gld${EMULATION_NAME}_after_open (void) memcpy (pdb_name, base, len); memcpy (pdb_name + len, suffix, sizeof (suffix)); } +#endif if (emit_build_id != NULL) { diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index e61414893ad..7b2a656c8ab 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -17,6 +17,13 @@ case ${target} in ;; esac +case ${target} in + x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin | \ + i[3-7]86-*-mingw32* | i[3-7]86-*-cygwin* | i[3-7]86-*-winnt | i[3-7]86-*-pe) + pdb_support=" ";; + *) +esac + rm -f e${EMULATION_NAME}.c (echo;echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-) fragment <pe_opthdr.ImageBase; +#ifdef PDB_H if (pdb_name) pdb_base_name = lbasename (pdb_name); +#endif /* Construct a debug directory entry which points to an immediately following CodeView record. */ struct internal_IMAGE_DEBUG_DIRECTORY idd; @@ -1328,7 +1349,11 @@ write_build_id (bfd *abfd) idd.MajorVersion = 0; idd.MinorVersion = 0; idd.Type = PE_IMAGE_DEBUG_TYPE_CODEVIEW; - idd.SizeOfData = sizeof (CV_INFO_PDB70) + (pdb_base_name ? strlen (pdb_base_name) : 0) + 1; + idd.SizeOfData = (sizeof (CV_INFO_PDB70) +#ifdef PDB_H + + (pdb_base_name ? strlen (pdb_base_name) : 0) +#endif + + 1); idd.AddressOfRawData = asec->vma - ib + link_order->offset + sizeof (struct external_IMAGE_DEBUG_DIRECTORY); idd.PointerToRawData = asec->filepos + link_order->offset @@ -1344,11 +1369,13 @@ write_build_id (bfd *abfd) if (bfd_bwrite (contents, sizeof (*ext), abfd) != sizeof (*ext)) return 0; +#ifdef PDB_H if (pdb) { if (!create_pdb_file (abfd, pdb_name, build_id)) return 0; } +#endif /* Construct the CodeView record. */ CODEVIEW_INFO cvinfo; @@ -1403,12 +1430,13 @@ setup_build_id (bfd *ibfd) One IMAGE_DEBUG_DIRECTORY entry, of type IMAGE_DEBUG_TYPE_CODEVIEW, pointing at a CV_INFO_PDB70 record containing the build-id, followed by PdbFileName if relevant. */ - s->size = sizeof (struct external_IMAGE_DEBUG_DIRECTORY) - + sizeof (CV_INFO_PDB70) + 1; + s->size = (sizeof (struct external_IMAGE_DEBUG_DIRECTORY) + + sizeof (CV_INFO_PDB70) + 1); +#ifdef PDB_H if (pdb_name) s->size += strlen (lbasename (pdb_name)); - +#endif return true; } @@ -1440,6 +1468,7 @@ gld${EMULATION_NAME}_after_open (void) } #endif +#ifdef PDB_H if (pdb && !pdb_name) { const char *base = lbasename (bfd_get_filename (link_info.output_bfd)); @@ -1458,6 +1487,7 @@ gld${EMULATION_NAME}_after_open (void) memcpy (pdb_name, base, len); memcpy (pdb_name + len, suffix, sizeof (suffix)); } +#endif if (emit_build_id != NULL) {