aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl/pep.em
AgeCommit message (Collapse)AuthorFilesLines
2024-01-19ld: Put all emulation options in ldlex.hH.J. Lu1-73/+0
For each command line option, parse_args() calls ldemul_parse_args() to check if the command line option is an emulation option. But when there is a conflict between the emulation option value and the default option value, the default command line option will be processed as if the emulation option is used. Remove PARSE_AND_LIST_PROLOGUE and move all emulation options to ldlex.h to avoid conflicts. PR ld/31247 * ldlex.h (option_values): Add all emulation options. * emulparams/elf32mcore.sh (PARSE_AND_LIST_PROLOGUE): Removed. * emulparams/plt_unwind.sh (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/aarch64elf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/alphaelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/armelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/avrelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/bfin.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/cskyelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/hppaelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/ia64elf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/m68hc1xelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/m68kelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/metagelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/mipself.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/nds32elf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/nto.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/ppc32elf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/ppc64elf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/riscvelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/rxelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/s390.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/scoreelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/spuelf.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/tic6xdsbt.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/vxworks.em (PARSE_AND_LIST_PROLOGUE): Likewise. * emultempl/aix.em: Include "ldlex.h". (OPTION_XXX): Removed. (gld${EMULATION_NAME}_read_file): Replace lineno with linenumber. * emultempl/beos.em (OPTION_XXX): Removed. * emultempl/elf.em: Include "ldlex.h". Don't check PARSE_AND_LIST_PROLOGUE. (OPTION_XXX): Removed. * emultempl/msp430.em: Include "ldlex.h". (OPTION_XXX): Removed. * emultempl/pe.em (OPTION_XXX): Removed. * emultempl/pep.em (OPTION_XXX): Likewise. * emultempl/ticoff.em: Include "ldlex.h". (OPTION_XXX): Removed. * emultempl/vms.em: Include "ldlex.h". (OPTION_XXX): Removed. * emultempl/xtensaelf.em (elf32xtensa_size_opt, elf32xtensa_no_literal_movement, elf32xtensa_abi): Moved out of PARSE_AND_LIST_PROLOGUE. (PARSE_AND_LIST_PROLOGUE): Removed.
2024-01-04Update year range in copyright notice of binutils filesAlan Modra1-1/+1
Adds two new external authors to etc/update-copyright.py to cover bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then updates copyright messages as follows: 1) Update cgen/utils.scm emitted copyrights. 2) Run "etc/update-copyright.py --this-year" with an extra external author I haven't committed, 'Kalray SA.', to cover gas testsuite files (which should have their copyright message removed). 3) Build with --enable-maintainer-mode --enable-cgen-maint=yes. 4) Check out */po/*.pot which we don't update frequently.
2023-08-26ld STRINGIFYAlan Modra1-1/+1
Delete support for old compilers that don't support string concatentation. * Makefile.am (stringify.sed): Delete rule. (GEN_DEPENDS, DISTCLEANFILES): Adjust. * configure.ac (STRINGIFY): Delete. * emultempl/beos.em: Use stringify.sed from srcdir. * emultempl/elf.em: Likewise. * emultempl/generic.em: Likewise. * emultempl/msp430.em: Likewise. * emultempl/pdp11.em: Likewise. * emultempl/pe.em: Likewise. * emultempl/pep.em: Likewise. * emultempl/stringify.sed: Renamed from.. * emultempl/astring.sed: ..this. * emultempl/ostring.sed: Delete. * Makefile.in: Regenerate. * configure: Regenerate.
2023-08-09Rename bfd_bread and bfd_bwriteAlan Modra1-2/+2
These were renamed from bfd_read and bfd_write back in 2001 when they lost an unnecessary parameter. Rename them back, and get rid of a few casts that are only needed without prototyped functions (K&R C).
2023-08-03ld: sprintf sanitizer null destination pointerAlan Modra1-2/+2
* configure.ac (stpcpy): AC_CHECK_DECLS. * sysdep.h (stpcpy): Add fallback declaraion. * config.in: Regenerate. * configure: Regenerate. * emultempl/pe.em (open_dynamic_archive): Use stpcpy rather than sprintf plus strlen. * emultempl/pep.em (open_dynamic_archive): Likewise. * emultempl/xtensaelf.em (elf_xtensa_before_allocation): Use auto rather than malloc'd buffer. Use sprintf count. * ldelf.c (ldelf_search_needed): Use memcpy in place of sprintf. * pe-dll.c (pe_process_import_defs): Use string already formed for alias match rather than recreating.
2023-07-17PR10957, Missing option to really print section+offsetAlan Modra1-1/+1
Many of the reloc error messages have already been converted from using %C to using %H in ld.bfd, to print section+offset as well as file/line/function. This catches a few remaining, and changes gold to do the same. PR 10957 bfd/ * elf32-sh.c (sh_elf_relocate_section): Use %H in error messages. gold/ * object.cc (Relocate_info::location): Always report section+offset. * testsuite/debug_msg.sh: Adjust to suit. * testsuite/x32_overflow_pc32.sh: Likewise. * testsuite/x86_64_overflow_pc32.sh: Likewise. ld/ * emultempl/pe.em (read_addend): Use %H in error message. * emultempl/pep.em (read_addend): Likewise. * ldcref.c (check_reloc_refs): Likewise. * ldmain.c (warning_find_reloc, undefined_symbol): Likewise. * pe-dll.c (pe_create_import_fixup): Likewise. * testsuite/ld-cris/undef2.d: Adjust expected output to suit. * testsuite/ld-cris/undef3.d: Likewise. * testsuite/ld-elf/shared.exp: Likewise. * testsuite/ld-i386/compressed1.d: Likewise. * testsuite/ld-ia64/line.exp: Likewise. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-undefined/undefined.exp: Likewise. * testsuite/ld-x86-64/compressed1.d: Likewise. * testsuite/ld-x86-64/line.exp: Likewise. * testsuite/ld-x86-64/pr27587.err: Likewise.
2023-05-17Decorated symbols in import libs (BUG 30421)Luca Bacci1-0/+25
PR 30421 * cofflink.c (_decoration_hash_newfunc): New function. (_bfd_coff_link_hash_table_init): Call it. * libcoff-in.h (struct coff_link_hash_table): Add decoration_hash field. (struct decoration_hash_entry): Declare. (_decoration_hash_newfunc): Prototype. * libcoff.h: Regenerate. * emultempl/pe.em (set_decoration): New function. (pe_fixup_stdcalls): Call the new function. * emultempl/pep.em (set_decoration): New function. (pep_fixup_stdcalls): Call the new function. * pe-dll.c (make_one): Check for decoated symbols.
2023-05-08pe.em and pep.em make_import_fixupAlan Modra1-33/+50
This is a little cleanup that I made when looking at pr30343 that makes it more obvious that make_import_fixup in both files are identical (and in fact the new pep.em read_addend could be used in both files). * emultempl/pep.em (read_addend): Extract from.. (make_import_fixup): ..here. * emultempl/pe.em (read_addend): Similarly. (make_import_fixup): Similarly. Add debug code from pep.em.
2023-05-08PR30343, LTO ignores linker reference to _pei386_runtime_relocatorAlan Modra1-0/+33
Make a reference to _pei386_runtime_relocator before LTO recompilation. This is done regardless of whether such a reference will be used, because it can't be known whether it is needed before LTO. I also found it necessary to enable long section names for the bfd created in make_runtime_pseudo_reloc, because otherwise when writing it out to the bfd-in-memory we get the section written as .rdata_r which when read back in leads to a linker warning ".rdata_r: section below image base" and likely runtime misbehaviour. PR 30343 * emultempl/pe.em (make_runtime_ref): New function. (gld${EMULATION_NAME}_before_plugin_all_symbols_read): New function. (LDEMUL_BEFORE_PLUGIN_ALL_SYMBOLS_READ): Define. * emultempl/pep.em: Similarly to pe.em. * pe-dll.c (make_runtime_pseudo_reloc): Set long section names.
2023-05-04Stop the linker from loosing the entry point for COFF/PE code when compiling ↵Nick Clifton1-0/+3
with LTO enabled. PR 30300 * emultempl/pep.em (set_entry_point): Add an undefined reference to the entry point if it has been constructed heuristically. * emultempl/pe.em (set_entry_point): Likewise.
2023-01-27Call bfd_close_all_done in ld_cleanupAlan Modra1-19/+22
This is similar to "Call bfd_close_all_done in output_file_close", but with some code tidying in the pe/pep write_build_id functions. write_build_id is passed the output bfd as its parameter, so there is no need to go looking for the output bfd via link_info (and doing so will no longer work since I clear link_info.output_bfd before calling bfd_close). * emultempl/pe.em (write_build_id): Rename t to td. Formatting. Don't access pe_data(link_info.output_bfd), use td instead. (setup_build_id): Rename t to td. Formatting. * emultempl/pep.em: As for pe.em. * ldmain.c (ld_cleanup): Call bfd_close_all_done on linker bfds. (main): Clear link_info.output_bfd when closing.
2023-01-25ld: Add pdb support to aarch64-w64-mingw32Mark Harmstone1-1/+2
This extends PDB support to the aarch64 PE targets. The changes to the test files are just to make it so they can be assembled as either x86, x86_64, or aarch64, mainly by changing the comment style. The only actual code change here is in adding the architecture constants to pdb.c.
2023-01-24ld: Avoid magic numbers for subsystems in pe.em and pep.emMark Harmstone1-2/+2
2023-01-12Use __func__ rather than __FUNCTION__Alan Modra1-2/+2
We already use C99's __func__ in places, use it more generally. This patch doesn't change uses in the testsuite. I've also left one in gold.h that is protected by GCC_VERSION < 4003. If any of the remaining uses bothers anyone I invite patches. bfd/ * bfd-in.h: Replace __FUNCTION__ with __func__. * elf32-bfin.c: Likewise. * elfnn-aarch64.c: Likewise. * elfxx-sparc.c: Likewise. * bfd-in2.h: Regenerate. gas/ * config/tc-cris.c: Replace __FUNCTION__ with __func__. * config/tc-m68hc11.c: Likewise. * config/tc-msp430.c: Likewise. gold/ * dwp.h: Replace __FUNCTION__ with __func__. * gold.h: Likewise, except for use inside GCC_VERSION < 4003. ld/ * emultempl/pe.em: Replace __FUNCTION__ with __func__. * emultempl/pep.em: Likewise. * pe-dll.c: Likewise.
2023-01-10Add aarch64-w64-mingw32 targetMark Harmstone1-4/+7
This adds a mingw target for aarch64, including windres and dlltool. Note that the old value of jmp_aarch64_bytes was wrong, and this does the same thing as MSVC does.
2023-01-06ld: yet another PDB build fix (or workaround)Jan Beulich1-8/+12
Older bash looks to improperly deal with backslashes in here-documents, leaving them in place on the escaped double quotes inside the parameter expansion. Convert to a model without using such a construct, by simply splitting the here-documents into three ones.
2023-01-06Tidy pe flag in coff_dataAlan Modra1-1/+1
Make it a bool, use obj_pe accessor everywhere.
2023-01-05Add an extra emulation called arm64pe to the aarch64pe emulation.Nick Clifton1-0/+4
2023-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
The newer update-copyright.py fixes file encoding too, removing cr/lf on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2022-12-23pdb build fixesAlan Modra1-5/+35
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.
2022-12-23COFF build-id writes uninitialised data to fileAlan Modra1-4/+2
1) The first write in write_build_id wrote rubbish past the struct external_IMAGE_DEBUG_DIRECTORY, which was later overwritten with correct data. No user visible problem there, except that tools like valgrind complain. 2) The size for the pdb name was incorrectly calculated. * emultempl/pe.em (write_build_id): Write the debug directory, not the entire section contents. (setup_build_id): Add size for the base name of pdb_name, not the full path. * emultempl/pep.em: Likewise. * testsuite/ld-pe/pdb2-section-contrib.d: Update.
2022-10-20ld: Add minimal pdb generationMark Harmstone1-0/+7
2022-10-20ld: Add --pdb optionMark Harmstone1-4/+44
Second patch incorporates fixes for endian and UB issues in calc_hash, as per https://sourceware.org/pipermail/binutils/2022-October/123514.html.
2022-10-19aarch64-pe support for LD, GAS and BFDJedidiah Thompson1-1/+9
Allows aarch64-pe to be targeted natively, not having to use objcopy to convert it from ELF to PE. Based on initial work by Jedidiah Thompson Co-authored-by: Jedidiah Thompson <wej22007@outlook.com> Co-authored-by: Zac Walker <zac.walker@linaro.org>
2022-08-30ld: pe: Fix linking against Microsoft import libraries with multiple DLLsMartin Storsjö1-54/+16
Initially, since c6c37250e98f113755e0d787f7070e2ac80ce77e (in 1999), in order to fix linking against Microsoft import libraries, ld did internally rename members of such libraries. At that point, the criteria for being considered a Microsoft import library was that every archive member had the same name (no regard for exactly what that name was). This was later amended in 44dbf3639f127af46d569ad96b6242dfbc4c0a89 (in 2003) to allow for Microsoft import libraries with intermixed static object files. At this point, the criteria were extended, so that all members following the first member named *.dll either had the exact same member name, or be named *.obj. (Curiously, this would allow members with any name if it precedes the first one named *.dll.) In practice, Microsoft style import libraries can contain members for linking against more than one DLL (built by merging multiple regular import libraries into one). Instead of trying to do validation of the whole archive before considering it a Microsoft style import library, relax the criteria for doing the member renaming: If an archive member is named *.dll and it contains .idata sections, assume that that member is a Microsoft import file, and apply the renaming scheme. This works for imports for any number of DLLs in the same library, intermixed with other static object files (regardless of their names), and vastly simplifies the code. LLVM generates Microsoft style import libraries, and Rust builds seem to bundle up multiple import libraries together with some Rust specific static objects. This fixes linking directly against them with ld.bfd.
2022-08-25ld: pe: Move the return type to a separate line from the function nameMartin Storsjö1-1/+2
This fixes the coding style of an old, preexisting function.
2022-08-24ld: pe: Make archive member file extension comparisons case insensitive when ↵Martin Storsjö1-5/+22
cross compiling too On Windows, filename_cmp is case insensitive, but when cross compiling with libraries that may contain members with uppercase file names, we should keep those comparisons case insensitive when running the build tools on other OSes too. Also make the check for .def consistent with the other ones, fixing out of bounds reads if file names are shorter than 4 characters.
2022-08-03Fix a conflict between the linker's need to rename some PE format input ↵Alan Modra1-11/+14
libraries and the BFD library's file caching mechanism. PR 29389 bfd * bfd.c (BFD_CLOSED_BY_CACHE): New bfd flag. * cache.c (bfd_cache_delete): Set BFD_CLOSED_BY_DELETE on the closed bfd. (bfd_cache_lookup_worker): Clear BFD_CLOSED_BY_DELETE on the newly reopened bfd. * opncls.c (bfd_set_filename): Refuse to change the name of a bfd that has been closed by bfd_cache_delete. Mark changed bfds as uncacheable. * bfd-in2.h: Regenerate. ld * ldlang.h (lang_input_statement_struct): Add sort_key field. * emultempl/pe.em (after_open): If multiple import libraries refer to the same bfd, store their names in the sort_key field. * emultempl/pep.em (after_open): Likewise. * ldlang.c (sort_filename): New function. Returns the filename to be used when sorting input files. (wild_sort): Use the sort_filename function.
2022-02-06ld: Add emultempl/emulation.emH.J. Lu1-52/+28
Add emultempl/emulation.em to define ld_${EMULATION_NAME}_emulation so that new emulation hooks can be added easily. * emultempl/aix.em (LDEMUL_AFTER_OPEN): New. (LDEMUL_SET_OUTPUT_ARCH): Likewise. (LDEMUL_CHOOSE_TARGET): Likewise. (LDEMUL_BEFORE_ALLOCATION): Likewise. (LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS): Likewise. (LDEMUL_OPEN_DYNAMIC_ARCHIVE): Likewise. (LDEMUL_PARSE_ARGS): Likewise. (LDEMUL_ADD_OPTIONS): Likewise. (LDEMUL_HANDLE_OPTION): Likewise. (LDEMUL_UNRECOGNIZED_FILE): Likewise. (LDEMUL_PRINT_SYMBOL): Likewise. (ld_${EMULATION_NAME}_emulation): Removed. Source ${srcdir}/emultempl/emulation.em. * emultempl/beos.em (gld_${EMULATION_NAME}_before_parse): Renamed to ... (gld${EMULATION_NAME}_before_parse): This. (gld_${EMULATION_NAME}_set_symbols): Renamed to ... (gld${EMULATION_NAME}_set_symbols): This. (gld_${EMULATION_NAME}_after_open): Renamed to ... (gld${EMULATION_NAME}_after_open): This. (gld_${EMULATION_NAME}_before_allocation): Renamed to ... (gld${EMULATION_NAME}_before_allocation): This. (gld_${EMULATION_NAME}_get_script): Renamed to ... (gld${EMULATION_NAME}_get_script): This. (LDEMUL_AFTER_OPEN): New. (LDEMUL_BEFORE_ALLOCATION): Likewise. (LDEMUL_PLACE_ORPHAN): Likewise. (LDEMUL_SET_SYMBOLS): Likewise. (LDEMUL_ADD_OPTIONS): Likewise. (LDEMUL_HANDLE_OPTION): Likewise. (ld_${EMULATION_NAME}_emulation): Removed. Source ${srcdir}/emultempl/emulation.em. * emultempl/elf.em (LDEMUL_AFTER_PARSE): New. (LDEMUL_AFTER_OPEN): Likewise. (LDEMUL_BEFORE_PLACE_ORPHANS): Likewise. (LDEMUL_AFTER_ALLOCATION): Likewise. (LDEMUL_SET_OUTPUT_ARCH): Likewise. (LDEMUL_BEFORE_ALLOCATION): Likewise. (LDEMUL_OPEN_DYNAMIC_ARCHIVE): Likewise. (LDEMUL_PLACE_ORPHAN): Likewise. (LDEMUL_ADD_OPTIONS): Likewise. (LDEMUL_HANDLE_OPTION): Likewise. (LDEMUL_LIST_OPTIONS): Likewise. (LDEMUL_UNRECOGNIZED_FILE): Likewise. (ld_${EMULATION_NAME}_emulation): Removed. Source ${srcdir}/emultempl/emulation.em. * emultempl/emulation.em: New file. * emultempl/generic.em (ld_${EMULATION_NAME}_emulation): Removed. Source ${srcdir}/emultempl/emulation.em. * emultempl/msp430.em (LDEMUL_AFTER_OPEN): New. (LDEMUL_AFTER_ALLOCATION): Likewise. (LDEMUL_PLACE_ORPHAN): Likewise. (LDEMUL_FINISH): Likewise. (LDEMUL_ADD_OPTIONS): Likewise. (LDEMUL_HANDLE_OPTION): Likewise. (LDEMUL_LIST_OPTIONS): Likewise. (ld_${EMULATION_NAME}_emulation): Removed. Source ${srcdir}/emultempl/emulation.em. * emultempl/pe.em (gld_${EMULATION_NAME}_before_parse): Renamed to ... (gld${EMULATION_NAME}_before_parse): This. (gld_${EMULATION_NAME}_list_options): Renamed to ... (gld${EMULATION_NAME}_list_options): This. (gld_${EMULATION_NAME}_set_symbols): Renamed to ... (gld${EMULATION_NAME}_set_symbols): This. (gld_${EMULATION_NAME}_after_parse): Renamed to ... (gld${EMULATION_NAME}_after_parse): This. (gld_${EMULATION_NAME}_after_open): Renamed to ... (gld${EMULATION_NAME}_after_open): This. (gld_${EMULATION_NAME}_before_allocation): Renamed to ... (gld${EMULATION_NAME}_before_allocation): This. (gld_${EMULATION_NAME}_unrecognized_file): Renamed to ... (gld${EMULATION_NAME}_unrecognized_file): This. (gld_${EMULATION_NAME}_recognized_file): Renamed to ... (gld${EMULATION_NAME}_recognized_file): This. (gld_${EMULATION_NAME}_finish): Renamed to ... (gld${EMULATION_NAME}_finish): This. (gld_${EMULATION_NAME}_place_orphan): Renamed to ... (gld${EMULATION_NAME}_place_orphan): This. (gld_${EMULATION_NAME}_open_dynamic_archive): Renamed to ... (gld${EMULATION_NAME}_open_dynamic_archive): This. (gld_${EMULATION_NAME}_find_potential_libraries): Renamed to ... (gld${EMULATION_NAME}_find_potential_libraries): This. (gld_${EMULATION_NAME}_get_script): Renamed to ... (gld${EMULATION_NAME}_get_script): This. (LDEMUL_AFTER_PARSE): New. (LDEMUL_AFTER_OPEN): Likewise. (LDEMUL_BEFORE_ALLOCATION): Likewise. (LDEMUL_FINISH=): Likewise. (LDEMUL_OPEN_DYNAMIC_ARCHIVE): Likewise. (LDEMUL_PLACE_ORPHAN): Likewise. (LDEMUL_SET_SYMBOLS): Likewise. (LDEMUL_ADD_OPTIONS): Likewise. (LDEMUL_HANDLE_OPTION): Likewise. (LDEMUL_UNRECOGNIZED_FILE): Likewise. (LDEMUL_LIST_OPTIONS): Likewise. (LDEMUL_RECOGNIZED_FILE): Likewise. (LDEMUL_FIND_POTENTIAL_LIBRARIES): Likewise. (ld_${EMULATION_NAME}_emulation): Removed. Source ${srcdir}/emultempl/emulation.em. * emultempl/pep.em (gld_${EMULATION_NAME}_before_parse): Renamed to ... (gld${EMULATION_NAME}_before_parse): This. (gld_${EMULATION_NAME}_list_options): Renamed to ... (gld${EMULATION_NAME}_list_options): This. (gld_${EMULATION_NAME}_set_symbols): Renamed to ... (gld${EMULATION_NAME}_set_symbols): This. (gld_${EMULATION_NAME}_after_parse): Renamed to ... (gld${EMULATION_NAME}_after_parse): This. (gld_${EMULATION_NAME}_after_open): Renamed to ... (gld${EMULATION_NAME}_after_open): This. (gld_${EMULATION_NAME}_before_allocation): Renamed to ... (gld${EMULATION_NAME}_before_allocation): This. (gld_${EMULATION_NAME}_unrecognized_file): Renamed to ... (gld${EMULATION_NAME}_unrecognized_file): This. (gld_${EMULATION_NAME}_recognized_file): Renamed to ... (gld${EMULATION_NAME}_recognized_file): This. (gld_${EMULATION_NAME}_finish): Renamed to ... (gld${EMULATION_NAME}_finish): This. (gld_${EMULATION_NAME}_place_orphan): Renamed to ... (gld${EMULATION_NAME}_place_orphan): This. (gld_${EMULATION_NAME}_open_dynamic_archive): Renamed to ... (gld${EMULATION_NAME}_open_dynamic_archive): This. (gld_${EMULATION_NAME}_find_potential_libraries): Renamed to ... (gld${EMULATION_NAME}_find_potential_libraries): This. (gld_${EMULATION_NAME}_get_script): Renamed to ... (gld${EMULATION_NAME}_get_script): This. (LDEMUL_AFTER_PARSE): New. (LDEMUL_AFTER_OPEN): Likewise. (LDEMUL_BEFORE_ALLOCATION): Likewise. (LDEMUL_FINISH=): Likewise. (LDEMUL_OPEN_DYNAMIC_ARCHIVE): Likewise. (LDEMUL_PLACE_ORPHAN): Likewise. (LDEMUL_SET_SYMBOLS): Likewise. (LDEMUL_ADD_OPTIONS): Likewise. (LDEMUL_HANDLE_OPTION): Likewise. (LDEMUL_UNRECOGNIZED_FILE): Likewise. (LDEMUL_LIST_OPTIONS): Likewise. (LDEMUL_RECOGNIZED_FILE): Likewise. (LDEMUL_FIND_POTENTIAL_LIBRARIES): Likewise. (ld_${EMULATION_NAME}_emulation): Removed. Source ${srcdir}/emultempl/emulation.em. * emultempl/ticoff.em (gld_${EMULATION_NAME}_list_options): Renamed to ... (gld${EMULATION_NAME}_list_options): This. (gld_${EMULATION_NAME}_before_parse): Renamed to ... (gld_${EMULATION_NAME}_get_script): Renamed to ... (gld${EMULATION_NAME}_get_script): This. (LDEMUL_ADD_OPTIONS): New. (LDEMUL_HANDLE_OPTION): Likewise. (LDEMUL_LIST_OPTIONS): Likewise. (ld_${EMULATION_NAME}_emulation): Removed. Source ${srcdir}/emultempl/emulation.em. * emultempl/vanilla.em (LDEMUL_BEFORE_PARSE): New. (LDEMUL_SET_OUTPUT_ARCH): Likewise. (LDEMUL_GET_SCRIPT): Likewise. (EMULATION_NAME): Likewise. (OUTPUT_FORMAT): Likewise. (ld_vanilla_emulation): Removed. Source ${srcdir}/emultempl/emulation.em.
2022-01-02Update year range in copyright notice of binutils filesAlan Modra1-1/+1
The result of running etc/update-copyright.py --this-year, fixing all the files whose mode is changed by the script, plus a build with --enable-maintainer-mode --enable-cgen-maint=yes, then checking out */po/*.pot which we don't update frequently. The copy of cgen was with commit d1dd5fcc38ead reverted as that commit breaks building of bfp opcodes files.
2021-11-17Set the default DLL chracteristics to 0 for Cygwin based targets.Jeremy Drake1-2/+5
* emultempl/pep.em (DEFAULT_DLL_CHARACTERISTICS): Set to 0 for Cygwin targets. * emultempl/pep.em (DEFAULT_DLL_CHARACTERISTICS): Likewise.
2021-03-31Use bool in ldAlan Modra1-65/+65
* sysdep.h (POISON_BFD_BOOLEAN): Define. * configure.ac (elf_list_options, elf_shlib_list_options=false), (elf_plt_unwind_list_options=false): Replace FALSE with false, and TRUE with true. * emulparams/call_nop.sh, * emulparams/cet.sh, * emulparams/dynamic_undefined_weak.sh, * emulparams/elf32b4300.sh, * emulparams/elf32lm32.sh, * emulparams/elf32lr5900.sh, * emulparams/elf32lr5900n32.sh, * emulparams/elf32visium.sh, * emulparams/elf_x86_64.sh, * emulparams/extern_protected_data.sh, * emulparams/plt_unwind.sh, * emulparams/reloc_overflow.sh, * emulparams/static.sh, * emulparams/x86-64-lam.sh, * emultempl/aarch64elf.em, * emultempl/aix.em, * emultempl/alphaelf.em, * emultempl/armcoff.em, * emultempl/armelf.em, * emultempl/avrelf.em, * emultempl/beos.em, * emultempl/bfin.em, * emultempl/cr16elf.em, * emultempl/crxelf.em, * emultempl/cskyelf.em, * emultempl/elf.em, * emultempl/genelf.em, * emultempl/hppaelf.em, * emultempl/linux.em, * emultempl/m68hc1xelf.em, * emultempl/metagelf.em, * emultempl/mipself.em, * emultempl/mmix-elfnmmo.em, * emultempl/mmixelf.em, * emultempl/mmo.em, * emultempl/msp430.em, * emultempl/nios2elf.em, * emultempl/pdp11.em, * emultempl/pe.em, * emultempl/pep.em, * emultempl/ppc32elf.em, * emultempl/ppc64elf.em, * emultempl/rxelf.em, * emultempl/rxlinux.em, * emultempl/scoreelf.em, * emultempl/solaris2.em, * emultempl/spuelf.em, * emultempl/ticoff.em, * emultempl/v850elf.em, * emultempl/vms.em, * emultempl/xtensaelf.em, * emultempl/z80.em, * ld.h, * ldbuildid.c, * ldbuildid.h, * ldcref.c, * ldctor.c, * ldctor.h, * ldelf.c, * ldelf.h, * ldelfgen.c, * ldelfgen.h, * ldemul.c, * ldemul.h, * ldexp.c, * ldexp.h, * ldfile.c, * ldfile.h, * ldgram.y, * ldlang.c, * ldlang.h, * ldmain.c, * ldmain.h, * ldmisc.c, * ldmisc.h, * ldwrite.c, * lexsup.c, * mri.c, * pe-dll.c, * pe-dll.h, * pep-dll.h, * plugin.c, * plugin.h, * testplug.c, * testplug2.c, * testplug3.c, * testplug4.c: Replace bfd_boolean with bool, FALSE with false, and TRUE with true. * configure: Regenerate.
2021-03-22Add startswith function and use it instead of CONST_STRNEQ.Martin Liska1-1/+1
bfd/ChangeLog: * bfd-in.h (startswith): Add startswith function. (CONST_STRNEQ): Remove. * bfd-in2.h (startswith): Regenerate with make headers. * archive.c (bfd_slurp_armap): Replace usage of CONST_STRNEQ with startswith. (_bfd_slurp_extended_name_table): Likewise. * archive64.c (_bfd_archive_64_bit_slurp_armap): Likewise. * bfd.c (bfd_get_sign_extend_vma): Likewise. (bfd_convert_section_size): Likewise. (bfd_convert_section_contents): Likewise. * coff-stgo32.c (go32exe_create_stub): Likewise. (go32exe_check_format): Likewise. * coffcode.h (styp_to_sec_flags): Likewise. (GNU_DEBUGALTLINK): Likewise. * coffgen.c (_bfd_coff_section_already_linked): Likewise. (coff_gc_sweep): Likewise. (bfd_coff_gc_sections): Likewise. * cofflink.c (coff_link_add_symbols): Likewise. (process_embedded_commands): Likewise. * compress.c (bfd_is_section_compressed_with_header): Likewise. (bfd_init_section_decompress_status): Likewise. * dwarf2.c (find_debug_info): Likewise. (place_sections): Likewise. * ecoff.c (_bfd_ecoff_slurp_armap): Likewise. * elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Likewise. * elf.c (_bfd_elf_make_section_from_shdr): Likewise. (assign_section_numbers): Likewise. (elfcore_grok_win32pstatus): Likewise. * elf32-arm.c (cmse_scan): Likewise. (elf32_arm_gc_mark_extra_sections): Likewise. (elf32_arm_size_dynamic_sections): Likewise. (is_arm_elf_unwind_section_name): Likewise. * elf32-bfin.c (bfin_size_dynamic_sections): Likewise. * elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise. * elf32-cris.c (elf_cris_size_dynamic_sections): Likewise. * elf32-csky.c (csky_elf_size_dynamic_sections): Likewise. * elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise. * elf32-iq2000.c (iq2000_elf_check_relocs): Likewise. * elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise. * elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise. * elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise. * elf32-metag.c (elf_metag_size_dynamic_sections): Likewise. * elf32-msp430.c (msp430_elf_relax_delete_bytes): Likewise. * elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise. * elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise. * elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise. * elf32-s390.c (elf_s390_size_dynamic_sections): Likewise. * elf32-score.c (s3_bfd_score_elf_size_dynamic_sections): Likewise. * elf32-score7.c (s7_bfd_score_elf_size_dynamic_sections): Likewise. * elf32-sh.c (sh_elf_size_dynamic_sections): Likewise. * elf32-tic6x.c (is_tic6x_elf_unwind_section_name): Likewise. (elf32_tic6x_size_dynamic_sections): Likewise. * elf32-vax.c (elf_vax_size_dynamic_sections): Likewise. * elf32-xtensa.c (elf_xtensa_size_dynamic_sections): Likewise. (xtensa_is_insntable_section): Likewise. (xtensa_is_littable_section): Likewise. (xtensa_is_proptable_section): Likewise. (xtensa_property_section_name): Likewise. (xtensa_callback_required_dependence): Likewise. * elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise. * elf64-hppa.c (elf64_hppa_size_dynamic_sections): Likewise. * elf64-ia64-vms.c (is_unwind_section_name): Likewise. (get_reloc_section): Likewise. (elf64_ia64_size_dynamic_sections): Likewise. (elf64_ia64_object_p): Likewise. * elf64-mmix.c (mmix_elf_add_symbol_hook): Likewise. * elf64-ppc.c (ppc64_elf_size_dynamic_sections): Likewise. * elf64-s390.c (elf_s390_size_dynamic_sections): Likewise. * elflink.c (elf_link_add_object_symbols): Likewise. (_bfd_elf_gc_mark_extra_sections): Likewise. (bfd_elf_parse_eh_frame_entries): Likewise. (_bfd_elf_section_already_linked): Likewise. * elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Likewise. * elfnn-ia64.c (is_unwind_section_name): Likewise. (elfNN_ia64_size_dynamic_sections): Likewise. (elfNN_ia64_object_p): Likewise. * elfxx-mips.c (FN_STUB_P): Likewise. (CALL_STUB_P): Likewise. (CALL_FP_STUB_P): Likewise. (_bfd_mips_elf_section_from_shdr): Likewise. (_bfd_mips_elf_fake_sections): Likewise. (_bfd_mips_elf_size_dynamic_sections): Likewise. (_bfd_mips_final_write_processing): Likewise. (_bfd_mips_elf_final_link): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise. * elfxx-x86.c (elf_i386_is_reloc_section): Likewise. (elf_x86_64_is_reloc_section): Likewise. * hpux-core.c (thread_section_p): Likewise. * libcoff.h (bfd_pei_p): Likewise. * linker.c (REAL): Likewise. (unwrap_hash_lookup): Likewise. (_bfd_generic_link_add_one_symbol): Likewise. * mmo.c (mmo_internal_write_section): Likewise. * osf-core.c (osf_core_core_file_p): Likewise. * pef.c (bfd_pef_print_symbol): Likewise. * pei-x86_64.c (pex64_print_all_pdata_sections): Likewise. * som.c (som_slurp_symbol_table): Likewise. (som_slurp_armap): Likewise. * wasm-module.c (wasm_compute_custom_section_file_position): Likewise. binutils/ChangeLog: * dlltool.c (scan_drectve_symbols): Replace usage of CONST_STRNEQ with startswith. * emul_aix.c (ar_emul_aix_parse_arg): Likewise. * objcopy.c (is_mergeable_note_section): Likewise. * objdump.c (dump_dwarf_section): Likewise. * prdbg.c (pr_method_type): Likewise. (pr_class_baseclass): Likewise. (tg_class_baseclass): Likewise. * readelf.c (process_lto_symbol_tables): Likewise. * stabs.c (ULLHIGH): Likewise. (parse_stab_argtypes): Likewise. (stab_demangle_function_name): Likewise. gas/ChangeLog: * config/tc-i386.c (md_parse_option): Replace usage of CONST_STRNEQ with startswith. (x86_64_section_word): Likewise. * config/tc-sparc.c (md_parse_option): Likewise. gdb/ChangeLog: * arm-tdep.c (show_disassembly_style_sfunc): Replace usage of CONST_STRNEQ with startswith. (_initialize_arm_tdep): Likewise. ld/ChangeLog: * emultempl/aix.em: Replace usage of CONST_STRNEQ with startswith. * emultempl/beos.em: Likewise. * emultempl/elf.em: Likewise. * emultempl/pe.em: Likewise. * emultempl/pep.em: Likewise. * emultempl/xtensaelf.em: Likewise. * ldctor.c (ctor_prio): Likewise. * ldelf.c (ldelf_try_needed): Likewise. (ldelf_parse_ld_so_conf): Likewise. (ldelf_after_open): Likewise. (output_rel_find): Likewise. (ldelf_place_orphan): Likewise. * ldfile.c (ldfile_add_library_path): Likewise. * ldlang.c (lang_add_input_file): Likewise. * ldmain.c (get_sysroot): Likewise. (get_emulation): Likewise. (add_archive_element): Likewise. * ldwrite.c (unsplittable_name): Likewise. (clone_section): Likewise. * lexsup.c (parse_args): Likewise. * pe-dll.c (is_import): Likewise. (pe_implied_import_dll): Likewise. opcodes/ChangeLog: * aarch64-dis.c (parse_aarch64_dis_option): Replace usage of CONST_STRNEQ with startswith. * arc-dis.c (parse_option): Likewise. * arm-dis.c (parse_arm_disassembler_options): Likewise. * cris-dis.c (print_with_operands): Likewise. * h8300-dis.c (bfd_h8_disassemble): Likewise. * i386-dis.c (print_insn): Likewise. * ia64-gen.c (fetch_insn_class): Likewise. (parse_resource_users): Likewise. (in_iclass): Likewise. (lookup_specifier): Likewise. (insert_opcode_dependencies): Likewise. * mips-dis.c (parse_mips_ase_option): Likewise. (parse_mips_dis_option): Likewise. * s390-dis.c (disassemble_init_s390): Likewise. * wasm32-dis.c (parse_wasm32_disassembler_options): Likewise.
2021-01-26PR27226, ld.bfd contains huge .rodata sectionAlan Modra1-0/+34
This makes it possible to build ld without any compiled-in scripts, by setting COMPILE_IN=no in the environment. pe, beos and pdp11 targets didn't support scripts from the file system, with pdp11 nastily editing the ld/ldscripts file so that the built-in script didn't match. PR 27226 * emulparams/alphavms.sh: Don't set COMPILE_IN. * emulparams/elf64_ia64_vms.sh: Likewise. * emulparams/elf64mmix.sh: Likewise. * emulparams/elf_iamcu.sh: Likewise. * emulparams/elf_k1om.sh: Likewise. * emulparams/elf_l1om.sh: Likewise. * emulparams/mmo.sh: Likewise. * emulparams/pdp11.sh: Set DATA_SEG_ADDR. * scripttempl/pdp11.sc: Use it. * emultempl/pdp11.em: Don't edit .xn script for separate_code, instead use .xe script. Support scripts from file system. * emultempl/beos.em: Support scripts from file system. * emultempl/pe.em: Likewise. * emultempl/pep.em: Likewise. * testsuite/ld-bootstrap/bootstrap.exp: Make tmpdir/ldscripts link.
2021-01-13SHF_LINK_ORDER fixup_link_order in ldAlan Modra1-2/+2
This moves the SHF_LINK_ORDER sorting from bfd_elf_final_link to the linker which means generic ELF targets now support SHF_LINK_ORDER and we cope with odd cases that require resizing of output sections. The patch also fixes two bugs in the current implementation, introduced by commit cd6d537c48fa. The pattern test used by that commit meant that sections matching something like "*(.IA_64.unwind* .gnu.linkonce.ia64unw.*)" would not properly sort a mix of sections matching the two wildcards. That commit also assumed a stable qsort. bfd/ PR 27160 * section.c (struct bfd_section): Remove pattern field. (BFD_FAKE_SECTION): Adjust to suit. * bfd-in2.h: Regenerate. * elflink.c (compare_link_order, elf_fixup_link_order): Delete. (bfd_elf_final_link): Don't call elf_fixup_link_order. ld/ PR 27160 * ldlang.h (lang_output_section_statement_type): Add data field. (lang_input_section_type, lang_section_bst_type): Add pattern field. (statement_list): Declare. (lang_add_section): Adjust prototype. * emultempl/aarch64elf.em: Adjust lang_add_section calls. * emultempl/armelf.em: Likewise. * emultempl/beos.em: Likewise. * emultempl/cskyelf.em: Likewise. * emultempl/hppaelf.em: Likewise. * emultempl/m68hc1xelf.em: Likewise. * emultempl/metagelf.em: Likewise. * emultempl/mipself.em: Likewise. * emultempl/mmo.em: Likewise. * emultempl/msp430.em: Likewise. * emultempl/nios2elf.em: Likewise. * emultempl/pe.em: Likewise. * emultempl/pep.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/spuelf.em: Likewise. * emultempl/vms.em: Likewise. * ldelf.c: Likewise. * ldelfgen.c: Include ldctor.h. (struct os_sections): New. (add_link_order_input_section, link_order_scan): New functions. (compare_link_order, fixup_link_order): New functions. (ldelf_map_segments): Call link_order_scan and fixup_link_order. * ldlang.c (statement_list): Make global. (output_section_callback_fast): Save pattern in tree node. (lang_add_section): Add pattern parameter, save in lang_input_section. (output_section_callback_tree_to_list): Adjust lang_add_section calls. (lang_insert_orphan, output_section_callback): Likewise. (ldlang_place_orphan): Likewise. (gc_section_callback): Don't set section->pattern * testsuite/ld-elf/pr26256-2a.d: Don't xfail generic. * testsuite/ld-elf/pr26256-3b.d: Likewise. * testsuite/ld-elf/pr26256-2b.d: Likewise. notarget xgate.
2021-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1
2020-11-20bfd, include, ld, binutils, libctf: CTF should use the dynstr/symNick Alcock1-1/+2
This is embarrassing. The whole point of CTF is that it remains intact even after a binary is stripped, providing a compact mapping from symbols to types for everything in the externally-visible interface of an ELF object: it has connections to the symbol table for that purpose, and to the string table to avoid duplicating symbol names. So it's a shame that the hooks I implemented last year served to hook it up to the .symtab and .strtab, which obviously disappear on strip, leaving any accompanying the CTF dict containing references to strings (and, soon, symbols) which don't exist any more because their containing strtab has been vaporized. The original Solaris design used .dynsym and .dynstr (well, actually, .ldynsym, which has more symbols) which do not disappear. So should we. Thankfully the work we did before serves as guide rails, and adjusting things to use the .dynstr and .dynsym was fast and easy. The only annoyance is that the dynsym is assembled inside elflink.c in a fairly piecemeal fashion, so that the easiest way to get the symbols out was to hook in before every call to swap_symbol_out (we also leave in a hook in front of symbol additions to the .symtab because it seems plausible that we might want to hook them in future too: for now that hook is unused). We adjust things so that rather than being offered a whole hash table of symbols at once, libctf is now given symbols one at a time, with st_name indexes already resolved and pointing at their final .dynstr offsets: it's now up to libctf to resolve these to names as needed using the strtab info we pass it separately. Some bits might be contentious. The ctf_new_dynstr callback takes an elf_internal_sym, and this remains an elf_internal_sym right down through the generic emulation layers into ldelfgen. This is no worse than the elf_sym_strtab we used to pass down, but in the future when we gain non-ELF CTF symtab support we might want to lower the elf_internal_sym to some other representation (perhaps a ctf_link_symbol) in bfd or in ldlang_ctf_new_dynsym. We rename the 'apply_strsym' hooks to 'acquire_strings' instead, becuse they no longer have anything to do with symbols. There are some API changes to pieces of API which are technically public but actually totally unused by anything and/or unused by anything but ld so they can change freely: the ctf_link_symbol gains new fields to allow symbol names to be given as strtab offsets as well as strings, and a symidx so that the symbol index can be passed in. ctf_link_shuffle_syms loses its callback parameter: the idea now is that linkers call the new ctf_link_add_linker_symbol for every symbol in .dynsym, feed in all the strtab entries with ctf_link_add_strtab, and then a call to ctf_link_shuffle_syms will apply both and arrange to use them to reorder the CTF symtab at CTF serialization time (which is coming in the next commit). Inside libctf we have a new preamble flag CTF_F_DYNSTR which is always set in v3-format CTF dicts from this commit forwards: CTF dicts without this flag are associated with .strtab like they used to be, so that old dicts' external strings don't turn to garbage when loaded by new libctf. Dicts with this flag are associated with .dynstr and .dynsym instead. (The flag is not the next in sequence because this commit was written quite late: the missing flags will be filled in by the next commit.) Tests forthcoming in a later commit in this series. bfd/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * elflink.c (elf_finalize_dynstr): Call examine_strtab after dynstr finalization. (elf_link_swap_symbols_out): Don't call it here. Call ctf_new_symbol before swap_symbol_out. (elf_link_output_extsym): Call ctf_new_dynsym before swap_symbol_out. (bfd_elf_final_link): Likewise. * elf.c (swap_out_syms): Pass in bfd_link_info. Call ctf_new_symbol before swap_symbol_out. (_bfd_elf_compute_section_file_positions): Adjust. binutils/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * readelf.c (dump_section_as_ctf): Use .dynsym and .dynstr, not .symtab and .strtab. include/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * bfdlink.h (struct elf_sym_strtab): Replace with... (struct elf_internal_sym): ... this. (struct bfd_link_callbacks) <examine_strtab>: Take only a symstrtab argument. <ctf_new_symbol>: New. <ctf_new_dynsym>: Likewise. * ctf-api.h (struct ctf_link_sym) <st_symidx>: New. <st_nameidx>: Likewise. <st_nameidx_set>: Likewise. (ctf_link_iter_symbol_f): Removed. (ctf_link_shuffle_syms): Remove most parameters, just takes a ctf_dict_t now. (ctf_link_add_linker_symbol): New, split from ctf_link_shuffle_syms. * ctf.h (CTF_F_DYNSTR): New. (CTF_F_MAX): Adjust. ld/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ldelfgen.c (struct ctf_strsym_iter_cb_arg): Rename to... (struct ctf_strtab_iter_cb_arg): ... this, changing fields: <syms>: Remove. <symcount>: Remove. <symstrtab>: Rename to... <strtab>: ... this. (ldelf_ctf_strtab_iter_cb): Adjust. (ldelf_ctf_symbols_iter_cb): Remove. (ldelf_new_dynsym_for_ctf): New, tell libctf about a single symbol. (ldelf_examine_strtab_for_ctf): Rename to... (ldelf_acquire_strings_for_ctf): ... this, only doing the strtab portion and not symbols. * ldelfgen.h: Adjust declarations accordingly. * ldemul.c (ldemul_examine_strtab_for_ctf): Rename to... (ldemul_acquire_strings_for_ctf): ... this. (ldemul_new_dynsym_for_ctf): New. * ldemul.h: Adjust declarations accordingly. * ldlang.c (ldlang_ctf_apply_strsym): Rename to... (ldlang_ctf_acquire_strings): ... this. (ldlang_ctf_new_dynsym): New. (lang_write_ctf): Call ldemul_new_dynsym_for_ctf with NULL to do the actual symbol shuffle. * ldlang.h (struct elf_strtab_hash): Adjust accordingly. * ldmain.c (bfd_link_callbacks): Wire up new/renamed callbacks. libctf/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ctf-link.c (ctf_link_shuffle_syms): Adjust. (ctf_link_add_linker_symbol): New, unimplemented stub. * libctf.ver: Add it. * ctf-create.c (ctf_serialize): Set CTF_F_DYNSTR on newly-serialized dicts. * ctf-open-bfd.c (ctf_bfdopen_ctfsect): Check for the flag: open the symtab/strtab if not present, dynsym/dynstr otherwise. * ctf-archive.c (ctf_arc_bufpreamble): New, get the preamble from some arbitrary member of a CTF archive. * ctf-impl.h (ctf_arc_bufpreamble): Declare it.
2020-09-30After preventing creating an import library for an exe when there are no ↵Jeremy Drake1-1/+2
exports, to avoid a crash, it turned out that some projects expected to be able to create an import library for a dll with no exports, so more closely match the condition to the condition around initializing the dll name. PR 26588 * emultempl/pe.em (_finish): Generate an import library for DLLs, even if they have no exports. * emultempl/pep.em (_finish): Likewise.
2020-09-22Linker: If the type is pie the results should be an executable which entry ↵Frediano Ziglio1-1/+1
point should be an executable entry point, not a DLL one. * emultempl/pe.em (set_entry_point): Only use the DLL entry point for DLLs. * emultempl/pep.em (set_entry_point): Likewise.
2020-09-11Fix a segfault when creating an import library with 0 exports.Jeremy Drake1-1/+2
PR 26588 * emultempl/pe.em (_finish): Only generate a import library if not exporting relocs. * emultempl/pep.em: Likewise.
2020-08-27Change the default characteristics of DLLs built by the linker to more ↵Jeremy Drake1-17/+74
secure settings. PR 19011 * emultempl/pe.em (DEFAULT_DLL_CHARACTERISTICS): Define. (pe_dll_characteristics): Initialise to DEFAULT_DLL_CHARACTERISTICS. (add_options): Add options to disable DLL characteristics. (list_options): List the new options. (handle_options): Handle the new options. * emultempl/pep.em: Similar changes to above. (NT_EXE_IMAGE_BASE): Default to an address above 4G. (NT_DLL_IMAGE_BASE, NT_DLL_AUTO_IMAGE_BASE, (NT_DLL_AUTO_IMAGE_MASK): Likewise. * ld.texi: Document the new options. * pe-dll.c (pe_dll_enable_reloc_section): Change to default to true. (generate_reloc): Do nothing if there is no reloc section. (pe_exe_fill_sections): Only assign the reloc section contents if the section exists. * testsuite/ld-pe/pe.exp: Add the --disable-reloc-section flag to the .secrel32 tests. * testsuite/ld-scripts/provide-8.d: Expect for fail on PE targets. * NEWS: Mention the change in DLL generation.
2020-05-21Replace "if (x) free (x)" with "free (x)", ldAlan Modra1-5/+2
* deffilep.y: Replace "if (x) free (x)" with "free (x)" thoughout. * emultempl/elf.em: Likewise. * emultempl/msp430.em: Likewise. * emultempl/pe.em: Likewise. * emultempl/pep.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/xtensaelf.em: Likewise. * ldelf.c: Likewise. * ldfile.c: Likewise. * ldmain.c: Likewise. * ldmisc.c: Likewise. * lexsup.c: Likewise. * pe-dll.c: Likewise.
2020-05-20PR25993, read of freed memoryAlan Modra1-26/+11
ldmain.c:add_archive_element copies file name pointers from the bfd to a lang_input_statement_type. input->filename = abfd->filename; input->local_sym_name = abfd->filename; This results in stale pointers when twiddling the bfd filename in places like the pe ld after_open. So don't free the bfd filename, and make copies using bfd_alloc memory that won't result in small memory leaks that annoy memory checkers. PR 25993 bfd/ * archive.c (_bfd_get_elt_at_filepos): Don't strdup filename, use bfd_set_filename. * elfcode.h (_bfd_elf_bfd_from_remote_memory): Likewise. * mach-o.c (bfd_mach_o_fat_member_init): Likewise. * opncls.c (bfd_fopen, bfd_openstreamr, bfd_openr_iovec, bfd_openw), (bfd_create): Likewise. (_bfd_delete_bfd): Don't free filename. (bfd_set_filename): Copy filename param to bfd_alloc'd memory, return pointer to the copy or NULL on alloc fail. * vms-lib.c (_bfd_vms_lib_get_module): Free newname and test result of bfd_set_filename. * bfd-in2.h: Regenerate. gdb/ * solib-darwin.c (darwin_bfd_open): Don't strdup pathname for bfd_set_filename. * solib-aix.c (solib_aix_bfd_open): Use std::string for name passed to bfd_set_filename. * symfile-mem.c (add_vsyscall_page): Likewise for string passed to symbol_file_add_from_memory. (symbol_file_add_from_memory): Make name param a const char* and don't strdup. ld/ * emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Don't copy other_bfd_filename for bfd_set_filename, and test result of bfd_set_filename call. Don't create a new is->filename, simply copy from bfd filename. Free new_name after bfd_set_filename. * emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
2020-05-19Use bfd_get_filename throughout ldAlan Modra1-9/+11
* emultempl/beos.em (sort_by_file_name): Use bfd_get_filename rather than accessing bfd->filename directly. * emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Likewise. * emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise. * emultempl/spuelf.em (embedded_spu_file): Likewise. * ldlang.c (input_statement_is_archive_path, wild_sort), (check_excluded_libs): Likewise. * ldmain.c (add_archive_element): Likewise. * ldmisc.c (vfinfo): Likewise. * pe-dll.c (auto_export, generate_edata, pe_create_import_fixup), (pe_dll_generate_implib, pe_process_import_defs): Likewise. * plugin.c (plugin_object_p): Likewise.
2020-05-18Show AIX gc'd symbol address adjustments in map fileDouglas B Rupp1-1/+2
* ldemul.h (ldemul_print_symbol): New. (ld_emulation_xfer_type) <print_symbol): Likewise. * ldemul.c (ldemul_print_symbol): New. * ldlang.c (SECTION_NAME_MAP_LANGTH): Move to ... (print_one_symbol): Make global and move declaration to ... (print_all_symbols): Rename print_one_symbol to ldemul_print_symbol (print_input_section): Likewise * ldlang.h: ... here. * emultempl/aix.em (gld${EMULATION_NAME}_print_symbol): New. (ld_emulation_xfer_struct): Use it. * emultempl/armcoff.em (ld_emulation_xfer_struct): Add print_symbol and default to NULL. * emultempl/beos.em (ld_emulation_xfer_struct): Likewise * emultempl/elf.em (ld_emulation_xfer_struct): Likewise * emultempl/generic.em (ld_emulation_xfer_struct): Likewise * emultempl/linux.em (ld_emulation_xfer_struct): Likewise * emultempl/msp430.em (ld_emulation_xfer_struct): Likewise * emultempl/pe.em (ld_emulation_xfer_struct): Likewise * emultempl/pep.em (ld_emulation_xfer_struct): Likewise * emultempl/ticoff.em (ld_emulation_xfer_struct): Likewise * emultempl/vanilla.em (ld_emulation_xfer_struct): Likewise
2020-05-18Prevent a potential use-after-fee memory corruption bug in the linker (for ↵Nick Clifton1-6/+19
PE format files). PR 25993 * emultempl/pe.em (_after_open): Check for duplicate filename pointers before renaming the dll. * emultempl/pep.em (_after_open): Likewise.
2020-03-30Fix objcopy's --preserve-dates command line option so that it will work with ↵Nick Clifton1-1/+4
PE format files. PR binutils/pr25662 bfd * libcoff-in.h (struct pe_tdata): Rename the insert_timestamp field to timestamp and make it an integer. * libcoff.h: Regenerate. * peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Test the timestamp field in the pe_data structure rather than the insert_timestamp field. binutils* objcopy.c (copy_object): When copying PE format files set the timestamp field in the pe_data structure if the preserve_dates flag is set. * testsuite/binutils-all/objcopy.exp (objcopy_test) Use --preserve-dates in place of the -p option, in order to make its effect more obvious. ld * emultempl/pe.em (after_open): Replace initialisation of the insert_timestamp field in the pe_data structure with an initialisation of the timestamp field. * emultemp/pep.em: Likewise. * pe-dll.c (fill_edata): Use the timestamp field in the pe_data structure instead of the insert_timestamp field.
2020-02-06ELF: Discard a section if any of its linked-to sections has been discardedH.J. Lu1-0/+1
Add ldelf_before_place_orphans to call before lang_place_orphans to discard a section if any of its linked-to sections has been discarded. PR ld/25022 * emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Add before_place_orphans_default. * emultempl/armcoff.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/beos.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/generic.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/linux.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/msp430.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/pe.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/pep.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/ticoff.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/vanilla.em (ld_${EMULATION_NAME}_emulation): Likewise. * emultempl/elf.em (ld_${EMULATION_NAME}_emulation): Use ldelf_before_place_orphans. * ldelf.c (ldelf_before_place_orphans): New. * ldelf.h (ldelf_before_place_orphans): Likewise. * ldemul.c (ldemul_before_place_orphans): Likewise. (before_place_orphans_default): Likewise. * ldemul.h (ldemul_before_place_orphans): Likewise. (before_place_orphans_default): Likewise. (ld_emulation_xfer_struct): Add before_place_orphans. * ldlang.c (lang_process): Call ldemul_before_place_orphans before lang_place_orphans. * testsuite/ld-elf/pr25022.d: New file. * testsuite/ld-elf/pr25022.s: Likewise. * testsuite/ld-elf/pr25022.t: Likewise.
2020-01-03For PE format files, the base relocation table is necessary if the image is ↵Hannes Domani1-2/+9
loaded at a different image base than specified in the PE header. This patch provides a new option --enable-reloc-section to force the generation of this section. * emultempl/pe.em: Add new option --enable-reloc-section. * emultempl/pep.em: Likewise. * ld.texi: Document --enable-reloc-section. * pe-dll.c (pe_dll_build_sections): Use pe_dll_enable_reloc_section. (pe_dll_fill_sections): Simplify by calling pe_exe_fill_sections. * pe-dll.h: Add extern declaration of option flag. * pep-dll.c (pe_dll_enable_reloc_section): Add alias define for pep_dll_enable_reloc_section. * pep-dll.h: Add extern declaration of option flag.
2020-01-01Update year range in copyright notice of binutils filesAlan Modra1-1/+1