deliverable/binutils-gdb.git
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.

2 years agox86: permit parenthesized expressions again as addressing scale factor
Jan Beulich [Tue, 15 Jun 2021 05:57:11 +0000 (07:57 +0200)] 
x86: permit parenthesized expressions again as addressing scale factor

The description of e68c3d59acd0 ("x86: better respect quotes in
parse_operands()") wrongly states:

"In i386_att_operand(), which needs adjustment to remain in sync, besides
 respecting double quotes now, also change the logic such that we don't
 count parentheses anymore: Finding any opening or closing parenthesis or
 any double quote means we're done, because the subsequent parsing code
 wouldn't accept (extra) instances of these anyway."

I didn't pay attention to the possibility of the scale factor being
specified as an expression, which may contain parentheses. Thanks to
Martin for pointing this out. Restore prior behavior or matching
parentheses (backwards), while giving the variable a more suitable name.
Note that this simple and immediate fix is not ging to be enough: This
expression could itself involve quoted symbols. However, to address this
backwards parsing needs to be done away with altogether here (such that
parentheses which are part of such a quoted symbol name can also
properly be accounted for), which is going to be a more intrusive
change.

2 years agoreadelf: report DF_1_PIE as "Position-Independent Executable"
Alan Modra [Fri, 11 Jun 2021 04:53:57 +0000 (14:23 +0930)] 
readelf: report DF_1_PIE as "Position-Independent Executable"

I finally found time to teach readelf to identify PIEs in the file
header display and program header display.  So in place of
"DYN (Shared object file)" which isn't completely true, show
"DYN (Position-Independent Executable file)".

It requires a little bit of untangling code in readelf due to
process_program_headers setting up dynamic_addr and dynamic_size,
needed to scan .dynamic for the DT_FLAGS_1 entry, and
process_program_headers itself wanting to display the file type in
some cases.  At first I modified process_program_header using a
"probe" parameter similar to get_section_headers in order to inhibit
output, but decided it was cleaner to separate out
locate_dynamic_sections.

binutils/
* readelf.c (locate_dynamic_section, is_pie): New functions.
(get_file_type): Replace e_type parameter with filedata.  Call
is_pie for ET_DYN.  Update all callers.
(process_program_headers): Use local variables dynamic_addr and
dynamic_size, updating filedata on exit from function.  Set
dynamic_size of 1 to indicate no dynamic section or segment.
Update tests of dynamic_size throughout.
* testsuite/binutils-all/x86-64/pr27708.dump: Update expected output.
ld/
* testsuite/ld-pie/vaddr-0.d: Update expected output.
gdb/
* testsuite/lib/gdb.exp (exec_is_pie): Match new PIE readelf output.

2 years agosim: mn10300: enable -Werror
Mike Frysinger [Tue, 15 Jun 2021 03:45:42 +0000 (23:45 -0400)] 
sim: mn10300: enable -Werror

Now that all warnings are fixed in this port, enable -Werror by default.

2 years agosim: mn10300: switch abort to sim_engine_abort
Mike Frysinger [Tue, 15 Jun 2021 03:44:48 +0000 (23:44 -0400)] 
sim: mn10300: switch abort to sim_engine_abort

This allows the caller to catch engine aborts if they want, and fixes
the warning about missing stdlib.h include by not using abort().

2 years agosim: erc32: fix build w/out F_{G,S}ETFL
Mike Frysinger [Tue, 15 Jun 2021 03:25:01 +0000 (23:25 -0400)] 
sim: erc32: fix build w/out F_{G,S}ETFL

Add conditional logic around fcntl.h F_{G,S}ETFL usage to fix builds
on systems that don't have it (e.g. Windows).  The code is only used
to save & restore limited terminal stdin state.

2 years agosim: erc32: fix build w/out termios.h
Mike Frysinger [Tue, 15 Jun 2021 03:23:19 +0000 (23:23 -0400)] 
sim: erc32: fix build w/out termios.h

Add conditional logic around termios.h usage to fix builds on systems
that don't have it (e.g. Windows).

2 years agosim: drop redundant SIM_AC_OPTION_WARNINGS
Mike Frysinger [Tue, 15 Jun 2021 03:16:49 +0000 (23:16 -0400)] 
sim: drop redundant SIM_AC_OPTION_WARNINGS

The common code already calls this, so no need to do so in arch dirs.
We leave the calls that disable -Werror.  This will help unify the
configure scripts.

2 years agosim: enable silent rules in common builds
Mike Frysinger [Mon, 14 Jun 2021 23:54:04 +0000 (19:54 -0400)] 
sim: enable silent rules in common builds

We only do the common code as automake simplifies the logic.

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

2 years agognulib: define the path to gnulib's parent dir
Mike Frysinger [Tue, 8 Jun 2021 22:04:28 +0000 (18:04 -0400)] 
gnulib: define the path to gnulib's parent dir

The current setting assumes that gnulib is only used by dirs
immediately under the source root.  Trying to build it two or
more levels deep fails.  Switch GNULIB_BUILDDIR to a relative
GNULIB_PARENT_DIR so that it can be used to construct both the
build & source paths.

2 years agofbsd nat: Disable address space randomization when requested.
John Baldwin [Mon, 14 Jun 2021 21:28:26 +0000 (14:28 -0700)] 
fbsd nat: Disable address space randomization when requested.

Use procctl(2) with PROC_ASLR_CTL to disable address space
randomization in the current gdb process before forking a child
process for a new inferior when address space randomization is
disabled.

gdb/ChangeLog:

* configure.ac: Check for <sys/procctl.h>.
* config.in, configure: Regenerate.
* fbsd-nat.c: Include <sys/procctl.h> if present.
[PROC_ASLR_CTL] (maybe_disable_address_space_randomization): New.
(fbsd_nat_target::create_inferior)
(fbsd_nat_target::supports_disable_randomization): New.
* fbsd-nat.h (fbsd_nat_target::create_inferior)
(fbsd_nat_target::supports_disable_randomization): New.

2 years agoFix silent gdb.base/annota1.exp test coverage regression
Pedro Alves [Mon, 14 Jun 2021 20:29:32 +0000 (21:29 +0100)] 
Fix silent gdb.base/annota1.exp test coverage regression

This commit fixes a test coverage regression caused by:

 commit b001de2320446ec803b4ee5e0b9710b025b84469
 Author:     Andrew Burgess <andrew.burgess@embecosm.com>
 AuthorDate: Mon Nov 26 17:56:39 2018 +0000
 Commit:     Andrew Burgess <andrew.burgess@embecosm.com>
 CommitDate: Wed Dec 12 17:33:52 2018 +0000

     gdb: Update test pattern to deal with native-extended-gdbserver

While looking at a regression caused by a local patch I was working
on, I noticed this:

 \1a\1apre-prompt
 (gdb)
 \1a\1aprompt
 PASS: gdb.base/annota1.exp: breakpoint info
 PASS: gdb.base/annota1.exp: run until main breakpoint
 run

 \1a\1apost-prompt
 Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/outputs/gdb.base/annota1/annota1
 next

Note how above, we get the "run until main breakpoint" pass even
before "run" shows up in the log!  The issue is that the test isn't
really testing anything, it always passes regardless of the gdb
output.

There are a few problems here, fixed by this commit:

 - using {} to build the list for [join], when the strings we're
   joining include variable names that must be expanded.  Such list
   need to be built with [list] instead.

 - [join] joins strings with a space character by default.  We need to
   pass the empty string as second parameter so that it just concats
   the strings.

 - doing too much in a "-re" (calling procedures), which doesn't work
   correctly.  I've seen this before and never digged deeper into why.
   Probably something to do with how gdb_test_multiple is implemented.
   Regardless, easy and clear enough to build the pattern first into a
   variable.

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

* gdb.base/annota1.exp: Build list using [list] instead of {}.
Tell [join] to join with no character.  Build expected pattern in
separate variable instead of in the -re expression directly.

Change-Id: Ib3c89290f0e9ae4a0a43422853fcd4a7a7e12b18

2 years agoInclude missing header signal.h
Bernd Edlinger [Mon, 14 Jun 2021 12:49:21 +0000 (14:49 +0200)] 
Include missing header signal.h

2021-06-14  Bernd Edlinger  <bernd.edlinger@hotmail.de>

* compile/compile.c: Include missing header signal.h.

2 years agoUse consistent type in binutils/dwarf.c
Eric Botcazou [Mon, 14 Jun 2021 13:43:19 +0000 (15:43 +0200)] 
Use consistent type in binutils/dwarf.c

If you look at the type used for implicit_const objects in binutils/dwarf.c,
you'll get sometimes bfd_signed_vma and sometimes dwarf_signed_vma.

They are the same on 64-bit hosts, but not on 32-bit hosts, and the latter
discrepancy, in particular in process_abbrev_set, is responsible for the
following error issued by objdump on some object files containing DWARF 5:

binutils/dwarf.c:1108: read LEB value is too large to store in destination
variable

binutis/
* dwarf.c (struct abbrev_attr): Change type of implicit_const.
(add_abbrev_attr): Likewise.
(process_abbrev_set): Likewise.
(display_debug_abbrev): Adjust to above change.

2 years agoGNU gettext introduced this change[0] in version 0.19.8 to fix gettext detection...
Michael Forney [Mon, 14 Jun 2021 13:05:39 +0000 (14:05 +0100)] 
GNU gettext introduced this change[0] in version 0.19.8 to fix gettext detection with musl libc, since it does not define these internal symbols.

This allows binutils to build with musl gettext rather than falling
back to the bundled version.

[0] https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=commit;h=b67399b4

2021-06-13  Michael Forney  <mforney@mforney.org>

config/ChangeLog:

        * gettext.m4 (AM_GNU_GETTEXT): Skip checks for the internal
        symbols _nl_msg_cat_cntr, _nl_domain_bindings, and
        _nl_expand_alias, if __GNU_GETTEXT_SUPPORTED_REVISION is defined.
Backport of gettext serial 68 patch.

intl/ChangeLog:

* configure: Regenerate.
---
Thi

2 years agogas: fold three as_warn() in emit_expr_with_reloc()
Jan Beulich [Mon, 14 Jun 2021 06:18:58 +0000 (08:18 +0200)] 
gas: fold three as_warn() in emit_expr_with_reloc()

Simply use the available abstraction instead of, effectively, trying to
open-code it.

2 years agogas: drop TC_ADDRESS_BYTES conditionals
Jan Beulich [Mon, 14 Jun 2021 06:18:07 +0000 (08:18 +0200)] 
gas: drop TC_ADDRESS_BYTES conditionals

I've been repeatedly confused by, in particular, the .dc.a potable[]
entry being conditional. Grepping in gas/config/ reveals only very few
targets actually #define-ing it. But as of 7be1c4891a20 the symbol is
always defined, so #ifdef-s are pointless (and, as said, potentially
confusing).

Also adjust documentation to reflect this.

2 years agosim: ppc: use common version.o too
Mike Frysinger [Mon, 14 Jun 2021 01:35:05 +0000 (21:35 -0400)] 
sim: ppc: use common version.o too

The common version.o we're building can be used for the ppc subdir,
so switch it over too.

2 years agosim: rx: move cycle-accurate settings to CPPFLAGS
Mike Frysinger [Sun, 13 Jun 2021 05:32:33 +0000 (01:32 -0400)] 
sim: rx: move cycle-accurate settings to CPPFLAGS

This is the last unique setting that rx has in its config.h, so by
moving this to CPPFLAGS, we can drop its config.h entirely.

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

2 years agosim: start unifying portability shims
Mike Frysinger [Sat, 29 May 2021 20:07:43 +0000 (16:07 -0400)] 
sim: start unifying portability shims

There are some functions that gnulib does not yet provide fallbacks
for, so start a common file of our own for holding existing stubs.

2 years agosim: unify sim-load.o building
Mike Frysinger [Mon, 7 Jun 2021 05:48:06 +0000 (01:48 -0400)] 
sim: unify sim-load.o building

Since this file does not rely on any port-specific settings, move it
up to building as part of the common step so we only do it once in a
multibuild.

2 years agosim: rx: replace cycle-stats with common profile settings
Mike Frysinger [Sat, 12 Jun 2021 16:01:27 +0000 (12:01 -0400)] 
sim: rx: replace cycle-stats with common profile settings

The common sim-profile option controls whether to keep track of
runtime execution (like cycle count), so switch the rx-specific
cycle-stats option over to that.

2 years agosim: assume sys/select.h always exists
Mike Frysinger [Sat, 29 May 2021 19:20:28 +0000 (15:20 -0400)] 
sim: assume sys/select.h always exists

Now that gnulib provides this, assume it exists.

2 years agosim: erc32: replace caddr_t with void*
Mike Frysinger [Wed, 9 Jun 2021 22:05:25 +0000 (18:05 -0400)] 
sim: erc32: replace caddr_t with void*

This BSDism was never accepted into standards, so replace it with the
portable void* type instead.

2 years agosim: erc32/ppc: fix handling of $EXEEXT
Mike Frysinger [Wed, 9 Jun 2021 22:04:57 +0000 (18:04 -0400)] 
sim: erc32/ppc: fix handling of $EXEEXT

2 years agosim: overhaul alignment settings management
Mike Frysinger [Mon, 7 Jun 2021 04:54:20 +0000 (00:54 -0400)] 
sim: overhaul alignment settings management

Currently, the sim-config module will abort if alignment settings
haven't been specified by the port's configure.ac.  This is a bit
weird when we've allowed SIM_AC_OPTION_ALIGNMENT to seem like it's
optional to use.  Thus everyone invokes it.

There are 4 alignment settings, but really only 2 matters: strict
and nonstrict.  The "mixed" setting is just the default ("unset"),
and "forced" isn't used directly by anyone (it's available as a
runtime option for some ports).

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, then the
build won't work (see above as if SIM_AC_OPTION_ALIGNMENT wasn't
called).  If default settings are provided, then that is used, but
we allow the user to override at runtime.  Otherwise, the "wire"
settings are used and user runtime options to change are ignored.

Most ports specify a default, or set the "wire" to nonstrict.  A
few set "wire" to strict, but it's not clear that's necessary as
it doesn't make the code behavior, by default, any different.  It
might make things a little faster, but we should provide the user
the choice of the compromises to make: force a specific mode at
compile time for faster runtime, or allow the choice at runtime.
More likely it seems like an oversight when these ports were
initially created, and/or copied & pasted from existing ports.

With all that backstory, let's get to what this commit does.

First kill off the idea of a compile-time default alignment and
set it to nonstrict in the common code.  For any ports that want
strict alignment by default, that code is moved to sim_open while
initializing the sim.  That means WITH_DEFAULT_ALIGNMENT can be
completely removed.

Moving the default alignment to the runtime also allows removal
of setting the "wire" settings at configure time.  Which allows
removing of all arguments to SIM_AC_OPTION_ALIGNMENT and moving
that call to common code.

The macro logic can be reworked to not pass WITH_ALIGNMENT as -D
CPPFLAG and instead move it to config.h.

All of these taken together mean we can hoist the macro up to the
top level and share it among all sims so behavior is consistent
among all the ports.

2 years agosim: unify bug & package settings
Mike Frysinger [Mon, 7 Jun 2021 00:48:46 +0000 (20:48 -0400)] 
sim: unify bug & package settings

Move these options up to the common dir so we only test & export
them once across all ports.  The AC_INIT macro does a lot of the
heavy lifting already which allows further simplification.

2 years agosim: unify debug/stdio/trace/profile build settings
Mike Frysinger [Mon, 7 Jun 2021 00:35:02 +0000 (20:35 -0400)] 
sim: unify debug/stdio/trace/profile build settings

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

The ppc code needs a little extra care with its trace settings as
it's not exactly the same API as the common code.  The other knobs
are the same though.

2 years agosim: split debug/stdio/trace/profile options into dedicated m4 files
Mike Frysinger [Mon, 7 Jun 2021 00:16:48 +0000 (20:16 -0400)] 
sim: split debug/stdio/trace/profile options into dedicated m4 files

This follows existing organizational structure with one configure option
per m4 file, and will make it easier to move to the common configure dir.

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

2 years agosim: ppc: unify header & function & type tests too
Mike Frysinger [Sat, 12 Jun 2021 17:18:29 +0000 (13:18 -0400)] 
sim: ppc: unify header & function & type tests too

Since ppc now shares a config.h with the top-level, move all of its
relevant settings up a level.  The ppc port tests a lot more funcs,
but that's because its syscall emulation is a lot more complete.
We'll probably utilize some of these in the common code too.

2 years agoremote: Fix indentation in remote_new_objfile.
John Baldwin [Sat, 12 Jun 2021 17:43:29 +0000 (10:43 -0700)] 
remote: Fix indentation in remote_new_objfile.

gdb/remote.c:14541:5: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
    if (current_inferior ()->in_initial_library_scan)
    ^
gdb/remote.c:14527:3: note: previous statement is here
  if (remote == nullptr)
  ^

gdb/ChangeLog:

* remote.c (remote_new_objfile): Fix indentation.

2 years agosim: ppc: unify env settings too
Mike Frysinger [Sat, 12 Jun 2021 16:57:02 +0000 (12:57 -0400)] 
sim: ppc: unify env settings too

The ppc port doesn't share a lot of the common logic, but there are
a few bits that bleed across.  Have it use the common configure for
environment settings too to avoid duplicate define errors after the
recent unification with the other ports.

2 years agosim: unify environment build settings
Mike Frysinger [Mon, 7 Jun 2021 00:11:02 +0000 (20:11 -0400)] 
sim: unify environment build settings

Move the --sim-enable-environment option up to the common dir so we
only test & export it once across all ports.

2 years agosim: unify assert build settings
Mike Frysinger [Sun, 6 Jun 2021 22:45:05 +0000 (18:45 -0400)] 
sim: unify assert build settings

Move the --sim-enable-assert option up to the common dir so we only
test & export it once across all ports.

2 years agosim: unify platform function & header tests
Mike Frysinger [Tue, 18 May 2021 00:34:52 +0000 (20:34 -0400)] 
sim: unify platform function & header tests

Move the various platform tests up a level to avoid duplication
across the ports.  When building multiple versions, this speeds
things up a bit.

For now we move the obvious stuff up a level, but we don't turn
own the config.h entirely just yet -- we still have some tests
related to libraries that need consideration.

2 years agoreadelf: don't clear section_headers in process_file_header
Alan Modra [Sat, 12 Jun 2021 02:29:22 +0000 (11:59 +0930)] 
readelf: don't clear section_headers in process_file_header

* readelf.c (process_file_header): Don't clear section_headers.

2 years agoRe: readelf section reading
Alan Modra [Sat, 12 Jun 2021 01:24:21 +0000 (10:54 +0930)] 
Re: readelf section reading

Fix commit 4de91c10cdd9, which cached the single section header read
to pick up file header extension fields.  Also, testing e_shoff in
get_section_headers opened a hole for fuzzers where we'd end up with
segfaults due to non-zero e_shnum but NULL section_headers.

* readelf.c (get_section_headers): Don't test e_shoff here, leave
that to get_32bit_section_headers or get_64bit_section_headers.
(process_object): Throw away section header read to print file
header extension.

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

2 years agoFix ChangeLog entry location
Simon Marchi [Fri, 11 Jun 2021 22:09:57 +0000 (18:09 -0400)] 
Fix ChangeLog entry location

This ChangeLog entry is in the wrong file, fix that.

Change-Id: I43464e1bdb94d2f40d4c7dfaf425fc498851964c

2 years agomi-sym-info.exp: Increase timeout for 114-symbol-info-functions
Kevin Buettner [Thu, 10 Jun 2021 02:52:08 +0000 (19:52 -0700)] 
mi-sym-info.exp: Increase timeout for 114-symbol-info-functions

Loading libc.so's symbols increased the amount of time needed for
114-symbol-info-function to fetch symbols, causing a timeout during my
testing.  I enclosed the entire block with a "with_timeout_factor 4",
which fixes the problem for me.  (Using 2 also fixed it for me, but it
might not be enough when running this test on slower machines.)

gdb/testsuite/ChangeLog:

* gdb.mi/mi-sym-info.exp (114-symbol-info-function test): Increase
timeout.

2 years agoprint-symbol-loading.exp: Allow libc symbols to be already loaded
Kevin Buettner [Thu, 10 Jun 2021 02:31:18 +0000 (19:31 -0700)] 
print-symbol-loading.exp: Allow libc symbols to be already loaded

One consequence of changing libpthread_name_p() in solib.c to (also)
match libc is that the symbols for libc will now be loaded by
solib_add() in solib.c.  I think this is mostly harmless because
we'll likely want these symbols to be loaded anyway, but it did cause
two failures in gdb.base/print-symbol-loading.exp.

Specifically...

1)

sharedlibrary .*
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib off: load shared-lib

now looks like this:

sharedlibrary .*
Symbols already loaded for /lib64/libc.so.6
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib off: load shared-lib

2)

sharedlibrary .*
Loading symbols for shared libraries: .*
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib brief: load shared-lib

now looks like this:

sharedlibrary .*
Loading symbols for shared libraries: .*
Symbols already loaded for /lib64/libc.so.6
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib brief: load shared-lib

Fixing case #2 ended up being easier than #1.  #1 had been using
gdb_test_no_output to correctly match this no-output case.  I
ended up replacing it with gdb_test_multiple, matching the exact
expected output for each of the two now acceptable cases.

For case #2, I simply added an optional non-capturing group
for the potential new output.

gdb/testsuite/ChangeLog:

* gdb.base/print-symbol-loading.exp (proc test_load_shlib):
Allow "Symbols already loaded for..." messages.

2 years agotestsuite/glib-2.34: Match/consume optional libthread_db related output
Kevin Buettner [Thu, 10 Jun 2021 01:56:23 +0000 (18:56 -0700)] 
testsuite/glib-2.34: Match/consume optional libthread_db related output

When using glibc-2.34, we now see messages related to the loading of
the thread library for non-thread programs.  E.g.  for the test case,
gdb.base/execl-update-breakpoints.exp, we will see the following when
starting the program:

(gdb) break -qualified main
Breakpoint 1 at 0x100118c: file /ironwood1/sourceware-git/f34-2-glibc244_fix/bld/../../worktree-glibc244_fix/gdb/testsuite/gdb.base/execl-update-breakpoints.c, line 34.
(gdb) run
Starting program: [...]/execl-update-breakpoints1
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

The two lines of output related to libthread_db are new; we didn't see
these in the past.  This is a side effect of libc now containing the
pthread API - we can no longer tell whether the program is
multi-threaded by simply looking for libpthread.so.  That said, I
think that we now want to load libthread_db anyway since it's used to
resolve TLS variables; i.e. we need it for correctly determining the
value of errno.

This commit adds the necessary regular expressions to match this
(optional) additional output in the two tests which were failing
without it.

gdb/testsuite/ChangeLog:

* gdb.base/execl-update-breakpoints.exp: Add regular
expression for optionally matching output related to
libthread_db.
* gdb.base/fork-print-inferior-events.exp: Likewise.

2 years agolibthread_db initialization changes related to upcoming glibc-2.34
Kevin Buettner [Thu, 10 Jun 2021 01:07:45 +0000 (18:07 -0700)] 
libthread_db initialization changes related to upcoming glibc-2.34

This commit makes some adjustments to accomodate the upcoming
glibc-2.34 release.  Beginning with glibc-2.34, functionality formerly
contained in libpthread has been moved to libc.  For the time being,
libpthread.so still exists in the file system, but it won't show up in
ldd output and therefore won't be able to trigger initialization of
libthread_db related code.  E.g...

Fedora 34 / glibc-2.33.9000:

[kev@f34-2 gdb]$ ldd testsuite/outputs/gdb.threads/tls/tls
linux-vdso.so.1 (0x00007ffcf94fa000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007ff0ba9af000)
libm.so.6 => /lib64/libm.so.6 (0x00007ff0ba8d4000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007ff0ba8b9000)
libc.so.6 => /lib64/libc.so.6 (0x00007ff0ba6c6000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff0babf0000)

Fedora 34 / glibc-2.33:

[kev@f34-1 gdb]$ ldd testsuite/outputs/gdb.threads/tls/tls
linux-vdso.so.1 (0x00007fff32dc0000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f815f6de000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f815f4bf000)
libm.so.6 => /lib64/libm.so.6 (0x00007f815f37b000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f815f360000)
libc.so.6 => /lib64/libc.so.6 (0x00007f815f191000)
/lib64/ld-linux-x86-64.so.2 (0x00007f815f721000)

Note that libpthread is missing from the ldd output for the
glibc-2.33.9000 machine.

This means that (unless we happen to think of some entirely different
mechanism), we'll now need to potentially match "libc" in addition to
"libpthread" as libraries which might be thread libraries.  This
accounts for the change made in solib.c.  Note that the new code
attempts to match "/libc." via strstr().  That trailing dot (".")
avoids inadvertently matching libraries such as libcrypt (and
all the other many libraries which begin with "libc").

To avoid attempts to load libthread_db when encountering older
versions of libc, we now attempt to find "pthread_create" (which is a
symbol that we'd expect to be in any pthread library) in the
associated objfile.  This accounts for the changes in
linux-thread-db.c.

I think that other small adjustments will need to be made elsewhere
too.  I've been working through regressions on my glibc-2.33.9000
machine; I've fixed some fairly "obvious" changes in the testsuite
(which are in other commits).  For the rest, it's not yet clear to me
whether the handful of remaining failures represent a problem in glibc
or gdb.  I'm still investigating, however, I'll note that these are
problems that I only see on my glibc-2.33.9000 machine.

gdb/ChangeLog:

* solib.c (libpthread_name_p): Match "libc" in addition
to "libpthread".
* linux-thread-db.c (libpthread_objfile_p): New function.
(libpthread_name_p): Adjust preexisting callers to use
libpthread_objfile_p().

2 years agogdb: remove unused struct call_site_stuff forward declaration
Simon Marchi [Fri, 11 Jun 2021 15:36:48 +0000 (11:36 -0400)] 
gdb: remove unused struct call_site_stuff forward declaration

This is unused (and was event when it was introduced).  Remove it.

gdb/ChangeLog:

* dwarf2/loc.h (struct call_site_stuff): Remove.

Change-Id: Iaa82cb7cfd9768998553b4c9211aca7529eb402f

2 years agogdb, testsuite: Fix mi-var-child-f.exp for Intel compilers.
Felix Willgerodt [Thu, 6 May 2021 12:14:07 +0000 (14:14 +0200)] 
gdb, testsuite: Fix mi-var-child-f.exp for Intel compilers.

mi-var-child-f.exp uses array.f as the inferior, which uses an unnamed
main function.  This causes false positive fails for Intel compilers, as
they emit the following DWARF:

~~~
0x0000002a:   DW_TAG_subprogram
                DW_AT_low_pc    (0x0000000000404800)
                DW_AT_high_pc   (0x000000000040484c)
                DW_AT_frame_base        (DW_OP_reg6 RBP)
                DW_AT_linkage_name      ("MAIN__")
                DW_AT_name      ("_unnamed_main$$")
                DW_AT_decl_file ("array.f")
                DW_AT_decl_line (16)
                DW_AT_external  (true)
                DW_AT_main_subprogram   (true)
~~~

The testsuite for fortran uses test_compiler_info to determine a hardcoded
string which is used to run to main and as a testing regex:

~~~
proc fortran_main {} {
    if {[test_compiler_info {gcc-4-[012]-*}]
         || [test_compiler_info {gcc-*}]
         || [test_compiler_info {icc-*}] {
return "MAIN__"
    } elseif {[test_compiler_info {clang-*}]} {
return "MAIN_"
    } else {
return "unknown"
    }
}
~~~

GDB however uses DW_AT_name mostly in its output, which fails the regex.
To fix this testcase immediately, I modernized array.f and gave it a named
main.  There was no specific reason it was unnamed anyway.  Fixing
the testsuite properly is not straightforward.  fortran_main and
test_compiler_info would need some changes, which has broader influences.
I might look at this later down the road.

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

* gdb.mi/array.f: Convert into...
* gdb.mi/array.f90: ...this.
* gdb.mi/mi-var-child-f.exp: Use array.f90.

2 years agoImplement Rust raw identifiers
Tom Tromey [Fri, 11 Jun 2021 14:14:09 +0000 (08:14 -0600)] 
Implement Rust raw identifiers

This patch implements Rust raw identifiers in the lexer in gdb.  There
was an earlier patch to do this, but the contributor didn't reply to
my email asking whether he had sorted out his copyright assignment.

This is relatively straightforward, but a small test suite addition
was needd to ensure that the new test is skipped on older versions of
rustc -- ones that predate the introduction of raw identifiers.

gdb/ChangeLog
2021-06-11  Tom Tromey  <tom@tromey.com>

PR rust/23427
* rust-parse.c (rust_parser::lex_identifier): Handle raw
identifiers.
(rust_lex_tests): Add raw identifier tests.

gdb/testsuite/ChangeLog
2021-06-11  Tom Tromey  <tom@tromey.com>

PR rust/23427
* lib/rust-support.exp (rust_compiler_version): New caching proc.
* gdb.rust/rawids.exp: New file.
* gdb.rust/rawids.rs: New file.

2 years agox86: Always define TC_PARSE_CONS_EXPRESSION
H.J. Lu [Fri, 11 Jun 2021 13:19:16 +0000 (06:19 -0700)] 
x86: Always define TC_PARSE_CONS_EXPRESSION

Always define TC_PARSE_CONS_EXPRESSION to properly wrap constants for
all x86 targets.

* config/tc-i386.c (x86_cons): Handle GOT/PLT relocations only
if needed.
* config/tc-i386.h (TC_PARSE_CONS_EXPRESSION): Always define.

2 years agoRISC-V: Update the riscv_opts.[rvc|rve] in the riscv_set_arch.
Nelson Chu [Fri, 11 Jun 2021 09:23:43 +0000 (17:23 +0800)] 
RISC-V: Update the riscv_opts.[rvc|rve] in the riscv_set_arch.

We also need to update the riscv_opts.[rvc|rve] for elf attributes.
Otherwise, the following case will fail,

$ cat cadd.s
.attribute arch, "rv64gc"
c.add   a0, a1
$ riscv64-unknown-elf-as cadd.s -o cadd.o
cadd.s: Assembler messages:
cadd.s:2: Error: illegal operands `c.add a0,a1

After applying this patch,

$ riscv64-unknown-elf-as cadd.s -o cadd.o
$ riscv64-unknown-elf-objdump -d cadd.o

cadd.o:     file format elf64-littleriscv

Disassembly of section .text:

0000000000000000 <.text>:
   0:   952e                    add     a0,a0,a1
        ...

gas/
    * config/tc-riscv.c (riscv_set_arch): Call riscv_set_rvc
    and riscv_set_rve both for -march and elf attributes.
    (riscv_after_parse_args): Likewise.

2 years agoreadelf info leaks from one object to the next
Alan Modra [Fri, 11 Jun 2021 03:19:02 +0000 (12:49 +0930)] 
readelf info leaks from one object to the next

A number of filedata entries were not cleared.  Make sure they are
all cleared out, except the ones needed for archive handling.

* readelf.c (struct filedata): Move archive_file_offset and
archive_file_size earlier.
(free_filedata): Clear using memset.

2 years agoreadelf section reading
Alan Modra [Fri, 11 Jun 2021 04:42:07 +0000 (14:12 +0930)] 
readelf section reading

This is a followup to git commit 8ff66993e0b5, a patch aimed at
segfaults found invoking readelf multiple times with fuzzed objects.
In that patch I added code to clear more stashed data early in
process_section_headers, along with any stashed section headers.  This
patch instead relies on clearing out the stash at the end of
process_object, making sure that process_object doesn't exit early.

The patch also introduces some new wrapper functions.

* readelf.c (GET_ELF_SYMBOLS): Delete.  Replace with..
(get_elf_symbols): ..this new function throughout.
(get_32bit_section_headers): Don't free section_headers.
(get_64bit_section_headers): Likewise.
(get_section_headers): New function, use throughout in place of
32bit and 64bit variants.
(get_dynamic_section): Similarly.
(process_section_headers): Don't free filedata memory here.
(get_file_header): Don't get section headers here..
(process_object): ..Read them here instead.  Don't exit without
freeing filedata memory.

2 years agoPR27952, Disallow ET_DYN DF_1_PIE linker input
Alan Modra [Fri, 11 Jun 2021 04:36:47 +0000 (14:06 +0930)] 
PR27952, Disallow ET_DYN DF_1_PIE linker input

This patch adds a new elf_tdata flag, is_pie, set during the linker's
open_input_bfds processing.  The flag is then used to reject attempts
to link a PIE as if it were a shared library.

bfd/
PR 27952
* elf-bfd.h (struct elf_obj_tdata): Add is_pie.
* elflink.c (elf_link_add_object_symbols): Set is_pie.
ld/
PR 27952
* ldelf.c (ldelf_after_open): Error on input PIEs too.

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

2 years agogdb/testsuite: capture GDB tty name in default_gdb_spawn
Simon Marchi [Thu, 10 Jun 2021 18:30:33 +0000 (14:30 -0400)] 
gdb/testsuite: capture GDB tty name in default_gdb_spawn

The TUI test gdb.tui/empty.exp fails with the native-extended-gdbserver
board, and takes a very long time to run due to numerous timeouts.  The
symptom, when looking at the logs, is that the TUI windows that we
expect to be resized are not resized.  Digging down, I found that GDB
didn't receive any SIGWINCH that should have resulted from
Term::resize's stty calls.

The reason for this is:

- The native-extended-gdbserver overrides gdb_start to first start GDB,
  then start GDBserver with --multi, then connect GDB to GDBserver.
  This means that two TCL "spawn"s are done, one for GDB and one for
  GDBserver.

- The TUI test framework  wants to know GDB's TTY name, so it can pass
  it to stty, to fake terminal resizes.  To do so, it overrides the
  spawn built-in proc to capture the tty name from the internals of the
  built-in proc.  It saves the TTY name to the gdb_spawn_name global
  variable.

- Because the native-extended-gdbserver boards starts both GDB and
  GDBserver, the final value of gdb_spawn_name is the name of
  GDBserver's TTY.

- When the TUI test framework attempts to resize GDB's terminal, it in
  fact resizes GDBserver's terminal.  So obviously, GDB doesn't get the
  SIGWINCH, and we don't get the expected TUI redraw.

Fix that by moving the hack to lib/gdb.exp, overriding the builtin spawn
all the time.  The override saves the TTY name in the
last_spawn_tty_name global.  The default_gdb_spawn proc then saves it in
the gdb_tty_name global.  This way, we specifically capture GDB's TTY
name in gdb_tty_name, not the TTY name of other spawned processes.

Remove tuiterm_env_init and tuiterm_env_finish, since they are now
empty.  In turn, the gdb_finish_hooks mechanism is now unused, remove it
as well.  It would be easy to add them back if needed.

gdb/ChangeLog:

* lib/gdb.exp (default_gdb_exit): Unset gdb_tty_name.
(spawn_capture_tty_name): New, override builtin spawn.
(default_gdb_spawn): Capture GDB's TTY name.
* lib/tuiterm.exp (tuiterm_spawn): Remove.
(tuiterm_env_init, tuiterm_env_finish): Remove spawn override.
(Term) <resize>: Use new variable name.
(tuiterm_env_init, tuiterm_env_finish): Remove.
(tuiterm_env): Don't call tuiterm_env_init and register
tuiterm_env_finish in gdb_finish_hooks.
(gdb_finish_hooks): Remove.
(gdb_finish): Don't call finish hooks.

Change-Id: Ia5ab74184a52a996416022308f8d0cc523355a78

2 years ago[gdb/testsuite] Fix timeout in gdb.mi/user-selected-context-sync.exp with gcc-11
Tom de Vries [Thu, 10 Jun 2021 11:38:03 +0000 (13:38 +0200)] 
[gdb/testsuite] Fix timeout in gdb.mi/user-selected-context-sync.exp with gcc-11

When running test-case gdb.mi/user-selected-context-sync.exp with gcc-11, we
get:
...
continue^M
Continuing.^M
FAIL: gdb.mi/user-selected-context-sync.exp: mode=all-stop: test_setup: \
  inferior 1: continue to breakpoint: continue thread 1.2 to infinite \
  loop breakpoint (timeout)
...

This is a regression since commit aa33ea68330 "testsuite, mi: avoid a clang
bug in 'user-selected-context-sync.exp'", which fixes a similar hang when
using clang.

The source before the commit contains:
...
  while (1);
...
and after the commit:
...
  int spin = 1;
  while (spin);
...

[ FWIW, I've filed a PR gcc/101011 - Inconsistent debug info for "while (1);"
to mention that gcc-11 has different behaviour for these two loops. ]

The problem is that:
- the test-case expects the behaviour that a breakpoint set
  on the while line will trigger on every iteration, and
- that is not guaranteed by either version of the loop.

Fix this by using a while loop with a dummy body:
...
  volatile int dummy = 0;
  while (1)
    dummy = !dummy;
...
and setting the breakpoint in the body.

Tested on x86_64-linux with clang 10.0.1, gcc-4.8, gcc 7.5.0 and gcc 11.1.1.

gdb/testsuite/ChangeLog:

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

* gdb.mi/user-selected-context-sync.c (child_sub_function, main):
Rewrite while (1) using dummy loop body.

2 years agoarm: avoid "shadowing" of glibc function name
Jan Beulich [Thu, 10 Jun 2021 10:40:11 +0000 (12:40 +0200)] 
arm: avoid "shadowing" of glibc function name

Old enough glibc has an (unguarded) declaration of index() in string.h,
which triggers a "shadows a global declaration" warning.

2 years agoarm: fix array-out-of-bounds upon register parsing error
Jan Beulich [Thu, 10 Jun 2021 10:39:40 +0000 (12:39 +0200)] 
arm: fix array-out-of-bounds upon register parsing error

Despite the comment ahead of the enum explicitly pointing out the need
to also update the corresponding array, 1b8833198c0 ("Add support for
MVE instructions: vcmp and vpt") failed to do so. Oddly enough the issue
appears to be spotted only by rather old gcc (4.3-ish in my case).

2 years agox86: suppress LEA optimization in a specific 16-bit case
Jan Beulich [Thu, 10 Jun 2021 10:39:08 +0000 (12:39 +0200)] 
x86: suppress LEA optimization in a specific 16-bit case

In 16-bit mode a 16-bit address size LEA with a 16-bit displacement and
a 32-bit destination is shorter to encode than the corresponding MOV.
Commit fe134c656991 ("x86: optimize LEA")'s promise was to only do the
transformation when the encoding size wouldn't grow, i.e. it did go a
little too far. Restrict this specific case of the transformation to
-O2.

2 years ago [gdb/testsuite] Convert multi-line function call into single line.
Bhuvanendra Kumar N [Thu, 10 Jun 2021 07:15:27 +0000 (12:45 +0530)] 
[gdb/testsuite] Convert multi-line function call into single line.

    After this clang backend patch(https://reviews.llvm.org/D91734), 8 test points
    started to FAIL in this test case. As mentioned in this PR, "...this test is
    trying to next over a function call; gcc attributes all parameter evaluation
    to the function name, while clang will attribute each parameter to its own
    location. And when the parameters span across multiple source lines, the
    is_stmt heuristic kicks in, so we stop on each line with actual parameters...".

    gdb.base/foll-exec.c test file snippet :
    . . .
     42   execlp (prog, /* tbreak-execlp */
     43           prog,
     44           "execlp arg1 from foll-exec",
     45           (char *) 0);
     46
     47   printf ("foll-exec is about to execl(execd-prog)...\n");
    . . .

    Line table: (before clang backend patch for the above code snippet) :
    0x000000b0: 84 address += 8,  line += 2
                0x000000000020196a     42      3      1   0             0
    0x000000b1: 08 DW_LNS_const_add_pc (0x0000000000000011)
    0x000000b2: 41 address += 3,  line += 5
                0x000000000020197e     47      3      1   0             0

    Line table: (after clang backend patch for the above code snippet) :
    0x000000b5: 84 address += 8,  line += 2
                0x0000000000201958     42     11      1   0             0
    0x000000b6: 05 DW_LNS_set_column (4)
    0x000000b8: 75 address += 7,  line += 1
                0x000000000020195f     43      4      1   0             0
    0x000000b9: 05 DW_LNS_set_column (3)
    0x000000bb: 73 address += 7,  line += -1
                0x0000000000201966     42      3      1   0             0
    0x000000bc: 08 DW_LNS_const_add_pc (0x0000000000000011)
    0x000000bd: 4f address += 4,  line += 5
                0x000000000020197b     47      3      1   0             0

    Following 8 test points started to fail after the above clang backend patch.

    FAIL: gdb.base/foll-exec.exp: step through execlp call
    FAIL: gdb.base/foll-exec.exp: step after execlp call
    FAIL: gdb.base/foll-exec.exp: print execd-program/global_i (after execlp)
    FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execlp)
    FAIL: gdb.base/foll-exec.exp: print follow-exec/local_k (after execlp)
    FAIL: gdb.base/foll-exec.exp: step through execl call
    FAIL: gdb.base/foll-exec.exp: step after execl call
    FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execl)

    As we can note, reason for these new test failures is due to additional
    .debug_line entries getting created in case of clang compiler, hence to fix
    this issue, test case required either additional next command during
    these multi-line function call or combine these multi-line function call into
    single line. This PR has taken the latter approach and converted the multi-line
    function call into single line in foll-exec.c, thereby there is no change in
    .debug_line entries now and test case works as expected.

2 years ago[gdb/testsuite] Fix gdb.cp/nested-types.exp with check-read1
Tom de Vries [Thu, 10 Jun 2021 05:36:19 +0000 (07:36 +0200)] 
[gdb/testsuite] Fix gdb.cp/nested-types.exp with check-read1

With check-read1 I occasionally run into:
...
FAIL: gdb.cp/nested-types.exp: ptype S10 (limit = 7) \
  // parse failed (timeout)
...
I can trigger this reliably by running check-read1 in conjunction with
stress -c 5.

Fix this by breaking up the regexp in cp_test_ptype_class.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

* lib/cp-support.exp (cp_test_ptype_class): Break up regexp.
* gdb.cp/nested-types.exp: Remove usage of read1 timeout factor.

2 years ago[gdb/testsuite] Fix gdb.cp/cplusfuncs.exp with check-read1
Tom de Vries [Thu, 10 Jun 2021 05:36:19 +0000 (07:36 +0200)] 
[gdb/testsuite] Fix gdb.cp/cplusfuncs.exp with check-read1

When running check-read1, we run into:
...
FAIL: gdb.cp/cplusfuncs.exp: info function for "operator=(" (timeout)
...

Fix this by using using gdb_test_lines in info_func_regexp.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

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

* gdb.cp/cplusfuncs.exp (info_func_regexp): Use gdb_test_lines.

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

2 years agosim: cleanup obsolete NULL fallback
Mike Frysinger [Sun, 6 Jun 2021 22:13:41 +0000 (18:13 -0400)] 
sim: cleanup obsolete NULL fallback

We require C11 which defines NULL, so drop the inconsistent set of
fallback defines in the codebase.

2 years agosim: mn10300: tweak engine halt hook
Mike Frysinger [Sun, 6 Jun 2021 03:10:14 +0000 (23:10 -0400)] 
sim: mn10300: tweak engine halt hook

The hook is a void func, so defining it to 0 triggers warnings,
and isn't really needed.

2 years agosim: nrun: tweak init of callback endian
Mike Frysinger [Sun, 6 Jun 2021 02:50:57 +0000 (22:50 -0400)] 
sim: nrun: tweak init of callback endian

Allow ports to initialize the callback endian if they want.  This will
allow delegation of the logic out of common code in the future.

Also switch from the CURRENT_TARGET_BYTE_ORDER macro to the underlying
current_target_byte_order storage since the latter has been setup by
the sim-config module based on the same macros.  This will allow the
nrun module to be moved to common building for sharing.

2 years agosim: bpf: use CURRENT_TARGET_BYTE_ORDER
Mike Frysinger [Sun, 6 Jun 2021 02:48:23 +0000 (22:48 -0400)] 
sim: bpf: use CURRENT_TARGET_BYTE_ORDER

Code should be going through this macro rather than accessing the
underlying value directly.

2 years agosim: cgen: inline cgen_init logic
Mike Frysinger [Sat, 5 Jun 2021 14:21:46 +0000 (10:21 -0400)] 
sim: cgen: inline cgen_init logic

This function has done only one thing: post-process command line
settings to see if profiling or tracing has been enabled, and if
so, set the run_fast_p flag in the simulator state.  That flag is
only used in one place: to select the fast or slow cgen engine.
By inlining the run_fast_p logic to the one place it's used, we
can delete a good amount of logic specific to cgen ports: both
the call to cgen_init and the conditional simulator state.  This
in turn allows us to have a single simulator state struct across
all ports so we can share objects more between them, and makes
the sim_open calls look more consistent.

2 years agoUpdate read1 example in gdb/testsuite/README
Tom Tromey [Wed, 9 Jun 2021 14:34:47 +0000 (08:34 -0600)] 
Update read1 example in gdb/testsuite/README

Tom de Vries noticed that the recent changes to the testsuite's
configury required an update to the README.  This patch changes the
text to document the new reality.

2021-06-09  Tom Tromey  <tromey@adacore.com>

* README (Example): Update read1 example.

This page took 0.046627 seconds and 4 git commands to generate.