aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2020-10-22Automatic date update in version.inGDB Administrator1-1/+1
2020-10-21gdb: fix two comments in infrunSimon Marchi2-3/+7
These comments are stale, they refer to non-existent parameters. Fix that. gdb/ChangeLog: * infrun.c (displaced_step_in_progress_thread): Fix comment. (displaced_step_in_progress): Fix comment. Change-Id: I7a39f1338fbfbf73153b49cbca0345d495d12762
2020-10-21Remove libctf/mkerrors.sedTom Tromey7-114/+104
This patch removes libctf/mkerrors.sed, replacing it with a macro in ctf-api.h. This simplifies the build and avoids possible unportable code in the sed script. 2020-10-21 Tom Tromey <tromey@adacore.com> * ctf-api.h (_CTF_ERRORS): New macro. libctf/ChangeLog 2020-10-21 Tom Tromey <tromey@adacore.com> * mkerrors.sed: Remove. * ctf-error.c (_CTF_FIRST): New define. (_CTF_ITEM): Define this, not _CTF_STR. (_ctf_errlist, _ctf_erridx): Use _CTF_ERRORS. (ERRSTRFIELD): Rewrite. (ERRSTRFIELD1): Remove. * Makefile.in: Rebuild. * Makefile.am (BUILT_SOURCES): Remove. (ctf-error.h): Remove.
2020-10-21aarch64: Add testcase for HCR_EL2 system registerPrzemyslaw Wirkus2-0/+11
HCR_EL2 is a 64-bit Hypervisor Configuration Register. gas/ChangeLog: 2020-10-16 Przemyslaw Wirkus <przemyslaw.wirkus@arm.com> * testsuite/gas/aarch64/sysreg-6.d: New test. * testsuite/gas/aarch64/sysreg-6.s: New test.
2020-10-21Work around problem in DWARF decoding library which can result in attempts ↵Nick Clifton2-18/+36
to read arbitrary bytes as if they were an LEB128 encoded value. * dwarf.c (skip_attr_bytes): Accept DWARF versions higher than 4 when processing the DW_FORM_ref_addr form. Skip bytes in DW_FORM_block and DW_FORM_exprloc forms. Handle DW_FORM_indirect. (get_type_signedness): Allow a limited amount of recursion. Do not attempt to decode types that use the DW_FORM_ref_addr form. (read_and_display_attr_value): Do not attempt to decode types that use the DW_FORM_ref_addr form.
2020-10-21gdb: make gdbarch_make_corefile_notes return a unique ptrSimon Marchi7-122/+185
This patch starts by making the gdbarch_make_corefile_notes function return a gdb::unique_xmalloc_ptr<char> and takes care of the fallouts, mostly in linux-tdep.c and fbsd-tdep.c. The difficulty in these files is that they use the BFD API for writing core files, where you pass in a pointer to a malloc-ed buffer (or NULL in the beginning), it re-allocs it if needed, and returns you the possibly updated pointer. I therefore used this pattern everywhere: note_data.reset (elfcore_write_note (obfd, note_data.release (), ...) This hands over the ownership of note_data to the BFD function for the duration of the call, and then puts its back in note_data right after the call. gdb/ChangeLog: * gdbarch.sh (make_corefile_notes): Return unique pointer. * gdbarch.c: Re-generate. * gdbarch.h: Re-generate. * gcore.c (write_gcore_file_1): Adjust. * fbsd-tdep.c (struct fbsd_collect_regset_section_cb_data): Add constructor. <note_data>: Change type to unique pointer. <abort_iteration>: Change type to bool. (fbsd_collect_regset_section_cb): Adjust to unique pointer. (fbsd_collect_thread_registers): Return void, adjust. (struct fbsd_corefile_thread_data): Add construtor. <note_data>: Change type to unique pointer. (fbsd_corefile_thread): Adjust. (fbsd_make_corefile_notes): Return unique pointer, adjust. * linux-tdep.c (linux_make_mappings_corefile_notes): Change type to unique pointer, adjust. (struct linux_collect_regset_section_cb_data): Add constructor. <note_data>: Change type to unique pointer. <abort_iteration>: Change type to bool. (linux_collect_thread_registers): Return void, adjust. (struct linux_corefile_thread_data): Add constructor. <note_data>: Change type to unique pointer. (linux_corefile_thread): Adjust. (linux_make_corefile_notes): Return unique pointer, adjust. Change-Id: I1e03476bb47b87c6acb3e12204d193f38cc4e02b
2020-10-21gdbserver: fix overlap in sprintf argument and bufferSimon Marchi2-2/+9
While trying to build on Cygwin (gcc 10.2.0), I got: CXX server.o /home/Baube/src/binutils-gdb/gdbserver/server.cc: In function 'void handle_general_set(char*)': /home/Baube/src/binutils-gdb/gdbserver/server.cc:832:12: error: 'sprintf' argument 3 overlaps destination object 'own_buf' [-Werror=restrict] 832 | sprintf (own_buf, "E.Unknown thread-events mode requested: %s\n", | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 833 | mode); | ~~~~~ /home/Baube/src/binutils-gdb/gdbserver/server.cc:553:27: note: destination object referenced by 'restrict'-qualified argument 1 was declared here 553 | handle_general_set (char *own_buf) | ~~~~~~^~~~~~~ There is indeed a problem: mode points somewhere into own_buf. And by the time mode gets formatted as a %s, whatever it points to has been overwritten. I hacked gdbserver to coerce it into that error path, and this is the resulting message: (gdb) p own_buf $1 = 0x629000000200 "E.Unknown thread-events mode requested: ad-events mode requested: 00;10:9020fdf7ff7f0000;thread:p49388.49388;core:e;\n" Fix it by formatting the error string in an std::string first. gdbserver/ChangeLog: * server.cc (handle_general_set): Don't use sprintf with argument overlapping buffer. Change-Id: I4fdf05c0117f63739413dd67ddae7bd6ee414824
2020-10-21Fix gdb.mi/mi-fullname-deleted.exp with ClangGary Benson2-4/+27
gdb.mi/mi-fullname-deleted.exp attempts to generate an executable with a doubled slash in the source filename recorded in its debug info. This attempt fails when compiling using Clang, causing the substituted filename test to fail. This commit fixes this issue. It also expands the comments in the file, to clarify what the test is attempting to do, and to document where it doesn't succeed. gdb/testsuite/ChangeLog: * gdb.mi/mi-fullname-deleted.exp: Fix substituted fullname test with Clang. Also expand comments generally.
2020-10-21Automatic date update in version.inGDB Administrator1-1/+1
2020-10-20gdb: make gdbarch_displaced_step_hw_singlestep return boolSimon Marchi10-14/+28
Replace the int-used-as-a-bool with a bool. gdb/ChangeLog: * gdbarch.sh (displaced_step_hw_singlestep): Return bool. * gdbarch.c: Re-generate. * gdbarch.h: Re-generate. * aarch64-tdep.c (aarch64_displaced_step_hw_singlestep): Return bool. * aarch64-tdep.h (aarch64_displaced_step_hw_singlestep): Likewise. * arch-utils.h (default_displaced_step_hw_singlestep): Likewise. * arch-utils.c (default_displaced_step_hw_singlestep): Likewise. * rs6000-tdep.c (ppc_displaced_step_hw_singlestep): Likewise. * s390-tdep.c (s390_displaced_step_hw_singlestep): Likewise. Change-Id: I76a78366dc5c0afb03f8f4bddf9f4e8d68fe3114
2020-10-20gdb: make gdbarch predicates return boolSimon Marchi4-124/+130
gdbarch predicates (functions suffixed _p to check whether a gdbarch implements a given method) currently return int. Make them return bool. There is no expected behavior change. gdb/ChangeLog: * gdbarch.sh: Make generated predicates return bool. * gdbarch.c: Re-generate. * gdbarch.h: Re-generate. Change-Id: Ie7ebc1acae62df83da9085ba69327fca551c5a30
2020-10-20Remove varobj_item typedefTom Tromey2-2/+6
While working on some minor varobj cleanups, I noticed this obvious one: the varobj_item typedef isn't redundant in C++, and so can be removed. gdb/ChangeLog 2020-10-20 Tom Tromey <tom@tromey.com> * varobj-iter.h (struct varobj_item): Remove typedef.
2020-10-20Add AMD znver3 processor supportGanesh Gopalasubramanian25-4216/+4757
gas/ * config/tc-i386.c (cpu_arch): Add CPU_ZNVER3_FLAGS flags. (i386_align_code): Add PROCESSOR_ZNVER cases. * doc/c-i386.texi: Add znver3, snp, invlpgb and tlbsync. * gas/i386/i386.exp: Add new znver3 test cases. * gas/i386/arch-14-znver3.d: New. * gas/i386/arch-14.d: New. * gas/i386/arch-14.s: New. * gas/i386/invlpgb.d: New. * gas/i386/invlpgb64.d: New. * gas/i386/invlpgb.s: New. * gas/i386/snp.d: New. * gas/i386/snp64.d: New. * gas/i386/snp.s: New. * gas/i386/tlbsync.d: New. * gas/i386/tlbsync.s: New. * gas/i386/x86-64-arch-4-znver3.d: New. * gas/i386/x86-64-arch-4.d: New. * gas/i386/x86-64-arch-4.s: New. opcodes/ * i386-dis.c (rm_table): Add tlbsync, snp, invlpgb. * i386-gen.c (cpu_flag_init): Add new CPU_INVLPGB_FLAGS, CPU_TLBSYNC_FLAGS, and CPU_SNP_FLAGS. Add CPU_ZNVER3_FLAGS. (cpu_flags): Add CpuINVLPGB, CpuTLBSYNC, CpuSNP. * i386-opc.h: Add CpuINVLPGB, CpuTLBSYNC, CpuSNP. * i386-opc.tbl: Add invlpgb, tlbsync, psmash, pvalidate, rmpupdate, rmpadjust. * i386-init.h: Re-generated. * i386-tbl.h: Re-generated.
2020-10-20gdb: change some int to bool in infrun.cSimon Marchi2-70/+98
Change these int-used-as-a-bool to bool. I searched for "static int" in that file and changed what I found. gdb/ChangeLog: * infrun.c (currently_stepping): Change int to bool (maybe_software_singlestep): Likewise. (show_stop_on_solib_events): Likewise. (stepping_past_nonsteppable_watchpoint): Likewise. (displaced_step_in_progress_any_inferior): Likewise. (displaced_step_in_progress_thread): Likewise. (keep_going_stepped_thread): Likewise. (thread_still_needs_step_over): Likewise. (start_step_over): Likewise. (do_target_resume): Likewise. (resume_1): Likewise. (clear_proceed_status): Likewise. (thread_still_needs_step_over_bp): Likewise. (proceed): Likewise. (switch_back_to_stepped_thread): Likewise. (adjust_pc_after_break): Likewise. (stepped_in_from): Likewise. (handle_stop_requested): Likewise. (handle_syscall_event): Likewise. (handle_no_resumed): Likewise. (handle_inferior_event): Likewise. (finish_step_over): Likewise. (handle_signal_stop): Likewise. (process_event_stop_test): Likewise. Change-Id: I897527c4a3da5e647f9d97f7d4477649985b8b77
2020-10-20gdb: fix comment of get_displaced_stepping_stateSimon Marchi2-1/+5
The comment mentions PID instead of INF, fix that. gdb/ChangeLog: * infrun.c (get_displaced_stepping_state): Fix comment. Change-Id: Id9554807c50792db1fcdb7c14590397d1fa6f8f7
2020-10-20Fix undefined behavior in gdbserverTom Tromey2-1/+7
PR gdb/26742 points out some undefined behavior in gdbserver. The bug is that remove_thread does: free_one_thread (thread); if (current_thread == thread) current_thread = NULL; However, the equality check is undefined, because "thread" has already been freed. This patch fixes the bug by moving the check earlier. Tested on x86-64 Fedora 32. 2020-10-20 Tom Tromey <tromey@adacore.com> PR gdb/26742: * inferiors.cc (remove_thread): Clear current_thread before freeing the thread.
2020-10-20Fix help string of alias commandAndreas Schwab2-2/+6
* cli/cli-cmds.c (_initialize_cli_cmds): Fix alias command help.
2020-10-20[gdb/testsuite] Remove superfluous marker in pr13961.STom de Vries2-1/+4
When looking at readelf output for test-case gdb.dwarf2/pr13961.exp, we have: ... $ readelf -wi ./outputs/gdb.dwarf2/pr13961/pr13961 ... <0><14c>: Abbrev Number: 0 readelf: Warning: Bogus end-of-siblings marker detected at offset 14c in \ .debug_info section ... Fix this by removing the superfluous end-of-siblings marker. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-10-20 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/pr13961.S: Remove superfluous end-of-siblings marker.
2020-10-20[gdb/testsuite] Use main.c in gdb.dwarf2Tom de Vries21-232/+33
Eliminate copies of main.c in gdb.dwarf2. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-10-20 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/arr-stride.c: Remove. * gdb.dwarf2/arr-stride.exp: Use main.c. * gdb.dwarf2/arr-subrange.c: Remove. * gdb.dwarf2/arr-subrange.exp: Use main.c. * gdb.dwarf2/bad-regnum.c: Remove. * gdb.dwarf2/bad-regnum.exp: Use main.c. * gdb.dwarf2/corrupt.c: Remove. * gdb.dwarf2/corrupt.exp: Use main.c. * gdb.dwarf2/dw2-bad-elf.c: Remove. * gdb.dwarf2/dw2-bad-elf.exp: Use main.c. * gdb.dwarf2/dw2-icycle.c: Remove. * gdb.dwarf2/dw2-icycle.exp: Use main.c. * gdb.dwarf2/formdata16.c: Remove. * gdb.dwarf2/formdata16.exp: Use main.c. * gdb.dwarf2/implptrconst.c: Remove. * gdb.dwarf2/implptrconst.exp: Use main.c. * gdb.dwarf2/info-locals-optimized-out.c: Remove. * gdb.dwarf2/info-locals-optimized-out.exp: Use main.c. * gdb.dwarf2/opaque-type-lookup.c: Remove. * gdb.dwarf2/opaque-type-lookup.exp: Use main.c.
2020-10-20[gdb/testsuite] Clean up redundant info in gdb.dwarf2Tom de Vries3-2/+8
In gdb.dwarf2/ada-valprint-error.exp we find: ... untested ${testfile}.exp ... such that we have: ... UNTESTED: gdb.dwarf2/ada-valprint-error.exp: ada-valprint-error.exp ... Fix this and a likewise unsupported message in gdb.dwarf2/dw2-dir-file-name.exp. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-10-20 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/ada-valprint-error.exp: Remove redundant mention of .exp file. * gdb.dwarf2/dw2-dir-file-name.exp: Same.
2020-10-20[gdb/testsuite] Use $gdb_test_file_name in gdb.dwarf2Tom de Vries8-14/+22
In f.i. gdb.dwarf2/dw2-line-number-zero.exp we find: ... verbose "Skipping dw2-line-number-zero test." ... Make the skip messages use the gdb_test_file_name variable, to reduce the amount of changes that needs to be made when coping a test-case. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-10-20 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/dw2-error.exp: Use $gdb_test_file_name. * gdb.dwarf2/dw2-line-number-zero.exp: Same. * gdb.dwarf2/dw2-main-no-line-number.exp: Same. * gdb.dwarf2/dw2-ranges-base.exp: Same. * gdb.dwarf2/dw2-ranges.exp: Same. * gdb.dwarf2/dw2-vendor-extended-opcode.exp: Same. * gdb.dwarf2/var-access.exp: Same.
2020-10-20readelf.c display_lto_symtab offset outside bounds of constant stringAlan Modra2-37/+77
Using gcc-10 or current mainline gcc, binutils configured with --disable-nls results in: readelf.c: In function 'display_lto_symtab': readelf.c:12283:26: error: offset '17' outside bounds of constant string [-Werror=array-bounds] 12283 | SECTION_NAME (section) + strlen (".gnu.lto_.symtab.")) > 0 | ^ Which is actually a bogus warning in this case because we've already checked the name string for validity, so SECTION_NAME won't ever be "<none>", "<no-strings>" or "<corrupt>". This patch fixes the problem by making SECTION_NAME simply return the string from the string table. Other places also shouldn't be trying to match any of the error strings against a section name, so fix them too. * readelf.c: Delete whitespace at end of line throughout. (SECTION_NAME, SECTION_NAME_VALID): New. (SECTION_NAME_PRINT): Rename from SECTION_NAME. Formatting. (printable_section_name, dump_relocations): Use SECTION_NAME_PRINT. (process_section_headers, process_section_groups): Likewise. (shdr_to_ctf_sect): Likewise. (find_section, find_section_in_set): Use SECTION_NAME_VALID. (ia64_process_unwind, hppa_process_unwind): Likewise. (display_debug_section, initialise_dumps_byname): Likewise. (process_lto_symbol_tables): Likewise. Check trailing period of lto symbol table names. (display_lto_symtab): Use sizeof instead of strlen.
2020-10-20binutils: Add myself as RISC-V co-maintainer.Nelson Chu2-0/+5
binutils/ * MAINTAINERS (RISC-V): Add myself as RISC-V co-maintainer.
2020-10-20Automatic date update in version.inGDB Administrator1-1/+1
2020-10-19Don't erase TUI source window when switching focusTom Tromey5-7/+24
PR tui/26719 points out that switching the focus can erase the TUI source window. This is a regression introduced by the patch to switch the source window to using a pad. This patch fixes the bug by arranging to call prefresh whenever the window is refreshed. 2020-10-19 Tom Tromey <tromey@adacore.com> PR tui/26719 * tui/tui-winsource.h (struct tui_source_window_base) <refresh_window>: Rename from refresh_pad. * tui/tui-winsource.c (tui_source_window_base::refresh_window): Rename from refresh_pad. (tui_source_window_base::show_source_content) (tui_source_window_base::do_scroll_horizontal): Update. gdb/testsuite/ChangeLog 2020-10-19 Tom Tromey <tromey@adacore.com> PR tui/26719 * gdb.tui/list.exp: Check source window contents after focus change.
2020-10-19gdb/thread: fine-tune 'info threads' help textTankut Baris Aktemur2-3/+8
The help text of 'info threads' is below: (gdb) help info threads Display currently known threads. Usage: info threads [OPTION]... [ID]... Options: -gid Show global thread IDs.If ID is given, it is a space-separated list of IDs of threads to display. Otherwise, all threads are displayed. (gdb) I think the "If ID is given ..." info should have come right below the the usage line. This patch reorganizes the text so that we get (gdb) help info threads Display currently known threads. Usage: info threads [OPTION]... [ID]... If ID is given, it is a space-separated list of IDs of threads to display. Otherwise, all threads are displayed. Options: -gid Show global thread IDs. (gdb) gdb/ChangeLog: 2020-10-19 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * thread.c (_initialize_thread): Fine-tune the help text of 'info threads'.
2020-10-19gdb/frame: remove an unused type aliasTankut Baris Aktemur2-2/+4
Tested by rebuilding. gdb/ChangeLog: 2020-10-19 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * frame.c: Remove the unused 'uinteger_option_def' type alias.
2020-10-19gdb: get jiter objfile from a bound minsymMihails Strasuns2-8/+16
This fixes a regression introduced by the following commit: fe053b9e853 gdb/jit: pass the jiter objfile as an argument to jit_event_handler In the refactoring `handle_jit_event` function was changed to pass a matching objfile pointer to the `jit_event_handler` explicitly, rather using internal storage: ``` --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5448,8 +5448,9 @@ handle_jit_event (void) frame = get_current_frame (); gdbarch = get_frame_arch (frame); + objfile *jiter = symbol_objfile (get_frame_function (frame)); - jit_event_handler (gdbarch); + jit_event_handler (gdbarch, jiter); ``` This was needed to add support for multiple jiters. However it has also introduced a regression, because `get_frame_function (frame)` here may return `nullptr`, resulting in a crash. A more resilient way would be to use an approach mirroring `jit_breakpoint_re_set` - to find a minimal symbol matching the breakpoint location and use its object file. We know that this breakpoint event comes from a breakpoint set by `jit_breakpoint_re_set`, thus using the reverse approach should be reliable enough. gdb/Changelog: 2020-10-14 Mihails Strasuns <mihails.strasuns@intel.com> * breakpoint.c (handle_jit_event): Add an argument, change how `jit_event_handler` is called.
2020-10-19Readelf: Add --lto-syms option to display LTO symbol tables.Nick Clifton4-4/+289
* readelf.c (do_lto_syms): New local. (long_option_values): Add OPTION_LTO_SYMS. (options): Add --lto-syms. (usage): Mention the new option. (parse_args): Parse the new option. (get_lto_kind): New function. (get_lto_visibility): New function. (get_lto_sym_type): New function. (display_lto_symtab): New function - displays the contents of an LTo symbol table section. (process_lto_symbol_tables): New functions. Calls dipslay_lto_symtab on any LTO symbol table section. (process_object_file): Call process_lto_symbol_tables. * doc/binutils.texi: Document the new option. * NEWS: Mention the new feature.
2020-10-19Provide dummy libraries for alpha-vmsAlan Modra10-276/+98
alpha-dec-vms always loads a number of libraries, -limagelib, -lstarlet, and -lsys$public_vectors. When running the ld testsuite without a full cross-build environment, those libraries are missing and cause fails. This patch provides dummies, and tidies default.exp a little. * testsuite/config/default.exp: Provide dummy libraries for alpha-dec-vms. (compiler_supports): New proc. Use it for compiler tests. * testsuite/lib/ld-lib.exp (default_ld_assemble): Don't die if subdir not set. (run_ld_link_tests): Pass LDFLAGS to ld. * testsuite/ld-checks/checks.exp (section_check): Likewise. * testsuite/ld-scripts/assert.exp: Likewise. * testsuite/ld-scripts/extern.exp: Likewise. * testsuite/ld-scripts/log2.exp: Likewise. * testsuite/ld-scripts/map-address.exp: Likewise. * testsuite/ld-scripts/script.exp: Likewise. * testsuite/ld-scripts/sizeof.exp: Likewise.
2020-10-19Automatic date update in version.inGDB Administrator1-1/+1
2020-10-18Automatic date update in version.inGDB Administrator1-1/+1
2020-10-17Have partial symbol tables own psymbol vectorsTom Tromey10-468/+392
Currently pointers to all partial symbols are stored in two vectors; and then indices into these vectors are stored in each partial_symtab. This patch changes this so that each partial symtab instead has vectors of symbols. add_psymbol_to_list can now be changed into a method on partial_symtab as well. My main motivation for doing this is that I am looking into calling sort_pst_symbols in the background. However, I haven't actually implemented this yet. (Also this may make it more feasible to also sort the static psymbols, though I haven't tried that either.) Also, though, this lets us remove the "current_global_psymbols" vector, because now the callers can simply refer directly to the psymtab that they are modifying (formerly this was implicit). The main drawback of this patch is that it increases the size of partial symtab. gdb/ChangeLog 2020-10-17 Tom Tromey <tom@tromey.com> * xcoffread.c (xcoff_end_psymtab): Use partial_symtab::empty. (scan_xcoff_symtab): Update. * psymtab.h (class psymtab_storage) <global_psymbols, static_psymbols, current_global_psymbols, current_static_psymbols>: Remove. * psymtab.c (require_partial_symbols, find_pc_sect_psymbol) (match_partial_symbol, lookup_partial_symbol): Update. (print_partial_symbols): Change parameters. (dump_psymtab, recursively_search_psymtabs) (psym_fill_psymbol_map, psym_find_compunit_symtab_by_address) (sort_pst_symbols, partial_symtab::partial_symtab): Update. (concat): Remove. (end_psymtab_common): Simplify. (append_psymbol_to_list): Change parameters. (partial_symtabs::add_psymbol): Rename from add_psymbol_to_list. (init_psymbol_list): Simplify. (maintenance_info_psymtabs, maintenance_check_psymtabs): Update. * psympriv.h (struct partial_symtab) <empty>: New method. <globals_offset, n_global_syms, statics_offset, n_static_syms>: Remove. <global_psymbols, static_psymbols>: New members. <add_psymbol>: New methods. (add_psymbol_to_list): Don't declare. (psymbol_placement): Move earlier. * mdebugread.c (parse_partial_symbols): Update. (handle_psymbol_enumerators): Change parameters. (mdebug_expand_psymtab): Update. * dwarf2/read.c (process_psymtab_comp_unit_reader) (add_partial_symbol): Update. * dwarf2/index-write.c (write_psymbols): Change parameters. (write_one_signatured_type): Update. (recursively_count_psymbols): Update. (recursively_write_psymbols): Update. (class debug_names) <recursively_write_psymbols>: Update. <write_psymbols>: Change parameters. <write_one_signatured_type>: Update. * dbxread.c (read_dbx_symtab): Update. (dbx_end_psymtab): Use partial_symtab::empty. * ctfread.c (struct ctf_context) <pst>: New member. (create_partial_symtab): Set it. (ctf_psymtab_type_cb, ctf_psymtab_var_cb): Update. (scan_partial_symbols): Use the psymtab's context. Update.
2020-10-17Make range types inherit signed-ness from base typeTom Tromey4-27/+8
I ran across this comment in valprint.c: /* FIXME: create_static_range_type does not set the unsigned bit in a range type (I think it probably should copy it from the target type), so we won't print values which are too large to fit in a signed integer correctly. */ It seems to me that a range type ought to inherit its signed-ness from the underlying type, so this patch implements this change, and removes the comment. (It was also copied into m2-valprint.c.) I also remove the comment about handling ranges of enums, because I think that comment is incorrect. gdb/ChangeLog 2020-10-17 Tom Tromey <tom@tromey.com> * valprint.c (generic_value_print): Remove comment. * m2-valprint.c (m2_value_print_inner): Remove comment. * gdbtypes.c (create_range_type): Set TYPE_UNSIGNED from base type.
2020-10-17gas: Add a -gdwarf-5 debug_line test with .s fileH.J. Lu4-0/+62
PR gas/25878 PR gas/26740 * testsuite/gas/i386/dwarf5-line-4.d: New file. * testsuite/gas/i386/dwarf5-line-4.s: Likewise. * testsuite/gas/i386/i386.exp: Run dwarf5-line-4.
2020-10-17gas: Replace dwarf5-line-2.S with dwarf5-line-3.SH.J. Lu3-4/+12
PR gas/25878 PR gas/26740 * testsuite/gas/i386/dwarf5-line-3.s: Replace dwarf5-line-2.S with dwarf5-line-3.S. * testsuite/gas/i386/dwarf5-line-3.d: Updated.
2020-10-17gas: Always use as_where for preprocessed assembly codesH.J. Lu7-19/+155
Always clear the slot 1 if it was assigned to the input file before the first .file <NUMBER> directive has been seen. Always use as_where to generate the correct debug infor for preprocessed assembly codes. PR gas/25878 PR gas/26740 * dwarf2dbg.c (allocate_filename_to_slot): Don't reuse the slot 1 here. (dwarf2_where): Restore as_where. (dwarf2_directive_filename): Clear the slot 1 if it was assigned to the input file. * testsuite/gas/i386/dwarf5-line-2.d: New file. * testsuite/gas/i386/dwarf5-line-2.s: Likewise. * testsuite/gas/i386/dwarf5-line-3.d: Likewise. * testsuite/gas/i386/dwarf5-line-3.s: Likewise. * testsuite/gas/i386/i386.exp: Run dwarf5-line-2 and dwarf5-line-3.
2020-10-17Automatic date update in version.inGDB Administrator1-1/+1
2020-10-17[gdb/symtab] Handle setting line bp without debug line infoTom de Vries4-1/+85
When setting a breakpoint on a line in an executable without debug line info, we run into an abort. The problem occurs when calling set_default_source_symtab_and_line, which calls select_source_symtab (0), which is where we try to find the line number for main: ... /* Make the default place to list be the function `main' if one exists. */ block_symbol bsym = lookup_symbol (main_name (), 0, VAR_DOMAIN, 0); if (bsym.symbol != nullptr && SYMBOL_CLASS (bsym.symbol) == LOC_BLOCK) { symtab_and_line sal = find_function_start_sal (bsym.symbol, true); loc->set (sal.symtab, std::max (sal.line - (lines_to_list - 1), 1)); return; } ... However, due to the missing debug line info, find_function_start_sal returns a sal with sal.symtab == 0: ... (gdb) p /x sal $2 = {pspace = 0x1a4a7f0, symtab = 0x0, symbol = 0x1d9e480, section = 0x1d5b398, msymbol = 0x0, line = 0x0, pc = 0x4004ab, end = 0x0, explicit_pc = 0x0, explicit_line = 0x0, is_stmt = 0x0, prob = 0x0, objfile = 0x0} ... which eventually causes an segfault in create_sals_line_offset because self->default_symtab->filename is accessed while self->default_symtab == NULL. Fix this by handling sal.symtab == NULL in select_source_symtab. Tested on x86_64-linux. gdb/ChangeLog: 2020-10-17 Tom de Vries <tdevries@suse.de> PR symtab/26317 * source.c (select_source_symtab): Handling sal.symtab == NULL for symbol main. gdb/testsuite/ChangeLog: 2020-10-17 Tom de Vries <tdevries@suse.de> PR symtab/26317 * gdb.dwarf2/dw2-main-no-line-number.exp: New file.
2020-10-17[gdb/testsuite] Remove hardcoded filenames in gdb.dwarf2/*.expTom de Vries64-82/+138
There's a common occurance in dwarf assembly test-cases, where a file test.exp contains: ... standard_testfile test.c test-dw.S ... The "test.c" arg can be abbreviated to ".c". Make standard_testfile treat args with "-" prefix the same as with "." prefix, such that we can write: ... standard_testfile .c -dw.S ... and apply this in gdb.dwarf2/*.exp. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-10-17 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (standard_testfile): Also treat args starting with '-' as suffix. * gdb.dwarf2/atomic.c: Rename to ... * gdb.dwarf2/atomic-type.c: ... this. * gdb.dwarf2/dw2-ranges2.c: Rename to ... * gdb.dwarf2/dw2-ranges-2.c: ... this. * gdb.dwarf2/dw2-ranges3.c: Rename to ... * gdb.dwarf2/dw2-ranges-3.c: ... this. * gdb.dwarf2/fission-mix2.c: Rename to ... * gdb.dwarf2/fission-mix-2.c: ... this. * gdb.dwarf2/ada-linkage-name.exp: Use more suffix args for standard_testfile. * gdb.dwarf2/ada-valprint-error.exp: Same. * gdb.dwarf2/arr-stride.exp: Same. * gdb.dwarf2/arr-subrange.exp: Same. * gdb.dwarf2/atomic-type.exp: Same. * gdb.dwarf2/bad-regnum.exp: Same. * gdb.dwarf2/break-inline-psymtab.exp: Same. * gdb.dwarf2/clang-debug-names-2.exp: Same. * gdb.dwarf2/clang-debug-names.exp: Same. * gdb.dwarf2/comp-unit-lang.exp: Same. * gdb.dwarf2/corrupt.exp: Same. * gdb.dwarf2/count.exp: Same. * gdb.dwarf2/cpp-linkage-name.exp: Same. * gdb.dwarf2/data-loc.exp: Same. * gdb.dwarf2/dw2-align.exp: Same. * gdb.dwarf2/dw2-bad-elf.exp: Same. * gdb.dwarf2/dw2-bad-mips-linkage-name.exp: Same. * gdb.dwarf2/dw2-bad-unresolved.exp: Same. * gdb.dwarf2/dw2-case-insensitive.exp: Same. * gdb.dwarf2/dw2-cp-infcall-ref-static.exp: Same. * gdb.dwarf2/dw2-ifort-parameter.exp: Same. * gdb.dwarf2/dw2-inline-many-frames.exp: Same. * gdb.dwarf2/dw2-inline-param.exp: Same. * gdb.dwarf2/dw2-inline-small-func.exp: Same. * gdb.dwarf2/dw2-inline-stepping.exp: Same. * gdb.dwarf2/dw2-is-stmt-2.exp: Same. * gdb.dwarf2/dw2-is-stmt.exp: Same. * gdb.dwarf2/dw2-line-number-zero.exp: Same. * gdb.dwarf2/dw2-namespaceless-anonymous.exp: Same. * gdb.dwarf2/dw2-opt-structptr.exp: Same. * gdb.dwarf2/dw2-param-error.exp: Same. * gdb.dwarf2/dw2-ranges-base.exp: Same. * gdb.dwarf2/dw2-ranges.exp: Same. * gdb.dwarf2/dw2-unusual-field-names.exp: Same. * gdb.dwarf2/dw2-vendor-extended-opcode.exp: Same. * gdb.dwarf2/dw4-sig-types.exp: Same. * gdb.dwarf2/dynarr-ptr.exp: Same. * gdb.dwarf2/enum-type.exp: Same. * gdb.dwarf2/fission-mix.exp: Same. * gdb.dwarf2/formdata16.exp: Same. * gdb.dwarf2/implptrconst.exp: Same. * gdb.dwarf2/implptrpiece.exp: Same. * gdb.dwarf2/info-locals-optimized-out.exp: Same. * gdb.dwarf2/main-subprogram.exp: Same. * gdb.dwarf2/method-ptr.exp: Same. * gdb.dwarf2/missing-sig-type.exp: Same. * gdb.dwarf2/nonvar-access.exp: Same. * gdb.dwarf2/opaque-type-lookup.exp: Same. * gdb.dwarf2/shortpiece.exp: Same. * gdb.dwarf2/staticvirtual.exp: Same. * gdb.dwarf2/subrange.exp: Same. * gdb.dwarf2/symtab-producer.exp: Same. * gdb.dwarf2/typedef-void-finish.exp: Same. * gdb.dwarf2/var-access.exp: Same. * gdb.dwarf2/variant.exp: Same. * gdb.dwarf2/void-type.exp: Same. * gdb.dwarf2/dw2-ranges-psym.exp: Same. Use main.c instead of dw2-ranges-main.c. * gdb.dwarf2/dw2-ranges-main.c: Remove.
2020-10-16ld: Allow symbols from PROVIDE to be use in MEMORY regionsAndrew Burgess11-20/+118
I wanted to write a linker script like this: PROVIDE(mem_origin = 0x1000); PROVIDE(mem_length = 0x1000); MEMORY { REGION : ORIGIN = mem_origin, LENGTH = mem_length } .... Then when I link using this script I can optionally supply: --defsym=mem_origin=..... --defsym=mem_length=.... to override the defaults. And though passing `--defsym' does work, if I remove the use of `--defsym' and just rely on the defaults I get an error: ld-new: invalid origin for memory region REGION Interestingly, if I make the above error non-fatal and dump a linker map file I see that (a) REGION has origin 0x0, and length 0xffff..., and (b) the symbol from the PROVIDE is provided. An examination of ldlang.c:lang_process shows us what the issue is, the origin and length of all memory regions are set as a result of a single call to lang_do_memory_regions, this call is done after calling open_input_bfds. During the open_input_bfds call provide statements can be converted to provided statements if we know that the assigned symbol is needed, but for symbols that are only used in the memory regions we are unaware that we need these symbols. What I propose in this patch is to make two calls to lang_do_memory_regions, in the first call we process the expressions for the origin and length fields of each region, however, errors, especially undefined symbols, will be ignored. The origin and length values are not updated. However, by evaluating the expressions any symbols we need will be added to the symbol table. Now when we call open_input_bfds, when we process the provide statements, we will see that the assigned symbol is needed add its new value to the symbol table. Finally we reach the original call to lang_do_memory_regions, in this (now second) call we again process the expressions, and this time update the origin and length values. Any errors encountered now are reported to the user. ld/ChangeLog: * ldlang.c (lang_process): Add extra call to lang_do_memory_regions, and pass parameter. (lang_do_memory_regions): Add parameter, only define origin and length when requested. Reindent. * testsuite/ld-scripts/provide-10.d: New file. * testsuite/ld-scripts/provide-10.map: New file. * testsuite/ld-scripts/provide-11.d: New file. * testsuite/ld-scripts/provide-11.map: New file. * testsuite/ld-scripts/provide-12.d: New file. * testsuite/ld-scripts/provide-12.map: New file. * testsuite/ld-scripts/provide-9.d: New file. * testsuite/ld-scripts/provide-9.map: New file. * testsuite/ld-scripts/provide-9.t: New file.
2020-10-16ld: More documentation for --defsymAndrew Burgess2-0/+13
The ordering of command line options --defsym and -T is important, however, the description of --defsym in the manual doesn't mention this. This commit adds more text to the description of --defsym to try and explain this ordering requirement. ld/ChangeLog: * ld.texi (Options): Extend the description of --defsym.
2020-10-16gas: Reuse the input file entry in the file tableH.J. Lu5-19/+84
Some instructions can be emitted (dwarf2_emit_insn is called) before the first .file <NUMBER> directive has been seen, which allocates the input file as the first file entry. Reuse the input file entry in the file table. PR gas/25878 PR gas/26740 * dwarf2dbg.c (file_entry): Remove auto_assigned. (assign_file_to_slot): Remove the auto_assign argument. (allocate_filenum): Updated. (allocate_filename_to_slot): Reuse the input file entry in the file table. (dwarf2_where): Replace as_where with as_where_physical. * testsuite/gas/i386/dwarf5-line-1.d: New file. * testsuite/gas/i386/dwarf5-line-1.s: Likewise. * testsuite/gas/i386/i386.exp: Run dwarf5-line-1.
2020-10-16Add a new option to the linker: --error-handling-script=<NAME>. Run the ↵Nick Clifton11-2/+178
script <NAME> if an undefined symbol or unfound library error is encountered. PR 26626 * ldmain.c (undefined_symbol): If an error handlign script is available, call it. * ldfile.c (error_handling_script): Declare. (ldfile_open_file): If a library cannot be found and an error handling script is available, call it. * ldmain.h (error_handling_script): Prototype. * ldlex.h (OPTION_ERROR_HANDLING_SCRIPT): Define. * lexsup.c (ld_options): Add --error-handling-script. (parse_args): Add support for --errror-handling-script. * ld.texi: Document the new feature. * configure.ac: Add --error-handling-script option to disable support for the new feature. * NEWS: Mention the new feature. * config.in: Regenerate. * configure: Regenerate.
2020-10-16[gdb/testsuite] Fix function comment for gdb_breakpointTom de Vries2-1/+5
Commit 5b7d00507b adds a mention at gdb_breakpoint of a supported argument "passfail". There's no corresponding argument handling though. Remove the mention of the "passfail" argument. gdb/testsuite/ChangeLog: 2020-10-16 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (gdb_breakpoint): Remove mention of "passfail".
2020-10-16[gdb/testsuite] Be more verbose about abort in gdb_breakpointTom de Vries2-0/+8
I noticed that an abort when setting a breakpoint does not result in more than: ... (gdb) break 27^M FAIL: gdb.a/b.exp: setting breakpoint at 27 (eof) ... Handle this more verbosely, as is done in gdb_test_multiple, such that we have instead: ... (gdb) break 27^M ERROR: GDB process no longer exists GDB process exited with wait status 29309 exp9 0 0 CHILDKILLED SIGABRT SIGABRT UNRESOLVED: gdb.a/b.exp: setting breakpoint at 27 (eof) ... Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-10-16 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (gdb_breakpoint): Handle eof as in gdb_test_multiple.
2020-10-16Enhancement for avx-vnni patchCui,Lili17-11456/+11480
1. Rename CpuVEX_PREFIX to PseudoVexPrefix and move it from cpu_flags to opcode_modifiers. 2. Delete {vex2} invalid test. 3. Use VexW0 and VexVVVV in the AVX-VNNI instructions. gas/ * config/tc-i386.c: Move Pseudo Prefix check to match_template. * testsuite/gas/i386/avx-vnni-inval.l: New file. * testsuite/gas/i386/avx-vnni-inval.s: Likewise. * testsuite/gas/i386/avx-vnni.d: Delete invalid {vex2} test. * testsuite/gas/i386/avx-vnni.s: Likewise. * testsuite/gas/i386/i386.exp: Add AVX VNNI invalid tests. * testsuite/gas/i386/x86-64-avx-vnni-inval.l: New file. * testsuite/gas/i386/x86-64-avx-vnni-inval.s: Likewise. * testsuite/gas/i386/x86-64-avx-vnni.d: Delete invalid {vex2} test. * testsuite/gas/i386/x86-64-avx-vnni.s: Likewise. opcodes/ * i386-opc.tbl: Rename CpuVEX_PREFIX to PseudoVexPrefix and move it from cpu_flags to opcode_modifiers. Use VexW0 and VexVVVV in the AVX-VNNI instructions. * i386-gen.c: Likewise. * i386-opc.h: Likewise. * i386-opc.h: Likewise. * i386-init.h: Regenerated. * i386-tbl.h: Likewise.
2020-10-16RISC-V: Fix that IRELATIVE relocs may be inserted to the wrong place.Nelson Chu9-7/+140
For the ifunc symbol, which is referenced by GOT rather than PLT relocs, we should add the dynamic reloc (usually IRELATIVE) into the .rel.iplt when generating the static executable. But if we use riscv_elf_append_rela to add the dynamic relocs into .rela.iplt, this may cause the overwrite problem. The reason is that we don't handle the `reloc_index` of .rela.iplt, but the riscv_elf_append_rela adds the relocs to the place that are calculated from the reloc_index (in seqential). Therefore, we may overwrite the dynamic relocs when the `reloc_index` of .rela.iplt isn't handled correctly. One solution is that we can add these dynamic relocs (GOT ifunc) from the last of .rela.iplt section. But I'm not sure if it is the best way. bfd/ * elfnn-riscv.c (riscv_elf_link_hash_table): Add last_iplt_index. (riscv_elf_size_dynamic_sections): Initialize the last_iplt_index. (riscv_elf_relocate_section): Use riscv_elf_append_rela. (riscv_elf_finish_dynamic_symbol): If the use_elf_append_rela is false, then we should add the dynamic relocs from the last of the .rela.iplt, and don't use the riscv_elf_append_rela to add. ld/ * testsuite/ld-riscv-elf/ifunc-plt-got-overwrite.s: New testcase. * testsuite/ld-riscv-elf/ifunc-plt-got-overwrite.d: Likewise. * testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-exe.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-pic.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-pie.rd: Likewise. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
2020-10-16RISC-V: Support GNU indirect functions.Nelson Chu63-53/+1523
Generally, glibc dynamic linker should have two ways to deal with ifunc - one is to handle the IRELATIVE relocations for the non-preemtive ifunc symbols, the other is to handle the R_RISCV_32/64 and R_RISCV_JUMP_SLOT relocations with the STT_IFUNC preemtive symbols. No matter which method is used, both of them should get the resolved ifunc symbols at runtime. Therefore, linker needs to generate the correct dynamic relocations for ifunc to make sure the the dynamic linker works well. For now, there are thirteen relocations are supported for ifunc in GNU ld, * R_RISCV_CALL and R_RISCV_CALL_PLT: The RISC-V compiler won't generate R_RISCV_JAL directly to jump to an ifunc. Besides, we disable the relaxations for the relocation referenced to ifunc, so just handling the R_RISCV_CALL and R_RISCV_CALL_PLT should be enough. Linker should generate a .plt entry and a .got.plt entry for it, and also needs to insert a dynamic IRELATIVE in the .got.plt enrty, or insert a R_RISCV_JUMP_SLOT when generating shared library. * R_RISCV_PCREL_HI20 and R_RISCV_PCREL_LO12_I/S: LA/LLA pattern with local fPIC ifunc symbol, or any non-PIC ifunc symbol. The PC-relative relocation. The current linker will deal with them in the same way as R_RISCV_CALL_PLT. * R_RISCV_GOT_HI20 and R_RISCV_PCREL_LO12_I/S: LA pattern with global PIC ifunc symbol. Linker should insert a dynamic IRELATIVE in the .got entry, or insert a R_RISCV_32/64 when generating shared library. * R_RISCV_32 and R_RISCV_64: Store the ifunc symbol into the data section. Linker should insert a dynamic IRELATIVE in the data section, or insert a R_RISCV_32/64 when generating shared library. * R_RISCV_HI20 and R_RISCV_LO12_I/S: The LUI + ADDI/LW/SW patterns. The absolute access relocation. The medlow model without the -fPIC compiler option should generate them. The ld ifunc testsuites "Build pr23169a" and "Build pr23169d" need the relocations, they are in the ld/testsuite/ld-ifunc/, and need compiler support. However, we also made some optimizations with reference to x86, * If GOT and PLT relocations refer to the same ifunc symbol when generating pie, then they can actually share a .got entry without creating two entries to store the same value and relocation. * If GOT, PLT and DATA relocations refer to the same ifunc symbol when generating position dependency executable, then linker will fill the address of .plt entry into the corresponding .got entry and data section, without insert any dynamic relocations for the GOT and DATA relocations. For the ifunc testcases, there are three types of them, 1. ifunc-reloc-*: Only check the single type of relocation refers to ifunc symbol. * ifunc-reloc-call: R_RISCV_CALL and R_RISCV_CALL_PLT. * ifunc-reloc-data: R_RISCV_32 and R_RISCV_64. * ifunc-reloc-got: R_RISCV_GOT_HI20 and R_RISCV_PCREL_LO_I/S. * ifunc-reloc-pcrel: R_RISCV_PCREL_HI20 and R_RISCV_PCREL_LO_I/S. 2. ifunc-[nonplt|plt]-*: If we don't have PLT relocs, then don't need to create the PLT and it's .plt entries. * ifunc-nonplt: Combine R_RISCV_GOT_HI20 and R_RISCV_32/64. * ifunc-plt: Combine all ifunc relocations. 3. ifunc-seperate-*: If we link the ifunc caller and resolver into the same module (link the objects), then the results are the same as the ifunc-reloc-* and ifunc-[noplt|plt]-* testcases. Consider the cases that the ifunc callers and resolver are in the different modules, that is, we compile the ifunc resolver to the shared library first, and then link it with the ifunc callers. The output of ifunc callers should be the same as the normal STT_FUNC cases, and the shared ifunc resolver should define the symbols as STT_IFUNC. The R_RISCV_PCREL_HI20 reloc is special. It should be linked and resolved locally, so if the ifunc resolver is defined in other modules (other shared libraries), then the R_RISCV_PCREL_HI20 is unresolvable, and linker should issue an unresolvable reloc error. bfd/ * elfnn-riscv.c: Include "objalloc.h" since we need objalloc_alloc. (riscv_elf_link_hash_table): Add loc_hash_table and loc_hash_memory for local STT_GNU_IFUNC symbols. (riscv_elf_got_plt_val): Removed. (riscv_elf_local_htab_hash, riscv_elf_local_htab_eq): New functions. Use to compare local hash entries. (riscv_elf_get_local_sym_hash): New function. Find a hash entry for local symbol, and create a new one if needed. (riscv_elf_link_hash_table_free): New function. Destroy an riscv elf linker hash table. (riscv_elf_link_hash_table_create): Create hash table for local ifunc. (riscv_elf_check_relocs): Create a fake global symbol to track the local ifunc symbol. Add support to check and handle the relocations reference to ifunc symbols. (allocate_dynrelocs): Let allocate_ifunc_dynrelocs and allocate_local_ifunc_dynrelocs to handle the ifunc symbols if they are defined and referenced in a non-shared object. (allocate_ifunc_dynrelocs): New function. Allocate space in .plt, .got and associated reloc sections for ifunc dynamic relocs. (allocate_local_ifunc_dynrelocs): Likewise, but for local ifunc dynamic relocs. (riscv_elf_relocate_section): Add support to handle the relocation referenced to ifunc symbols. (riscv_elf_size_dynamic_sections): Updated. (riscv_elf_adjust_dynamic_symbol): Updated. (riscv_elf_finish_dynamic_symbol): Finish up the ifunc handling, including fill the PLT and GOT entries for ifunc symbols. (riscv_elf_finish_local_dynamic_symbol): New function. Called by riscv_elf_finish_dynamic_symbol to handle the local ifunc symbols. (_bfd_riscv_relax_section): Don't do the relaxation for ifunc. * elfxx-riscv.c: Add R_RISCV_IRELATIVE. * configure.ac: Link elf-ifunc.lo to use the generic ifunc support. * configure: Regenerated. include/ * elf/riscv.h: Add R_RISCV_IRELATIVE to 58. ld/ * emulparams/elf32lriscv-defs.sh: Add IREL_IN_PLT. * testsuite/ld-ifunc/ifunc.exp: Enable ifunc tests for RISC-V. * testsuite/ld-riscv-elf/ld-riscv-elf.exp (run_dump_test_ifunc): New dump test for ifunc. There are two arguments, 'target` and `output`. The `target` is rv32 or rv64, and the `output` is used to choose which output you want to test (exe, pie or .so). * testsuite/ld-riscv-elf/ifunc-reloc-call-01.s: New testcase. * testsuite/ld-riscv-elf/ifunc-reloc-call-01.d: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-call-01-exe.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-call-01-pic.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-call-01-pie.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-call-02.s: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-call-02.d: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-call-02-exe.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-call-02-pic.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-call-02-pie.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-data.s: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-data.d: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-data-exe.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-data-pic.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-data-pie.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-got.s: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-got.d: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-got-exe.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-got-pic.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-got-pie.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-pcrel.s: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-pcrel.d: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-pcrel-exe.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-pcrel-pic.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-reloc-pcrel-pie.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-nonplt.s: Likewise. * testsuite/ld-riscv-elf/ifunc-nonplt.d: Likewise. * testsuite/ld-riscv-elf/ifunc-nonplt-exe.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-nonplt-pic.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-nonplt-pie.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-plt-01.s: Likewise. * testsuite/ld-riscv-elf/ifunc-plt-01.d: Likewise. * testsuite/ld-riscv-elf/ifunc-plt-01-exe.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-plt-01-pic.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-plt-01-pie.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-plt-02.s: Likewise. * testsuite/ld-riscv-elf/ifunc-plt-02.d: Likewise. * testsuite/ld-riscv-elf/ifunc-plt-02-exe.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-plt-02-pic.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-plt-02-pie.rd: Likewise. * testsuite/ld-riscv-elf/ifunc-seperate-resolver.s: Likewise. * testsuite/ld-riscv-elf/ifunc-seperate-caller.s: Likewise. * testsuite/ld-riscv-elf/ifunc-seperate-exe.d: Likewise. * testsuite/ld-riscv-elf/ifunc-seperate-pic.d: Likewise. * testsuite/ld-riscv-elf/ifunc-seperate-pie.d: Likewise. * testsuite/ld-riscv-elf/ifunc-seperate-caller-pcrel.s: Likewise. * testsuite/ld-riscv-elf/ifunc-seperate-pcrel-pic.d: Likewise. * testsuite/ld-riscv-elf/ifunc-seperate-pcrel-pie.d: Likewise.
2020-10-16elf32-arc.c: Don't cast between function pointer and void pointerAlan Modra2-4/+10
Casts should be avoided if at all possible, and in particular the C standard doesn't promise that function pointers can be cast to void* or vice-versa. It is only mentioned under J.5 Common extensions, saying "The following extensions are widely used in many systems, but are not portable to all implementations." * elf32-arc.c (replace_func): Correct return type. (get_replace_function): Use a replace_func function pointer rather than void*. Update associated ARC_RELOC_HOWTO define.