Commit Graph

118290 Commits

Author SHA1 Message Date
Indu Bhagat
a1c6a60cc5 gas: gcfg: add_bb_at_ginsn must return root_bb
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-10 13:45:59 -07:00
Christophe Lyon
96c1bcb38b gdb, gdbserver: Add missing install-dvi Makefile target
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-10 13:37:05 +00:00
Nick Clifton
ea83005a36 readelf: Add -j/--display-section command line option. 2024-04-10 12:23:44 +01:00
H.J. Lu
303da223b1 mmap: Avoid the sanitizer configure check failure
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-10 03:57:46 -07:00
H.J. Lu
219822fd5d mmap: Avoid the sanitizer configure check failure
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-10 03:57:02 -07:00
Alan Modra
bdefc07306 Re: ld testsuite: Append NOSANITIZE_CFLAGS to CFLAGS_FOR_TARGET
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-10 11:28:32 +09:30
GDB Administrator
2c8dd9b1c3 Automatic date update in version.in 2024-04-10 00:00:22 +00:00
Tom Tromey
e8cd90f039 Rewrite gdb_bfd_error_handler
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-09 09:39:15 -06:00
Jens Remus
6f3cf71845 aarch64: Treat operand "SME list of ZA tiles" as immediate (PR 31561)
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-09 17:21:53 +02:00
Jens Remus
676b98078f s390: Flag conditional branch relative insns as condjump
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 c5306fed7d ("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-09 17:17:02 +02:00
H.J. Lu
56756c571e bfd: Define pagesize variables only for mmap
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-09 05:22:41 -07:00
Alex Coplan
cd714ac07c arm: Fix disassembly of MVE vq[r]shr[u]n
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-09 10:09:25 +01:00
Alex Coplan
b3a561abc3 arm: Fix encoding of MVE vqshr[u]n
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-09 10:09:25 +01:00
Alex Coplan
f9d6cf2e9f arm: Refactor condition for print_mve_shift_n
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-09 10:09:25 +01:00
Jiawei
9132c8152b RISC-V: Support Zcmp push/pop instructions.
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-09 15:56:12 +08:00
mengqinggang
2bf280a827 LoongArch: ld: Move .got .got.plt before .data and protect .got with relro
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-09 14:31:04 +08:00
Hu, Lin1
edb30f5782 Support {evex} pseudo prefix for decode evex promoted insns without egpr32.
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-09 11:18:23 +08:00
Alan Modra
7c71e67e11 Remove dead code in bfdwin.c
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-09 11:21:57 +09:30
Alan Modra
c8d45dbd0a ld testsuite: Append NOSANITIZE_CFLAGS to CFLAGS_FOR_TARGET
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-09 11:21:57 +09:30
GDB Administrator
38d2fa177e Automatic date update in version.in 2024-04-09 00:00:14 +00:00
H.J. Lu
d05e1a4a6d ld: Add PR ld/31615 tests
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-08 05:18:24 -07:00
Alexandra Hájková
94a94c904d remote.c: Make packet_ok return struct packet_result
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-08 13:46:03 +02:00
Alexandra Hájková
3623271997 remote.c: Use packet_check_result
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>
2024-04-08 13:39:51 +02:00
Andrew Burgess
36192c2be1 gdb/configure: realign the AC_ARG_ENABLE(sim, ....) block
Following the suggestion in this review comment:

  https://inbox.sourceware.org/gdb-patches/9420bbb0-2614-4847-9157-8562f8a62d03@simark.ca

this commit realigns the AC_ARG_ENABLE(sim, ....) block.  I've added
additional [...] quoting in a couple of places, which is inline with
how other AC_ARG_ENABLE blocks are formatted within GDB's configure.ac
file.

There should be no change in how GDB configures or builds after this
commit.
2024-04-08 10:56:51 +01:00
Andrew Burgess
76bbe1f597 gdb/build: apply silent-rules.mk to the data-directory Makefile.in
This commit makes use of gdb/silent-rules.mk in the data-directory
Makefile.in.  I've only updated the rules that actually generate
things, I've not touched the install or uninstall rules, this matches
gdb/Makefile.in.

I've not managed to completely silence all of the recipe output, the
mkinstalldirs command outputs some diagnostic text which looks 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 have a patch for mkinstalldirs that fixes this (by adding a new
--silent command line flag), but that patch needs to be submitted to
automake, then an updated mkinstalldirs sync'd to the gcc repository,
and then copied into the binutils-gdb repository... so I'm leaving
that for a future project.

Then the guild compiler also emits some diagnostic output, which looks
like this:

    GEN    stamp-guile
  mkdir -p -- ./guile/.
  mkdir -p -- ./guile/gdb
  wrote `./gdb.go'
  wrote `gdb/experimental.go'
  wrote `gdb/iterator.go'
  wrote `gdb/printing.go'
  wrote `gdb/support.go'
  wrote `gdb/types.go'

The 'wrote' lines are from the guild compiler.  The only way to
silence these would be to redirect stdout to /dev/null I think.  I did
prototype this, but wasn't 100% convinced about that part of the
patch, so I've decided to leave that for another day.

I did need to add a new SILENT_ECHO variable to silent-rules.mk, this
is set to a suitable 'echo' command to use within recipes.  When we
are in silent mode then I use the 'true' command, while in verbose
mode we actually use 'echo'.

So, other than the issues outlined above, the output when building the
data-directory is now greatly reduced, and more inline with the output
when building in the gdb/ directory.

There should be no change in what is actually built after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-04-08 10:25:42 +01:00
Andrew Burgess
ff69d6e9af gdb/configure: use AC_MSG_NOTICE not a direct echo call
After the recent commits, I noticed that GDB's configure script would
still emit two lines even when run in silent mode.  If you touch
gdb/Makefile.in and then run 'make all' in the gdb/ build directory
you'll see this:

    GEN    config.status
  enable_sim = no
  enableval = no

Obviously the 'no' might be 'yes' depending on how you actually
configured GDB.

This is caused by two direct invocations of 'echo' in GDB's
configure.ac script.

In this commit I replace these calls with use of AC_MSG_NOTICE
instead.  Now when configure is run with the --silent command line
option these lines will not be printed.

There should be no changes in the built GDB after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-04-08 10:25:41 +01:00
Andrew Burgess
b6a12c1451 gdb/Makefile: Print 'GEN' message, and pass SILENT_FLAG more
The targets that use config.status to regenerate themselves don't
currently follow the silent rules that the rest of GDB's Makefile
does.  For example, touch the gdb/gcore.in file and then 'make all' in
the gdb/ directory prints:

  /bin/sh config.status gcore
  config.status: creating gcore

In this commit I make use of the silent-rules.mk mechanism for these
targets, now we get:

  GEN    gcore

Which matches the rest of our Makefile.  Obviously, if you pass 'V=1'
to the build then you'll get the old output back.

There's no change in what is generated after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-04-08 10:25:40 +01:00
Andrew Burgess
cb1bef582e gdb/Makefile: add some missing config.status dependencies
I noticed that for the build targets jit-reader.h, gcore, gdb-gdb.py,
and gdb-gdb.gdb the rules all use the config.status script, but don't
have a dependency on the config.status target.  This means we might
fail to regenerate these targets in a case where config.status, or one
of its dependencies changes.

Two other targets that use config.status do correctly have a
dependency on config.status.

Fixed in this commit by adding the missing dependencies.

There should be no changes in _what_ is generated after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-04-08 10:25:39 +01:00
Andrew Burgess
766f411f08 gdb/Makefile: rewrite dependencies for config.status target
I noticed something weird, the rule for the config.status target looks
like this:

  config.status: $(srcdir)/configure configure.nat configure.tgt configure.host ../bfd/development.sh
          $(SHELL) config.status --recheck

What bothered me is that 'configure' is specified as being in
$(srcdir), while all of the other files are not, even though those
files are in the same $(srcdir) as the configure script.

However, I tried touching one of those files, and the config.status
rule does trigger!

This is thanks to the VPATH variable, which is set to $(srcdir), so
make looks in $(srcdir) for any dependencies.

However, this inconsistency bothers me.  Better, I think, to add the
$(srcdir) prefix to each of these files.

I also spotted that the configure script also includes the files
../bfd/config.bfd, yet that is missing from the include list, so in
this commit I plan to add this as a dependency.

The configure script also pulls in two TCL and TK related files:

	. ${TCL_BIN_DIR}/tclConfig.sh
	. ${TK_BIN_DIR}/tkConfig.sh

However, I don't think ${TCL_BIN_DIR} and ${TK_BIN_DIR} are currently
visible in GDB's Makefile, so I'm not planning to add these
dependencies at this time.

In this commit I add a new variable config_status_deps which holds the
list of all the dependencies for config.status, with the $(srcdir)
prefix included, and then I use this in the config.status rule.

After this commit config.status will regenerate if config.bfd changes,
which it wouldn't before, but nothing else changes.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-04-08 10:25:38 +01:00
Andrew Burgess
cc7ae3ac7e gdb/Makefile: add gcore to the 'all' target dependency list
The gcore script is initially generated by the configure process, just
like gdb-gdb.gdb and gdb-gdb.py.  However if the gdb/gcore.in input
source is modified then 'make all' in the gdb/ directory does not
regenerate the gcore script.

This is different than the gdb-gdb.gdb and gdb-gdb.py files, if their
input is updated then 'make all' will regenerate these files.

The difference is that for gdb-gdb.* there is an explicit dependency
between the 'all' target and the generated file, this dependency is
missing for gcore.

This commit adds the dependency.  Now, if gcore.in is changed, running
'make all' will regenerate the gcore script.

There is no change in _what_ is generated after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-04-08 10:25:37 +01:00
Simon Marchi
ecc3c38667 gdb: ignore -Wregister instead of -Wdeprecated-register
When building GDB on Centos 7 (which has flex 2.5.37) and Clang, I get:

    $ make ada-exp.o
      YACC   ada-exp.c
      LEX    ada-lex.c
      CXX    ada-exp.o
    In file included from /home/smarchi/src/binutils-gdb/gdb/ada-exp.y:1179:
    <stdout>:1106:2: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
     1106 |         register yy_state_type yy_current_state;
          |         ^~~~~~~~

In ada-lex.l, we already use `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER`,
which for Clang translates to ignoring `-Wdeprecated-register` [1].  I think
that was produced when compiling as C++11, but now that we always compile as
C++17, Clang produces a `-Wregister` error [2].

For GCC, `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER` already translates to
ignoring `-Wregister`.  So, rename
`DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER` to `DIAGNOSTIC_IGNORE_REGISTER`
and ignore `-Wregister` for Clang too.

[1] https://releases.llvm.org/17.0.1/tools/clang/docs/DiagnosticsReference.html#wdeprecated-register
[2] https://releases.llvm.org/17.0.1/tools/clang/docs/DiagnosticsReference.html#wregister

include/ChangeLog:

	* diagnostics.h (DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER): Rename
	to...
	(DIAGNOSTIC_IGNORE_REGISTER): ... this.  Ignore `-Wregister`
	instead of `-Wdeprecated-register`.

Change-Id: I8a4a51c7222c68577fa22ecacdddfcba32d9dbc5
2024-04-07 22:57:39 -04:00
Alan Modra
248b6326a4 Re: PR26978, Inconsistency for strong foo@v1 and weak foo@@v1
Commit 726d7d1ecf opened a hole that allowed a u.i.link loop to be
created, resulting in _bfd_generic_link_add_one_symbol never
returning.  Fix that.  Note that the MIND case handles two types of
redefinition.  For a new indirect symbol we'll have string non-NULL.
For a new def, string will be NULL.  So moving the string comparison
earlier would work.  However, we've already looked up inh in the first
case so can dispense with name comparisons.  Either way, for a new def
we'll get to the defweak test and possibly cycle.  Which is what we
want here.

	PR 31615
	PR 26978
	* linker.c (_bfd_generic_link_add_one_symbol <MIND>): Test for
	exactly matching indirect symbols before cycling on a defweak.
2024-04-08 11:27:42 +09:30
GDB Administrator
261d6a6776 Automatic date update in version.in 2024-04-08 00:00:09 +00:00
Cui, Lili
dd74a60337 Support APX NF
For the case when NDD and NF are both 0 in evex-promoted format,
we will fully support and test it in another patch.

gas/ChangeLog:

       * NEWS: Support Intel APX NF.
       * config/tc-i386.c (enum i386_error): Add unsupported_nf.
       (struct _i386_insn): Add has_nf.
       (is_apx_evex_encoding): Ditto.
       (build_apx_evex_prefix): Encode the NF bit.
       (md_assemble): Handle unsupported_nf.
       (parse_insn): Handle Prefix_NF and report bad for illegal combination.
       (can_convert_NDD_to_legacy): Replace i.tm.opcode_modifier.nf with i.has_nf.
       (match_template): Support D for APX_F insns and check NF support.
       * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d: Add bad test for NF bit.
       * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s: Ditto.
       * testsuite/gas/i386/x86-64-apx-inval.l: Ditto.
       * testsuite/gas/i386/x86-64-apx-inval.s: Ditto.
       * testsuite/gas/i386/x86-64.exp: Add apx nf tests.
       * testsuite/gas/i386/x86-64-apx-nf-intel.d: New test.
       * testsuite/gas/i386/x86-64-apx-nf.d: Ditto.
       * testsuite/gas/i386/x86-64-apx-nf.s: Ditto.

opcodes/ChangeLog:

       * i386-dis-evex.h: Add %NF to the instructions that support APX NF and
       add new instruction imul, popcnt, tzcnt and lzcnt to EVEX table.
       * i386-dis-evex-reg.h: Ditto.
       * i386-dis.c (struct instr_info): Add nf.
       (struct dis386): Add "NF" for EVEX.NF.
       (get_valid_dis386): Set ins->vex.nf and report bad-nf for illegal case.
       (print_insn): Handle ins.vex.nf.
       (putop): Handle "%NF".
       * i386-opc.h (Prefix_NF): New.
       * i386-opc.tbl: Added new entries to support full APX NF instructions.
       * i386-mnem.h: Regenerated.
       * i386-tbl.h: Regenerated.
2024-04-07 17:28:25 +08:00
GDB Administrator
bc0d0a5596 Automatic date update in version.in 2024-04-07 00:00:10 +00:00
H.J. Lu
c411ee9883 elf: Call bfd_malloc instead xmalloc
* elflink.c (elf_link_add_object_symbols): Call bfd_malloc
	instead of xmalloc.
2024-04-06 05:07:33 -07:00
H.J. Lu
cca46dea4d Revert "x86: Restore APX shift-double instructions with omitted shift count"
This reverts commit c2d698fe03.

GCC 14 has been changed to use explicit shift count in shift-double
instructions by the commit:

06a7e7514af x86: Use explicit shift count in double-precision shifts

gas/

	PR gas/31606
	* testsuite/gas/i386/x86-64-apx-ndd-wig.d: Updated.
	* testsuite/gas/i386/x86-64-apx-ndd.d: Likewise.
	* testsuite/gas/i386/x86-64-apx-ndd.s: Remove tests for APX
	shift-double instructions with omitted shift count.

opcodes/

	PR gas/31606
	* i386-opc.tbl: Remove APX shift-double instructions with
	omitted shift count.
	* i386-tbl.h: Regenerated.
2024-04-06 05:07:18 -07:00
Alan Modra
e7e05a9dd0 Don't have first_hash entries of strings that can be freed.
Seen running "LTO 1" under valgrind.
==1443263== Invalid read of size 1
==1443263==    at 0x484CFE4: strcmp (vg_replace_strmem.c:939)
==1443263==    by 0x56E16C: bfd_hash_lookup (hash.c:564)
==1443263==    by 0x5A3C8F: elf_link_add_to_first_hash (elflink.c:4316)
==1443263==    by 0x5AE60F: elf_link_add_object_symbols (elflink.c:5663)
==1443263==    by 0x5B0672: bfd_elf_link_add_symbols (elflink.c:6333)
==1443263==    by 0x41448F: load_symbols (ldlang.c:3129)
==1443263==    by 0x4149D8: open_input_bfds (ldlang.c:3621)
==1443263==    by 0x414968: open_input_bfds (ldlang.c:3569)
==1443263==    by 0x4166A2: lang_process (ldlang.c:8162)
==1443263==    by 0x4194D5: main (ldmain.c:504)
==1443263==  Address 0x525e230 is 192 bytes inside a block of size 4,064 free'd
==1443263==    at 0x484810F: free (vg_replace_malloc.c:974)
==1443263==    by 0x8D4D87: objalloc_free_block (objalloc.c:248)
==1443263==    by 0x5AEACC: elf_link_add_object_symbols (elflink.c:5790)
==1443263==    by 0x5B0672: bfd_elf_link_add_symbols (elflink.c:6333)
==1443263==    by 0x41448F: load_symbols (ldlang.c:3129)
==1443263==    by 0x4149D8: open_input_bfds (ldlang.c:3621)
==1443263==    by 0x414968: open_input_bfds (ldlang.c:3569)
==1443263==    by 0x4166A2: lang_process (ldlang.c:8162)
==1443263==    by 0x4194D5: main (ldmain.c:504)

	PR ld/31482
	PR ld/31489
	* elflink.c (elf_link_add_to_first_hash): Add "copy" param.
	(elf_link_add_object_symbols): Flag that name must be copied
	when appending version string to symbol name.
2024-04-06 16:35:35 +10:30
GDB Administrator
82475fa2fa Automatic date update in version.in 2024-04-06 00:00:09 +00:00
H.J. Lu
816fd3dced elf: Use elf_link_first_hash_entry for first_hash
Add elf_link_first_hash_entry and use it for first_hash.  Free first_hash
before freeing the main hash table.

	PR ld/31482
	PR ld/31489
	* elf-bfd.h (elf_link_hash_table): Change first_hash to
	bfd_hash_table.
	* elflink.c (elf_link_first_hash_entry): New.
	(elf_link_first_hash_newfunc): Likewise.
	(elf_link_add_to_first_hash): Updated.
	(elf_link_add_object_symbols): Initialize first_hash with
	elf_link_first_hash_newfunc.
	(elf_link_add_object_symbols): Updated.
	(elf_link_add_archive_symbols): Likewise.
	(_bfd_elf_link_hash_table_free): Free first_hash before freeing
	the main hash table.
2024-04-05 16:49:09 -07:00
H.J. Lu
c0419c024b elf: Always honor the first definition in shared object and archive
GCC doesn't put builtin function symbol references, which are defined in
the shared C library, in the IR symbol table.  When linker rescans shared
objects and archives for newly added symbol references generated from the
IR inputs, it skips definitions of the builtin functions in shared
objects and archives.

Add first_hash to elf_link_hash_table to track unreferenced definitions
defined first in shared objects and archives.  Always use them to resolve
any references.

bfd/

	PR ld/31482
	PR ld/31489
	* elf-bfd.h (elf_link_hash_table): Add first_hash.
	* elflink.c (elf_link_add_to_first_hash): New function.
	(elf_link_add_object_symbols): Initialize first_hash for an IR
	input.  Always use the first definition in shared object.  Add
	the first unreferenced dynamic definition to first_hash.
	(_bfd_elf_archive_symbol_lookup): Add the first unreferenced
	definition to first_hash..
	(elf_link_add_archive_symbols): Use the symbol definition in
	archive if symbol is defined first in this archive.
	(_bfd_elf_link_hash_table_free): Also free first_hash.

ld/

	PR ld/31482
	PR ld/31489
	* testsuite/ld-plugin/lto.exp: Add PR ld/31482 and PR ld/31489
	tests.
	* testsuite/ld-elf/pr31482a-no-lto.c: New file.
	* testsuite/ld-elf/pr31482b-no-lto.c: Likewise.
	* testsuite/ld-elf/pr31482c-no-lto.c: Likewise.
	* testsuite/ld-elf/pr31482d-no-lto.c: Likewise.
	* testsuite/ld-plugin/pass1.out: Likewise.
	* testsuite/ld-plugin/pr31482a.c: Likewise.
	* testsuite/ld-plugin/pr31482b.c: Likewise.
	* testsuite/ld-plugin/pr31482c.c: Likewise.
2024-04-05 05:02:38 -07:00
Zhiqing Xiong
eac88f3298 Add support for Windows network paths to the UNC support in _bfd_real_open().
PR 31527
2024-04-05 09:41:40 +01:00
Christophe Lyon
54e2d897a6 Add missing install-dvi and install-ps Makefie targets.
For some reason, these targets are missing although others from the
same family are present. This looks like an oversight.

This enables calling 'make install-dvi' from the top-level build
directory.
2024-04-05 07:02:56 +00:00
H.J. Lu
37eac4810b bfd: Munmap readonly memory after bfd_free_cached_info
Munmap readonly memory after bfd_free_cached_info which may use munmapped
readonly memory.

	PR ld/31608
	* opncls.c (_bfd_delete_bfd): Munmap readonly memory after
	bfd_free_cached_info.
2024-04-04 18:52:58 -07:00
GDB Administrator
c069de3491 Automatic date update in version.in 2024-04-05 00:00:11 +00:00
H.J. Lu
0ffdc37b98 bfd_mmap_local: Check offset and size
Update bfd_mmap_local to return NULL if filesize < offset or filesize -
offset < rsize.

	* libbfd.c (bfd_mmap_local): Validate offset and size against
	the file size.
2024-04-04 15:35:48 -07:00
H.J. Lu
360d244b24 bfd: Handle bmmap failure in _bfd_mmap_read_temporary
iovec->bmmap may return MAP_FAILED, which happens in GDB on objects with
iovec == opncls_iovec.  Update _bfd_mmap_read_temporary to handle
iovec->bmmap failure.

	* libbfd.c (_bfd_mmap_read_temporary): Handle iovec->bmmap
	failure.
2024-04-04 15:35:31 -07:00
H.J. Lu
c2d698fe03 x86: Restore APX shift-double instructions with omitted shift count
Restore APX shift-double instructions with omitted shift count since
they are generated by GCC as shown in:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114590

gas/

	PR gas/31606
	* testsuite/gas/i386/x86-64-apx-ndd-wig.d: Updated.
	* testsuite/gas/i386/x86-64-apx-ndd.d: Likewise.
	* testsuite/gas/i386/x86-64-apx-ndd.s: Add tests for APX
	shift-double instructions with omitted shift count.

opcodes/

	PR gas/31606
	* i386-opc.tbl: Restore APX shift-double instructions with
	omitted shift count.
	* i386-tbl.h: Regenerated.
2024-04-04 13:16:20 -07:00
Tom Tromey
16810e455f Add flake8 and isort to .pre-commit-config.yaml
This adds flake8 and isort to .pre-commit-config.yaml.  This way, they
will automatically be run on commit.

I chose the most recent available versions after verifying that they
don't cause any reports or changes in the current tree.

Internally at AdaCore, we also use a few flake8 plugins as well, so
perhaps that's another avenue for investigation.

v2: Also update the various file-selection clauses to pick up
gdb-gdb.py.in; include the isort change made to this file; and finally
add a comment about the exclusions from flake8.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-04-04 06:43:39 -06:00
Bernd Edlinger
b0ca740e8f Fix a test failure in gdb.threads/stepi-over-clone.exp
When the XML support was disabled at compile time,
the test case gdb.threads/stepi-over-clone.exp fails
with lots of time-outs, which can be annoying.
This makes the test case unsupported instead.

Approved-By: Tom Tromey <tom@tromey.com>
2024-04-04 14:26:19 +02:00