In commit b86d3af60f and 0ab0435fe6 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.
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.
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.
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.
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.
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.
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.
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>
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.
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.
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.
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>
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>
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.
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.
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.
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.
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.
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.
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).
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.
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.
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>
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>
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.
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>
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>
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>
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>
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>
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>
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
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.
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.
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.
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.