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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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:
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.
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.
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.
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.
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.
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".
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.