aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-04-15LoongArch: ld:Report an error when seeing an unrecognized relocationLulu Cai1-2/+7
If we generate an object file using an assembler with the new relocations added, and then linking those files with an older linker, the link will still complete and the linked file will be generated. In this case we should report an error instead of continuing the linking process.
2024-04-15Automatic date update in version.inGDB Administrator1-1/+1
2024-04-14Automatic date update in version.inGDB Administrator1-1/+1
2024-04-13Automatic date update in version.inGDB Administrator1-1/+1
2024-04-12Fix setting watchpoints when current thread is runningPedro Alves3-4/+192
Currently, when the current thread is running, you can print global variables. However, if you try to set a watchpoint on the same globals, GDB errors out, complaining that the selected thread is running. Like so: (gdb) c& Continuing. (gdb) p global $1 = 1098377287 (gdb) watch global Selected thread is running. This patch makes setting the watchpoint work. You'll now get: (gdb) c& Continuing. (gdb) [New Thread 0x7ffff7d6e640 (LWP 434993)] [New Thread 0x7ffff756d640 (LWP 434994)] p global $1 = 88168 (gdb) watch global Hardware watchpoint 2: global (gdb) [Switching to Thread 0x7ffff7d6e640 (LWP 434993)] Thread 2 "function0" hit Hardware watchpoint 2: global Old value = 185420 New value = 185423 int_return () at threads.c:39 39 } The problem is that update_watchpoint calls get_selected_frame unconditionally. We can skip it if the watchpoint expression is only watching globals. This adds a testcase that exercises both all-stop and non-stop, and also software and hardware watchpoints. It is kfailed for software watchpoints, as those require another fix not handled by this patch (the sw watchpoint doesn't fire because GDB doesn't force the running-free thread to switch to single-stepping). Change-Id: I68ca948541aea3edd4f70741f272f543187abe40
2024-04-12New testcase gdb.threads/leader-exit-attach.exp (PR threads/8153)Pedro Alves1-0/+87
Add a new testcase for exercising attaching to a process after its main thread has exited. This is not possible on Linux, the kernel does not allow attaching to a zombie task, so the test is kfailed there. It is possible however on Windows at least, and was the scenario addressed by the Windows backend fix in https://sourceware.org/legacy-ml/gdb-patches/2003-12/msg00479.html, nowadays PR threads/8153, back in 2003. Passes cleanly on Cygwin. KFAILed on GNU/Linux native and gdbserver. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=8153 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31554 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31555 Change-Id: Ib554f92f68c965bb4603cdf2aadb55ca45ded53b
2024-04-12Cygwin/testsuite: Avoid infinite hangPedro Alves1-1/+1
On Cygwin, the gdb.base/fork-no-detach-follow-child-dlopen.exp testcase hits a sequence of cascading FAILs: (gdb) run Starting program: ..../gdb.base/fork-no-detach-follow-child-dlopen/fork-no-detach-follow-child-dlopen [New Thread 12672.0x318c] [New Thread 12672.0x2844] [New Thread 12672.0x714] FAIL: gdb.base/fork-no-detach-follow-child-dlopen.exp: runto: run to add (timeout) frame FAIL: gdb.base/fork-no-detach-follow-child-dlopen.exp: frame (timeout) list FAIL: gdb.base/fork-no-detach-follow-child-dlopen.exp: list (timeout) And the test program never makes progress. ... and at this point, Cygwin is completely stuck. I can't run any other Cygwin program. However, if we run the test program outside DejaGnu, we see something different: (gdb) b add Function "add" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (add) pending. (gdb) r Starting program: ..../gdb.base/fork-no-detach-follow-child-dlopen/fork-no-detach-follow-child-dlopen [New Thread 10968.0x834] [New Thread 10968.0x29a4] [New Thread 10968.0x16b8] [New Thread 10968.0xf9c] [Switching to Thread 10968.0x16b8] Thread 4 "sig" hit Breakpoint 1.2, pending_signals::add (pack=..., this=0x7ffa1e748a40 <sigq>) at /usr/src/debug/cygwin-3.4.9-1/winsup/cygwin/sigproc.cc:1304 1304 se = sigs + pack.si.si_signo; (gdb) Ah, the test wanted to run to a global "add" function, but managed to stop at an internal Cygwin method called "add". And stopping there deadlocks everything Cygwin in the system. (I believe some cygwin1.dll mechanisms use cross-process synchronization or communication, we're probably blocking something like that.) Fix this by using "break -q". The tests FAIL because we don't support follow-fork for Cygwin, but at least we no longer deadlock the machine. Approved-by: Kevin Buettner <kevinb@redhat.com> Change-Id: I7181d8481c2ae1024b0d73e3bb194f9a4f0a7eb9
2024-04-12gdb/data-directory: silence output from mkinstalldirs scriptAndrew Burgess1-1/+1
After my recent changes the data-directory build now uses silent-rules.mk to reduce the output. One problem that remains was the use of mkinstalldirs by stamp-python and stamp-guile for creating some directories, the mkinstalldirs prints some messages, so we're left with output like this: GEN stamp-python mkdir -p -- ./python/gdb mkdir -p -- ./python/gdb/command mkdir -p -- ./python/gdb/dap mkdir -p -- ./python/gdb/function mkdir -p -- ./python/gdb/printer I was looking at adding a --silent option to the mkinstalldirs script, however, when I took a look at the automake package (which is where mkinstalldirs comes from) it turns out that mkinstalldirs is deprecated, at the advice is to use 'install-sh -d' instead. Just like we carry mkinstalldirs in the top-level directory, we also carry install-sh, and a version of install-sh which supports the -d flag. And best of all, 'install-sh -d' doesn't appear to print any of the information messages to stdout that mkinstalldirs does, so if we switch to use that, we get a quieter build. There should be no changes in what is built after this commit Approved-By: Tom Tromey <tom@tromey.com>
2024-04-12Update description of macro keyword argument assignment in assembler ↵Nick Clifton1-1/+34
documentation. PR 31255
2024-04-12gas: Fix memory leaks in gen-sframe.cH.J. Lu1-0/+4
* gen-sframe.c (sframe_xlate_ctx_cleanup): Call XDELETE on xlate_ctx->cur_fre. (create_sframe_all): Call XDELETE on xlate_ctx after use.
2024-04-12Automatic date update in version.inGDB Administrator1-1/+1
2024-04-12Re: Fix null pointer dereference in process_debug_info()Alan Modra1-11/+8
read_bases has a potential null-pointer deref too, and without a debug_info_p there isn't any point in calling read_bases. * dwarf.c (process_debug_info): Don't call read_bases when debug_info_p is NULL.
2024-04-11Improve readelf's display of RELR relocs.Nick Clifton17-168/+420
2024-04-11Add -j/--display-section option to readelf.Nick Clifton6-133/+287
2024-04-11[gdb/testsuite] Fix gdb.threads/access-mem-running-thread-exit.exp with clangTom de Vries1-0/+2
When running test-case gdb.threads/access-mem-running-thread-exit.exp with clang, we run into: ... (gdb) print global_var = 555^M No symbol "global_var" in current context.^M (gdb) FAIL: gdb.threads/access-mem-running-thread-exit.exp: all-stop: \ access mem (write to global_var, inf=2, iter=1) ... The problem is that clang removes the unused variable. Fix this in the same way as done in commit b4f767131f7 ("Fix gdb.base/align-*.exp and Clang + LTO and AIX GCC"), by incrementing the variable. Tested on x86_64-linux with gcc and clang.
2024-04-11gas: Fix a CFI label name memory leak in scfi.cH.J. Lu2-2/+3
CFI label name can be freed only after use. * scfi.c (handle_scfi_dot_cfi): Free CFI label name after use. * scfidw2gen.c (scfi_process_cfi_label): Add a comment. Remove TODO on freeing CFI label name.
2024-04-11gas: Fix memory leaks in ginsn.cH.J. Lu1-3/+11
Free buffer memory after use in ginsn.c. * ginsn.c (ginsn_dst_print): Free buffer after use. (ginsn_print): Likewise.
2024-04-11gdb: fix format in remote.cTankut Baris Aktemur1-3/+3
Fix space-before-parenthesis format at three spots in remote.c.
2024-04-11Remove bfdwin.cAlan Modra39-629/+55
In commit b86d3af60ffc and 0ab0435fe672 I fixed SIGBUS errors found by oss-fuzz now that --with-mmap defaults to enabled. It turns out there are further problems with the aout mmap code: aout_read_minisymbols returns the external symbol array, which is later freed by nm.c. If the array is mmaped you can't free it. Now this could be fixed by making aout minisymbols an array of pointers, but I figure there's not much point in expending effort on that. So delete the aout mmap support along with bfdwin.c and get_section_contents_in_window.
2024-04-11asan: heap buffer overflow elf_link_add_to_first_hashAlan Modra1-1/+4
Seen on mmix. mmix +FAIL: ld-misc/defsym1 mmix +FAIL: sysroot-prefix common plain -Lpath, quoted mmix +FAIL: sysroot-prefix common plain -Lpath, unquoted mmix +FAIL: sysroot-prefix common full-path, quoted mmix +FAIL: sysroot-prefix common full-path, unquoted mmix +FAIL: sysroot-prefix common plain =-prefixed with empty, quoted mmix +FAIL: sysroot-prefix common plain =-prefixed with empty, unquoted mmix +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, quoted mmix +FAIL: sysroot-prefix common plain $SYSROOT-prefixed with empty, unquoted mmix +FAIL: sysroot-prefix common plain =-prefixed -Lpath, quoted mmix +FAIL: sysroot-prefix common plain =-prefixed -Lpath, unquoted mmix +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, quoted mmix +FAIL: sysroot-prefix common plain $SYSROOT-prefixed -Lpath, unquoted mmix +FAIL: sysroot-prefix common full-path =-prefixed without, quoted mmix +FAIL: sysroot-prefix common full-path =-prefixed without, unquoted mmix +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, quoted mmix +FAIL: sysroot-prefix common full-path $SYSROOT-prefixed without, unquoted ==3746597==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6070000007a0 at pc 0x56d87b0d1a40 bp 0x7fffb1629bf0 sp 0x7fffb1629be0 READ of size 8 at 0x6070000007a0 thread T0 #0 0x56d87b0d1a3f in elf_link_add_to_first_hash /home/alan/src/binutils-gdb/bfd/elflink.c:4312 mmix uses bfd_link_generic_hash_table. * elflink.c (_bfd_elf_archive_symbol_lookup): Dont use first_hash unless the hash table is bfd_link_elf_hash_table. (elf_link_add_archive_symbols): Likewise.
2024-04-11Re: Update objcopy's --section-alignment optionAlan Modra1-2/+6
ubsan: shift exponent 255 is too large for 64-bit type I should have known oss-fuzz wouldn't be satisfied so easily. The pef format allows quite silly section alignments in object files. * objcopy.c (setup_section): Limit shift exponent when checking vma and lma for alignment.
2024-04-10x86-64: Use long NOPs for Intel Core processorsH.J. Lu5-9/+397
Use long NOPs for Intel Core processors since they are faster than multiple NOPs. Don't use them for 64-bit processors by default since Intel Atom processors can only decode 4 prefixes in 1 cycle. * config/tc-i386.c (alt64_9): New. (alt64_10): Likewise. (alt64_11): Likewise. (alt64_12): Likewise. (alt64_13): Likewise. (alt64_14): Likewise. (alt64_15): Likewise. (alt64_patt): Likewise. (i386_generate_nops): Use alt64_patt for Intel Core processors in 64-bit mode. * testsuite/gas/i386/x86-64-nops-1-core2.d: Expect long NOPs. * testsuite/gas/i386/x86-64-nops-4-core2.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-nops-1-core2.d: Replace ../x86-64-nops-1.d with ../x86-64-nops-1-core2.d. * testsuite/gas/i386/ilp32/x86-64-nops-4-core2.d: Replace ../x86-64-nops-4.d with ../x86-64-nops-4-core2.d.
2024-04-10mmap: Fix a memory leak in _bfd_mmap_read_temporaryH.J. Lu1-1/+5
Return malloced memory in *mmap_base so that _bfd_munmap_readonly_temporary will free it. * libbfd.c (_bfd_mmap_read_temporary): Return malloced memory in *mmap_base.
2024-04-10elf: Fix a memory leak in _bfd_elf_add_dynamic_entryH.J. Lu3-7/+12
Normally, the section contents is allocated by bfd_alloc which is freed when the object is closed. But the .dynamic section contents is allocated by bfd_realloc, which should be freed by calling free. Add a dynamic field to elf_link_hash_table for the .dynamic section and free its contents in _bfd_elf_link_hash_table_free. * elf-bfd.h (elf_link_hash_table): Add dynamic. * elflink.c (_bfd_elf_link_create_dynamic_sections): Set the dynamic field in elf_link_hash_table. (_bfd_elf_add_dynamic_entry): Use hash_table->dynamic. (_bfd_elf_strip_zero_sized_dynamic_sections): Likewise. (bfd_elf_add_dt_needed_tag): Likewise. (elf_finalize_dynstr): Likewise. (_bfd_elf_link_hash_table_free): Free htab->dynamic->contents. (bfd_elf_final_link): Use htab->dynamic. * elfxx-x86.c (_bfd_x86_elf_finish_dynamic_sections): Use htab->elf.dynamic.
2024-04-11Segfault in _bfd_delete_bfd with USE_MMAPAlan Modra1-1/+2
Any of the calls to _bfd_delete_bfd in bfd_fopen will hit this. * opncls.c (_bfd_delete_bfd): Check for non-NULL xvec before accessing flavour.
2024-04-11Automatic date update in version.inGDB Administrator1-1/+1
2024-04-10gas: scfi: bugfixes for SCFI state propagationIndu Bhagat5-8/+87
There are two state propagation functions in SCFI machinery - forward and backward flow. The patch addresses two issues: - In forward_flow_scfi_state (), the state being compared in forward flow must be that at the exit of a prev bb and that at the entry of the next bb. The variable holding the state to be compared was previously (erroneously) stale. - In cmp_scfi_state (), the assumption that two different control flows, leading to the same basic block, cannot have a mismatched notion of CFA base register, is not true. Remove the assertion and instead return err if mismatch. Fixing these issues helps correctly synthesize CFI, when previously SCFI was erroring out for an otherwise valid input asm. gas/ * scfi.c (cmp_scfi_state): Remove assertion and return mismatch in return value as applicable. (forward_flow_scfi_state): Update state object to be the same as the exit state of the prev bb before comparing. gas/testsuite/ * gas/scfi/x86_64/scfi-x86-64.exp: Add new test. * gas/scfi/x86_64/scfi-cfg-5.d: New test. * gas/scfi/x86_64/scfi-cfg-5.l: New test. * gas/scfi/x86_64/scfi-cfg-5.s: New test.
2024-04-10gas: gcfg: add_bb_at_ginsn must return root_bbIndu Bhagat5-26/+164
A GCFG (ginsn control flow graph) is created for SCFI purposes in GAS. The existing GCFG creation process was ignoring some paths. add_bb_at_ginsn () is a recursive function which should return the root of the added basic blocks. This property was being violated in some traversals, e.g., where a taken path involving a sequence of a few basic blocks eventually culminated in a GINSN_TYPE_RETURN instruction. This patch fixes the issue by keeping an explicit variable root_bb to memorize the bb to be returned. Next, find_or_make_bb () must either create or find the bb with the first ginsn as the provided ginsn. Add a few assertions to ensure health of the cfg creation process. Note that the testcase, in its current shape, is not fit for catching regressions for the issue at hand. Although the testcase does exercise the updated code path, the testcase passes even without the current fix, because the added edge in this specific testcase does not alter the synthesized CFI. (The missing edge is the fallthrough edge of the conditional branch "jne .L13" in the testcase.) Using a manual gcfg_print (), one can see the missing edge without the fix. Lets keep the testcase for now, until there is a better way to test the GCFG for this issue (e.g., either by dumping the GCFG in textual format, or a case when the missing edge does cause wrong synthesized CFI). gas/ * ginsn.c (bb_add_edge): Fix a code comment. (find_bb): Likewise. (find_or_make_bb): Add new assertions to ensure health of cfg creation process. (add_bb_at_ginsn): Keep reference to the root_bb and return it. gas/testsuite/ * gas/scfi/x86_64/scfi-x86-64.exp: Add new test. * gas/scfi/x86_64/scfi-cfg-4.d: New test. * gas/scfi/x86_64/scfi-cfg-4.l: New test. * gas/scfi/x86_64/scfi-cfg-4.s: New test.
2024-04-10gdb, gdbserver: Add missing install-dvi Makefile targetChristophe Lyon5-4/+21
For some reason install-dvi is missing although other targets of the same family are present. This looks like an oversight. This enables calling 'make install-dvi' from the top-level build directory. Fix what looks like another oversight: include 'pdf' in 'all-doc' in gdb/doc/Makefile.in. Approved-By: Luis Machado <luis.machado@arm.com> Tested-By: Luis Machado <luis.machado@arm.com>
2024-04-10readelf: Add -j/--display-section command line option.Nick Clifton2-0/+5
2024-04-10mmap: Avoid the sanitizer configure check failureH.J. Lu20-9/+40
When -fsanitize=address,undefined is used to build, the mmap configure check failed with ================================================================= ==231796==ERROR: LeakSanitizer: detected memory leaks Direct leak of 4096 byte(s) in 1 object(s) allocated from: #0 0x7cdd3d0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x5750c7f6d72b in main /home/alan/build/gas-san/all/bfd/conftest.c:239 Direct leak of 4096 byte(s) in 1 object(s) allocated from: #0 0x7cdd3d0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x5750c7f6d2e1 in main /home/alan/build/gas-san/all/bfd/conftest.c:190 SUMMARY: AddressSanitizer: 8192 byte(s) leaked in 2 allocation(s). Replace AC_FUNC_MMAP with GCC_AC_FUNC_MMAP to avoid the sanitizer configure check failure. bfd/ * configure.ac: Replace AC_FUNC_MMAP with GCC_AC_FUNC_MMAP. * Makefile.in: Regenerated. * aclocal.m4: Likewise. * configure: Likewise. binutils/ * configure.ac: Replace AC_FUNC_MMAP with GCC_AC_FUNC_MMAP. * Makefile.in: Regenerated. * aclocal.m4: Likewise. * configure: Likewise. ld/ * configure.ac: Replace AC_FUNC_MMAP with GCC_AC_FUNC_MMAP. * Makefile.in: Regenerated. * aclocal.m4: Likewise. * configure: Likewise. libctf/ * configure.ac: Replace AC_FUNC_MMAP with GCC_AC_FUNC_MMAP. * Makefile.in: Regenerated. * aclocal.m4: Likewise. * configure: Likewise. libsframe/ * configure.ac: Replace AC_FUNC_MMAP with GCC_AC_FUNC_MMAP. * Makefile.in: Regenerated. * aclocal.m4: Likewise. * configure: Likewise.
2024-04-10mmap: Avoid the sanitizer configure check failureH.J. Lu9-11/+34
When -fsanitize=address,undefined is used to build, the mmap configure check failed with ================================================================= ==231796==ERROR: LeakSanitizer: detected memory leaks Direct leak of 4096 byte(s) in 1 object(s) allocated from: #0 0x7cdd3d0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x5750c7f6d72b in main /home/alan/build/gas-san/all/bfd/conftest.c:239 Direct leak of 4096 byte(s) in 1 object(s) allocated from: #0 0x7cdd3d0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x5750c7f6d2e1 in main /home/alan/build/gas-san/all/bfd/conftest.c:190 SUMMARY: AddressSanitizer: 8192 byte(s) leaked in 2 allocation(s). Define GCC_AC_FUNC_MMAP with export ASAN_OPTIONS=detect_leaks=0 to avoid the sanitizer configure check failure. config/ * mmap.m4 (GCC_AC_FUNC_MMAP): New. * no-executables.m4 (AC_FUNC_MMAP): Renamed to GCC_AC_FUNC_MMAP. Change AC_FUNC_MMAP to GCC_AC_FUNC_MMAP. libiberty/ * Makefile.in (aclocal_deps): Add $(srcdir)/../config/mmap.m4. * acinclude.m4: Change AC_FUNC_MMAP to GCC_AC_FUNC_MMAP. * aclocal.m4: Regenerated. * configure: Likewise. zlib/ * acinclude.m4: Include ../config/mmap.m4. * Makefile.in: Regenerated. * configure: Likewise.
2024-04-10Re: ld testsuite: Append NOSANITIZE_CFLAGS to CFLAGS_FOR_TARGETAlan Modra1-4/+4
Don't use CC_FOR_TARGET in the bootstrap test, a silly idea aiming at consistency that made things worse. The objects being linked were built using $CC, so $CC should be used to link. * testsuite/ld-bootstrap/bootstrap.exp: Revert last change.
2024-04-10Automatic date update in version.inGDB Administrator1-1/+1
2024-04-09Rewrite gdb_bfd_error_handlerTom Tromey1-15/+24
This patch rewrites gdb_bfd_error_handler to use 'bfd_print_error' to generate the text of the warning, and then emits it using 'warning'. The current code in the tree is a bit wrong because it may do the wrong thing when BFD uses ones of its printf extensions. This also adds locking to increment_bfd_error_count. This is important now that some BFD operations can be done on worker threads. This approach makes it simpler for worker threads to intercept any messages. Regression tested on x86-64 Fedora 38.
2024-04-09aarch64: Treat operand "SME list of ZA tiles" as immediate (PR 31561)Jens Remus1-1/+1
The AArch64 instruction table (aarch64-tbl.h) defines the operand "SME list of ZA tiles" (SME_list_of_64bit_tiles) as immediate. During assembly it is correctly encoded as immediate value (imm.value) in parse_operands. During disassembly it is first correctly decoded as immediate value (imm.value) in aarch64_ext_imm called by aarch64_extract_operand, but then erroneously treated as register number (reg.regno) in aarch64_print_operand. This resolves the assembler test case "SME extension (ZERO)" to erroneously fail on s390. On AArch64 - being little-endian - the struct aarch64_opnd_info union fields reg.regno and imm.value share their least-significant bits. On s390 - being big-endian - they do not. opcodes/ PR binutils/31561 * aarch64-opc.c: Treat operand "SME list of ZA tiles" as immediate. Bug: https://sourceware.org/PR31561 Signed-off-by: Jens Remus <jremus@linux.ibm.com> Acked-by: Nick Clifton <nickc@redhat.com>
2024-04-09s390: Flag conditional branch relative insns as condjumpJens Remus1-4/+4
Flag conditional branch relative (extended) mnemonics clij* and clgij* as "condjump" for jump visualization in disassembly. They were missed to be flagged as such in commit c5306fed7d40 ("s390: Support for jump visualization in disassembly"). opcodes/ * s390-opc.txt: Flag conditional branch relative instructions clij* and clgij* as condjump for jump visualization in disassembly. Signed-off-by: Jens Remus <jremus@linux.ibm.com> Acked-by: Nick Clifton <nickc@redhat.com>
2024-04-09bfd: Define pagesize variables only for mmapH.J. Lu4-1/+7
Define _bfd_pagesize, _bfd_pagesize_m1 and _bfd_minimum_mmap_size only if HAVE_MMAP is defined. * libbfd-in.h (_bfd_pagesize): Declare only if HAVE_MMAP is defined. (_bfd_pagesize_m1): Likewise. (_bfd_minimum_mmap_size): Likewise. * libbfd.c (_bfd_pagesize): Define only if HAVE_MMAP is defined. (_bfd_pagesize_m1): Likewise. (_bfd_minimum_mmap_size): Likewise. (bfd_init_pagesize): Likewise. * lynx-core.c (lynx_core_file_p): Replace _bfd_pagesize with getpagesize.
2024-04-09arm: Fix disassembly of MVE vq[r]shr[u]nAlex Coplan4-1808/+1879
This patch fixes the disassembly of vq[r]shr[u]n insns so that the shift immediate is properly decoded. See the description of the previous patch for an example of the incorrect disassembly. As part of this patch we also fix the mve-vqrshrn.d test which was testing for the incorrect disassembly of the immediates. The disassembly now matches the assembled instructions in that test. Finally we add an mve-vqshrn test which tests the non-rounding variants of those insns, whose encoding we fixed with the previous patch in this series.
2024-04-09arm: Fix encoding of MVE vqshr[u]nAlex Coplan1-4/+4
As it stands, these insns are incorrectly encoded as vqrshr[u]n. Concretely, the problem can be seen as follows: $ cat t.s vqrshrnb.s16 q0,q0,#8 vqshrnb.s16 q0,q0,#8 $ gas/as-new t.s -march=armv8.1-m.main+mve -o t.o $ binutils/objdump -d t.o -m armv8.1-m.main t.o: file format elf32-littlearm Disassembly of section .text: 00000000 <.text>: 0: ee88 0f41 vqrshrnb.s16 q0, q0, #0 4: ee88 0f41 vqrshrnb.s16 q0, q0, #0 Here we assemble these two instructions to the same opcode. The encoding of the first is the correct, while the encoding of the second is incorrect, and the bottom bit should be clear, see the Armv8-M ARM: https://developer.arm.com/documentation/ddi0553/latest/ There is an additional problem here in that the disassembly of the immediate is incorrect. llvm-objdump shows the correct disassembly here: t.o: file format elf32-littlearm Disassembly of section .text: 00000000 <$t>: 0: ee88 0f41 vqrshrnb.s16 q0, q0, #8 4: ee88 0f41 vqrshrnb.s16 q0, q0, #8 Note that we defer adding a test for the correct encoding of these insns until the next patch which fixes the disassembly issue.
2024-04-09arm: Refactor condition for print_mve_shift_nAlex Coplan1-10/+25
This is intended to have no functional change, but refactors the condition guarding the call to print_mve_shift_n in arm-dis.c ahead of a later patch which adds additional insns to the set of those whose shift immediate is disassembled using print_mve_shift_n.
2024-04-09RISC-V: Support Zcmp push/pop instructions.Jiawei13-0/+641
Support zcmp extension push/pop/popret and popret zero instructions. The `reg_list' is a list containing 1 to 13 registers, we can use: "{ra}, {ra, s0}, {ra, s0-s1}, {ra, s0-s2} ... {ra, s0-sN}" to present this feature. Passed gcc/binutils regressions of riscv-gnu-toolchain. Most of work was finished by Sinan Lin. Co-Authored by: Charlie Keaney <charlie.keaney@embecosm.com> Co-Authored by: Mary Bennett <mary.bennett@embecosm.com> Co-Authored by: Nandni Jamnadas <nandni.jamnadas@embecosm.com> Co-Authored by: Sinan Lin <sinan.lin@linux.alibaba.com> Co-Authored by: Simon Cook <simon.cook@embecosm.com> Co-Authored by: Shihua Liao <shihua@iscas.ac.cn> Co-Authored by: Yulong Shi <yulong@iscas.ac.cn> bfd/ChangeLog: * elfxx-riscv.c (riscv_implicit_subset): Imply zca for zcmp. (riscv_supported_std_z_ext): Added zcmp with version 1.0. (riscv_parse_check_conflicts): Zcmp conflicts with d/zcd. (riscv_multi_subset_supports): Handle zcmp. (riscv_multi_subset_supports_ext): Ditto. gas/ChangeLog: * NEWS: Updated. * config/tc-riscv.c (regno_to_reg_list): New function, used to map register to reg_list number. (reglist_lookup): Called reglist_lookup_internal. Return false if reg_list number is zero, which is an invalid value. (reglist_lookup_internal): Parse register list, and return the last register by regno_to_reg_list. (validate_riscv_insn): New operators. (riscv_ip): Ditto. * testsuite/gas/riscv/march-help.l: Updated. * testsuite/gas/riscv/zcmp-push-pop-fail.d: New test. * testsuite/gas/riscv/zcmp-push-pop-fail.l: New test. * testsuite/gas/riscv/zcmp-push-pop-fail.s: New test. * testsuite/gas/riscv/zcmp-push-pop.d: New test. * testsuite/gas/riscv/zcmp-push-pop.s: New test. include/ChangeLog: * opcode/riscv-opc.h (MATCH/MASK_CM_PUSH): New macros for zcmp. (MATCH/MASK_CM_POP): Ditto. (MATCH/MASK_CM_POPRET): Ditto. (MATCH/MASK_CM_POPRETZ): Ditto. (DECLARE_INSN): New declarations for zcmp. * opcode/riscv.h (EXTRACT/ENCODE/VALID_ZCMP_SPIMM): Handle spimm operand for zcmp. (OP_MASK_REG_LIST): Handle operand for zcmp register list. (OP_SH_REG_LIST): Ditto. (ZCMP_SP_ALIGNMENT): New argument, used in riscv_get_sp_base. (X_S0, X_S1, X_S2, X_S10, X_S11): New register numbers. (enum riscv_insn_class): Added INSN_CLASS_ZCMP. (extern riscv_get_sp_base): Added. opcodes/ChangeLog: * riscv-dis.c (print_reg_list): New function, used to get zcmp reg_list field. (riscv_get_spimm): New function, used to get zcmp sp adjustment immediate. (print_insn_args): Handle new operands for zcmp. * riscv-opc.c (riscv_get_sp_base): New function, used by gas and objdump. Get sp base adjustment. (riscv_opcodes): Added zcmp instructions.
2024-04-09LoongArch: ld: Move .got .got.plt before .data and protect .got with relromengqinggang5-1/+29
Move .got .got.plt before .data so .got can be protected with -zrelro. And the first two entries of .got.plt (_dl_runtime_resolve and link map) are placed within the relro region.
2024-04-09Support {evex} pseudo prefix for decode evex promoted insns without egpr32.Hu, Lin112-42/+1500
This patch is based on APX NF patch and also adds test cases for Checking 64-bit insns not sizeable through register operands with evex. gas/ChangeLog: * testsuite/gas/i386/x86-64-apx-evex-promoted-intel.d: Added no-egpr testcases for movbe. * testsuite/gas/i386/x86-64-apx-evex-promoted-wig.d: Ditto. * testsuite/gas/i386/x86-64-apx-evex-promoted.d: Ditto. * testsuite/gas/i386/x86-64-apx-evex-promoted.s: Ditto. * testsuite/gas/i386/x86-64.exp: Added tests. * testsuite/gas/i386/noreg64-evex.d: New test. * testsuite/gas/i386/noreg64-evex.e: Ditto. * testsuite/gas/i386/noreg64-evex.s: Ditto. * testsuite/gas/i386/x86-64-apx_f-evex.d: Ditto. * testsuite/gas/i386/x86-64-apx_f-evex.s: Ditto. opcodes/ChangeLog: * i386-dis-evex.h: Added %ME to movbe. * i386-dis.c : Added %XE to evex_from_vex instructions to output {evex}. (struct dis386): New %ME. (putop): Handle %ME and output {evex} for evex_from_legacy instructions. * Return early when the instruction name is (bad).
2024-04-09Remove dead code in bfdwin.cAlan Modra1-10/+0
All of bfdwin.c is wrapped in USE_MMAP. There isn't any point in HAVE_MMAP tests inside USE_MMAP. * bfdwin.c (bfd_free_window, bfd_get_file_window): Delete HAVE_MMAP conditionals.
2024-04-09ld testsuite: Append NOSANITIZE_CFLAGS to CFLAGS_FOR_TARGETAlan Modra2-4/+7
The idea here is build tests without sanitizer flags, so they don't fail due to many not using the compiler to link and thus result in undefined symbols, since libasan is not supplied. We definitely do not want a compiler to perform linking in most cases, and it's complicated to supply libasan (and would possibly disturb testcase output). * testsuite/config/default.exp (CFLAGS_FOR_TARGET), (CXXFLAGS_FOR_TARGET): Append NOSANITIZE_CFLAGS. * testsuite/ld-bootstrap/bootstrap.exp: Use CC_FOR_TARGET and CFLAGS_FOR_TARGET throughout.
2024-04-09Automatic date update in version.inGDB Administrator1-1/+1
2024-04-08ld: Add PR ld/31615 testsH.J. Lu6-0/+66
PR ld/31615 * testsuite/ld-plugin/lto.exp: Run ld/31615 tests. * testsuite/ld-plugin/pr31615.ver: New file. * testsuite/ld-plugin/pr31615a.c: Likewise. * testsuite/ld-plugin/pr31615b.c: Likewise. * testsuite/ld-plugin/pr31615c.c: Likewise. * testsuite/ld-plugin/pr31615d.c: Likewise.
2024-04-08remote.c: Make packet_ok return struct packet_resultAlexandra Hájková1-103/+96
This allows the error message stored in a packet_result to be easily printed in the calling function. Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-04-08remote.c: Use packet_check_resultAlexandra Hájková1-35/+46
when processing the GDBserver reply to qRcmd packet. Print error message or the error code. Currently, when qRcmd request returns an error, GDB just prints: Protocol error with Rcmd After this change, GDB will also print the error code: Protocol error with Rcmd: 01. Add an accept_msg argument to packet_check result. qRcmd request (such as many other packets) does not recognise "E.msg" form as an error right now. We want to recognise "E.msg" as an error response only for the packets where it's documented. Also use packet_check result in remote_read_bytes_1. Approved-By: Andrew Burgess <aburgess@redhat.com>