Commit Graph

96221 Commits

Author SHA1 Message Date
Sam Tebbs 0903806253 Move aarch64 CIE code to aarch64 backend
This commit moves all aarch64-specific code to deal with CIE structure
introduced in 3a67e1a6b4 from
target-independent files to the aarch64 backend.

2018-12-13  Sam Tebbs  <sam.tebbs@arm.com>

binutils/
	* dwarf.c (read_cie):  Add check for 'B'.

gas/
	* config/tc-aarch64.h (enum pointer_auth_key,
	tc_fde_entry_extras, tc_cie_entry_extras, tc_fde_entry_init_extra,
	tc_output_cie_extra, tc_cie_fde_equivalent_extra,
	tc_cie_entry_init_extra): Define.
	* dw2gencfi.c (struct cie_entry): Add tc_cie_entry_extras invocation.
	(alloc_fde_entry, select_cie_for_fde): Add tc_fde_entry_init_extra
	invocation.
	(output_cie): Add tc_output_cie_extra invocation.
	(select_cie_for_fde): Add tc_cie_fde_equivalent_extra invocation.
	* dw2gencfi.h (enum pointer_auth_key): Move to config/tc-aarch64.h.
	(struct fde_entry): Add tc_fde_entry_extras invocation
2018-12-13 16:37:40 +00:00
GDB Administrator fe554d200d Automatic date update in version.in 2018-12-13 00:00:36 +00:00
Stafford Horne 66ac1ae906 gdb: Update NEWS for OpenRISC Linux support
gdb/ChangeLog:

	* NEWS(New targets): Add or1k*-*-linux*.
2018-12-13 06:06:12 +09:00
Philippe Waroquiers c8749e5810 OBVIOUS: Forward declare linux_xfer_osdata_info_os_types on one line to fix ARI warning.
2018-12-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* nat/linux-osdata.c (linux_xfer_osdata_info_os_types): Forward
	declare on one line to fix ARI warning.
2018-12-12 21:14:48 +01:00
Andrew Burgess b001de2320 gdb: Update test pattern to deal with native-extended-gdbserver
When running the test gdb.base/annota1.exp with:

  make check-gdb RUNTESTFLAGS="--target_board=native-extended-gdbserver gdb.base/annota1.exp"

I would see a failure due to some unexpected lines in GDB's output.
The extra lines (when compared with a native run) were about file
transfer from the remote back to GDB.

This commit extends the regexp for this test to allow for these extra
lines, and also splits the rather long regexp up into a list of parts.

With this change in place I see no failures for gdb.base/annota1.exp
when using the native-extended-gdbserver target board, nor with a
native run on X86-64/Linux.

gdb/testsuite/ChangeLog:

	* gdb.base/annota1.exp: Update a test regexp.
2018-12-12 17:33:52 +00:00
Andrew Burgess 6bf78e29a1 gdb/infcall: Make infcall_suspend_state into a class
I ran into a situation where attempting to make an inferior function
call would trigger an assertion, like this:

    (gdb) call some_inferior_function ()
    ../../src/gdb/regcache.c:310: internal-error: void regcache::restore(readonly_detached_regcache*): Assertion `src != NULL' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n)

The problem that triggers the assertion is that in the function
save_infcall_suspend_state, we basically did this:

    1. Create empty infcall_suspend_state object.
    2. Fill fields of infcall_suspend_state object.

The problem is causes is that if filling any of the fields triggered
an exception then the infcall_suspend_state object would be deleted
while in a partially filled in state.

In the specific case I encountered, I had a remote RISC-V target that
claimed in its target description to support floating point registers.
However, this was not true, and when GDB tried to read a floating
point register the remote sent back an error.  This error would cause
an exception to be thrown while creating the
readonly_detached_regcache, which in turn caused GDB to try and delete
an infcall_suspend_state which didn't have any register state, and
this triggered the assertion.

To prevent this problem we have two possibilities, either, rewrite the
restore code the handle partially initialised infcall_suspend_state
objects, or, prevent partially initialised infcall_suspend_state
objects from existing.  The second of these seems like a better
solution.

So, in this patch, I move the filling in of the different
infcall_suspend_state fields within a new constructor for
infcall_suspend_state.  Now, if generating one of those fields fails
the destructor for infcall_suspend_state will not be executed and GDB
will not try to restore the partially saved state.

With this patch in place GDB now behaves like this:

    (gdb) call some_inferior_function ()
    Could not fetch register "ft0"; remote failure reply 'E99'
    (gdb)

The inferior function call is aborted due to the error.

This has been tested against x86-64/Linux native, native-gdbserver,
and native-extended-gdbserver with no regressions.  I've manually
tested this against my baddly behaving target and confirmed the
inferior function call is aborted as described above.

gdb/ChangeLog:

	* infrun.c (infcall_suspend_state::infcall_suspend_state): New.
	(infcall_suspend_state::registers): New.
	(infcall_suspend_state::restore): New.
	(infcall_suspend_state::thread_suspend): Rename to...
	(infcall_suspend_state::m_thread_suspend): ...this.
	(infcall_suspend_state::registers): Rename to...
	(infcall_suspend_state::m_registers): ...this.
	(infcall_suspend_state::siginfo_gdbarch): Rename to...
	(infcall_suspend_state::m_siginfo_gdbarch): ...this.
	(infcall_suspend_state::siginfo_data): Rename to...
	(infcall_suspend_state::m_siginfo_data): ...this.
	(save_infcall_suspend_state): Rewrite to use infcall_suspend_state
	constructor.
	(restore_infcall_suspend_state): Rewrite to use
	infcall_suspend_state::restore method.
	(get_infcall_suspend_state_regcache): Use
	infcall_suspend_state::registers method.
2018-12-12 17:33:14 +00:00
Andrew Burgess 4de3d8d066 gdb/riscv: Handle passing variadic floating point arguments
This commit fixes some test failures in gdb.base/varargs.exp when
running on targets with floating point hardware.  Floating point
unnamed (variadic) arguments should be passed in integer registers
according to the abi.

After this commit I see no failures in gdb.base/varargs.exp on 32 or
64 bit targets with floating point hardware.

gdb/ChangeLog:

	* riscv-tdep.c (riscv_call_arg_scalar_float): Unnamed (variadic)
	arguments are passed in integer registers.
	(riscv_call_arg_complex_float): Likewise.
2018-12-12 14:21:31 +00:00
Andre Vieira 13dc50ee16 [GAS][Arm] Skip Local BLX Thumb tests for arm-netbsdelf and arm-nto
gas/ChangeLog
2018-12-12  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	* testsuite/gas/arm/blx-local-thumb.d: Skip arm-nto and
	arm-netbsdelf.
2018-12-12 13:31:46 +00:00
GDB Administrator 60f9fdc9c2 Automatic date update in version.in 2018-12-12 00:00:28 +00:00
Max Filippov 00863b8e40 bfd: xtensa: ignore overflow in hight part of const16 relocation
32-bit constants loaded by two const16 opcodes that involve relocation
(e.g. calculated as a sum of a symbol and a constant) may overflow,
resulting in linking error with the following message:

  dangerous relocation: const16: cannot encode: (_start+0x70000000)

They should wrap around instead. Limit const16 opcode immediate field to
16 least significant bits to implement this wrap around.

bfd/
2018-12-11  Max Filippov  <jcmvbkbc@gmail.com>

	* elf32-xtensa.c (elf_xtensa_do_reloc): Limit const16 opcode
	immediate field to 16 least significant bits.
2018-12-11 14:21:39 -08:00
Philippe Waroquiers 750b258ef8 Fix leaks in all the linux osdata annex transfers + code factorization.
Valgrind reports leaks in all linux osdata annex transfers of linux-osdata.c.

A typical leak (this one is of gdb.base/info-os) is:
==10592== VALGRIND_GDB_ERROR_BEGIN
==10592== 65,536 bytes in 1 blocks are definitely lost in loss record 3,175 of 3,208
==10592==    at 0x4C2E273: realloc (vg_replace_malloc.c:826)
==10592==    by 0x409B0C: xrealloc (common-utils.c:62)
==10592==    by 0x408BC3: buffer_grow(buffer*, char const*, unsigned long) [clone .part.1] (buffer.c:40)
==10592==    by 0x5263DF: linux_xfer_osdata_processes(unsigned char*, unsigned long, unsigned long) (linux-osdata.c:370)
==10592==    by 0x520875: linux_nat_xfer_osdata (linux-nat.c:4214)
...

The leaks are created because the linux_xfer_osdata_* functions
transfer the ownership of their 'static struct buffer' memory
to their 'static char *buf' local var, but then call buffer_free
instead of xfree-ing buf.

I see no reason why the ownership of the memory has to be transferred
from a local var to another local var, so the fix consists in dropping
the 'static char *buf' and accessing the struct buffer memory where needed.

Also, because this bug was replicated in all functions, and there was
a non neglectible amount of duplicated code, the setup and usage
of the 'static struct buffer' is factorized in a new function
common_getter.  The buffer for a specific annex is now a member
of the struct osdata_type instead of being a static var of each
linux_xfer_osdata_* function.

Thanks to this, all the linux_xfer_osdata_* do not have
anymore any logic related to the partial transfer of data: they now
only build the xml data in a struct buffer.
This all removes about 300 SLOC.

Note: git diff/git format-patch shows a lot of differences only due
to space changes/indentation changes.
So, git diff -w helps to look only at the relevant differences.

gdb/ChangeLog
2018-12-11  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* nat/linux-osdata.c (common_getter): New function.
	(struct osdata_type): Change getter to take_snapshot.
	Add LONGEST len_avail and struct buffer buffer.
	Change all elements in the initializer.
	Add an element for the list of types.
	(linux_xfer_osdata_info_os_types): New function.
	(linux_common_xfer_osdata): Use common_getter for the list of types.
	Replace getter call by common_getter.
	(linux_xfer_osdata_cpus): Remove args READBUF, OFFSET, LEN.
	Add arg BUFFER.  Only keep the code that adds data in BUFFER.
	(linux_xfer_osdata_fds): Likewise.
	(linux_xfer_osdata_modules): Likewise.
	(linux_xfer_osdata_msg): Likewise.
	(linux_xfer_osdata_processes): Likewise.
	(linux_xfer_osdata_processgroups): Likewise.
	(linux_xfer_osdata_sem): Likewise.
	(linux_xfer_osdata_shm): Likewise.
	(linux_xfer_osdata_isockets): Likewise.
	(linux_xfer_osdata_threads): Likewise.
2018-12-11 23:00:47 +01:00
Philippe Waroquiers 9f37501839 Fix the date in the ChangeLog 2018-12-11 22:35:19 +01:00
Philippe Waroquiers 326b0c1289 PATCH/OBVIOUS Remove various trailing spaces in linux-osdata.c 2018-12-11 22:32:54 +01:00
H.J. Lu 550892eb5a Fix a typo in scripttempl/elf32xc16x.sc
* scripttempl/elf32xc16x.sc: Fix a typo.
2018-12-11 06:18:12 -08:00
H.J. Lu 209d1499de xc16x: Add elf32_xc16x_rtype_to_howto
Add elf32_xc16x_rtype_to_howto to get reloc_howto_type pointer from
ELF32_R_TYPE.

	* elf32-xc16x.c (elf32_xc16x_rtype_to_howto): New function.
	(elf32_xc16x_relocate_section): Call elf32_xc16x_rtype_to_howto
	instead of xc16x_reloc_type_lookup to get reloc_howto_type.
2018-12-11 06:01:46 -08:00
Nick Clifton 69799d67e8 Fix a failure in the libiberty testsuite by increasing the recursion limit to 2048.
PR 88409
include	* demangle.h (DEMANGLE_RECURSION_LIMIT): Increase to 2048.

binutils* NEWS: Note that recursion limit has increased to 2048.
	* doc/binutils.texi: Likewise.
2018-12-11 12:01:15 +00:00
Andrew Burgess 99e1a184a7 gdb/riscv: Update test to handle targets without an fpu
The FPU is optional on RISC-V.  The gdb.base/float.exp test currently
assumes that an fpu is always available on RISC-V.  Update the test so
that this is not the case.

gdb/testsuite/ChangeLog:

	* gdb.base/float.exp: Handle RISC-V targets without an FPU.
2018-12-11 11:36:52 +00:00
Jim Wilson 8970c0224e RISC-V: Don't segfault for two regs in auipc or lui.
gas/
	PR gas/23954
	* config/tc-riscv.c (my_getSmallExpression): Expand comment for
	register support.  Set expr_end if parse a register.
	(riscv_ip) <'u'>: Break if imm_expr is not a symbol or constant.
	* testsuite/gas/riscv/auipc-parsing.d: New.
	* testsuite/gas/riscv/auipc-parsing.l: New.
	* testsuite/gas/riscv/auipc-parsing.s: New.
2018-12-10 16:40:46 -08:00
GDB Administrator 5136770380 Automatic date update in version.in 2018-12-11 00:00:36 +00:00
H.J. Lu e771f7a770 Correct gas/ChangeLog entry for PR gas/23968 2018-12-10 04:08:52 -08:00
Andrew Burgess 69cb29528e gdb/riscv: Remove whitespace before #include line
This fixes an ARI warning in riscv-tdep.c that whitespace before a

gdb/ChangeLog:

	* riscv-tdep.c (riscv_register_name): Fix ARI warning by removing
	leading whitespace before #include line.
2018-12-10 10:18:46 +00:00
GDB Administrator ecfe6254b5 Automatic date update in version.in 2018-12-10 00:00:44 +00:00
H.J. Lu 9f52eab6a7 x86: Put back BFD_RELOC_X86_64_GOTPCREL
Put back BFD_RELOC_X86_64_GOTPCREL in TC_FORCE_RELOCATION_LOCAL, which
was removed by

commit 56ceb5b540
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Oct 22 04:49:20 2015 -0700

    Add R_X86_64_[REX_]GOTPCRELX support to gas and ld

by accident.
2018-12-09 07:22:14 -08:00
Philippe Waroquiers 7a81c1e2d4 Fix tid-reuse sometimes blocks for a very long (infinite?) time.
A failure that seems to cause a long/infinite time is the following:

For a not clear reason, tid-reuse.c spawner thread sometimes gets an error:
     tid-reuse: /bd/home/philippe/gdb/git/build_moreaa/gdb/testsuite/../../../moreaa/gdb/testsuite/gdb.threads/tid-reuse.c:58: spawner_thread_func: Assertion `rc == 0' failed.

which causes a SIGABRT to be trapped by gdb, and tid-reuse does not reach the
after_count breakpoint:
  Thread 2 "tid-reuse" received signal SIGABRT, Aborted.
  [Switching to Thread 0x7ffff7518700 (LWP 10368)]
  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
  51	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
  (gdb) FAIL: gdb.threads/tid-reuse.exp: continue to breakpoint: after_count

After that, tid-reuse.exp gets the value of reuse_time, but this one kept its
initial value of -1 (as unsigned) :
  print reuse_time
  $1 = 4294967295
  (gdb) PASS: gdb.threads/tid-reuse.exp: get reuse_time

tid-reuse then dies, and the .exp script continues (with some FAIL)
till it executes:
  set timeout [expr $reuse_time * 2]

leading to the error:

  (gdb) ERROR: integer value too large to represent as non-long integer
      while executing
  "expect {
  -i exp8 -timeout 8589934590
          -re ".*A problem internal to GDB has been detected" {
              fail "$message (GDB internal error)"
              gdb_intern..."
      ("uplevel" body line 1)
      invoked from within
  "uplevel $body" ARITH IOVERFLOW {integer value too large to represent as non-long integer} integer value too large to represent as non-long integer
  ERROR: GDB process no longer exists

and then everything blocks.
This last 'GDB process no longer exists' is strange, as I still see the gdb
when this all blocks, e.g.
philippe 16058 31085  0 20:30 pts/15   00:00:00                         /bin/bash -c rootme=`pwd`; export rootme; srcdir=../../../binutils-gdb/gdb/testsuite ; export srcdir ; EXPECT=`if [
philippe 16386 16058  0 20:30 pts/15   00:00:00                           expect -- /usr/share/dejagnu/runtest.exp --status GDB_PARALLEL=yes --outdir=outputs/gdb.threads/tid-reuse gdb.thre
philippe 24848 16386  0 20:30 pts/20   00:00:00                             /bd/home/philippe/gdb/git/build_binutils-gdb/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /bd/home/philip

This patch gives a default value of 60, so that if ever something wrong happens
in tid-reuse, then the value retrieved by the .exp script stays in a reasonable
range.

Simon verified the patch by:
"I replaced the pthread_create call with the value 1 to simulate a
failure, and the test succeeds to fail quickly with your patch applied.
Without your patch, I get the infinite hang that you describe."

Compared to V1:
As suggested by Pedro, this version checks the pthread calls return
code (in particular of pthread_create) and reports the failure reason,
instead of just aborting.

gdb/testsuite/ChangeLog

2018-12-09  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.threads/tid-reuse.c (REUSE_TIME_CAP): Declare as 60.
	(reuse_time): Initialize to REUSE_TIME_CAP.
	(check_rc): New function.
	(main): Use REUSE_TIME_CAP instead of hardcoded 60.
	Check pthread_create rc.
	(spawner_thread_func): Check pthread_create and pthread_join rc.
2018-12-09 09:24:27 +01:00
Simon Marchi 2578ecb1b5 Look for tgetent in libtinfow
On some systems where ncurses is only available in the "wide" version
(compiled with --with-widec), there might be no libtinfo.so, only a
libtinfow.so.  Look for libtinfow in addition to libtinfo.

gdb/ChangeLog:

YYYY-MM-DD  Simon Marchi  <simon.marchi@ericsson.com>
        Дилян Палаузов  <dilyan.palauzov@aegee.org>

    PR gdb/23950
    * configure.ac: Search for tgetent in libtinfow.
    * configure: Re-generate.
2018-12-08 19:36:19 -05:00
GDB Administrator b5ac78ffc6 Automatic date update in version.in 2018-12-09 00:00:45 +00:00
Philippe Waroquiers a2419b98d9 Fix leak by using td_ta_delete() to deregister target process and deallocate internal process handle.
Valgrind reports the below leak:

==25327== VALGRIND_GDB_ERROR_BEGIN
==25327== 672 bytes in 1 blocks are definitely lost in loss record 2,759 of 3,251
==25327==    at 0x4C2E07C: calloc (vg_replace_malloc.c:752)
==25327==    by 0x7FDCB3E: ???
==25327==    by 0x532A7A: try_thread_db_load_1 (linux-thread-db.c:828)
==25327==    by 0x532A7A: try_thread_db_load(char const*, int) (linux-thread-db.c:997)
==25327==    by 0x53354D: try_thread_db_load_from_sdir (linux-thread-db.c:1074)
==25327==    by 0x53354D: thread_db_load_search (linux-thread-db.c:1129)
==25327==    by 0x53354D: thread_db_load() (linux-thread-db.c:1187)
==25327==    by 0x611AF1: operator() (functional:2127)
==25327==    by 0x611AF1: notify (observable.h:106)
==25327==    by 0x611AF1: symbol_file_add_with_addrs(bfd*, char const*, enum_flags<symfile_add_flag>, std::vector<other_sections, std::allocator<other_sections> >*, enum_flags<objfile_flag>, objfile*) (symfile.c:1158)
==25327==    by 0x5F5C4A: solib_read_symbols(so_list*, enum_flags<symfile_add_flag>) (solib.c:691)
==25327==    by 0x5F6A8B: solib_add(char const*, int, int) (solib.c:1003)
==25327==    by 0x5F6BF7: handle_solib_event() (solib.c:1281)
==25327==    by 0x3D0A94: bpstat_stop_status(address_space const*, unsigned long, thread_info*, target_waitstatus const*, bpstats*) (breakpoint.c:5417)
==25327==    by 0x4FF133: handle_signal_stop(execution_control_state*) (infrun.c:5874)
==25327==    by 0x502C29: handle_inferior_event_1 (infrun.c:5300)
==25327==    by 0x502C29: handle_inferior_event(execution_control_state*) (infrun.c:5335)
==25327==    by 0x5041DB: fetch_inferior_event(void*) (infrun.c:3868)
==25327==    by 0x4A1E7C: gdb_wait_for_event(int) (event-loop.c:859)
...

This leak is created because a call to td_ta_new allocates some resources
that must be freed with td_ta_delete, and that was missing.

With this patch, the nr of GDB executions leaking during regression tests
decreases further from 566 to 380.

Note that the gdbserver equivalent code is properly calling
td_ta_delete: see thread_db_mourn in thread-db.c.

Tests run natively on debian/amd64, and run under valgrind.

gdb/ChangeLog
2018-12-08  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* linux-thread-db.c (struct thread_db_info): Add td_ta_delete_p.
	(thread_db_err_str): Forward declare.
	(delete_thread_db_info): Call td_ta_delete_p if available.
	(try_thread_db_load_1): Acquire td_ta_delete address.
	* nat/gdb_thread_db.h (td_ta_delete_ftype): Declare.
2018-12-08 17:06:09 +01:00
Pedro Alves 73e8dc90a8 Merge forward-search/reverse-search, use gdb::def_vector, remove limit
Back in:

 commit 85ae1317ad
 Author:     Stan Shebs <shebs@codesourcery.com>
 AuthorDate: Thu Dec 8 02:27:47 1994 +0000

	     * source.c: Various cosmetic changes.
	     (forward_search_command): Handle very long source lines correctly.

a buffer with a hard limit was converted to a heap buffer:

  @@ -1228,15 +1284,26 @@ forward_search_command (regex, from_tty)
     stream = fdopen (desc, FOPEN_RT);
     clearerr (stream);
     while (1) {
  -/* FIXME!!!  We walk right off the end of buf if we get a long line!!! */
  -    char buf[4096];            /* Should be reasonable??? */
  -    register char *p = buf;
  +    static char *buf = NULL;
  +    register char *p;
  +    int cursize, newsize;
  +
  +    cursize = 256;
  +    buf = xmalloc (cursize);
  +    p = buf;

However, reverse_search_command has the exact same problem, and that
wasn't fixed.  We still have that "we walk right off" comment...

Recently, the xmalloc above was replaced with a xrealloc, because as
can be seen above, that 'buf' variable above was a static local,
otherwise we'd be leaking.  This commit replaces that and the
associated manual buffer growing with a gdb::def_vector<char>.  I
don't think there's much point in reusing the buffer across command
invocations.

While doing this, I realized that reverse_search_command is almost
identical to forward_search_command.  So this commit factors out a
common helper function instead of duplicating a lot of code.

There are some tests for "forward-search" in gdb.base/list.exp, but
since they use the "search" alias, they were a bit harder to find than
expected.  That's now fixed, both by testing both variants, and by
adding some commentary.  Also, there are no tests for the
"reverse-search" command, so this commit adds some for that too.

gdb/ChangeLog:
2018-12-08  Pedro Alves  <palves@redhat.com>

	* source.c (forward_search_command): Rename to ...
	(search_command_helper): ... this.  Add 'forward' parameter.
	Tweak to use a gdb::def_vector<char> instead of a xrealloc'ed
	buffer.  Handle backward searches too.
	(forward_search_command, reverse_search_command): Reimplement by
	calling search_command_helper.

gdb/testsuite/ChangeLog:
2018-12-08  Pedro Alves  <palves@redhat.com>

	* gdb.base/list.exp (test_forward_search): Rename to ...
	(test_forward_reverse_search): ... this.  Also test reverse-search
	and the forward-search alias.
2018-12-08 15:03:29 +00:00
Alan Modra c0ab2ae3cc [GOLD] icf_safe_so_test
PR 21128
	* testsuite/icf_safe_so_test.sh (check_fold): Rewrite to check
	multiple symbols at once.
	(arch_specific_safe_fold): Likewise, and call with the four foo*
	symbols expected to fold.
2018-12-08 13:24:14 +10:30
Alan Modra 7ca166c940 Fix strings.c endian issue and strings test
git commit 71f5e3f7b6 obviously wasn't tested on a big-endian host,
and the test fail message resulted in tcl errors.

	* strings.c (unget_part_char): New function.
	(print_strings): Use unget_part_char.  Formatting.
	* testsuite/binutils-all/strings.exp (test_multibyte): Don't
	use square brackets in fail message.  Expect "String1\nString2".
2018-12-08 13:22:33 +10:30
GDB Administrator 5aee1c38f9 Automatic date update in version.in 2018-12-08 00:00:28 +00:00
H.J. Lu fbcc8bafeb Override the previous definition from IR object
Mark the previous definition from IR object as undefined so that the
generic linker will override it.

bfd/

	PR ld/23958
	* elflink.c (_bfd_elf_add_default_symbol): Override the previous
	definition from IR object.

ld/

	PR ld/23958
	* testsuite/ld-plugin/lto.exp: Run PR ld/23958 test.
	* testsuite/ld-plugin/pr23958.c: New file.
	* testsuite/ld-plugin/pr23958.t: Likewise.
2018-12-07 15:40:02 -08:00
Andrew Burgess d9c859da9f gdb/emacs/dir-locals: Update settings for c++-mode
The current .dir-locals file for GDB causes files that would usually
open in c-mode (for example, files ending in .c) to open in c++-mode.
However, all of the other settings applied for c-mode appear to get
reset when the file is switched over to c++-mode.

For example, we currently say:

 (c-mode . ((c-file-style . "GNU")
	    (mode . c++)
	    (indent-tabs-mode . t)
	    (tab-width . 8)
	    (c-basic-offset . 2)
	    (eval . (c-set-offset 'innamespace 0))
	    ))
 (c++-mode . ((eval . (when (fboundp 'c-toggle-comment-style)
			(c-toggle-comment-style 1)))))

So, when we enter c++-mode `indent-tabs-mode` is reset to its global
value, as are all of the other settings listed for c-mode.

This commit copies all of the settings (except the `mode` setting)
from the c-mode list to the c++-mode list.

The emacs documentation doesn't mention that `mode` causes this
resetting behaviour, so, in case this is an emacs bug, I'm using emacs
version 26.1.  Having the settings duplicated shouldn't cause any
problems except for a slight maintenance overhead.

gdb/ChangeLog:

	* .dir-locals.el: Copy most of the settings from c-mode over to
	c++-mode.
2018-12-07 23:20:30 +00:00
Stafford Horne 42e151bf4c gdb/or1k: Add linux debugging support
Up until now OpenRISC GDB only has supported bare metal debugging.  This
patch adds linux userspace debugging and core dump analysis support.

The changes are loosely based on nios2 and riscv implementations.

This was tested with linux 4.20 core dumps for executables linked
against musl libc.

bfd/ChangeLog:

	* elf32-or1k.c (or1k_grok_prstatus): New function.
	(or1k_grok_psinfo): Likewise.

gdb/ChangeLog:

	* Makefile.in (ALL_TARGET_OBS): Add or1k-linux-tdep.o.
	* configure.tgt: Add or1k*-*-linux*.
	* or1k-linux-tdep.c: New file.
	* or1k-tdep.c (or1k_gdbarch_init): Call gdbarch_init_osabi.
2018-12-08 07:07:36 +09:00
Jim Wilson f50fabe4f6 RISC-V: Fix 4-arg add parsing.
PR gas/23956
	gas/
	* config/tc-riscv.c (validate_riscv_insn) <'1'>: New case.
	(percent_op_null): New.
	(riscv_ip) <'j'>: Set imm_reloc before p.
	<'1'>: New case.
	<'0'>: Use percent_op_null and don't set imm_reloc.
	<alu_op>: Handle *args == '1'.
	* testsuite/gas/riscv/tprel-add.d: New.
	* testsuite/gas/riscv/tprel-add.l: New.
	* testsuite/gas/riscv/tprel-add.s: New.
	opcodes/
	* riscv-opc.c (riscv_opcodes) <"add">: Use 1 not 0 for fourth arg.
2018-12-07 12:31:05 -08:00
Pedro Alves 8bebfcda34 Fix gdb build on 32-bit hosts w/ --enable-64-bit-bfd
Building for x86_64/-m32 with --enable-64-bit-bfd, compilation fails
with:

 src/gdb/dwarf2read.c: In instantiation of ‘gdb::array_view<const unsigned char> get_gdb_index_contents_from_section(objfile*, T*) [with T = dwarf2_per_objfile]’:
 src/gdb/dwarf2read.c:6266:54:   required from here
 src/gdb/dwarf2read.c:6192:37: error: narrowing conversion of ‘section->dwarf2_section_info::size’ from ‘bfd_size_type {aka long long unsigned int}’ to ‘size_t {aka unsigned int}’ inside { } [-Werror=narrowing]
    return {section->buffer, section->size};
			     ~~~~~~~~~^~~~

This fixes it.

gdb/ChangeLog:
2018-12-07  Pedro Alves  <palves@redhat.com>

	* dwarf2read.c (get_gdb_index_contents_from_section): Use
	gdb::make_array_view.
2018-12-07 19:54:19 +00:00
H.J. Lu d2ef37ebd9 elf: Report property change when merging properties
With merging properties, report property change in linker map file, like

Merging program properties

Removed property 0xc0010000 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (0x0) and /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crti.o (0x0)
Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (0x3) and x.o (not found)
Removed property 0xc0000000 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (not found) and /usr/lib64/libc_nonshared.a(elf-init.oS) (0x0)
Removed property 0xc0000001 to merge /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/crt1.o (not found) and /usr/lib64/libc_nonshared.a(elf-init.oS) (0x0)

bfd/

	* elf-properties.c (elf_find_and_remove_property): Add a
	bfd_boolean argument to indicate if the property should be
	removed.
	(elf_merge_gnu_property_list): Updated.  Report
	property change in linker map file.
	(elf_get_gnu_property_section_size): Skip property_remove
	properties.
	(elf_write_gnu_properties): Likewise.
	(_bfd_elf_link_setup_gnu_properties): Report property merge
	in linker map file.  Pass abfd to elf_merge_gnu_property_list.

include/

	* bfdlink.h (bfd_link_info): Add has_map_file.

ld/

	* NEWS: Updated for property change report.
	* ld.texi: Document property change report.
	* ldmain.c (main): Set link_info.has_map_file to TRUE when
	linker map file is used.
	* testsuite/ld-scripts/rgn-over1.d: Updated.
	* testsuite/ld-scripts/rgn-over2.d: Likewise.
	* testsuite/ld-scripts/rgn-over3.d: Likewise.
	* testsuite/ld-scripts/rgn-over4.d: Likewise.
	* testsuite/ld-scripts/rgn-over5.d: Likewise.
	* testsuite/ld-scripts/rgn-over6.d: Likewise.
	* testsuite/ld-scripts/rgn-over7.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Check linker map
	file.
	* testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a.map: New file.
2018-12-07 08:30:43 -08:00
Philippe Waroquiers 4a8110007b Fix a (one shot small) leak in language.c
Valgrind detects the following leak:
==28395== VALGRIND_GDB_ERROR_BEGIN
==28395== 5 bytes in 1 blocks are definitely lost in loss record 20 of 2,770
==28395==    at 0x4C2BE2D: malloc (vg_replace_malloc.c:299)
==28395==    by 0x41D9E7: xmalloc (common-utils.c:44)
==28395==    by 0x78BF39: xstrdup (xstrdup.c:34)
==28395==    by 0x51F1AC: _initialize_language() (language.c:1175)
==28395==    by 0x6B3356: initialize_all_files() (init.c:308)
==28395==    by 0x66D194: gdb_init(char*) (top.c:2159)
==28395==    by 0x554C11: captured_main_1 (main.c:863)
==28395==    by 0x554C11: captured_main (main.c:1167)
==28395==    by 0x554C11: gdb_main(captured_main_args*) (main.c:1193)
==28395==    by 0x29D837: main (gdb.c:32)
==28395==
==28395== VALGRIND_GDB_ERROR_END

This is a very small leak (1 block/5 bytes), happening only once
per GDB startup as far as I can see. But this fix make the nr of leaking
GDB in the testsuite decreasing from 628 to 566.

It is unclear why a xstrdup-ed value is assigned to 'language'
at initialization time, while a static "auto" string is assigned
as part of the set_language_command.
So, that shows that it is ok to initialize 'language' directly
with "auto".
Also, I cannot find any place where 'language' is xfree-d.
No leak was detected for 'range' and 'case_sensitive', but
similarly, no indication why a static string cannot be assigned.

Regression-tested on debian/x86_64.
Also, full testsuite run under valgrind, less tests leaking,
and no dangling pointer problem detected.

gdb/ChangeLog
2018-12-05  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* language.c (_initialize_language): Fix leak by assigning
	a static string to language.  Same for range and case_sensitive,
	even if no leak is detected for these variables.
2018-12-07 16:32:23 +01:00
Alan Modra c2f5dc30af PR23952, memory leak in _bfd_generic_read_minisymbols
bfd/
	PR 23952
	* syms.c (_bfd_generic_read_minisymbols): Free syms before
	returning with zero symcount.
binutils/
	* nm.c (display_rel_file): Use xrealloc to increase minisyms
	for synthetic symbols.
2018-12-08 00:11:16 +10:30
Nick Clifton af03af8f55 Synchronize libiberty with gcc and add --no-recruse-limit option to tools that support name demangling.
This patch addresses the multitude of bug reports about resource exhaustion
in libiberty's name demangling code.  It adds a limit to the amount of
recursion that is allowed, before an error is triggered.  It also adds a
new demangling option to disable this limit.  (The limit is enabled by
default).

	PR 87681
	PR 87675
	PR 87636
	PR 87335
libiberty * cp-demangle.h (struct d_info): Add recursion_limit field.
	* cp-demangle.c (d_function_type): If the recursion limit is
	enabled and reached, return with a failure result.
        (d_demangle_callback): If the recursion limit is enabled, check
	for a mangled string that is so long that there is not enough
	stack space for the local arrays.
        * cplus-dem.c (struct work): Add recursion_level field.
	(demangle_nested_args): If the recursion limit is enabled and
	reached, return with a failure result.

include	* demangle.h (DMGL_RECURSE_LIMIT): Define.
        (DEMANGLE_RECURSION_LIMIT): Prototype.

binutuils * addr2line.c (demangle_flags): New static variable.
        (long_options): Add --recurse-limit and --no-recurse-limit.
        (translate_address): Pass demangle_flags to bfd_demangle.
        (main): Handle --recurse-limit and --no-recurse-limit options.
        * cxxfilt.c (flags): Add DMGL_RECURSE_LIMIT.
        (long_options): Add --recurse-limit and --no-recurse-limit.
        (main): Handle new options.
        * dlltool.c (gen_def_file): Include DMGL_RECURSE_LIMIT in flags
        passed to cplus_demangle.
        * nm.c (demangle_flags): New static variable.
        (long_options): Add --recurse-limit and --no-recurse-limit.
        (main): Handle new options.
        * objdump.c (demangle_flags): New static variable.
        (usage): Add --recurse-limit and --no-recurse-limit.
        (long_options): Likewise.
        (objdump_print_symname): Pass demangle_flags to bfd_demangle.
        (disassemble_section): Likewise.
        (dump_dymbols): Likewise.
        (main): Handle new options.
        * prdbg.c (demangle_flags): New static variable.
        (tg_variable): Pass demangle_flags to demangler.
        (tg_start_function): Likewise.
        * stabs.c (demangle_flags): New static variable.
        (stab_demangle_template): Pass demangle_flags to demangler.
        (stab_demangle_v3_argtypes): Likewise.
        (stab_demangle_v3_arg): Likewise.
	* doc/binutuls.texi: Document new command line options.
	* NEWS: Mention the new feature.
        * testsuite/config/default.exp (CXXFILT): Define if not already
        defined.
        (CXXFILTFLAGS): Likewise.
        * testsuite/binutils-all/cxxfilt.exp: New file.  Runs a few
        simple tests of the cxxfilt program.
2018-12-07 11:32:55 +00:00
GDB Administrator 67bb16f345 Automatic date update in version.in 2018-12-07 00:00:46 +00:00
H.J. Lu 9da0a9988d gold: Provide more failed archive member info in error message
When gold fails to get an archive member, its error message doesn't
have information for

1. The failed archive member name.
2. The cause of failure: non-ELF object vs non-IR object.

This patch adds the failed archive member name and non-ELF/non-IR info
to gold error message.

	* archive.cc (Archive::get_elf_object_for_member): Also print
	archive member and non-ELF/non-IR info on error.
2018-12-06 12:29:01 -08:00
Alan Modra bb6bf75e7a PowerPC @l, @h and @ha warnings, plus VLE e_li
This patch started off just adding the warnings in tc-ppc.c about
incorrect usage of @l, @h and @ha in instructions that don't have
16-bit D-form fields.  That unfortunately showed up three warnings in
ld/testsuite/ld-powerpc/vle-multiseg.s on instructions like
	e_li r3, IV_table@l+0x00
which was being assembled to
   8:	70 60 00 00 	e_li    r3,0
			a: R_PPC_ADDR16_LO	IV_table
The ADDR16_LO reloc is of course completely bogus on e_li, which has
a split 20-bit signed integer field in bits 0x1f7fff, the low 11 bit
in 0x7ff, the next 5 bits in 0x1f0000, and the high 4 bits in 0x7800.
Applying an ADDR16_LO reloc to the instruction potentially changes
the e_li instruction to e_add2i., e_add2is, e_cmp16i, e_mull2i,
e_cmpl16i, e_cmph16i, e_cmphl16i, e_or2i, e_and2i., e_or2is, e_lis,
e_and2is, or some invalid encodings.

Now there is a relocation that suits e_li, R_PPC_VLE_ADDR20, which was
added 2017-09-05 but I can't see code in gas to generate the
relocation.  In any case, VLE_ADDR20 probably doesn't have the correct
semantics for @l since ideally you'd want an @l to pair with @h or @ha
to generate a 32-bit constant.  Thus @l should only produce a 16-bit
value, I think.  So we need some more relocations to handle e_li it
seems, or as I do in this patch, modify the behaviour of existing
relocations when applied to e_li instructions.

include/
	* opcode/ppc.h (E_OPCODE_MASK, E_LI_MASK, E_LI_INSN): Define.
bfd/
	* elf32-ppc.c (ppc_elf_howto_raw <R_PPC_VLE_ADDR20>): Correct
	mask and shift value.
	(ppc_elf_vle_split16): Use E_OPCODE_MASK.  Handle e_li
	specially.
gas/
	* config/tc-ppc.c (md_assemble): Adjust relocs for VLE before
	TLS tweaks.  Handle e_li.  Warn on unexpected operand field
	for lo16/hi16/ha16 relocs.
2018-12-06 23:01:03 +10:30
Andrew Burgess 23ebf37881 sim/cris: Fix references to cgen cpu directory
Don't assume that cgen is located within the binutils-gdb tree.  We
already have CGEN_CPU_DIR and CPU_DIR defined, these are the cpu/
directory within cgen, and the cpu/ directory within binutils-cpu.

The cris target tries to find CPU_DIR relative to the cgen source
tree, which can be wrong when building with an out of tree cgen.

sim/cris/ChangeLog:

	* Makefile.in: Replace uses of CGEN_CPU_DIR with CPU_DIR, and
	remove the definition of CGEN_CPU_DIR.
2018-12-06 12:21:11 +00:00
Andrew Burgess 7fb45a6895 sim/opcodes: Allow use of out of tree cgen source directory
When configuring with '--enbale-cgen-maint' the default for both the
opcodes/ and sim/ directories is to assume that the cgen source is
within the binutils-gdb source tree as binutils-gdb/cgen/.

In the old cvs days, this worked well, as cgen was just another
sub-module of the single cvs repository and could easily be checked
out within the binutils-gdb directory, and managed by cvs in the
normal way.

Now that binutils-gdb is in git, while cgen is still in cvs, placing
the cgen respository within the binutils-gdb tree is more troublesome,
and it would be nice if the two tools could be kept separate.

Luckily there is already some initial code in the configure.ac files
for both opcodes/ and sim/ to support having cgen be located outside
of the binutils-gdb tree, however, this was speculative code written
imagining a future where cgen would be built and installed to some
location.

Right now there is no install support for cgen, and so the configure
code in opcodes/ and sim/ doesn't really do anything useful.  In this
commit I repurpose this code to allow binutils-gdb to be configured so
that it can make use of a cgen source directory that is outside of the
binutils-gdb tree.

With this commit applied it is now possible to configure and build
binutils-gdb like this:

    /path/to/binutils-gdb/src/configure --enable-cgen-maint=/path/to/cgen/src/cgen/
    make all-opcodes
    make -C opcodes run-cgen-all

Just in case anyone is still using cgen inside the binutils-gdb tree,
I have left the default behaviour of '--enable-cgen-maint' (with no
parameter) unchanged, that is it looks for the cgen directory as
'binutils-gdb/cgen/'.

opcodes/ChangeLog:

	* configure.ac (enable-cgen-maint): Support passing path to cgen
	source tree.
	* configure: Regenerate.

sim/ChangeLog:

	* common/acinclude.m4 (enable-cgen-maint): Support passing path to
	cgen source tree.
	* cris/configure: Regenerate.
	* frv/configure: Regenerate.
	* iq2000/configure: Regenerate.
	* lm32/configure: Regenerate.
	* m32r/configure: Regenerate.
	* or1k/configure: Regenerate.
	* sh64/configure: Regenerate.
2018-12-06 12:21:10 +00:00
Andrew Burgess 884b49e3a9 opcodes/riscv: Hide '.L0 ' fake symbols
The RISC-V assembler generates fake labels with the name '.L0 ' as
part of the debug information (see
gas/config/tc-riscv.h:FAKE_LABEL_NAME).

The problem is that currently, when disassembling an object file, the
output looks like this (this is an example from the GDB testsuite, but
is pretty representative of anything with debug information):

  000000000000001e <main>:
    1e:   7179                    addi    sp,sp,-48
    20:   f406                    sd      ra,40(sp)
    22:   f022                    sd      s0,32(sp)
    24:   1800                    addi    s0,sp,48

  0000000000000026 <.L0 >:
    26:   87aa                    mv      a5,a0
    28:   feb43023                sd      a1,-32(s0)
    2c:   fcc43c23                sd      a2,-40(s0)
    30:   fef42623                sw      a5,-20(s0)

  0000000000000034 <.L0 >:
    34:   fec42783                lw      a5,-20(s0)
    38:   0007871b                sext.w  a4,a5
    3c:   678d                    lui     a5,0x3
    3e:   03978793                addi    a5,a5,57 # 3039 <.LASF30+0x2a9d>
    42:   02f71463                bne     a4,a5,6a <.L0 >

  0000000000000046 <.L0 >:
    46:   000007b7                lui     a5,0x0
    4a:   0007b783                ld      a5,0(a5) # 0 <need_malloc>
    4e:   6f9c                    ld      a5,24(a5)

  0000000000000050 <.L0 >:
    50:   86be                    mv      a3,a5
    52:   466d                    li      a2,27
    54:   4585                    li      a1,1
    56:   000007b7                lui     a5,0x0
    5a:   00078513                mv      a0,a5
    5e:   00000097                auipc   ra,0x0
    62:   000080e7                jalr    ra # 5e <.L0 +0xe>

  0000000000000066 <.L0 >:
    66:   4785                    li      a5,1
    68:   a869                    j       102 <.L0 >

  000000000000006a <.L0 >:
    6a:   000007b7                lui     a5,0x0
    6e:   00078513                mv      a0,a5
    72:   00000097                auipc   ra,0x0
    76:   000080e7                jalr    ra # 72 <.L0 +0x8>

The frequent repeated '.L0 ' labels are pointless, as they are
non-unique there's no way to match a use of '.L0 ' to its appearence
in the output, so we'd be better off just not printing it at all.
That's what this patch does by defining a 'symbol_is_valid' method for
RISC-V.  With this commit, the same disassembly now looks like this:

  000000000000001e <main>:
    1e:   7179                    addi    sp,sp,-48
    20:   f406                    sd      ra,40(sp)
    22:   f022                    sd      s0,32(sp)
    24:   1800                    addi    s0,sp,48
    26:   87aa                    mv      a5,a0
    28:   feb43023                sd      a1,-32(s0)
    2c:   fcc43c23                sd      a2,-40(s0)
    30:   fef42623                sw      a5,-20(s0)
    34:   fec42783                lw      a5,-20(s0)
    38:   0007871b                sext.w  a4,a5
    3c:   678d                    lui     a5,0x3
    3e:   03978793                addi    a5,a5,57 # 3039 <.LASF30+0x2a9d>
    42:   02f71463                bne     a4,a5,6a <.L4>
    46:   000007b7                lui     a5,0x0
    4a:   0007b783                ld      a5,0(a5) # 0 <need_malloc>
    4e:   6f9c                    ld      a5,24(a5)
    50:   86be                    mv      a3,a5
    52:   466d                    li      a2,27
    54:   4585                    li      a1,1
    56:   000007b7                lui     a5,0x0
    5a:   00078513                mv      a0,a5
    5e:   00000097                auipc   ra,0x0
    62:   000080e7                jalr    ra # 5e <main+0x40>
    66:   4785                    li      a5,1
    68:   a869                    j       102 <.L5>

  000000000000006a <.L4>:
    6a:   000007b7                lui     a5,0x0
    6e:   00078513                mv      a0,a5
    72:   00000097                auipc   ra,0x0
    76:   000080e7                jalr    ra # 72 <.L4+0x8>

In order to share the fake label between the assembler and the
libopcodes library, I've added some new defines RISCV_FAKE_LABEL_NAME
and RISCV_FAKE_LABEL_CHAR in include/opcode/riscv.h.  I could have
just moved FAKE_LABEL_NAME to the include file, however, I thnk this
would be confusing, someone working on the assembler would likely not
expect to find FAKE_LABEL_NAME defined outside of the assembler source
tree.  By introducing the RISCV_FAKE_LABEL_* defines I can leave the
assembler standard FAKE_LABEL_ defines in the assembler source, but
still share the RISCV_FAKE_LABEL_* with libopcodes.

gas/ChangeLog:

	* config/tc-riscv.h (FAKE_LABEL_NAME): Define as
	RISCV_FAKE_LABEL_NAME.
	(FAKE_LABEL_CHAR): Define as RISCV_FAKE_LABEL_CHAR.

include/ChangeLog:

	* dis-asm.h (riscv_symbol_is_valid): Declare.
	* opcode/riscv.h (RISCV_FAKE_LABEL_NAME): Define.
	(RISCV_FAKE_LABEL_CHAR): Define.

opcodes/ChangeLog:

        * disassembler.c (disassemble_init_for_target): Add RISC-V
        initialisation.
        * riscv-dis.c (riscv_symbol_is_valid): New function.
2018-12-06 09:40:56 +00:00
GDB Administrator eb7be1abbc Automatic date update in version.in 2018-12-06 00:00:31 +00:00
John Baldwin 2861ee4fde Use separate sed expressions to escape auto-load directories.
Not all sed implementations support alternation via \| in the default
regular expressions.  Instead, resort to separate sed expressions via
-e for $debugdir and $datadir.  This fixes the default setting of the
auto-load directories on FreeBSD.  Previously on FreeBSD the sed
invocation was a no-op causing the debugdir and datadir values to be
expanded yielding an autoload path of ':${prefix}/share/gdb'.

gdb/ChangeLog:

	* configure: Re-generate.
	* configure.ac: Use separate sed expressions to escape variables
	in auto-load directories.
2018-12-05 10:51:16 -08:00
Sam Tebbs 3a67e1a6b4 [aarch64] Add support for pointer authentication B key
Armv8.3-A has another key used in pointer authentication called the
B-key (other than the A-key that is already supported). In order for
stack unwinders to work it is necessary to be able to identify frames
that have been signed with the B-key rather than the A-key and it was
felt that keeping this as an augmentation character in the CIE was the
best bet. The DWARF extensions for ARM therefore propose to add a new
augmentation character 'B' to the CIE augmentation string and the
corresponding cfi directive ".cfi_b_key_frame". I've made the relevant
changes to GAS and LD to add support for B-key unwinding, which required
modifying LD to check for 'B' in the augmentation string, adding the
".cfi_b_key_frame" directive to GAS and adding a "pauth_key" field to
GAS's fde_entry and cie_entry structs.

The pointer authentication instructions will behave as NOPs on
architectures that don't support them, and so a check for the
architecture being assembled for is not necessary since there will be no
behavioural difference between augmentation strings with and without the
'B' character on such architectures.

2018-12-05  Sam Tebbs  <sam.tebbs@arm.com>

bfd/
	* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Add check for 'B'.

gas/
	* dw2gencfi.c (struct cie_entry): Add tc_cie_entry_extras invocation.
	(alloc_fde_entry): Add tc_fde_entry_init_extra invocation.
	(output_cie): Add tc_output_cie_extra invocation.
	(select_cie_for_fde): Add tc_cie_fde_equivalent_extra and
	tc_cie_entry_init_extra invocation.
	(frch_cfi_data, cfa_save_data): Move to dwgencfi.h.
	* config/tc-aarch64.c (s_aarch64_cfi_b_key_frame): Declare.
	(md_pseudo_table): Add "cfi_b_key_frame".
	* config/tc-aarch64.h (tc_fde_entry_extras, tc_cie_entry_extras,
	tc_fde_entry_init_extra, tc_output_cie_extra,
	tc_cie_fde_equivalent_extra, tc_cie_entry_init_extra): Define.
	* dw2gencfi.h (struct fde_entry): Add tc_fde_entry_extras invocation.
	(pointer_auth_key): Define.
	(frch_cfi_data, cfa_save_data): Move from dwgencfi.c.
	* doc/c-aarch64.texi (.cfi_b_key_frame): Add documentation.
	* testsuite/gas/aarch64/(pac_ab_key.d, pac_ab_key.s): New file.
2018-12-05 18:30:08 +00:00
Andrew Burgess 90af06793e gdb/riscv: Improve logic for when h/w float abi should be used
Currently, if the target announces that it has floating point
registers in its target description then GDB assumes that the hardware
float ABI should be used.  However, there's nothing stopping a user
compiling a program for the soft-float abi, and then trying to run
this on a target with hardware floating point registers.

This commit adjusts the logic that decides if GDB should use the
hardware float abi.  The primary decision now is based on what the ELF
currently being executed says in its headers.  If the file was
compiled for h/w float abi, then GDB uses h/w float abi, otherwise s/w
float is used.

If the current BFD is not an ELF then we don't currently have a
mechanism for figuring out if the file was compiled for float or not.
In this case we disable the h/w float abi.  This shouldn't be a
problem as, right now, the RISC-V linker can only produce ELFs.

If there is NO current BFD (can this happen?) then we will enable h/w
float abi if the target has floating point hardware, otherwise, s/w
float abi is used.

This commit also adds some sanity checking that the features requested
in the BFD (xlen and flen) match the target description.

For testing I ran the testsuite on a target that returns a target
description containing both integer and floating point registers, but
used a compiler that didn't have floating point support.  Before this
commit I would see failures on may tests that made inferior calls
using floating point arguments, after this commit, all of these issues
are resolved.  One example from the testsuite is
gdb.base/infcall-nested-structs.exp.

gdb/ChangeLog:

	* riscv-tdep.c (riscv_features_from_gdbarch_info): New function.
	(riscv_find_default_target_description): Use new function to
	extract feature from gdbarch_info.
	(riscv_gdbarch_init): Add error checks for xlen and flen between
	target description and bfd headers.  Be smarter about when we
	think the hardware floating point abi should be used.
2018-12-05 13:23:23 +00:00