]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
2 years agogdb/riscv: add support for vector registers in target descriptions
Andrew Burgess [Tue, 4 May 2021 10:41:09 +0000 (11:41 +0100)] 
gdb/riscv: add support for vector registers in target descriptions

This commit adds support to RISC-V GDB for vector registers in the
incoming target description.

The vector registers should be described in a feature called
"org.gnu.gdb.riscv.vector", and should contain the register v0 to
v31.  There's no restriction on the size or type of these registers,
so the target description can set these up as it requires.

However, if the target feature is present then all of the registers
must be present, and they must all be the same size, these
requirements are, I believe, inline with the RISC-V vector extension.

The DWARF register numbers for the vector registers have been added,
and the code to map between GDB's internal numbering and the DWARF
numbering has been updated.

I have not yet added a feature/riscv/*.xml file for the vector
extension, the consequence of this is that we can't, right now, detect
vector registers on a native target, this patch is all about
supporting vectors on a remote target.

It is worth noting that I don't actually have access to a RISC-V
target with vectors, so the only testing that this patch has had has
been done using 'set tdesc filename ....' to load a target description
to which I have manually added the vector feature.  This has shown
that the vector register feature can be successfully parsed, and that
the registers show up in the expected register groups.

Additionally, the RISC-V vector extension is currently at v0.10, which
is also the v1.0 draft release.  However, this extension is not yet
finalised.  It is possible (but unlikely I think) that the register
set could change between now and the final release of the vector
extension.  If this were to happen then we would potentially end up
changing the requirements for the new org.gnu.gdb.riscv.vector
feature.  I really don't think it is likely that the register set will
change this late in the process, and even if it did, changing the
feature requirements will not be a problem as far as I am
concerned (when the alternative is GDB just continues without this
feature for now).

gdb/ChangeLog:

* NEWS: Mention new target feature name.
* arch/riscv.c (riscv_create_target_description): GDB doesn't
currently create target descriptions containing vector registers.
* arch/riscv.h (struct riscv_gdbarch_features) <vlen>: New member
variable.
<operator==>: Also compare vlen.
<hash>: Also include vlen.
* riscv-tdep.c (riscv_feature_name_vector): New static global.
(struct riscv_vector_feature): New struct.
(riscv_vector_feature): New static global.
(riscv_register_reggroup_p): Ensure vector registers are part of
the 'all' group, and part of the 'vector' group.
(riscv_dwarf_reg_to_regnum): Handle vector registers.
(riscv_gdbarch_init): Check vector register feature.
* riscv-tdep.h: Add vector registers to GDB's internal register
numbers, and to the DWARF register numbers.

gdb/doc/ChangeLog:

* gdb.texinfo (RISC-V Features): Mention vector register feature.

2 years agogdb/python: add PendingFrame.level and Frame.level methods
Andrew Burgess [Wed, 26 May 2021 21:01:59 +0000 (22:01 +0100)] 
gdb/python: add PendingFrame.level and Frame.level methods

Add new methods to the PendingFrame and Frame classes to obtain the
stack frame level for each object.

The use of 'level' as the method name is consistent with the existing
attribute RecordFunctionSegment.level (though this is an attribute
rather than a method).

For Frame/PendingFrame I went with methods as these classes currently
only use methods, including for simple data like architecture, so I
want to be consistent with this interface.

gdb/ChangeLog:

* NEWS: Mention the two new methods.
* python/py-frame.c (frapy_level): New function.
(frame_object_methods): Register 'level' method.
* python/py-unwind.c (pending_framepy_level): New function.
(pending_frame_object_methods): Register 'level' method.

gdb/doc/ChangeLog:

* python.texi (Unwinding Frames in Python): Mention
PendingFrame.level.
(Frames In Python): Mention Frame.level.

gdb/testsuite/ChangeLog:

* gdb.python/py-frame.exp: Add Frame.level tests.
* gdb.python/py-pending-frame-level.c: New file.
* gdb.python/py-pending-frame-level.exp: New file.
* gdb.python/py-pending-frame-level.py: New file.

2 years agogdb/python: move PyLong_From* calls into py-utils.c
Andrew Burgess [Wed, 26 May 2021 20:28:11 +0000 (21:28 +0100)] 
gdb/python: move PyLong_From* calls into py-utils.c

We already have two helper functions in py-utils.c:

  gdb_py_object_from_longest (LONGEST l)
  gdb_py_object_from_ulongest (ULONGEST l)

these wrap around calls to either PyLong_FromLongLong,
PyLong_FromLong, or PyInt_From_Long (if Python 2 is being used).

There is one place in gdb/python/* where a call to PyLong_FromLong was
added outside of the above utility functions, this was done in the
recent commit:

  commit 55789354fcbaf879f3ca8475b647b2747dec486e
  Date:   Fri May 14 11:56:31 2021 +0200

      gdb/python: add a 'connection_num' attribute to Inferior objects

In this commit I replace the direct use of PyLong_FromLong with a call
to gdb_py_object_from_longest.  The only real change with this commit,
is that, for Python 2, we will now end up calling PyInt_FromLong
instead of PyLong_FromLong, but this should be invisible to the user.
For Python 3 there should be absolutely no change.

gdb/ChangeLog:

* python/py-inferior.c (infpy_get_connection_num): Call
gdb_py_object_from_longest instead of PyLong_FromLong directly.

2 years agogdb/python: handle saving user registers in a frame unwinder
Andrew Burgess [Wed, 26 May 2021 14:24:04 +0000 (15:24 +0100)] 
gdb/python: handle saving user registers in a frame  unwinder

This patch came about because I wanted to write a frame unwinder that
would corrupt the backtrace in a particular way.  In order to achieve
what I wanted I ended up trying to write an unwinder like this:

  class FrameId(object):
      .... snip class definition ....

  class TestUnwinder(Unwinder):
      def __init__(self):
          Unwinder.__init__(self, "some name")

      def __call__(self, pending_frame):
          pc_desc = pending_frame.architecture().registers().find("pc")
          pc = pending_frame.read_register(pc_desc)

          sp_desc = pending_frame.architecture().registers().find("sp")
          sp = pending_frame.read_register(sp_desc)

          # ... snip code to decide if this unwinder applies or not.

          fid = FrameId(pc, sp)
          unwinder = pending_frame.create_unwind_info(fid)
          unwinder.add_saved_register(pc_desc, pc)
          unwinder.add_saved_register(sp_desc, sp)
          return unwinder

The important things here are the two calls:

          unwinder.add_saved_register(pc_desc, pc)
          unwinder.add_saved_register(sp_desc, sp)

On x86-64 these would fail with an assertion error:

  gdb/regcache.c:168: internal-error: int register_size(gdbarch*, int): Assertion `regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch)' failed.

What happens is that in unwind_infopy_add_saved_register (py-unwind.c)
we call register_size, as register_size should only be called on
cooked (real or pseudo) registers, and 'pc' and 'sp' are implemented
as user registers (at least on x86-64), we trigger the assertion.

A simple fix would be to check in unwind_infopy_add_saved_register if
the register number we are handling is a cooked register or not, if
not we can throw a 'Bad register' error back to the Python code.

However, I think we can do better.

Consider that at the CLI we can do this:

  (gdb) set $pc=0x1234

This works because GDB first evaluates '$pc' to get a register value,
then evaluates '0x1234' to create a value encapsulating the
immediate.  The contents of the immediate value are then copied back
to the location of the register value representing '$pc'.

The value location for a user-register will (usually) be the location
of the real register that was accessed, so on x86-64 we'd expect this
to be $rip.

So, in this patch I propose that in the unwinder code, when
add_saved_register is called, if it is passed a
user-register (i.e. non-cooked) then we first fetch the register,
extract the real register number from the value's location, and use
that new register number when handling the add_saved_register call.

If either the value location that we get for the user-register is not
a cooked register then we can throw a 'Bad register' error back to the
Python code, but in most cases this will not happen.

gdb/ChangeLog:

* python/py-unwind.c (unwind_infopy_add_saved_register): Handle
saving user registers.

gdb/testsuite/ChangeLog:

* gdb.python/py-unwind-user-regs.c: New file.
* gdb.python/py-unwind-user-regs.exp: New file.
* gdb.python/py-unwind-user-regs.py: New file.

2 years agosim: cris: clean up printf & abort usage a bit
Mike Frysinger [Sun, 20 Jun 2021 16:32:27 +0000 (12:32 -0400)] 
sim: cris: clean up printf & abort usage a bit

Inline the stats printf calls to avoid compiler warnings about
non-literal format strings.  This in turn highlights bad type
sizes being passed in, so fix the strings to use the right size
type.  This in turn highlights the rest of the func using casts
rather than the right type directly, so adjust all of those.

Finally, replace a few abort+sim_engine_halt calls with the
common sim_engine_abort.  This provides good output while still
aborting as we want.

2 years agoAutomatic date update in version.in
GDB Administrator [Mon, 21 Jun 2021 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agosim: rx: scope the unique configure flag
Mike Frysinger [Sun, 20 Jun 2021 04:50:30 +0000 (00:50 -0400)] 
sim: rx: scope the unique configure flag

This will make it possible to merge into the common configure by
making sure we never collide with other arches.

2 years agosim: delete SIM_AC_COMMON macro
Mike Frysinger [Sat, 19 Jun 2021 05:36:30 +0000 (01:36 -0400)] 
sim: delete SIM_AC_COMMON macro

Now that we've moved all content out to the common file, this is
empty and can be deleted it entirely.

2 years agosim: unify general maintainer settings
Mike Frysinger [Sat, 19 Jun 2021 14:46:14 +0000 (10:46 -0400)] 
sim: unify general maintainer settings

Move these options up to the common dir so we only test & export
them once across all ports.  This takes a page from the cgen maint
logic to make $(MAINT) work for non-automake Makefiles which will
allow us to merge it together.

2 years agosim: unify cgen maintainer settings
Mike Frysinger [Sat, 19 Jun 2021 14:42:37 +0000 (10:42 -0400)] 
sim: unify cgen maintainer settings

Move these options up to the common dir so we only test & export
them once across all ports.  It makes it available to targets that
aren't cgen-based, but those will just ignore the settings, so it
shouldn't be an issue.

2 years agosim: m68hc11: fix unused function warnings with -O0
Mike Frysinger [Sun, 20 Jun 2021 02:24:57 +0000 (22:24 -0400)] 
sim: m68hc11: fix unused function warnings with -O0

Mark these functions as unused in case they don't get inlined when
building with -O0.

2 years agosim: move sim-inline to the common code
Mike Frysinger [Wed, 16 Jun 2021 02:45:07 +0000 (22:45 -0400)] 
sim: move sim-inline to the common code

This will allow us to build the common code with the same inline
settings as the arch subdirs, and only do the test once.

2 years agox86: Count PLT for GOTOFF relocation against IFUNC symbol
H.J. Lu [Sun, 20 Jun 2021 03:20:52 +0000 (20:20 -0700)] 
x86: Count PLT for GOTOFF relocation against IFUNC symbol

Since GOTOFF relocations against IFUNC symbols must go through PLT,
set PLT reference count to 1 for GOTOFF relocation.

bfd/

PR ld/27998
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Count PLT for GOTOFF
relocation against IFUNC symbols.
(_bfd_x86_elf_adjust_dynamic_symbol): Likewise.

ld/

PR ld/27998
* testsuite/ld-i386/i386.exp: Run PR ld/27998 tests.
* testsuite/ld-i386/pr27998a.d: New file.
* testsuite/ld-i386/pr27998a.s: Likewise.
* testsuite/ld-i386/pr27998b.d: Likewise.
* testsuite/ld-i386/pr27998b.s: Likewise.

2 years agogdb/gdbserver: switch to AC_CONFIG_MACRO_DIRS
Mike Frysinger [Tue, 15 Jun 2021 05:40:33 +0000 (01:40 -0400)] 
gdb/gdbserver: switch to AC_CONFIG_MACRO_DIRS

These dirs don't use automake, so use AC_CONFIG_MACRO_DIRS to specify
../config as a search dir for m4 macros.  This allows removal of a lot
of hand-written m4_include's from acinclude.m4 files, and simplifies
use of `aclocal` or `autoreconf` as manual -I is not needed.

2 years agosim: move UNUSED before TYPE in SIM_ENDIAN_INLINE's definition
Simon Marchi [Sun, 20 Jun 2021 02:49:21 +0000 (22:49 -0400)] 
sim: move UNUSED before TYPE in SIM_ENDIAN_INLINE's definition

I get this when building with gcc 11:

      CC       common/common_libcommon_a-sim-load.o
    In file included from /home/simark/src/binutils-gdb/sim/common/sim-n-bits.h:27,
                     from /home/simark/src/binutils-gdb/sim/common/sim-bits.c:259,
                     from /home/simark/src/binutils-gdb/sim/common/sim-bits.h:599,
                     from /home/simark/src/binutils-gdb/sim/common/sim-basics.h:122,
                     from /home/simark/src/binutils-gdb/sim/common/sim-load.c:30:
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:27: error: 'offset_16' defined but not used [-Werror=unused-function]
       39 | #define offset_N XCONCAT2(offset_,N)
          |                           ^~~~~~~
    /home/simark/src/binutils-gdb/sim/../include/symcat.h:23:26: note: in definition of macro 'CONCAT2'
       23 | #define CONCAT2(a,b)     a##b
          |                          ^
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:18: note: in expansion of macro 'XCONCAT2'
       39 | #define offset_N XCONCAT2(offset_,N)
          |                  ^~~~~~~~
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:138:1: note: in expansion of macro 'offset_N'
      138 | offset_N (unsigned_N *x,
          | ^~~~~~~~

offset_N uses INLINE_SIM_ENDIAN, which uses UNUSED to put the "unused"
attribute.  However, it appears after the function's return type, which
seems to make it not apply to the function.  Moving it to before the
return type fixes the error.

Change all instances found in that file.

sim/common/ChangeLog:

* sim-inline.h: Move UNUSED before TYPE.

Change-Id: Ide20106683ed7a9ebf35d484dabf70b309cb1ba6

2 years agosim: unify dtc tool checks
Mike Frysinger [Sun, 20 Jun 2021 02:13:00 +0000 (22:13 -0400)] 
sim: unify dtc tool checks

Only one arch uses this currently, but others could too.  By moving
it up to the common checks, it'll also let us simplify the moxie code
significantly.

2 years agosim: ppc: rename inline defines to match common code
Mike Frysinger [Wed, 16 Jun 2021 02:37:38 +0000 (22:37 -0400)] 
sim: ppc: rename inline defines to match common code

Use the same basic names as the common sim inline logic so we can
merge the two.  We don't do that here, just prepare for it.

The common code seems to be based on the ppc version but with slightly
different names as it was cleaned up & generalized.  I *think* these
concepts are the same, so binding them together is OK, but maybe I'm
misreading them.  If so, can always tweak them later.
REVEAL_MODULE  ->  H_REVEALS_MODULE
INLINE_MODULE  ->  C_REVEALS_MODULE

2 years agosim: drop old BUILT_SRC_FROM_COMMON ref
Mike Frysinger [Sun, 20 Jun 2021 02:23:14 +0000 (22:23 -0400)] 
sim: drop old BUILT_SRC_FROM_COMMON ref

The code that set & used this variable was deleted long ago,
but the clean target was missed.  Clean that up now.

2 years agoAutomatic date update in version.in
GDB Administrator [Sun, 20 Jun 2021 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agoelf: Correct DT_TEXTREL warning in PDE
H.J. Lu [Sat, 19 Jun 2021 23:33:24 +0000 (16:33 -0700)] 
elf: Correct DT_TEXTREL warning in PDE

Change

ld: warning: creating DT_TEXTREL in a PIE

to

ld: warning: creating DT_TEXTREL in a PDE

on PDE.

bfd/

* elflink.c (bfd_elf_final_link): Correct DT_TEXTREL warning in
PDE.

ld/

* testsuite/ld-x86-64/textrel-1.err: New file.
* testsuite/ld-x86-64/textrel-1a.s: Likewise.
* testsuite/ld-x86-64/textrel-1b.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run textrel-1 tests.

2 years agosim: unify gettext/intl probing logic
Mike Frysinger [Sat, 19 Jun 2021 04:52:10 +0000 (00:52 -0400)] 
sim: unify gettext/intl probing logic

Move these options up to the common dir so we only test & export
them once across all ports.

2 years agosim: unify toolchain dependency logic
Mike Frysinger [Fri, 18 Jun 2021 15:12:28 +0000 (11:12 -0400)] 
sim: unify toolchain dependency logic

The common dir is already probing this info since it's using automake,
so pass it down to the subdirs so they don't have to probe it at all.

2 years agosim: unify toolchain probing logic
Mike Frysinger [Fri, 18 Jun 2021 14:45:03 +0000 (10:45 -0400)] 
sim: unify toolchain probing logic

Move these options up to the common dir so we only test & export
them once across all ports.

2 years agoelf: Update GNU_PROPERTY_UINT32_[AND|OR]_XXX tests
H.J. Lu [Sat, 19 Jun 2021 02:56:47 +0000 (19:56 -0700)] 
elf: Update GNU_PROPERTY_UINT32_[AND|OR]_XXX tests

1. Skip am33_2.0-*-* hppa*-*-hpux* mn10300-*-* since assembly source file
for the HPPA assembler is renamed and modifed by sed.  mn10300 has RELA
relocations in .note.gnu.property section which elf_parse_notes doesn't
support.
2. Pass --generate-missing-build-notes=no to assembler.
3. Allow other note sections for xtensa.

* testsuite/ld-elf/property-and-1.d: Skip am33_2.0, hppa-hpux
and mn10300.
Pass --generate-missing-build-notes=no to assembler.  Allow
other note sections for xtensa.
* testsuite/ld-elf/property-and-2.d: Likewise.
* testsuite/ld-elf/property-and-3.d: Likewise.
* testsuite/ld-elf/property-and-4.d: Likewise.
* testsuite/ld-elf/property-or-1.d: Likewise.
* testsuite/ld-elf/property-or-2.d: Likewise.
* testsuite/ld-elf/property-or-3.d: Likewise.
* testsuite/ld-elf/property-or-4.d: Likewise.

2 years agosim: unify bfd library dependency testing logic
Mike Frysinger [Fri, 18 Jun 2021 06:03:44 +0000 (02:03 -0400)] 
sim: unify bfd library dependency testing logic

Move these options up to the common dir so we only test & export
them once across all ports.

2 years agosim: mips: drop unused AC_PATH_X call
Mike Frysinger [Fri, 18 Jun 2021 05:59:25 +0000 (01:59 -0400)] 
sim: mips: drop unused AC_PATH_X call

We don't use anything from X, so no sense in probing the env.

2 years agosim: unify various library testing logic
Mike Frysinger [Fri, 18 Jun 2021 05:58:00 +0000 (01:58 -0400)] 
sim: unify various library testing logic

Move these options up to the common dir so we only test & export
them once across all ports.

2 years agoubsan: vax: pointer overflow
Alan Modra [Sat, 19 Jun 2021 00:55:35 +0000 (10:25 +0930)] 
ubsan: vax: pointer overflow

"VAX export class call relocation test" fails with ubsan on a 32-bit
host.

* vax-dis.c (print_insn_vax): Avoid pointer overflow.

2 years agoubsan errors when 32-bit bfd
Alan Modra [Fri, 18 Jun 2021 12:57:01 +0000 (22:27 +0930)] 
ubsan errors when 32-bit bfd

A shift count exceeding the size of the value is undefined behaviour,
and so is negating a signed LONG_MIN.

* config/tc-z80.c (signed_overflow, unsigned_overflow): Avoid UB.

2 years agoppc raw test failure when 32-bit bfd
Alan Modra [Fri, 18 Jun 2021 12:56:11 +0000 (22:26 +0930)] 
ppc raw test failure when 32-bit bfd

The test contained an expression that can't be evaluated unless
expressions are 64-bit.

* testsuite/gas/ppc/raw.s: Use 0 as pli constant.
* testsuite/gas/ppc/raw.d: Update to suit.

2 years agoFix another strncpy warning
Alan Modra [Fri, 18 Jun 2021 12:55:10 +0000 (22:25 +0930)] 
Fix another strncpy warning

* tic30-dis.c (get_register_operand): Don't ask strncpy to fill
entire buffer.

2 years agodwarf.c: string_fortify.h strncpy error
Alan Modra [Fri, 18 Jun 2021 08:54:43 +0000 (18:24 +0930)] 
dwarf.c: string_fortify.h strncpy error

In function 'strncpy',
    inlined from 'display_debug_lines_decoded' at /home/alan/src/binutils-gdb/binutils/dwarf.c:5434:5,
    inlined from 'display_debug_lines' at /home/alan/src/binutils-gdb/binutils/dwarf.c:5567:21:
/usr/include/bits/string_fortified.h:95:10: error: '__builtin_strncpy' specified bound 36 equals destination size [-Werror=stringop-truncation]

No need for strncpy here, the string being copied always fits the
destination buffer.

* dwarf.c (display_debug_lines_decoded): Use memcpy rather than
strncpy when trimming file name length to MAX_FILENAME_LENGTH.
Don't make an unnecessary copy when length is good.

2 years agoAutomatic date update in version.in
GDB Administrator [Sat, 19 Jun 2021 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agoFix powerpc-power8.exp test with new mnemonics
Carl Love [Wed, 16 Jun 2021 19:51:46 +0000 (14:51 -0500)] 
Fix powerpc-power8.exp test with new mnemonics

This patch updates the gdb test to use the new bgetar and bnstarl mnemonics
introduced in commit 5a4037661bccd156d65093f1f0cf2cd43f31e9d9.  The test
previously used the bctar and bctarl mnemonics.

gdb/testsuite/ChangeLog
2021-06-17  Carl Love  <cel@us.ibm.com>

* gdb.arch/powerpc-power8.exp(bctar, bctarl): Update mnemonics
to bgetar and bgetarl.
* gdb.arch/powerpc-power8.s((bctar, bctarl): Update comments
for mnemonics to bgetar and bnstarl.

2 years agold.texi: Move -z unique-symbol after -z undefs.
H.J. Lu [Fri, 18 Jun 2021 14:32:25 +0000 (07:32 -0700)] 
ld.texi: Move -z unique-symbol after -z undefs.

* ld.texi: Move -z unique-symbol after -z undefs.

2 years agosim: unify -Werror build settings
Mike Frysinger [Fri, 18 Jun 2021 05:14:39 +0000 (01:14 -0400)] 
sim: unify -Werror build settings

Move these options up to the common dir so we only test & export
them once across all ports.  It also enables -Werror usage on the
common files we've been pulling out of arch subdirs.

2 years agoelf: Add GNU_PROPERTY_UINT32_AND_XXX/GNU_PROPERTY_UINT32_OR_XXX
H.J. Lu [Fri, 18 Jun 2021 14:18:02 +0000 (07:18 -0700)] 
elf: Add GNU_PROPERTY_UINT32_AND_XXX/GNU_PROPERTY_UINT32_OR_XXX

Implement GNU_PROPERTY_UINT32_AND_XXX/GNU_PROPERTY_UINT32_OR_XXX:

https://sourceware.org/pipermail/gnu-gabi/2021q1/000467.html

1. GNU_PROPERTY_UINT32_AND_LO..GNU_PROPERTY_UINT32_AND_HI

 #define GNU_PROPERTY_UINT32_AND_LO 0xb0000000
 #define GNU_PROPERTY_UINT32_AND_HI 0xb0007fff

A bit in the output pr_data field is set only if it is set in all
relocatable input pr_data fields.  If all bits in the the output
pr_data field are zero, this property should be removed from output.

If the bit is 1, all input relocatables have the feature.  If the
bit is 0 or the property is missing, the info is unknown.

2. GNU_PROPERTY_UINT32_OR_LO..GNU_PROPERTY_UINT32_OR_HI

 #define GNU_PROPERTY_UINT32_OR_LO 0xb0008000
 #define GNU_PROPERTY_UINT32_OR_HI 0xb000ffff

A bit in the output pr_data field is set if it is set in any
relocatable input pr_data fields. If all bits in the the output
pr_data field are zero, this property should be removed from output.

If the bit is 1, some input relocatables have the feature.  If the
bit is 0 or the property is missing, the info is unknown.

bfd/

* elf-properties.c (_bfd_elf_parse_gnu_properties): Handle
GNU_PROPERTY_UINT32_AND_LO, GNU_PROPERTY_UINT32_AND_HI,
GNU_PROPERTY_UINT32_OR_LO and GNU_PROPERTY_UINT32_OR_HI.
(elf_merge_gnu_properties): Likewise.

binutils/

* readelf.c (print_gnu_property_note): Handle
GNU_PROPERTY_UINT32_AND_LO, GNU_PROPERTY_UINT32_AND_HI,
GNU_PROPERTY_UINT32_OR_LO and GNU_PROPERTY_UINT32_OR_HI.

include/

* elf/common.h (GNU_PROPERTY_UINT32_AND_LO): New.
(GNU_PROPERTY_UINT32_AND_HI): Likewise.
(GNU_PROPERTY_UINT32_OR_LO): Likewise.
(GNU_PROPERTY_UINT32_OR_HI): Likewise.

ld/

* testsuite/ld-elf/property-and-1.d: New file.
* testsuite/ld-elf/property-and-1.s: Likewise.
* testsuite/ld-elf/property-and-2.d: Likewise.
* testsuite/ld-elf/property-and-2.s: Likewise.
* testsuite/ld-elf/property-and-3.d: Likewise.
* testsuite/ld-elf/property-and-3.s: Likewise.
* testsuite/ld-elf/property-and-4.d: Likewise.
* testsuite/ld-elf/property-and-empty.s: Likewise.
* testsuite/ld-elf/property-or-1.d: Likewise.
* testsuite/ld-elf/property-or-1.s: Likewise.
* testsuite/ld-elf/property-or-2.d: Likewise.
* testsuite/ld-elf/property-or-2.s: Likewise.
* testsuite/ld-elf/property-or-3.d: Likewise.
* testsuite/ld-elf/property-or-3.s: Likewise.
* testsuite/ld-elf/property-or-4.d: Likewise.
* testsuite/ld-elf/property-or-empty.s: Likewise.

2 years agosim: move -Werror disabling to Makefile
Mike Frysinger [Fri, 18 Jun 2021 06:14:52 +0000 (02:14 -0400)] 
sim: move -Werror disabling to Makefile

For the ports that still don't build with -Werror, rather than disable
the flag at configure time, do it at make time.  This will allow us to
unify these tests in the common sim configure script.

2 years agosim: create a makefile fragment to pass common settings down
Mike Frysinger [Wed, 16 Jun 2021 03:01:45 +0000 (23:01 -0400)] 
sim: create a makefile fragment to pass common settings down

As we merge settings from subdirs into the common configure, we
sometimes need to keep the settings working in both dirs.  Create
a makefile fragment to pass them down so we don't have to run the
checks twice.  For now, the file is empty, but we'll start moving
logic in shortly.

2 years agogas: fold symbol table entries generated for .startof.() / .sizeof.()
Jan Beulich [Fri, 18 Jun 2021 11:51:52 +0000 (13:51 +0200)] 
gas: fold symbol table entries generated for .startof.() / .sizeof.()

When the same such construct is used multiple times in a source file,
there's still no need to emit a separate symbol each time. Under the
assumption that there won't be many of these, use a simple array
lookup method to record previously used symbols.

2 years agosim: split sim-signal.h include out
Mike Frysinger [Mon, 14 Jun 2021 03:16:32 +0000 (23:16 -0400)] 
sim: split sim-signal.h include out

The sim-basics.h is too big and includes too many things.  This leads
to some arch's sim-main.h having circular loop issues with defs, and
makes it hard to separate out common objects from arch-specific defs.
By splitting up sim-basics.h and killing off sim-main.h, it'll make
it easier to separate out the two.

2 years agosim: drop core libiberty.h include
Mike Frysinger [Mon, 14 Jun 2021 02:27:08 +0000 (22:27 -0400)] 
sim: drop core libiberty.h include

This doesn't need to be included for every sim file, so drop it.
Every C file that needs it seems to already include it.

2 years agosim: overhaul & unify endian settings management
Mike Frysinger [Tue, 15 Jun 2021 23:51:52 +0000 (19:51 -0400)] 
sim: overhaul & unify endian settings management

The m4 macro has 2 args: the "wire" settings (which represents the
hardwired port behavior), and the default settings (which are used
if nothing else is specified).  If none are specified, the arch is
expected to support both, and the value will be probed based on the
user runtime options or the input program.

Only two arches today set the default value (bpf & mips).  We can
probably let this go as it only shows up in one scenario: the sim
is invoked, but with no inputs, and no user endian selection.  This
means bpf will not behave like the other arches: an error is shown
and forces the user to make a choice.  If an input program is used
though, we'll still switch the default to that.  This allows us to
remove the WITH_DEFAULT_TARGET_BYTE_ORDER setting.

For the ports that set a "wire" endian, move it to the runtime init
of the respective sim_open calls.  This allows us to change the
WITH_TARGET_BYTE_ORDER to purely a user-selected configure setting
if they want to force a specific endianness.

With all the endian logic moved to runtime selection, we can move
the configure call up to the common dir so we only process it once
across all ports.

The ppc arch was picking the wire endian based on the target used,
but since we weren't doing that for other biendian arches, we can
let this go too.  We'll rely on the input selecting the endian, or
make the user decide.

2 years agoAutomatic date update in version.in
GDB Administrator [Fri, 18 Jun 2021 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agosim: ppc: avoid "PAGE_SIZE" name
Mike Frysinger [Thu, 17 Jun 2021 23:03:32 +0000 (19:03 -0400)] 
sim: ppc: avoid "PAGE_SIZE" name

This define is used for a particular target and depends on the
simulated CPU hardware.  It has no relation to the host CPU that
the sim is running on.  So rename the common "PAGE_SIZE" here to
better reflect its usage and avoid conflicts with system headers.

2 years agoDon't call sigtimedwait for scoped_ignore_sigttou
Pedro Alves [Thu, 17 Jun 2021 15:23:03 +0000 (16:23 +0100)] 
Don't call sigtimedwait for scoped_ignore_sigttou

Because SIGTTOU is sent to the whole process instead of to a specific
thread, consuming a pending SIGTTOU in the destructor of
scoped_ignore_sigttou could consume a SIGTTOU signal raised due to
actions done by some other thread.  Simply avoid sigtimedwait in
scoped_ignore_sigttou, thus plugging the race.  This works because we
know that when the thread writes to the terminal and the signal is
blocked, the kernel does not raise the signal at all.

Tested on GNU/Linux, Solaris 11 and FreeBSD.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* scoped_ignore_signal.h (scoped_ignore_signal): Add
ConsumePending template parameter.
(scoped_ignore_signal::~scoped_ignore_signal): Skip calling
sigtimedwait if ConsumePending is false.
(scoped_ignore_sigpipe): Initialize with ConsumePending=true.
* scoped_ignore_sigttou.h (scoped_ignore_sigttou)
<m_ignore_signal>: Initialize with ConsumePending=false.

Change-Id: I92f754dbc45c45819dce2ce68b8c067d8d5c61b1

2 years agox86-64: Use $NOPIE_LDFLAGS/$NOPIE_CFLAGS on protected-func-1
H.J. Lu [Thu, 17 Jun 2021 17:32:27 +0000 (10:32 -0700)] 
x86-64: Use $NOPIE_LDFLAGS/$NOPIE_CFLAGS on protected-func-1

PR ld/27973
* testsuite/ld-x86-64/x86-64.exp: Pass $NOPIE_LDFLAGS and
$NOPIE_CFLAGS to protected-func-1 without PIE.

2 years agox86-64: Test protected function pointers
H.J. Lu [Thu, 17 Jun 2021 17:19:29 +0000 (10:19 -0700)] 
x86-64: Test protected function pointers

On x86-64, function pointers in executable for external funtions may be
resolved to their PLT entries in executable.  If it happens, function
pointers of protected funtions in shared libraries must be resolved to
the PLT entries in executable, not addresses of protected funtions in
shared libraries.

PR ld/27973
* testsuite/ld-x86-64/x86-64.exp: Run protected function tests.
* testsuite/ld-x86-64/protected-func-1.h: New file.
* testsuite/ld-x86-64/protected-func-1a.s: Likewise.
* testsuite/ld-x86-64/protected-func-1b.c: Likewise.

2 years agold: Add ChangeLog entry for -no-pie
Fangrui Song [Thu, 17 Jun 2021 17:18:28 +0000 (10:18 -0700)] 
ld: Add ChangeLog entry for -no-pie

2 years agold: Add -no-pie
Fangrui Song [Thu, 17 Jun 2021 16:57:40 +0000 (09:57 -0700)] 
ld: Add -no-pie

gold has had this option for many years. Not having this option caused
some confusion to users.  The help message clarifies the default state.

ld/
    * ldlex.h (enum option_values): Add OPTION_NO_PIE.
    * lexsup.c (struct ld_options): Add -no-pie.
    (parse_args): Handle -no-pie.
    * ld.texi: Document -no-pie.

2 years agoAdd a unit test for scoped_ignore_sigpipe
Pedro Alves [Thu, 17 Jun 2021 15:16:55 +0000 (16:16 +0100)] 
Add a unit test for scoped_ignore_sigpipe

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* Makefile.in (SELFTESTS_SRCS): Add
unittests/scoped_ignore_signal-selftests.c.
* unittests/scoped_ignore_signal-selftests.c: New.

Change-Id: Idce24aa9432a3f1eb7065bc9aa030b1d0d7dcad5

2 years agoscoped_ignore_signal: Use sigprocmask+sigtimedwait instead of signal
Pedro Alves [Thu, 17 Jun 2021 15:16:55 +0000 (16:16 +0100)] 
scoped_ignore_signal: Use sigprocmask+sigtimedwait instead of signal

The problem with using signal(...) to temporarily ignore a signal, is
that that changes the the signal disposition for the whole process.
If multiple threads do it at the same time, you have a race.

Fix this by using sigprocmask + sigtimedwait to implement the ignoring
instead, if available, which I think probably means everywhere except
Windows nowadays.  This way, we only change the signal mask for the
current thread, so there's no race.

Change-Id: Idfe3fb08327ef8cae926f3de9ee81c56a83b1738

gdbsupport/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* scoped_ignore_signal.h
(scoped_ignore_signal::scoped_ignore_signal)
[HAVE_SIGPROCMASK]: Use sigprocmask to block the signal instead of
changing the signal disposition for the whole process.
(scoped_ignore_signal::~scoped_ignore_signal) [HAVE_SIGPROCMASK]:
Use sigtimedwait and sigprocmask to flush and unblock the signal.

2 years agoIntroduce scoped_restore_signal
Pedro Alves [Thu, 17 Jun 2021 15:16:54 +0000 (16:16 +0100)] 
Introduce scoped_restore_signal

We currently have scoped_restore_sigttou and scoped_restore_sigpipe
doing basically the same thing -- temporarily ignoring a specific
signal.

This patch introduce a scoped_restore_signal type that can be used for
both.  This will become more important for the next patch which
changes how the signal-ignoring is implemented.

scoped_restore_sigpipe is a straight alias to
scoped_restore_signal<SIGPIPE> on systems that define SIGPIPE, and an
alias to scoped_restore_signal_nop (a no-op version of
scoped_restore_signal) otherwise.

scoped_restore_sigttou is not a straight alias because it wants to
check the job_control global.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* gdbsupport/scoped_ignore_signal.h: New.
* compile/compile.c: Include gdbsupport/scoped_ignore_signal.h
instead of <signal.h>.  Don't include <unistd.h>.
(scoped_ignore_sigpipe): Remove.
* gdbsupport/scoped_ignore_sigttou.h: Include gdbsupport/scoped_ignore_signal.h
instead of <signal.h>.  Don't include <unistd.h>.
(lazy_init): New.
(scoped_ignore_sigttou): Reimplement using scoped_ignore_signal
and lazy_init.

Change-Id: Ibb44d0bd705e96df03ef0787c77358a4a7b7086c

2 years agoMove scoped_ignore_sigttou to gdbsupport/
Pedro Alves [Thu, 17 Jun 2021 15:16:54 +0000 (16:16 +0100)] 
Move scoped_ignore_sigttou to gdbsupport/

A following patch will want to use scoped_ignore_sigttou in code
shared between GDB and GDBserver.  Move it under gdbsupport/.

Note that despite what inflow.h/inflow.c's first line says, inflow.c
is no longer about ptrace, it is about terminal management.  Some
other files were unnecessarily including inflow.h, I guess a leftover
from the days when inflow.c really was about ptrace.  Those inclusions
are simply dropped.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* Makefile.in (HFILES_NO_SRCDIR): Remove inflow.h.
* inf-ptrace.c, inflow.c, procfs.c: Don't include "inflow.h".
* inflow.h: Delete, moved to gdbsupport/ under a different name.
* ser-unix.c: Don't include "inflow.h".  Include
"gdbsupport/scoped_ignore_sigttou.h".

gdbsupport/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* scoped_ignore_sigttou.h: New file, moved from gdb/ and renamed.

Change-Id: Ie390abf42c3a78bec6d282ad2a63edd3e623559a

2 years agoFix an assertion failure in the AArch64 assembler triggered by incorrect instruction...
Nick Clifton [Thu, 17 Jun 2021 15:19:20 +0000 (16:19 +0100)] 
Fix an assertion failure in the AArch64 assembler triggered by incorrect instruction syntax.

PR 27904
* config/tc-aarch64.c (ldst_lo12_determine_real_reloc_type):
Generate a syntax error message if the reloc qualifier does not
match the instruction's size.

2 years agogas: handle csect in bss section for XCOFF
Clément Chigot [Tue, 15 Jun 2021 09:06:52 +0000 (11:06 +0200)] 
gas: handle csect in bss section for XCOFF

Latest gcc versions are now generating csects instead of .lcomm
for bss symbols.
Some adjustements are needed in order to handle them.

* config/tc-ppc.c (md_begin): Create bss section with dummy
symbol.
(ppc_frob_symbol): Output XTY_CM for bss csects.
(ppc_fix_adjustable): Adjust condition to avoid bss csects.

2 years agogdb/testsuite: gdb.base/args.exp: add KFAIL for native-extended-gdbserver
Simon Marchi [Thu, 17 Jun 2021 13:41:59 +0000 (09:41 -0400)] 
gdb/testsuite: gdb.base/args.exp: add KFAIL for native-extended-gdbserver

This test tests passing arguments made of exactly two single-quotes
('') or a single newline character through the --args argument of GDB.
For some reason, GDB adds some extra single quotes when transmitting the
arguments to GDBserver.  This produces some FAILs when testing with the
native-extended-gdbserver board:

    FAIL: gdb.base/args.exp: argv[2] for one empty (with single quotes)
    FAIL: gdb.base/args.exp: argv[2] for two empty (with single quotes)
    FAIL: gdb.base/args.exp: argv[3] for two empty (with single quotes)
    FAIL: gdb.base/args.exp: argv[2] for one newline
    FAIL: gdb.base/args.exp: argv[2] for two newlines
    FAIL: gdb.base/args.exp: argv[3] for two newlines

This is documented as PR 27989.  Add some appropriate KFAILs.

gdb/testsuite/ChangeLog:

* gdb.base/args.exp: Check target, KFAIL if remote.
(args_test): Add parameter and use it.

Change-Id: I49225d1c7df7ebaba480ebdd596df80f8fbf62f0

2 years agogdb/testsuite: gdb.base/args.exp: remove trailing parenthesis in test names
Simon Marchi [Thu, 17 Jun 2021 13:41:58 +0000 (09:41 -0400)] 
gdb/testsuite: gdb.base/args.exp: remove trailing parenthesis in test names

Some test names end with a parenthesis, we don't want that:

    https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Do_not_use_.22tail_parentheses.22_on_test_messages

Fix that.

gdb/testsuite/ChangeLog:

* gdb.base/args.exp: Remove trailing parenthesis in test names.

Change-Id: I0306ea202bae3a4ed5bf0bd65e0ab5ed5de52fe1

2 years agogdb/testsuite: gdb.base/args.exp: use $old_gdbflags last two tests
Simon Marchi [Thu, 17 Jun 2021 13:41:58 +0000 (09:41 -0400)] 
gdb/testsuite: gdb.base/args.exp: use $old_gdbflags last two tests

All tests in this file append to GDBFLAGS instead of overwriting it,
except the last two.  I noticed because when testing with the
native-extended-remote board, it removes the "set sysroot" argument, and
it causes the test to be very long to run, due to big glibc debug info
being read through the remote target.

I think this oddity is due to a race condition between these two
commits:

  [1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c22261528c50f7760dd6a2e29314662b377eebb4
  [2] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6b8ce727297b1e40738e50f83a75881b290fe6a6

The first one added the two tests.  The second one changes the test to
append to GDBFLAGS instead of overwriting it.  But the second one was
probably written before the first one was it, so missed the new tests.

Change those two tests to be like the others.

gdb/testsuite/ChangeLog:

* gdb.base/args.exp: Use $old_gdbflags in all tests.

Change-Id: I531276125ecb70e80f52adbd320ebb85b0c8eba0

2 years agogdb/testsuite: gdb.base/args.exp: use save_vars
Simon Marchi [Thu, 17 Jun 2021 13:41:58 +0000 (09:41 -0400)] 
gdb/testsuite: gdb.base/args.exp: use save_vars

Use save_vars instead of manually saving/restoring.  This ensures that
if anything throws an error, GDBFLAGS will be correctly restored.

Remove the global GDBFLAGS declaration at the top, it's not necessary.

gdb/testsuite/ChangeLog:

* gdb.base/args.exp: Use save_vars.

Change-Id: I3a45e4fc1635ec0212de2415040f91eecaf4a057

2 years agoMake the TUI command window support the mouse
Pedro Alves [Thu, 17 Jun 2021 10:57:56 +0000 (11:57 +0100)] 
Make the TUI command window support the mouse

Currently, when the focus is on the command window, we disable the
keypad.  This means that when the command window has the focus, keys
such as up/down/home/end etc. are not processed by curses, and their
escape sequences go straight to readline.

A side effect of disabling keypad mode is that wgetch no longer
processes mouse escape sequences, with the end result being the mouse
doesn't work, and worse, the raw mouse escape sequences are printed on
the terminal.

This commit makes the TUI command window support the mouse as well, by
always enabling the keypad, and then to avoid losing support for
up/down browsing the command history, home/end/left/right moving the
cursor position, etc., we forward those keys as raw escape sequences
to readline.  Note we don't make an effort to pass down to readline
all keys returned by curses, only the common ones that readline
understands by default.  Given users can specify their own readline
bindings (inputrc file, bind utility), this approach is good in
practice, though not 100% transparent or perfect.

Note that the patch makes it so that CTLC-L is always passed to
readline even if the command window does not have the focus.  It was
simpler to implement that way, and it just seems correct to me.  I
don't know of a reason we shouldn't do that.

The patch improves the TUI behavior in a related way.  Now we can pass
special keys to readline irrespective of which window has the focus.
First, we try to dispatch the key to a window, via
tui_displatch_ctrl_char.  If the key is dispatched, then we don't pass
it to readline.  E.g., pressing "up" when you have the source window
in focus results in scrolling the source window, and nothing else.  If
however, you press ctrl-del instead, that results in killing the next
word in the command window, no matter which window has has focus.
Before, it would only work if you had the command window in focus.
Similarly, ctrl-left/ctrl-right to move between words, etc.

Similarly, the previous spot where we handled mouse events was
incorrect.  It was never reached if the window with focus can't
scroll, which is the case for the command window.  Mouse scrolling
affects the window under the mouse cursor, not the window in focus.
We now always try to dispatch mouse events.

One last bit in the patch -- now if we don't recognize the non-8-bit
curses key, then we don't pass it down to readline at all.  Before
that would result in bogus characters in the input line.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* tui/tui-io.c (tui_dispatch_mouse_event): New, factored out from
...
(tui_dispatch_ctrl_char): ... this.  Move CTRL-L handling to
tui_getc_1.
(cur_seq, start_sequence): New.
(tui_getc_1): Pass key escape sequences for curses control keys to
readline.  Handle mouse and ctrl-l here.
(tui_resize_all): Disable/reenable the keypad if the command
window has the focus too.
* tui/tui-win.c (tui_set_focus_command): Don't change keypad
setting.
* tui/tui.c (tui_rl_other_window): Don't change keypad setting.

Change-Id: Ie0a7d849943cfb47f4a6589e1c73341563740fa9

2 years agogas: ensure sections contents is zero for BFD_RELOC_PPC*_TLSM on XCOFF.
Clément Chigot [Mon, 14 Jun 2021 11:25:42 +0000 (13:25 +0200)] 
gas: ensure sections contents is zero for BFD_RELOC_PPC*_TLSM on XCOFF.

AIX ld expects the section contents for relocations BFD_RELOC_PPC_TLSM
or BFD_RELOC_PPC64_TLSM to be zero.
Actually, it seems to be the case for all the TLS relocations
generated by AIX assembly but only these two are mandatory.

* config/tc-ppc.c (md_apply_fix): Adjust addend to nullify
section contents for BFD_RELOC_PPC_TLSM or
BFD_RELOC_PPC64_TLSM.
* testsuite/gas/ppc/xcoff-tlsm-32.d: New test.
* testsuite/gas/ppc/xcoff-tlsm-64.d: New test.
* testsuite/gas/ppc/xcoff-tlsm.s: New test.
* testsuite/gas/ppc/aix.exp: Run new tests.

2 years agopowerpc: move cell "or rx,rx,rx" hints
Alan Modra [Wed, 16 Jun 2021 07:05:53 +0000 (16:35 +0930)] 
powerpc: move cell "or rx,rx,rx" hints

* ppc-opc.c (powerpc_opcodes): Move cell db*cyc to proper location
in table.

2 years agosim: mn10300: tweak static inlines
Mike Frysinger [Thu, 17 Jun 2021 04:12:15 +0000 (00:12 -0400)] 
sim: mn10300: tweak static inlines

Use INLINE2 instead of INLINE to fix builds when -O0 are used -- the
latter define is omitted at -O0 levels while the former is always
set to inline.  These helper funcs are used by defines in here but
the defines aren't always called.

2 years agosim: split sim/callback.h include out
Mike Frysinger [Mon, 14 Jun 2021 02:14:40 +0000 (22:14 -0400)] 
sim: split sim/callback.h include out

The sim-basics.h is too big and includes too many things.  This leads
to some arch's sim-main.h having circular loop issues with defs, and
makes it hard to separate out common objects from arch-specific defs.
By splitting up sim-basics.h and killing off sim-main.h, it'll make
it easier to separate out the two.

Start with splitting out sim/callback.h.

2 years agoAutomatic date update in version.in
GDB Administrator [Thu, 17 Jun 2021 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agosim: make some rules silent by default in Make-common.in
Simon Marchi [Wed, 16 Jun 2021 15:55:53 +0000 (11:55 -0400)] 
sim: make some rules silent by default in Make-common.in

Use GDB's silent-rules.mk to make some rules silent by default.  These
rules cover most of what is built in sim/.

gdb/ChangeLog:

* silent-rules.mk (ECHO_CCLD, ECHO_AR, ECHO_RANLIB): New.

sim/ChangeLog:

* common/Make-common.in (COMPILE, libsim.a, run$(EXEEXT),
gentmap.o, gentmap): Make rules silent.

Change-Id: Idf9ba5beaee10c7c614859ace5fbdcd1de0287db

2 years agogdb, doc: Fix missed ChangeLog entry.
Felix Willgerodt [Wed, 16 Jun 2021 13:31:23 +0000 (15:31 +0200)] 
gdb, doc: Fix missed ChangeLog entry.

My previous commit "btrace, doc: Clarify record function-call-history
documentation." didn't add this to the actual ChangeLog file. Fix that.

2 years agobtrace, doc: Clarify record function-call-history documentation.
Felix Willgerodt [Wed, 16 Jun 2021 11:06:11 +0000 (13:06 +0200)] 
btrace, doc: Clarify record function-call-history documentation.

The documentation for 'record function-call-history' mentions lines instead
of functions when talking about the number of functions printed, as currently
there is only one line printed per function.  Yet the code actually handles
this on function granularity not on line basis.  Future patches will
extend the number of lines printed per function.  This also makes it
consistent with the 'record instruction-history' command, where multiple
lines can be printed per instruction.

gdb/doc/ChangeLog:
2021-06-16  Felix Willgerodt  <felix.willgerodt@intel.com>

* gdb.texinfo (Process Record and Replay): Stop mentioning lines
for "record function-call-history" and
"set record function-call-history-size".

2 years ago[gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder(), again
Tom de Vries [Wed, 16 Jun 2021 10:44:30 +0000 (12:44 +0200)] 
[gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder(), again

This is another attempt at fixing the problem described in commit 4cf88725da1
"[gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder()", which was
reverted in commit 3db19b2d724.

First off, some context.

A DWARF CU can be viewed as a symbol table: toplevel children of a CU DIE
represent symbol table entries for that CU.  Furthermore, there is a
hierarchy: a symbol table entry such as a function itself has a symbol table
containing parameters and local variables.

The dwarf reader maintains a notion of current symbol table (that is: the
symbol table a new symbol needs to be entered into) in dwarf2_cu member
list_in_scope.

A problem then presents itself when reading inter-CU references:
- a new symbol read from a CU B needs to be entered into the symbol table of
  another CU A.
- the notion of current symbol table is tracked on a per-CU basis.
This is addressed in inherit_abstract_dies by temporarily overwriting the
list_in_scope for CU B with the one for CU A.

The current symbol table is one aspect of the current dwarf reader context
that is tracked, but there are more, f.i. ones that are tracked via the
dwarf2_cu member m_builder, f.i. m_builder->m_local_using_directives.

A similar problem exists in relation to inter-CU references, but a different
solution was chosen:
- to keep track of an ancestor field in dwarf2_cu, which is updated
  when traversing inter-CU references, and
- to use the ancestor field in dwarf2_cu::get_builder to return the m_builder
  in scope.

There is no actual concept of a CU having an ancestor, it just marks the most
recent CU from which a CU was inter-CU-referenced.  Consequently, when
following inter-CU references from a CU A to another CU B and back to CU A,
the ancestors form a cycle, which causes dwarf2_cu::get_builder to hang or
segfault, as reported in PR26327.

ISTM that the ancestor implementation is confusing and fragile, and should
go.  Furthermore, it seems that keeping track of the m_builder in scope can be
handled simply with a per-objfile variable.

Fix the hang / segfault by:
- keeping track of the m_builder in scope using a new variable
  per_obj->sym_cu, and
- using it in dwarf2_cu::get_builder.

Tested on x86_64-linux (openSUSE Leap 15.2), no regressions for config:
- using default gcc version 7.5.0
  (with 5 unexpected FAILs)
- gcc 10.3.0 and target board
  unix/-flto/-O0/-flto-partition=none/-ffat-lto-objects
  (with 1000 unexpected FAILs)

gdb/ChangeLog:

2021-06-16  Tom de Vries  <tdevries@suse.de>

PR symtab/26327
* dwarf2/cu.h (dwarf2_cu::ancestor): Remove.
(dwarf2_cu::get_builder): Declare and move ...
* dwarf2/cu.c (dwarf2_cu::get_builder): ... here.  Use sym_cu instead
of ancestor.  Assert return value is non-null.
* dwarf2/read.c (read_file_scope): Set per_objfile->sym_cu.
(follow_die_offset, follow_die_sig_1): Remove setting of ancestor.
(dwarf2_per_objfile): Add sym_cu field.

2 years agogas: fix hex float parsing from .dcb.? directives
Jan Beulich [Wed, 16 Jun 2021 06:55:52 +0000 (08:55 +0200)] 
gas: fix hex float parsing from .dcb.? directives

Unlike for .dc.? the parsing here failed to skip the colon before
calling hex_float(). To avoid both variants of parsing going out of sync
again, introduce a helper used by both.

2 years agogas: fix overflow diagnostics
Jan Beulich [Wed, 16 Jun 2021 06:55:20 +0000 (08:55 +0200)] 
gas: fix overflow diagnostics

While the logic in fixup_segment() so far was off by 1 for fixups
dealing with quantities without known signedness, thus failing to report
an overflow when e.g. a byte-sized resulting value is -0x100, the logic
in emit_expr_with_reloc() reported an overflow even on large negative
values when the respective positive ones would not be warned
about, and when fixup_segment() wouldn't do so either. Such diagnostics
all ought to follow a similar pattern of what value range is acceptable.
(If expressions' X_unsigned was reliably set, emit_expr_with_reloc()'s
checking might make sense to tighten based on that flag.)

Note that with commit 80aab57939a0 ("Changes to let cons handle bignums
like general expressions") having added handling of nbytes >
sizeof(valueT) in the O_constant case, converting to O_big, the setting
to zero of "hibit" had become dead. With "hibit" no longer used, this
code now gets dropped altogether. But additionally a respective know()
gets inserted.

2 years agosim: mips: add printf attribute to trace func
Mike Frysinger [Tue, 15 Jun 2021 05:09:49 +0000 (01:09 -0400)] 
sim: mips: add printf attribute to trace func

This helps catch format errors in code, although they're all clean
at this point already.

2 years agosim: mips: rework dynamic printf logic to avoid compiler warnings
Mike Frysinger [Tue, 15 Jun 2021 04:41:22 +0000 (00:41 -0400)] 
sim: mips: rework dynamic printf logic to avoid compiler warnings

The compiler doesn't like passing non-constant strings to printf
functions, so tweak the code to always pass one in.  This code is
a little more verbose, but it's probably the same performance.

The macro usage is a bit ugly, but maybe less than copying &
pasting the extended conditional format logic.

2 years agosim: mips: tweak buffer sign
Mike Frysinger [Tue, 15 Jun 2021 04:40:17 +0000 (00:40 -0400)] 
sim: mips: tweak buffer sign

This model uses unsigned char buffers, but this temporary pointer is
declared as signed.  Switch it to unsigned since it's just a temporary
variable to hold the new pointer.

2 years agosim: mips: fix uninitialized register use
Mike Frysinger [Tue, 15 Jun 2021 04:39:28 +0000 (00:39 -0400)] 
sim: mips: fix uninitialized register use

In the default case, this code will read from this variable before
it is initialized as a dummy access.  Set it to 0 to fix the compiler
warning.

2 years agosim: drop obsolete AC_EXEEXT call
Mike Frysinger [Wed, 16 Jun 2021 02:48:50 +0000 (22:48 -0400)] 
sim: drop obsolete AC_EXEEXT call

The current autoconf 2.69 defines this to nothing because the logic
in AC_PROG_CC takes care of it all the time now.  Delete the call.

2 years agosim: ppc: use common sim-assert setting
Mike Frysinger [Wed, 16 Jun 2021 01:17:55 +0000 (21:17 -0400)] 
sim: ppc: use common sim-assert setting

The common sim code already sets this up for us, so no need to
duplicate the logic.

2 years agosim: ppc: convert to bfd_endian
Mike Frysinger [Wed, 16 Jun 2021 00:58:31 +0000 (20:58 -0400)] 
sim: ppc: convert to bfd_endian

Rather than re-invent endian defines, as well as maintain our own list
of OS & arch-specific includes, punt all that logic in favor of the bfd
ones already set up and maintained elsewhere.  We already rely on the
bfd library, so leveraging the endian aspect should be fine.

This was done for all the other ports years ago, so catch ppc up.

2 years agosim: ppc: replace local __attribute__ fallback
Mike Frysinger [Wed, 16 Jun 2021 00:50:16 +0000 (20:50 -0400)] 
sim: ppc: replace local __attribute__ fallback

The common ansidecl.h provides fallbacks for these so we don't need to.

2 years agosim: ppc: use common ATTRIBUTE_PRINTF macros
Mike Frysinger [Wed, 16 Jun 2021 00:46:10 +0000 (20:46 -0400)] 
sim: ppc: use common ATTRIBUTE_PRINTF macros

Use the common ansidecl.h macros to replace our ad-hoc printf attributes.

2 years agosim: ppc: use common ATTRIBUTE_PACKED macro
Mike Frysinger [Wed, 16 Jun 2021 00:43:22 +0000 (20:43 -0400)] 
sim: ppc: use common ATTRIBUTE_PACKED macro

Drop local packed attribute with the common ansidecl.h define.

2 years agosim: ppc: replace local NORETURN macros with common one
Mike Frysinger [Wed, 16 Jun 2021 00:40:31 +0000 (20:40 -0400)] 
sim: ppc: replace local NORETURN macros with common one

Drop local NORETURN macro with the common ansidecl.h ATTRIBUTE_NORETURN define.

2 years agosim: ppc: replace local UNUSED macros with common one
Mike Frysinger [Wed, 16 Jun 2021 00:38:45 +0000 (20:38 -0400)] 
sim: ppc: replace local UNUSED macros with common one

Drop local UNUSED macro with the common ansidecl.h ATTRIBUTE_UNUSED define.

2 years agosim: ppc: replace local CONCAT macros with common ones
Mike Frysinger [Wed, 16 Jun 2021 00:35:37 +0000 (20:35 -0400)] 
sim: ppc: replace local CONCAT macros with common ones

Drop local copies of CONCAT macros that the common ansidecl.h provides.

2 years agosim: ppc: change bool variable name to boolean
Mike Frysinger [Wed, 16 Jun 2021 00:28:35 +0000 (20:28 -0400)] 
sim: ppc: change bool variable name to boolean

This is a reserved type with stdbool.h.

2 years agosim: ppc: drop host endian configure option
Mike Frysinger [Wed, 16 Jun 2021 00:20:11 +0000 (20:20 -0400)] 
sim: ppc: drop host endian configure option

The --enable-sim-hostendian flag was purely so people had an escape route
for when cross-compiling.  This is because historically, AC_C_BIGENDIAN
did not work in those cases.  That was fixed a while ago though, so we can
require that macro everywhere now and simplify a good bit of code.

This was done for all the other ports years ago, so catch ppc up.

2 years agosim: mips: fix format warnings when setting up memory
Mike Frysinger [Tue, 15 Jun 2021 04:00:29 +0000 (00:00 -0400)] 
sim: mips: fix format warnings when setting up memory

The majority of these inputs are not long's, so don't use %lx.
This fixes compiler warnings about type mismatches.

2 years agosim: drop arch-specific config.h
Mike Frysinger [Sun, 13 Jun 2021 05:54:48 +0000 (01:54 -0400)] 
sim: drop arch-specific config.h

All of the settings in here are handled by the common top-level
config.h, so drop the individual arch-config.h files entirely.

This will also help guarantee that we don't add any new arch
specific defines that would affect common code which will help
with the effort of unifying them.

2 years agosim: move dv-sockser define to CPPFLAGS
Mike Frysinger [Sun, 13 Jun 2021 05:52:01 +0000 (01:52 -0400)] 
sim: move dv-sockser define to CPPFLAGS

This is the only define left in m4/ that is not in the common config.h,
so move it to sim_hw_cflags so we can drop the arch-specific config.h.

2 years agoAutomatic date update in version.in
GDB Administrator [Wed, 16 Jun 2021 00:00:06 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 years agosim: switch modules.c & version.c to stamp files
Mike Frysinger [Tue, 15 Jun 2021 00:38:52 +0000 (20:38 -0400)] 
sim: switch modules.c & version.c to stamp files

This fixes remaking of these files and avoids unnecessary rebuilds.

Also add both to `make clean` to match other stamp files.

2 years agoFix typo in vsx-regs.exp test
Carl Love [Tue, 15 Jun 2021 18:40:11 +0000 (13:40 -0500)] 
Fix typo in vsx-regs.exp test

gdb/ChangeLog
2021-06-15  Carl Love  <cel@us.ibm.com>

* testsuite/gdb.arch/vsx-regs.exp (gdb_test_no_output): Fix typo
in set \$vs$i.v2_double.

2 years agoAllow readelf to recognise GO buildid notes.
Nick Clifton [Tue, 15 Jun 2021 10:43:43 +0000 (11:43 +0100)] 
Allow readelf to recognise GO buildid notes.

binutils * readelf.c (get_note_type): Add support for NT_GO_BUILDID.

include  * elf/common.h (NT_GO_BUILDID): Define.

2 years agox86: bring "gas --help" output for --32 etc in sync with reality
Jan Beulich [Tue, 15 Jun 2021 06:01:12 +0000 (08:01 +0200)] 
x86: bring "gas --help" output for --32 etc in sync with reality

The testsuite uses the output to determine whether BFD64 is in effect.

--x32 is supported for ELF only; don't advertise it for PE/COFF. --64 is
also supported for Mach-O; advertise it. Adjust the testsuite's BFD64
check accordingly.

Also replace "code" by "object", since it's the object format that the
options primarily control. It's also _initial_ code bitness, but this
can be changed by directives.

2 years agox86: simplify .dispNN setting
Jan Beulich [Tue, 15 Jun 2021 06:00:45 +0000 (08:00 +0200)] 
x86: simplify .dispNN setting

First of all eliminate the disp{16,32,32s} static variables, which are
used solely for setting a temporary variable in build_modrm_byte(). The
effect there can be had without use of such a temporary and without
operand_type_or(), by just setting the single bit each that needs
setting.

Then use operand_type_and_not(..., anydisp) when all dispNN bits want
clearing together.

2 years agox86: slightly simplify offset_in_range()
Jan Beulich [Tue, 15 Jun 2021 06:00:17 +0000 (08:00 +0200)] 
x86: slightly simplify offset_in_range()

Applying a mask with all bits set (or its inverse, with hence all bits
clear) won't alter the result (or won't trigger the warning). Re-arrange
the code to eliminate two more of the somewhat odd (2 << width_minus_1)
constructs.

2 years agox86: harmonize disp with imm handling
Jan Beulich [Tue, 15 Jun 2021 05:59:44 +0000 (07:59 +0200)] 
x86: harmonize disp with imm handling

Certain disp values may trigger "... shortened to ..." warnings when
equivalent imm ones don't. In some of the cases there are also
differences (for non-64-bit code) between BFD64 and !BFD64 builds. The
resulting encodings (i.e. use [or not] of the shorter disp8 / imm8
forms) are also different in some cases. Make this handling consistent.

Note that using equivalent 16-bit mode displacements / immediates
continues to expose entirely different behavior (see the disp-imm-16
testcase added by an earlier patch). This may want to be the subject of
further changes, but it'll then quickly become obvious that e.g. keying
use of extend_to_32bit_address() to non-64-bit mode isn't appropriate
either: Once we allow wrapping operands, we would better do so
consistently, in which case all of this would need to become dependent
upon address or operand size instead of mode.

2 years agox86: make offset_in_range()'s warning contents useful (again)
Jan Beulich [Tue, 15 Jun 2021 05:58:57 +0000 (07:58 +0200)] 
x86: make offset_in_range()'s warning contents useful (again)

In case there is something which gets shortened (perhaps only on a BFD64
build targeting a 32-bit binary), seeing the full original value is
often helpful to understand what's actually going wrong. Of course for
non-64-bit binaries we better wouldn't be seeing such warnings at all,
as they're often indicative of a behavioral difference between BFD64 and
!BFD64 builds.

Prior to "gas: drop sprint_value()", which introduced the use of
bfd_sprintf_vma(), the output had other shortcomings.

2 years agox86: off-by-1 in offset_in_range()
Jan Beulich [Tue, 15 Jun 2021 05:58:18 +0000 (07:58 +0200)] 
x86: off-by-1 in offset_in_range()

Just like e.g. 0x10000 triggers a warning for size 2, -0x10000 ought to
as well.

Note that some of the encodings produced aren't ones one would expect,
and hence the generated code is not being checked for in the new
testcases.