Alan Modra [Sat, 30 Oct 2021 08:24:53 +0000 (18:54 +1030)]
ubsan: alpha-vms: undefined shift
* vms-alpha.c (evax_bfd_print_image): Shift left 1u.
Alan Modra [Sat, 30 Oct 2021 08:12:00 +0000 (18:42 +1030)]
PR28518: signed integer overflow & free on unmalloced address
PR 28518
* vms-alpha.c (build_module_list): Don't lose malloc buffer address.
Use unsigned variables.
GDB Administrator [Sun, 31 Oct 2021 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Sat, 30 Oct 2021 02:15:55 +0000 (22:15 -0400)]
gdb: fix gdb.gdb/unittest.exp with C++17 compiler
On a machine with gcc 11, I get:
FAIL: gdb.gdb/unittest.exp: test_completion: tab complete "maintenance selftest string_v" (second tab) (timeout)
FAIL: gdb.gdb/unittest.exp: test_completion: tab complete "maintenance selftest string_vie" (timeout)
That's because when compiling with C++ >= 17, we use the standard
version of string_view, and don't have a selftest for it. So the list
of selftests shown by the tab completion when completing "string_v"
differs.
Change the test to use the copy_* tests instead.
Change-Id: I85f6aa44ee5fc9652b9bd4451e0506b89773526b
Aaron Merey [Sat, 30 Oct 2021 00:49:29 +0000 (20:49 -0400)]
gdb.texinfo: Expand documentation for debuginfod
Add section describing GDB's usage of debuginfod.
Refer to this new section in the description of the '--with-debuginfod'
configure option.
Mention debuginfod in the 'Separate Debug Files' section.
Aaron Merey [Fri, 29 Oct 2021 23:55:57 +0000 (19:55 -0400)]
gdb: add set/show commands for managing debuginfod
Add 'set debuginfod' command. Accepts 'on', 'off' or 'ask' as an
argument. 'on' enables debuginfod for the current session. 'off'
disables debuginfod for the current session. 'ask' will prompt
the user to either enable or disable debuginfod when the next query
is about to be performed:
This GDB supports auto-downloading debuginfo from the following URLs:
<URL1> <URL2> ...
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod on' to .gdbinit.
For interactive sessions, 'ask' is the default. For non-interactive
sessions, 'off' is the default.
Add 'show debuginfod status' command. Displays whether debuginfod
is set to 'on', 'off' or 'ask'.
Add 'set/show debuginfod urls' commands. Accepts a string of
space-separated debuginfod server URLs to be queried. The default
value is copied from the DEBUGINFOD_URLS environment variable.
Finally add 'set/show debuginfod verbose' commands to control whether
debuginfod-related output is displayed. Verbose output is enabled
by default.
(gdb) run
Starting program: /bin/sleep 5
Download failed: No route to host. Continuing without debug info for /lib64/libc.so.6.
If GDB is not built with debuginfod then these commands will just display
Support for debuginfod is not compiled into GDB.
GDB Administrator [Sat, 30 Oct 2021 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Mon, 27 Sep 2021 01:08:36 +0000 (21:08 -0400)]
gdb: remove TYPE_FIELD_DWARF_BLOCK
Remove TYPE_FIELD_DWARF_BLOCK, replace with type::field +
field::loc_dwarf_block.
Change-Id: I10af9410bb5f46d342b8358a7956998c7e804b64
Simon Marchi [Mon, 27 Sep 2021 01:07:04 +0000 (21:07 -0400)]
gdb: remove TYPE_FIELD_STATIC_PHYSADDR
Remove TYPE_FIELD_STATIC_PHYSADDR replace with type::field +
field::loc_physaddr.
Change-Id: Ica9bc4a48f34750ec82ec86c298d3ecece81bcbd
Simon Marchi [Mon, 27 Sep 2021 01:06:12 +0000 (21:06 -0400)]
gdb: remove TYPE_FIELD_STATIC_PHYSNAME
Remove TYPE_FIELD_STATIC_PHYSNAME, replace with type::field +
field::loc_physname.
Change-Id: Ie35d446b67dd1d02f39998b406001bdb7e6d5abb
Simon Marchi [Sun, 26 Sep 2021 20:38:02 +0000 (16:38 -0400)]
gdb: remove TYPE_FIELD_ENUMVAL
Remove TYPE_FIELD_ENUMVAL, replace with type::field +
field::loc_enumval.
Change-Id: I2ada73e4635aad3363ce2eb22c1dc52698ee2072
Simon Marchi [Sun, 26 Sep 2021 20:36:15 +0000 (16:36 -0400)]
gdb: remove TYPE_FIELD_BITPOS
Remove TYPE_FIELD_BITPOS, replace its uses with type::field +
field::loc_bitpos.
Change-Id: Iccd8d5a77e5352843a837babaa6bd284162e0320
Simon Marchi [Sun, 26 Sep 2021 20:34:28 +0000 (16:34 -0400)]
gdb: remove TYPE_FIELD_LOC_KIND
Remove TYPE_FIELD_LOC_KIND, replace its uses with type::field +
field::loc_kind.
Change-Id: Ib124a26365df82ac1d23df7962d954192913bd90
Simon Marchi [Fri, 24 Sep 2021 03:51:40 +0000 (23:51 -0400)]
gdb: remove FIELD_DWARF_BLOCK macro
Remove FIELD_DWARF_BLOCK, replace its uses with field::loc_dwarf_block.
Change-Id: I66b7d6a960cb5e341e61e21bd3cc9a6ac26de6a8
Simon Marchi [Fri, 24 Sep 2021 03:50:02 +0000 (23:50 -0400)]
gdb: remove FIELD_STATIC_PHYSADDR macro
Remove FIELD_LOC_KIND_PHYSADDR, replace its uses with
field::loc_physaddr.
Change-Id: Ifd8b2bdaad75f42bfb1404ef8c396ffe7e10ac55
Simon Marchi [Fri, 24 Sep 2021 03:47:42 +0000 (23:47 -0400)]
gdb: remove FIELD_STATIC_PHYSNAME macro
Remove FIELD_STATIC_PHYSNAME, replace its uses with field::loc_physname.
Change-Id: Iaa8952410403b4eb5bbd68411feea27e2405d657
Simon Marchi [Fri, 24 Sep 2021 03:47:08 +0000 (23:47 -0400)]
gdb: remove FIELD_ENUMVAL macro
Remove FIELD_ENUMVAL, replace its uses with field::loc_enumval.
Change-Id: Id4861cee91a8bb583a9836f1aa5da0a320fbf4d9
Simon Marchi [Fri, 24 Sep 2021 03:43:13 +0000 (23:43 -0400)]
gdb: remove FIELD_BITPOS macro
Remove FIELD_BITPOD, replace its uses with field::loc_bitpos.
Change-Id: Idb99297e0170661254276c206383a7e9bf1a935a
Simon Marchi [Fri, 24 Sep 2021 03:35:24 +0000 (23:35 -0400)]
gdb: remove FIELD_LOC_KIND macro
Remove FIELD_LOC_KIND, replace its uses with field::loc_kind or
call_site_target::loc_kind.
Change-Id: I0368d8c3ea269d491bb215aa70e32edbdf55f389
Tom Tromey [Fri, 22 Oct 2021 16:49:19 +0000 (10:49 -0600)]
Add gdb.Architecture.integer_type Python function
This adds a new Python function, gdb.Architecture.integer_type, which
can be used to look up an integer type of a given size and
signed-ness. This is useful to avoid dependency on debuginfo when a
particular integer type would be useful.
v2 moves this to be a method on gdb.Architecture and addresses other
review comments.
Tom Tromey [Wed, 20 Oct 2021 20:25:21 +0000 (14:25 -0600)]
Remove ada_value_print_inner
I noticed that the only caller of ada_value_print_inner is
valprint.c:do_val_print (via ada_language::value_print_inner), meaning
that the try/catch logic in this function is redundant. This patch
removes the wrapper function.
Regression tested on x86-64 Fedora 34.
Tom Tromey [Tue, 19 Oct 2021 20:42:04 +0000 (14:42 -0600)]
Document resolve_dynamic_type oddity
Today I re-learned that resolve_dynamic_type can return a type for
which is_dynamic_type returns true. This can happen for an array
whose elements have dynamic type -- the array is reported as dynamic,
but resolving the elements would be incorrect, because each element
might have a different type after resolution.
You can see the special case in resolve_dynamic_array_or_string:
if (ary_dim != NULL && ary_dim->code () == TYPE_CODE_ARRAY)
...
else
...
I looked into having the TYPE_CODE_ARRAY case in
is_dynamic_type_internal follow this same logic, but that breaks down
on the gdb.fortran/dynamic-ptype-whatis.exp test case. In particular
this code in fortran_undetermined::evaluate:
value *callee = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
if (noside == EVAL_AVOID_SIDE_EFFECTS
&& is_dynamic_type (value_type (callee)))
callee = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_NORMAL);
... relies on is_dynamic_type returning true for such an array.
I wasn't really sure of the best way to fix this, so in the meantime I
wrote this patch, which documents the oddity so that I might have a
chance of remembering this in the future.
Tom Tromey [Wed, 29 Sep 2021 16:14:52 +0000 (10:14 -0600)]
Avoid self-test failures on x86-linux
The disassembly tests in "maint selftest" will fail on x86-linux.
This happens because opcodes rejects an attempt to disassemble for an
arch with a 64-bit address size when bfd_vma is 32-bit.
This patch avoids this problem by avoiding the test in this case. I
chose to do it this way because this seems to be the only situation
where opcodes checks the size of bfd_vma.
For v2 of this patch, I've also updated memory_error_test to do the
same thing. This is needed due to the "improve error reporting from
the disassembler" patch.
Tom de Vries [Fri, 29 Oct 2021 12:11:08 +0000 (14:11 +0200)]
[gdb/build] Fix build with --disable-unit-tests
A build with --disable-unit-tests currently run into:
...
ld: maint.o: in function \
`maintenance_selftest_completer(cmd_list_element*, completion_tracker&,
char const*, char const*)':
src/gdb/maint.c:1183: undefined reference to \
`selftests::for_each_selftest(
gdb::function_view<
void (std::__cxx11::basic_string<char,std::char_traits<char>,
std::allocator<char> > const&)>)'
...
Fix this by guarding the call to selftests::for_each_selftest in
maintenance_selftest_completer with GDB_SELF_TEST, such that the "-verbose"
completion still works.
Rebuild on x86_64-linux and ran gdb.gdb/unittest.exp.
Enze Li [Fri, 22 Oct 2021 14:30:30 +0000 (14:30 +0000)]
Document "memory-tag-violations".
* gdb/doc/gdb.texinfo: (Data): Document '-memory-tag-violations'.
(Command Options): Update the example.
Tejas Belagod [Tue, 5 Oct 2021 08:43:12 +0000 (08:43 +0000)]
Support for a new pacbti unwind opcode.
This patch adds readelf support for decoding the exception table
opcode for restoring the RA_AUTH_CODE pseudo register defined by the
EHABI
(https://github.com/ARM-software/abi-aa/releases/download/2021Q1/ehabi32.pdf
Section 10.3).
* readelf.c (decode_arm_unwind_bytecode): Add support to decode
restoring RA_AUTH_CODE pseudo register.
Alan Modra [Fri, 29 Oct 2021 09:14:40 +0000 (19:44 +1030)]
Re: arm: add unwinder encoding support for PACBTI
Move the gas testsuite files to where they belong.
Alan Modra [Fri, 29 Oct 2021 04:39:52 +0000 (15:09 +1030)]
ELF core file size checks
Catch fuzzed segments where p_offset + p_filesz wraps, and limit error
output.
* elfcore.h (elf_core_file_p): Rewrite segment checks using
bfd_get_file_size. Set read_only on file size errors.
* elfcode.h (elf_swap_shdr_in): Don't repeat error message.
Alan Modra [Fri, 29 Oct 2021 02:43:17 +0000 (13:13 +1030)]
obcopy vs. files with silly section alignment
We already ignore stupid segment alignment when rewriting headers,
ignore section alignment too.
* elf.c (rewrite_elf_program_header): Ignore section alignment
power greater than 62.
GDB Administrator [Fri, 29 Oct 2021 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Stafford Horne [Thu, 28 Oct 2021 20:52:28 +0000 (05:52 +0900)]
gdb: Add OpenRISC gdbserver and native config news
The previous patches added gdbserver and native debugging support
for OpenRISC targets. This patch documents that in the news.
Stafford Horne [Fri, 23 Oct 2020 04:39:53 +0000 (13:39 +0900)]
gdb: or1k: add single step for linux native debugging
Needed for single stepping in Linux, this adds the or1k implementation
of or1k_software_single_step. Most of the implementation is borrowed
from the bare metal single step code from or1k_single_step_through_delay
which has been extracted and shared in helper function
or1k_delay_slot_p.
Stafford Horne [Thu, 8 Oct 2020 21:26:30 +0000 (06:26 +0900)]
gdb: or1k: add native linux support
This patch adds support for running gdb natively on OpenRISC linux.
Debugging support is provided via the linux PTRACE interface which is
mostly handled by GDB genric code. This patch provides the logic of how
to read and write the ptrace registers between linux and GDB.
Single stepping is privided in a separate patch.
Stafford Horne [Thu, 8 Oct 2020 21:25:39 +0000 (06:25 +0900)]
gdb: or1k: add generated linux descriptor file
Stafford Horne [Thu, 8 Oct 2020 21:24:50 +0000 (06:24 +0900)]
gdb: or1k: fixup linux regcache comment
The old comment was not properly updated from the RISC-V example used.
Update it to match OpenRISC.
Stafford Horne [Sat, 15 Aug 2020 21:04:05 +0000 (06:04 +0900)]
gdb: or1k: implement gdb server
This patch adds gdbserver support for OpenRISC. This has been used for
debugging the glibc port that in being worked on here:
https://github.com/openrisc/or1k-glibc/tree/or1k-port-2
Hence the comment about registers definitions being inline with glibc.
Christian Biesinger [Thu, 28 Oct 2021 19:09:00 +0000 (15:09 -0400)]
[sim] Include defs.h in ppc/hw_memory.c
To fix this error (seen on cygwin):
/../../sim/ppc/../common ../../../sim/ppc/hw_memory.c
In file included from ../../gnulib/import/stdlib.h:100,
from ../../../sim/ppc/hw_memory.c:28:
../../gnulib/import/unistd.h:663:3: error: #error "Please include config.h first."
663 | #error "Please include config.h first."
| ^~~~~
../../gnulib/import/unistd.h:665:24: error: expected ';' before 'extern'
665 | _GL_INLINE_HEADER_BEGIN
| ^
| ;
../../gnulib/import/unistd.h:2806:22: error: expected ';' before 'extern'
2806 | _GL_INLINE_HEADER_END
| ^
| ;
Markus Klein [Thu, 28 Oct 2021 16:17:25 +0000 (17:17 +0100)]
ARM assembler: Allow up to 32 single precision registers in the VPUSH and VPOP instructions.
PR 28436
* config/tc-arm.c (do_vfp_nsyn_push_pop_check): New function.
(do_vfp_nsyn_pop): Use the new function.
(do_vfp_nsyn_push): Use the new function.
* testsuite/gas/arm/v8_1m-mve.s: Add new instructions.
* testsuite/gas/arm/v8_1m-mve.d: Updated expected disassembly.
Simon Marchi [Thu, 28 Oct 2021 15:25:45 +0000 (11:25 -0400)]
gdb: use ptid_t::to_string in infrun debug messages
In debug messages, I think it would be more helpful to print ptid using
the simple "pid.lwp.tid" notation in infrun debug messages. I am
currently debugging some fork issues, and find the pid_to_str output not
so useful, as it doesn't tell which process a thread belongs to.
It currently shows up like this:
[infrun] resume_1: step=1, signal=GDB_SIGNAL_0, trap_expected=0, current thread [Thread 0x7ffff7d95740 (LWP 892942)] at 0x55555555521f
With the patch, it shows up like this:
[infrun] resume_1: step=1, signal=GDB_SIGNAL_0, trap_expected=1, current thread [894072.894077.0] at 0x5555555551d9
Change-Id: I130796d7dfb0d8e763b8358d8a6002701d80c4ea
Simon Marchi [Thu, 23 Sep 2021 13:56:51 +0000 (09:56 -0400)]
gdb: add selftest name completion
After the previous commit, it is easy to add completion for selftest
names. Again, this is not particularly high value, but I rarely touched
completion, so it served as a simple example to get some practice.
Change the for_each_selftest_ftype parameter to gdb::function_view, so
that we can pass a lambda that captures things.
Change-Id: I87cac299ddca9ca7eb0ffab78342e850a98d954c
Tejas Belagod [Thu, 28 Oct 2021 14:44:42 +0000 (15:44 +0100)]
arm: add unwinder encoding support for PACBTI
This patch adds support for encoding the Return Address Authentication pseudo
register - '.save {ra_auth_code}' as defined by the DWARF ABI - in the
exception tables where the opcode is defined by the EHABI
gas/Changelog:
* config/tc-arm.c (arm_reg_type): Add new type REG_TYPE_PSEUDO.
(reg_expected_msgs): Add message for pseudo reg type.
(reg_list_els): Add new reg list type REGLIST_PSEUDO.
(parse_reg_list): Handle new REGLIST_PSEUDO type.
(s_arm_unwind_save_pseudo): Encode pseudo reg list save in exception
tables.
(s_arm_unwind_save): Handle new REG_TYPE_PSEUDO.
(reg_names): Add ra_auth_code pseudo register.
* testsuite/gas/arm/unwind-pacbti-m.s: New test.
* testsuite/gas/arm/unwind-pacbti-m.d: New test.
* testsuite/gas/arm/unwind-pacbti-m-readelf.d: New test.
Simon Marchi [Wed, 22 Sep 2021 14:38:16 +0000 (10:38 -0400)]
gdb: add "maint set/show selftest verbose" commands and use process_options
I saw the new -verbose switch to "maint selftests" and thought it would
be nice for it to use the option framework. For example, that makes
having completion easy. It's not that high value, given this is a
maintenance command, but I had never used the framework myself, so it
was a good way to practice.
This patch also adds the "maint set/show selftest verbose" setting. It
would be possible to use option framework without adding the setting,
but using the framework makes adding the option almost trivial, so I
thought why not.
Change-Id: I6687faa0713ff3da60b398253211777100094144
Tom de Vries [Thu, 28 Oct 2021 14:47:07 +0000 (16:47 +0200)]
[gdb/testsuite] Update some test-cases to GPLv3
I noticed some files in the test-suite have GPLv2 notices.
Update these to GPLv3.
Simon Marchi [Wed, 22 Sep 2021 17:43:25 +0000 (13:43 -0400)]
gdb: add add_setshow_prefix_cmd
There's a common pattern to call add_basic_prefix_cmd and
add_show_prefix_cmd to add matching set and show commands. Add the
add_setshow_prefix_cmd function to factor that out and use it at a few
places.
Change-Id: I6e9e90a30e9efb7b255bf839cac27b85d7069cfd
Tom de Vries [Thu, 28 Oct 2021 12:18:15 +0000 (14:18 +0200)]
[gdb/testsuite] Require python in gdb.server/server-kill-python.exp
I came across this when running test-case gdb.server/server-kill-python.exp
with a gdb configured without python:
...
builtin_spawn gdb -nw -nx -data-directory data-directory -iex set height 0 \
-iex set width 0 -quiet -iex set height 0 -iex set width 0 \
-ex source outputs/gdb.server/server-kill-python/file1.py^M
FAIL: gdb.server/server-kill-python.exp: ensure inferior is running
Executing on target: kill -9 28535 (timeout = 300)
builtin_spawn -ignore SIGHUP kill -9 28535^M
file1.py:1: Error in sourced command file:^M
Undefined command: "import". Try "help".^M
...
Fix this by testing for python support in the test-case.
Tested on aarch64-linux (with python support disabled) and x86_64-linux (with
python support enabled).
Tom de Vries [Thu, 28 Oct 2021 12:18:15 +0000 (14:18 +0200)]
[gdb/testsuite] Fix assembly comments in gdb.dwarf2/clang-debug-names.exp.tcl
On openSUSE Leap 15.2 aarch64 I ran into:
...
clang-debug-names-debug.S:72: \
Error: junk at end of line, first unrecognized character is `#'
...
due to:
...
71 .Ldebug_names_start:
72 .short 5 # Header: version
...
Fix this by using the /* ... */ comment style instead:
...
$ sed -i 's% #\([^"]*\)%/*\1 */%' clang-debug-names.exp.tcl
...
Tested on aarch64-linux and x86_64-linux.
Tom de Vries [Thu, 28 Oct 2021 08:43:34 +0000 (10:43 +0200)]
[gdb/symtab] Handle DW_AT_string_length with location list
Consider a fortran routine where a string variable s is modified:
...
subroutine f(s)
character*(*) s
print *, s
s(1:3) = 'oof'
print *, s
end subroutine f
...
When compiling with optimization level -O1 and printing the type of
variable s we get:
...
$ gdb -q -batch outputs/gdb.opt/fortran-string/fortran-string \
-ex "b f" \
-ex run \
-ex "ptype s"
Breakpoint 1 at 0x4006f7: file fortran-string.f90, line 21.
Breakpoint 1, f (s=..., _s=_s@entry=3) at fortran-string.f90:21
21 subroutine f(s)
type = character*1
...
while with -O0 we have instead:
...
type = character (3)
...
The problem is that the type of s is:
...
<1><2d6>: Abbrev Number: 21 (DW_TAG_string_type)
<2d7> DW_AT_string_length: 0xbf (location list)
<2db> DW_AT_byte_size : 4
...
where the DW_AT_string_length is a location list, a case that is not handled
by attr_to_dynamic_prop.
Fix this by handling attr->form_is_section_offset () in attr_to_dynamic_prop.
Tested on x86_64-linux.
The test-case is based on gdb.opt/fortran-string.exp from
https://src.fedoraproject.org/rpms/gdb/raw/f32/f/gdb-archer-vla-tests.patch .
I've updated the copyrights to stretch to 2021.
[ I've tried to create a dwarf assembly test-case for this, but didn't
manage. ]
Co-Authored-By: Jan Kratochvil <jan.kratochvil@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26910
Kavitha Natarajan [Thu, 28 Oct 2021 05:21:32 +0000 (10:51 +0530)]
[gdb/testsuite] Initialize anonymous union in gdb.cp/koenig.cc
GDB test fails while running the test case gdb.cp/koenig.exp using
clang compiler:
[...]
p foo (p_union)
No symbol "p_union" in current context.
(gdb) FAIL: gdb.cp/koenig.exp: p foo (p_union)
[...]
In the testcase, "p_union" is an unused/uninitialized variable of
anonymous union type. Clang does not emit symbol for unused anonymous
union/struct variables at any optimization level. Since the compiler
itself is not emitting the symbol for "p_union", debug info is also
not emitted when built with debug option. If the anonymous union is
initialized (or used), then clang emits the symbol "p_union" which
enables emitting debug info for "p_union".
[...]
p foo (p_union)
Cannot resolve function foo to any overloaded instance
(gdb) PASS: gdb.cp/koenig.exp: p foo (p_union)
[...]
Alan Modra [Thu, 28 Oct 2021 02:46:04 +0000 (13:16 +1030)]
asan: mmo: NULL dereferenc in mmo_xore_32
mmo_get_loc can return NULL. It's commented even, and that the caller
then must handle a split field. mmo_xore_* don't handle split fields,
instead just segfault. Stop that happening, and refuse to recognise
fuzzed mmo files that trigger this problem.
* mmo.c (mmo_get_loc): Don't declare inline.
(mmo_xore_64, mmo_xore_32, mmo_xore_16): Remove forward decls.
Return pointer, don't dereference NULL.
(mmo_scan): Return error on mmo_get_loc returning NULL.
Alan Modra [Thu, 28 Oct 2021 02:17:26 +0000 (12:47 +1030)]
bfd: remove use of INLINE
No need to use anything fancy, plain inline works just as well.
* bfd-in.h (INLINE): Don't define.
* bfd-in2.h: Regenerate.
* aoutx.h: Replace use of INLINE with inline.
* elf-eh-frame.c: Likewise.
* elf32-score7.c: Likewise.
* elfxx-mips.c: Likewise.
* ihex.c: Likewise.
* mach-o.c: Likewise.
* mmo.c: Likewise.
Alan Modra [Wed, 27 Oct 2021 22:33:00 +0000 (09:03 +1030)]
ASSERT in empty output section with address
* ldlang.c (lang_do_assignments_1): Correct "dot" inside ignored
sections.
* testsuite/ld-scripts/empty-address-4.d,
* testsuite/ld-scripts/empty-address-4.s,
* testsuite/ld-scripts/empty-address-4.t: New test.
* testsuite/ld-scripts/empty-address.exp: Run it.
GDB Administrator [Thu, 28 Oct 2021 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Wed, 27 Oct 2021 04:55:34 +0000 (15:25 +1030)]
asan: alpha-vms: buffer overflows
Yet more anti-fuzzer sanity checking
* vms-alpha.c (evax_bfd_print_egsd): Sanity check record and
name lengths before access.
(evax_bfd_print_etir_stc_ir, evax_bfd_print_etir): Likewise.
Alan Modra [Tue, 26 Oct 2021 09:09:12 +0000 (19:39 +1030)]
ubsan: arm: undefined shift
left shift of 2 by 31 places cannot be represented in type 'int'
* arm-dis.c (print_insn_thumb16): Avoid undefined behaviour.
Tom Tromey [Mon, 4 Oct 2021 18:38:23 +0000 (14:38 -0400)]
Fix watchpoints with multiple threads on Windows
A recent internal change pointed out that watchpoints were not working
on Windows when the inferior was multi-threaded. This happened
because the debug registers were only updated for certain threads --
in particular, those that were being resumed and that were not marked
as suspended. In the case of single-stepping, the need to update the
debug registers in other threads could also be "forgotten".
This patch changes windows-nat.c to mark all threads needing a debug
register update. This brings the code closer to what gdbserver does
(though, unfortunately, it still seems more complicated than needed).
Tom de Vries [Wed, 27 Oct 2021 16:57:15 +0000 (18:57 +0200)]
[gdb/testsuite] Fix port detection in gdb.debuginfod/fetch_src_and_symbols.exp
On OBS I ran into this failure with test-case
gdb.debuginfod/fetch_src_and_symbols.exp:
...
Failed to listen for connections: Address already in use^M
[Thu Oct 21 11:48:49 2021] (559/559): started http server on IPv6 port=8000^M
...
FAIL: gdb.debuginfod/fetch_src_and_symbols.exp: local_url: find port timeout
...
The test-case is trying to start debuginfod on a port to see if it's
available, and it handles either this message:
"started http server on IPv4 IPv6 port=$port"
meaning success, or:
"failed to bind to port"
meaning failure, in which case the debuginfod instance is killed, and we try
the next port.
The test-case only uses the v4 address 127.0.0.1, so fix this by:
- accepting "started http server on IPv4 port=$port"
- rejecting "started http server on IPv6 port=$port"
Tested on x86_64-linux.
Simon Marchi [Wed, 27 Oct 2021 13:38:51 +0000 (09:38 -0400)]
gdb: fix value.c build on 32-bits
When building on ARM (32-bits), we errors like this:
/home/smarchi/src/binutils-gdb/gdb/value.c: In function 'gdb::array_view<const unsigned char> value_contents_for_printing(value*)':
/home/smarchi/src/binutils-gdb/gdb/value.c:1252:35: error: narrowing conversion of 'length' from 'ULONGEST' {aka 'long long unsigned int'} to 'size_t' {aka 'unsigned int'} [-Werror=narrowing]
1252 | return {value->contents.get (), length};
| ^~~~~~
Fix that by using gdb::make_array_view, which does the appropriate
conversion.
Change-Id: I7d6f2e75d7440d248b8fb18f8272ee92954b404d
Nelson Chu [Wed, 27 Oct 2021 10:54:41 +0000 (18:54 +0800)]
RISC-V: Tidy riscv assembler and disassembler.
Tidy the gas/config/tc-riscv.c and opcodes/riscv-dis.c, to prepare for
moving the released extensions (including released vendor extensions)
from integration branch back to mainline.
* Added parts of missing comments.
* Updated md_show_usage.
* For validate_riscv_insn, riscv_ip and print_insn_args, unify the
following pointer names,
- oparg: pointed to the parsed operand defined in the riscv_opcodes.
- asarg: pointed to the parsed operand from assembly.
- opargStart: recorded the parsed operand name from riscv_opcodes.
- asargStart: recorded the parsed operand name from assembly.
gas/
* config/tc-riscv.c: Added parts of missind comments and updated
the md_show_usage.
(riscv_multi_subset_supports): Tidy codes.
(validate_riscv_insn): Unify the pointer names, oparg, asarg,
opargStart and asargStart, to prepare for moving the released
extensions from integration branch back to mainline.
(riscv_ip): Likewise.
(macro_build): Added fmtStart, also used to prepare for moving
released extensions.
(md_show_usage): Added missing descriptions for new options.
opcodes/
* riscv-dis.c (print_insn_args): Unify the pointer names,
oparg and opargStart, to prepare for moving the released
extensions from integration branch back to mainline.
Maciej W. Rozycki [Wed, 27 Oct 2021 11:21:14 +0000 (12:21 +0100)]
opcodes: Fix RPATH not being set for dynamic libbfd dependency
If built as a shared library, libopcodes has a load-time dependency on
libbfd, which is recorded in the dynamic section, however without a
corresponding RPATH entry for the directory to find libbfd in. This
causes loading to fail whenever libbfd is only pulled by libopcodes
indirectly and libbfd has been installed in a directory that is not in
the dynamic loader's search path.
It does not happen with the programs included with binutils or GDB,
because they all also pull libbfd when using libopcodes, but it can
happen with external software, e.g.:
$ gdbserver --help
gdbserver: error while loading shared libraries: libbfd-[...].so: cannot open shared object file: No such file or directory
$
(not our `gdbserver').
Indirect dynamic dependencies are handled by libtool automatically by
adding RPATH entries as required, however our setup for libopcodes
prevents this from happening by linking in libbfd with an explicit file
reference sneaked through to the linker directly behind libtool's back
via the `-Wl' linker command-line option rather than via `-l' combined
with a suitable library search path specified via `-L', as it would be
usually the case, or just referring to the relevant .la file in a fully
libtool-enabled configuration such as ours.
According to an observation in the discussion back in 2007[1][2][3] that
has led to the current arrangement it is to prevent libtool from picking
up the wrong version of libbfd. It does not appear to be needed though,
not at least with our current libtool incarnation, as directly referring
`libbfd.la' does exactly what it should, as previously suggested[4], and
with no link-time reference to the installation directory other than to
set RPATH. Uninstalled version of libopcodes has libbfd's build-time
location prepended to RPATH too, as also expected.
Use a direct reference to `libbfd.la' then, making the load error quoted
above go away. Alternatively `-L' and `-l' could be used to the same
effect, but it seems an unnecessary complication and just another way to
circumvent rather than making use of libtool.
References:
[1] "compile failure due to undefined symbol",
<https://sourceware.org/ml/binutils/2007-08/msg00476.html>
[2] same, <https://sourceware.org/ml/binutils/2007-09/msg00000.html>
[3] same, <https://sourceware.org/ml/binutils/2007-10/msg00019.html>
[4] same, <https://sourceware.org/ml/binutils/2007-10/msg00034.html>
opcodes/
* Makefile.am: Remove obsolete comment.
* configure.ac: Refer `libbfd.la' to link shared BFD library
except for Cygwin.
* Makefile.in: Regenerate.
* configure: Regenerate.
GDB Administrator [Wed, 27 Oct 2021 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Mon, 25 Oct 2021 15:42:24 +0000 (08:42 -0700)]
gold: Place .note.gnu.property section before other note sections
Place the .note.gnu.property section before all other note sections to
avoid being placed between other note sections with different alignments.
PR gold/28494
* layout.cc (Layout::create_note): Set order to ORDER_PROPERTY_NOTE
for the .note.gnu.property section.
* layout.h (Output_section_order): Add ORDER_PROPERTY_NOTE.
Tom de Vries [Tue, 26 Oct 2021 08:45:08 +0000 (10:45 +0200)]
[gdb/doc] Fix print inferior-events default
In the docs about print inferior-events we read:
...
By default, these messages will not be printed.
...
That used to be the case, but is no longer so since commit
f67c0c91715 "Enable
'set print inferior-events' and improve detach/fork/kill/exit messages".
Fix this by updating the docs.
GDB Administrator [Tue, 26 Oct 2021 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Tue, 5 Oct 2021 00:47:06 +0000 (20:47 -0400)]
gdb: change functions returning value contents to use gdb::array_view
The bug fixed by this [1] patch was caused by an out-of-bounds access to
a value's content. The code gets the value's content (just a pointer)
and then indexes it with a non-sensical index.
This made me think of changing functions that return value contents to
return array_views instead of a plain pointer. This has the advantage
that when GDB is built with _GLIBCXX_DEBUG, accesses to the array_view
are checked, making bugs more apparent / easier to find.
This patch changes the return types of these functions, and updates
callers to call .data() on the result, meaning it's not changing
anything in practice. Additional work will be needed (which can be done
little by little) to make callers propagate the use of array_view and
reap the benefits.
[1] https://sourceware.org/pipermail/gdb-patches/2021-September/182306.html
Change-Id: I5151f888f169e1c36abe2cbc57620110673816f3
Simon Marchi [Tue, 19 Oct 2021 19:32:08 +0000 (15:32 -0400)]
gdbsupport: add assertions in array_view
Add assertions to ensure we don't access an array_view out of bounds.
Enable these assertions only when _GLIBCXX_DEBUG is set, as we did for
gdb::optional.
Change-Id: Iffaee38252405073735ed123c8e57fde6b2c6be3
Simon Marchi [Mon, 25 Oct 2021 18:33:55 +0000 (14:33 -0400)]
gdbserver: make target_pid_to_str return std::string
I wanted to write a warning that included two target_pid_to_str calls,
like this:
warning (_("Blabla %s, blabla %s"),
target_pid_to_str (ptid1),
target_pid_to_str (ptid2));
This doesn't work, because target_pid_to_str stores its result in a
static buffer, so my message would show twice the same ptid. Change
target_pid_to_str to return an std::string to avoid this. I don't think
we save much by using a static buffer, but it is more error-prone.
Change-Id: Ie3f649627686b84930529cc5c7c691ccf5d36dc2
H.J. Lu [Sat, 23 Oct 2021 14:37:33 +0000 (07:37 -0700)]
x86: Also handle stores for -muse-unaligned-vector-move
* config/tc-i386.c (encode_with_unaligned_vector_move): Also
handle stores.
* testsuite/gas/i386/unaligned-vector-move.s: Add stores.
* testsuite/gas/i386/unaligned-vector-move.d: Updated.
* testsuite/gas/i386/x86-64-unaligned-vector-move.d: Likewise.
Tom de Vries [Mon, 25 Oct 2021 16:15:15 +0000 (18:15 +0200)]
[gdb/testsuite] Fix duplicate in gdb.mi/mi-var-cp.exp
With test-case gdb.mi/mi-var-cp.exp I run into this duplicate:
...
PASS: gdb.mi/mi-var-cp.exp: run to mi-var-cp.cc:104 (set breakpoint)
PASS: gdb.mi/mi-var-cp.exp: create varobj for s
PASS: gdb.mi/mi-var-cp.exp: create varobj for s
DUPLICATE: gdb.mi/mi-var-cp.exp: create varobj for s
...
This is due to a duplicate test name here:
...
$ cat -n gdb/testsuite/gdb.mi/mi-var-cp.cc
...
100 int reference_to_struct ()
101 {
102 /*: BEGIN: reference_to_struct :*/
103 S s = {7, 8};
104 S& r = s;
105 /*:
106 mi_create_varobj S s "create varobj for s"
107 mi_create_varobj R r "create varobj for s"
...
Fix this by using "create varobj for r" instead.
Tested on x86_64-linux.
Nick Alcock [Mon, 25 Oct 2021 10:17:02 +0000 (11:17 +0100)]
libctf, ld: handle nonrepresentable types better
ctf_type_visit (used, among other things, by the type dumping code) was
aborting when it saw a nonrepresentable type anywhere: even a single
structure member with a nonrepresentable type caused an abort with
ECTF_NONREPRESENTABLE. This is not useful behaviour, given that the
abort comes from a type-resolution we are only doing in order to
determine whether the type is a structure or union. We know
nonrepresentable types can't be either, so handle that case and
pass the nonrepresentable type down.
(The added test verifies that the dumper now handles this case and
prints nonrepresentable structure members as it already does
nonrepresentable top-level types, rather than skipping the whole
structure -- or, without the previous commit, skipping the whole types
section.)
ld/ChangeLog
2021-10-25 Nick Alcock <nick.alcock@oracle.com>
* testsuite/ld-ctf/nonrepresentable-member.*: New test.
libctf/ChangeLog
2021-10-25 Nick Alcock <nick.alcock@oracle.com>
* ctf-types.c (ctf_type_rvisit): Handle nonrepresentable types.
Nick Alcock [Mon, 25 Oct 2021 10:17:02 +0000 (11:17 +0100)]
libctf: dump: do not stop dumping types on error
If dumping of a single type fails, we obviously can't dump it; but just
as obviously this doesn't make the other types in the types section
invalid or undumpable. So we should not propagate errors seen when
type-dumping, but rather ignore them and carry on, so we dump as many
types as we can (leaving out the ones we can't grok).
libctf/ChangeLog
2021-10-25 Nick Alcock <nick.alcock@oracle.com>
* ctf-dump.c (ctf_dump_type): Do not abort on error.
Nick Alcock [Mon, 25 Oct 2021 10:17:02 +0000 (11:17 +0100)]
binutils, ld: make objdump --ctf's parameter optional
ld by default (and always, unless adjusted with a hand-rolled linker
script) emits deduplicated CTF into the .ctf section. But viewing
it needs you to explicitly tell objdump this: it doesn't default
its argument, even though what you always end up typing is
--ctf=.ctf.
This is annoying, so make the argument optional.
binutils/ChangeLog
2021-10-25 Nick Alcock <nick.alcock@oracle.com>
* objdump.c (usage): --ctf now has an optional argument.
(main): Adjust accordingly.
(dump_ctf): Default it.
* doc/ctf.options.texi: Adjust.
ld/ChangeLog
2021-10-25 Nick Alcock <nick.alcock@oracle.com>
* testsuite/ld-ctf/array.d: Change --ctf=.ctf to --ctf.
* testsuite/ld-ctf/conflicting-cycle-1.B-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-1.B-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-1.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.A-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.A-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.C-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.C-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-enums.d: Likewise.
* testsuite/ld-ctf/conflicting-typedefs.d: Likewise.
* testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Likewise.
* testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d: Likewise.
* testsuite/ld-ctf/cross-tu-into-cycle.d: Likewise.
* testsuite/ld-ctf/cross-tu-noncyclic.d: Likewise.
* testsuite/ld-ctf/cycle-1.d: Likewise.
* testsuite/ld-ctf/cycle-2.A.d: Likewise.
* testsuite/ld-ctf/cycle-2.B.d: Likewise.
* testsuite/ld-ctf/cycle-2.C.d: Likewise.
* testsuite/ld-ctf/data-func-conflicted.d: Likewise.
* testsuite/ld-ctf/diag-cttname-null.d: Likewise.
* testsuite/ld-ctf/diag-cuname.d: Likewise.
* testsuite/ld-ctf/diag-parlabel.d: Likewise.
* testsuite/ld-ctf/enum-forward.d: Likewise.
* testsuite/ld-ctf/enums.d: Likewise.
* testsuite/ld-ctf/forward.d: Likewise.
* testsuite/ld-ctf/function.d: Likewise.
* testsuite/ld-ctf/nonrepresentable.d: Likewise.
* testsuite/ld-ctf/slice.d: Likewise.
* testsuite/ld-ctf/super-sub-cycles.d: Likewise.
Nick Alcock [Mon, 25 Oct 2021 10:17:02 +0000 (11:17 +0100)]
binutils: make objdump/readelf --ctf-parent actually useful
This option has been present since the very early days of the
development of libctf as part of binutils, and it shows. Back in the
earliest days, I thought we might handle ambiguous types by introducing
new ELF sections on the fly named things like .ctf.foo.c for ambiguous
types found only in foo.c, etc. This turned out to be a terrible idea,
so we moved to using a CTF archive in the .ctf section which contained
all the CTF dictionaries -- but the --ctf-parent option in objdump and
readelf was never adjusted, and lingered as a mechanism to specify CTF
parent dictionaries in sections other than .ctf, even though the linker
has no way to produce parent dictionaries in different sections from
their children, libctf's ctf_open can't handle such split-up
parent/child dicts, and they are never found in the wild, emitted by GNU
ld or by any known third-party linking tool.
Meanwhile, the actually-useful ctf_link feature (albeit not used by ld)
which lets you remap the names of CTF archive members (so you can end up
with a parent archive member named something other than ".ctf", still
contained with all its children in a single .ctf section) had no support
in objdump or readelf: there was no way to tell them that these members
were parents, so all the types in the associated child dicts always
appeared corrupted, referencing nonexistent types from a parent objdump
couldn't find.
So adjust --ctf-parent so that rather than taking a section name it
takes a member name instead (if not specified, the name is ".ctf", which
is what GNU ld emits). Because the option was always useless before
now, this is expected to have no backward-compatibility implications.
As part of this, we have to slightly adjust the code which skips the
archive member name if redundant: right now it skips it if it's ".ctf",
on the assumption that this name will almost always be at the start
of the objdump output and thus we'll end up with a shared dump
and then smaller, headed dumps for the per-TU child dicts; but if
the parent name has been changed, that won't be true any more.
So change the rules to "members named .ctf which appear first in the
first have their member name skipped". Since we now need to count
members, move from ctf_archive_iter (for which passing in extra
parameters requires defining a new struct and is clumsy) to
ctf_archive_next, allowing us to just *call* dump_ctf_archive_member and
maintain a member count in the obvious way. In the process we fix a
tiny difference between readelf and objdump: if a ctf_dump ever failed,
readelf skipped every later member, while objdump tried to keep going as
much as it could. For a dumping tool the former is clearly preferable.
binutils/ChangeLog
2021-10-25 Nick Alcock <nick.alcock@oracle.com>
* objdump.c (usage): --ctf-parent now takes a name, not a section.
(dump_ctf): Don't open a separate section; use the parent_name in
ctf_dict_open instead. Use ctf_archive_next, not ctf_archive_iter,
so we can pass down a member count.
(dump_ctf_archive_member): Add the member count; don't return
anything. Import parents into children no matter what the
parent's name, while still avoiding displaying the header for the
common parent name of ".ctf".
* readelf.c (usage): Adjust similarly.
(dump_section_as_ctf): Likewise.
(dump_ctf_archive_member): Likewise. Never stop iterating over
archive members, even if ctf_dump of one member fails.
* doc/ctf.options.texi: Adjust.
Alan Modra [Mon, 25 Oct 2021 05:41:42 +0000 (16:11 +1030)]
objdump doesn't accept -L option
A followup to commit
ca0e11aa4b.
* objdump.c (main): Add 'L' to short options and sort them.
Alan Modra [Mon, 25 Oct 2021 05:12:40 +0000 (15:42 +1030)]
bfd_nonfatal_message, localise va_start
Nothing to see here, just a little tidier.
* bucomm.c (bfd_nonfatal_message): Localise va_list args.
Alan Modra [Mon, 25 Oct 2021 01:09:39 +0000 (11:39 +1030)]
ubsan: _bfd_xcoff64_swap_aux_in left shift of negative value
* coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Use bfd_vma for h.
Alan Modra [Sun, 24 Oct 2021 23:45:59 +0000 (10:15 +1030)]
asan: evax_bfd_print_image buffer overflow
* vms-alpha.c (evax_bfd_print_image): Sanity check printing of
"image activator fixup" section.
(evax_bfd_print_relocation_records): Sanity check buffer offsets.
(evax_bfd_print_address_fixups): Likewise.
(evax_bfd_print_reference_fixups): Likewise.
GDB Administrator [Mon, 25 Oct 2021 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Sun, 24 Oct 2021 09:57:06 +0000 (20:27 +1030)]
asan: c4x, c54x coff_canonicalize_reloc buffer overflow
Sometimes the investigation of a fuzzing bug report leads into areas
you'd rather not go. In this instance by the time I'd figured out the
real cause was a target variant that had never been properly supported
in binutils, the time needed to fix it was less than the time needed
to rip it out.
* coffcode.h (coff_set_alignment_hook): Call bfd_coff_swap_reloc_in
not coff_swap_reloc_in.
(coff_slurp_reloc_table): Likewise. Don't use RELOC type.
(ticoff0_swap_table): Use coff_swap_reloc_v0_out and
coff_swap_reloc_v0_in.
* coffswap.h (coff_swap_reloc_v0_in, coff_swap_reloc_v0_out): New.
* coff-tic54x.c (tic54x_lookup_howto): Don't abort.
* coffgen.c (coff_get_normalized_symtab): Use PTR_ADD.
* bfd-in.h (PTR_ADD, NPTR_ADD): Avoid warnings when passing an
expression.
* bfd-in2.h: Regenerate.
Alan Modra [Sun, 24 Oct 2021 08:06:03 +0000 (18:36 +1030)]
asan: arm-darwin: buffer overflow
PR 21813
* mach-o-arm.c (bfd_mach_o_arm_canonicalize_one_reloc): Sanity
check PAIR reloc in other branch of condition as was done for
PR21813. Formatting. Delete debug printf.
Alan Modra [Sat, 23 Oct 2021 00:57:14 +0000 (11:27 +1030)]
asan: aout: heap buffer overflow
* aoutx.h (aout_get_external_symbols): Sanity check before writing
zero index entry. Remove outdated comment.
* pdp11.c (aout_get_external_symbols): Likewise.
liuzhensong [Fri, 22 Oct 2021 08:42:07 +0000 (16:42 +0800)]
LoongArch ld support
2021-10-22 Chenghua Xu <xuchenghua@loongson.cn>
Zhensong Liu <liuzhensong@loongson.cn>
Weinan Liu <liuweinan@loongson.cn>
Xiaolin Tang <tangxiaolin@loongson.cn>
ld/
* Makefile.am: Add LoongArch.
* NEWS: Mention LoongArch support.
* configure.tgt: Add LoongArch.
* emulparams/elf32loongarch-defs.sh: New.
* emulparams/elf32loongarch.sh: Likewise.
* emulparams/elf64loongarch-defs.sh: Likewise.
* emulparams/elf64loongarch.sh: Likewise.
* emultempl/loongarchelf.em: Likewise.
* Makefile.in: Regenerate.
* po/BLD-POTFILES.in: Regenerate.
ld/testsuite/
* ld-loongarch-elf/disas-jirl.d: New.
* ld-loongarch-elf/disas-jirl.s: Likewise.
* ld-loongarch-elf/jmp_op.d: Likewise.
* ld-loongarch-elf/jmp_op.s: Likewise.
* ld-loongarch-elf/ld-loongarch-elf.exp: Likewise.
* ld-loongarch-elf/macro_op.d: Likewise.
* ld-loongarch-elf/macro_op.s: Likewise.
* ld-loongarch-elf/syscall-0.s: Likewise.
* ld-loongarch-elf/syscall-1.s: Likewise.
* ld-loongarch-elf/syscall.d: Likewise.
* ld-srec/srec.exp: Add LoongArch.
* ld-unique/pr21529.d: Likewise.
liuzhensong [Fri, 22 Oct 2021 08:42:06 +0000 (16:42 +0800)]
LoongArch gas support
2021-10-22 Chenghua Xu <xuchenghua@loongson.cn>
Zhensong Liu <liuzhensong@loongson.cn>
Weinan Liu <liuweinan@loongson.cn>
Xiaolin Tang <tangxiaolin@loongson.cn>
gas/
* Makefile.am: Add LoongArch.
* NEWS: Mention LoongArch support.
* config/loongarch-lex-wrapper.c: New.
* config/loongarch-lex.h: New.
* config/loongarch-lex.l: New.
* config/loongarch-parse.y: New.
* config/tc-loongarch.c: New.
* config/tc-loongarch.h: New.
* configure.ac: Add LoongArch.
* configure.tgt: Likewise.
* doc/as.texi: Likewise.
* doc/c-loongarch.texi: Likewise.
* Makefile.in: Regenerate.
* configure: Regenerate.
* po/POTFILES.in: Regenerate.
gas/testsuite/
* gas/all/gas.exp: Add LoongArch.
* gas/elf/elf.exp: Likewise.
* gas/loongarch/4opt_op.d: New.
* gas/loongarch/4opt_op.s: Likewise.
* gas/loongarch/fix_op.d: Likewise.
* gas/loongarch/fix_op.s: Likewise.
* gas/loongarch/float_op.d: Likewise.
* gas/loongarch/float_op.s: Likewise.
* gas/loongarch/imm_op.d: Likewise.
* gas/loongarch/imm_op.s: Likewise.
* gas/loongarch/jmp_op.d: Likewise.
* gas/loongarch/jmp_op.s: Likewise.
* gas/loongarch/load_store_op.d: Likewise.
* gas/loongarch/load_store_op.s: Likewise.
* gas/loongarch/loongarch.exp: Likewise.
* gas/loongarch/macro_op.d: Likewise.
* gas/loongarch/macro_op.s: Likewise.
* gas/loongarch/nop.d: Likewise.
* gas/loongarch/nop.s: Likewise.
* gas/loongarch/privilege_op.d: Likewise.
* gas/loongarch/privilege_op.s: Likewise.
* gas/loongarch/syscall.d: Likewise.
* gas/loongarch/syscall.s: Likewise.
* lib/gas-defs.exp: Add LoongArch.
liuzhensong [Fri, 22 Oct 2021 08:42:05 +0000 (16:42 +0800)]
LoongArch binutils support
2021-10-22 Chenghua Xu <xuchenghua@loongson.cn>
Zhensong Liu <liuzhensong@loongson.cn>
Weinan Liu <liuweinan@loongson.cn>
binutils/
* NEWS: Mention LoongArch support.
* readelf.c: Add LoongArch.
* testsuite/binutils-all/objdump.exp: Add LoongArch.
liuzhensong [Fri, 22 Oct 2021 08:42:04 +0000 (16:42 +0800)]
LoongArch opcodes support
2021-10-22 Chenghua Xu <xuchenghua@loongson.cn>
Zhensong Liu <liuzhensong@loongson.cn>
Weinan Liu <liuweinan@loongson.cn>
include/
* opcode/loongarch.h: New.
* dis-asm.h: Declare print_loongarch_disassembler_options.
opcodes/
* Makefile.am: Add LoongArch.
* configure.ac: Likewise.
* disassemble.c: Likewise.
* disassemble.h: Declare print_insn_loongarch.
* loongarch-coder.c: New.
* loongarch-dis.c: New.
* loongarch-opc.c: New.
* Makefile.in: Regenerate.
* configure: Regenerate.
* po/POTFILES.in: Regenerate.
liuzhensong [Fri, 22 Oct 2021 08:42:03 +0000 (16:42 +0800)]
LoongArch bfd support
2021-10-22 Chenghua Xu <xuchenghua@loongson.cn>
Zhensong Liu <liuzhensong@loongson.cn>
Weinan Liu <liuweinan@loongson.cn>
bfd/
* Makefile.am: Add LoongArch.
* archures.c: Likewise.
* config.bfd: Likewise.
* configure.ac: Likewise.
* cpu-loongarch.c: New.
* elf-bfd.h: Add LoongArch.
* elf.c: Add LoongArch elfcore_grok_xxx.
* elfnn-loongarch.c: New.
* elfxx-loongarch.c: New.
* elfxx-loongarch.h: New.
* reloc.c: Add LoongArch BFD RELOC ENUM.
* targets.c: Add LoongArch target.
* Makefile.in: Regenerate.
* bfd-in2.h: Regenerate.
* configure: Regenerate.
* libbfd.h: Regenerate.
* po/BLD-POTFILES.in: Regenerate.
* po/SRC-POTFILES.in: Regenerate.
include/
* elf/common.h: Add NT_LARCH_{CPUCFG,CSR,LSX,LASX}.
* elf/loongarch.h: New.
GDB Administrator [Sun, 24 Oct 2021 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sat, 23 Oct 2021 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Thu, 21 Oct 2021 13:15:31 +0000 (06:15 -0700)]
x86: Add -muse-unaligned-vector-move to assembler
Unaligned load/store instructions on aligned memory or register are as
fast as aligned load/store instructions on modern Intel processors. Add
a command-line option, -muse-unaligned-vector-move, to x86 assembler to
encode encode aligned vector load/store instructions as unaligned
vector load/store instructions.
* NEWS: Mention -muse-unaligned-vector-move.
* config/tc-i386.c (use_unaligned_vector_move): New.
(encode_with_unaligned_vector_move): Likewise.
(md_assemble): Call encode_with_unaligned_vector_move for
-muse-unaligned-vector-move.
(OPTION_MUSE_UNALIGNED_VECTOR_MOVE): New.
(md_longopts): Add -muse-unaligned-vector-move.
(md_parse_option): Handle -muse-unaligned-vector-move.
(md_show_usage): Add -muse-unaligned-vector-move.
* doc/c-i386.texi: Document -muse-unaligned-vector-move.
* testsuite/gas/i386/i386.exp: Run unaligned-vector-move and
x86-64-unaligned-vector-move.
* testsuite/gas/i386/unaligned-vector-move.d: New file.
* testsuite/gas/i386/unaligned-vector-move.s: Likewise.
* testsuite/gas/i386/x86-64-unaligned-vector-move.d: Likewise.
Tom Tromey [Tue, 19 Oct 2021 18:44:56 +0000 (12:44 -0600)]
Fix 'uninstall' target
This adds some missing code to the 'uninstall' targets in gdb and
gdbserver. It also changes gdb's uninstall target so that it no
longer tries to remove any man page -- this is already done (and more
correctly) by doc/Makefile.in.
I tested this with 'make install' followed by 'make uninstall', then
examining the install tree for regular files. Only the 'dir' file
remains, but this appears to just be how 'install-info' is intended to
work.
Tom Tromey [Tue, 19 Oct 2021 18:27:51 +0000 (12:27 -0600)]
Remove unused variables from gdbserver's Makefile
This removes a number of unused variables from gdbserver's Makefile.
I found these while working on the subsequent patches, and figured it
would be cleaner to have a separate patch for the deletions.
Tom de Vries [Fri, 22 Oct 2021 15:46:43 +0000 (17:46 +0200)]
[gdb/testsuite] Fix gdb.threads/linux-dp.exp
On openSUSE Tumbleweed with glibc-debuginfo installed I get:
...
(gdb) PASS: gdb.threads/linux-dp.exp: continue to breakpoint: thread 5's print
where^M
#0 print_philosopher (n=3, left=33 '!', right=33 '!') at linux-dp.c:105^M
#1 0x0000000000401628 in philosopher (data=0x40537c) at linux-dp.c:148^M
#2 0x00007ffff7d56b37 in start_thread (arg=<optimized out>) \
at pthread_create.c:435^M
#3 0x00007ffff7ddb640 in clone3 () \
at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81^M
(gdb) PASS: gdb.threads/linux-dp.exp: first thread-specific breakpoint hit
...
while without debuginfo installed I get instead:
...
(gdb) PASS: gdb.threads/linux-dp.exp: continue to breakpoint: thread 5's print
where^M
#0 print_philosopher (n=3, left=33 '!', right=33 '!') at linux-dp.c:105^M
#1 0x0000000000401628 in philosopher (data=0x40537c) at linux-dp.c:148^M
#2 0x00007ffff7d56b37 in start_thread () from /lib64/libc.so.6^M
#3 0x00007ffff7ddb640 in clone3 () from /lib64/libc.so.6^M
(gdb) FAIL: gdb.threads/linux-dp.exp: first thread-specific breakpoint hit
...
The problem is that the regexp used:
...
"\(from .*libpthread\|at pthread_create\|in pthread_create\)"
...
expects the 'from' part to match libpthread, but in glibc 2.34 libpthread has
been merged into libc.
Fix this by updating the regexp.
Tested on x86_64-linux.
Tom de Vries [Fri, 22 Oct 2021 15:42:37 +0000 (17:42 +0200)]
[gdb/testsuite] Fix FAILs in gdb.mi/mi-breakpoint-changed.exp
Since commit
e36788d1354 "[gdb/testsuite] Fix handling of nr_args < 3 in
mi_gdb_test" we run into:
...
PASS: gdb.mi/mi-breakpoint-changed.exp: test_auto_disable: mi runto main
Expecting: ^(-break-insert -f pendfunc1[^M
]+)?((&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-created,\
bkpt=\{number="2",type="breakpoint".*\}.*\n\^done[^M
]+[(]gdb[)] ^M
[ ]*)
-break-insert -f pendfunc1^M
^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",\
addr="0x00007ffff7bd559e",func="pendfunc1",\
file="gdb/testsuite/gdb.mi/pendshr1.c",\
fullname="gdb/testsuite/gdb.mi/pendshr1.c",line="21",thread-groups=["i1"],\
times="0",original-location="pendfunc1"}^M
(gdb) ^M
FAIL: gdb.mi/mi-breakpoint-changed.exp: test_auto_disable: \
-break-insert -f pendfunc1 (unexpected output)
...
The regexp expects a breakpoint-created event, but that's actually suppressed
by the command:
...
DEF_MI_CMD_MI_1 ("break-insert", mi_cmd_break_insert,
&mi_suppress_notification.breakpoint),
...
Fix this by updating the regexp.
Likewise for the following:
...
PASS: gdb.mi/mi-breakpoint-changed.exp: test_auto_disable: \
-break-insert -f pendfunc1
Expecting: ^(-break-enable count 1 2[^M
]+)?(=breakpoint-modified,\
bkpt=\{number="2",type="breakpoint",disp="dis",enabled="y".*\}.*\n\^done[^M
]+[(]gdb[)] ^M
[ ]*)
-break-enable count 1 2^M
^done^M
(gdb) ^M
FAIL: gdb.mi/mi-breakpoint-changed.exp: test_auto_disable: \
-break-enable count 1 2 (unexpected out\
put)
...
Tested on x86_64-linux.
Andrew Burgess [Thu, 16 Sep 2021 17:30:35 +0000 (18:30 +0100)]
gdb/python: move gdb.Membuf support into a new file
In a future commit I'm going to be creating gdb.Membuf objects from a
new file within gdb/python/py*.c. Currently all gdb.Membuf objects
are created directly within infpy_read_memory (as a result of calling
gdb.Inferior.read_memory()).
Initially I split out the Membuf creation code into a new function,
and left the new function in gdb/python/py-inferior.c, however, it
felt a little random that the Membuf creation code should live with
the inferior handling code.
So, then I moved all of the Membuf related code out into a new file,
gdb/python/py-membuf.c, the interface is gdbpy_buffer_to_membuf, which
wraps an array of bytes into a gdb.Membuf object.
Most of the code is moved directly from py-inferior.c with only minor
tweaks to layout and replacing NULL with nullptr, hence, I've left the
copyright date on py-membuf.c as 2009-2021 to match py-inferior.c.
Currently, the only user of this code is still py-inferior.c, but in
later commits this will change.
There should be no user visible changes after this commit.
Andrew Burgess [Wed, 15 Sep 2021 12:34:14 +0000 (13:34 +0100)]
gdb/python: new gdb.architecture_names function
Add a new function to the Python API, gdb.architecture_names(). This
function returns a list containing all of the supported architecture
names within the current build of GDB.
The values returned in this list are all of the possible values that
can be returned from gdb.Architecture.name().
Andrew Burgess [Wed, 13 Oct 2021 17:18:12 +0000 (18:18 +0100)]
gdb: make disassembler fprintf callback a static member function
The disassemble_info structure has four callbacks, we have three of
them as static member functions within gdb_disassembler, the fourth is
just a global static function.
However, this fourth callback, is still only used from the
disassemble_info struct, so there's no real reason for its special
handling.
This commit makes fprintf_disasm a static method within
gdb_disassembler.
There should be no user visible changes after this commit.
Lewis Revill [Fri, 22 Oct 2021 03:32:46 +0000 (11:32 +0800)]
RISC-V: Added ld testcase for pcgp relaxation.
Consider the the pcgp-relax-02 testcase,
.text
.globl _start
_start:
.L1: auipc a0, %pcrel_hi(data_a)
.L2: auipc a1, %pcrel_hi(data_b)
addi a0, a0, %pcrel_lo(.L1)
addi a1, a1, %pcrel_lo(.L2)
.data
.word 0x0
.globl data_a
data_a:
.word 0x1
.section .rodata
.globl data_b
data_b:
.word 0x2
If the first auipc is deleted, but we are still building the pcgp
table (connect the high and low pcrel relocations), then there is
an aliasing issue that we need some way to disambiguate which of
the two symbols we are targeting. Therefore, Palmer thought of a
way to use R_RISCV_DELETE to split this into two phases, so we
could resolve the addresses before creating the ambiguities.
This patch just add the ld testcase for the above case, in case we
have changed something but break this.
ld/
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Renamed pcgp-relax
to pcgp-relax-01, and added pcgp-relax-02.
* testsuite/ld-riscv-elf/pcgp-relax-01.d: Renmaed from pcgp-relax.
* testsuite/ld-riscv-elf/pcgp-relax-01.s: Likewise.
* testsuite/ld-riscv-elf/pcgp-relax-02.d: New testcase.
* testsuite/ld-riscv-elf/pcgp-relax-02.s: Likewise.
Lewis Revill [Thu, 21 Oct 2021 03:15:47 +0000 (11:15 +0800)]
RISC-V: Don't separate pcgp relaxation to another relax pass.
Commit
abd20cb637008da9d32018b4b03973e119388a0a and
ebdcad3fddf6ec21f6d4dcc702379a12718cf0c4 introduced additional
complexity into the paths run by the RISC-V relaxation pass in order to
resolve the issue of accurately keeping track of pcrel_hi and pcrel_lo
pairs. The first commit split up relaxation of these relocs into a pass
which occurred after other relaxations in order to prevent the situation
where bytes were deleted in between a pcrel_lo/pcrel_hi pair, inhibiting
our ability to find the corresponding pcrel_hi relocation from the
address attached to the pcrel_lo.
Since the relaxation was split into two passes the 'again' parameter
could not be used to perform the entire relaxation process again and so
the second commit added a way to restart ldelf_map_segments, thus
starting the whole process again.
Unfortunately this process could not account for the fact that we were
not finished with the relaxation process so in some cases - such as the
case where code would not fit in a memory region before the
R_RISCV_ALIGN relocation was relaxed - sanity checks in generic code
would fail.
This patch fixes all three of these concerns by reverting back to a
system of having only one target relax pass but updating entries in the
table of pcrel_hi/pcrel_lo relocs every time any bytes are deleted. Thus
we can keep track of the pairs accurately, and we can use the 'again'
parameter to restart the entire target relax pass, behaving in the way
that generic code expects. Unfortunately we must still have an
additional pass to delay deleting AUIPC bytes to avoid ambiguity between
pcrel_hi relocs stored in the table after deletion. This pass can only
be run once so we may potentially miss out on relaxation opportunities
but this is likely to be rare.
https://sourceware.org/bugzilla/show_bug.cgi?id=28410
bfd/
* elfnn-riscv.c (riscv_elf_link_hash_table): Removed restart_relax.
(riscv_elf_link_hash_table_create): Updated.
(riscv_relax_delete_bytes): Moved after the riscv_update_pcgp_relocs.
Update the pcgp_relocs table whenever bytes are deleted.
(riscv_update_pcgp_relocs): Add function to update the section
offset of pcrel_hi and pcrel_lo, and also update the symbol value
of pcrel_hi.
(_bfd_riscv_relax_call): Need to update the pcgp_relocs table
when deleting codes.
(_bfd_riscv_relax_lui): Likewise.
(_bfd_riscv_relax_tls_le): Likewise.
(_bfd_riscv_relax_align): Once we've handled an R_RISCV_ALIGN,
we can't relax anything else, so set the sec->sec_flg0 to true.
Besides, we don't need to update the pcgp_relocs table at this
stage, so just pass NULL pointer as the pcgp_relocs table for
riscv_relax_delete_bytes.
(_bfd_riscv_relax_section): Use only one pass for all target
relaxations.
(_bfd_riscv_relax_delete): Likewise, we don't need to update
the pcgp_relocs table at this stage, and don't need to set
the `again' since restart_relax mechanism is abandoned.
(bfd_elfNN_riscv_restart_relax_sections): Removed.
(_bfd_riscv_relax_section): Updated.
* elfxx-riscv.h (bfd_elf32_riscv_restart_relax_sections): Removed.
(bfd_elf64_riscv_restart_relax_sections): Likewise.
ld/
* emultempl/riscvelf.em: Revert restart_relax changes and set
relax_pass to 3.
* testsuite/ld-riscv-elf/align-small-region.d: New testcase.
* testsuite/ld-riscv-elf/align-small-region.ld: Likewise.
* testsuite/ld-riscv-elf/align-small-region.s: Likewise.
* testsuite/ld-riscv-elf/restart-relax.d: Removed sine the
restart_relax mechanism is abandoned.
* testsuite/ld-riscv-elf/restart-relax.s: Likewise.
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
Simon Marchi [Fri, 22 Oct 2021 04:13:43 +0000 (00:13 -0400)]
gdb: fix remote-sim.c build
Commit
183be222907a ("gdb, gdbserver: make target_waitstatus safe")
broke the remote-sim.c build. In fact, it does some wrong changes,
result of a bad sed invocation.
Fix it by adjusting the code to the new target_waitstatus API.
Change-Id: I3236ff7ef7681fc29215f68be210ff4263760e91
GDB Administrator [Fri, 22 Oct 2021 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Thu, 21 Oct 2021 20:12:04 +0000 (16:12 -0400)]
gdb, gdbserver: make target_waitstatus safe
I stumbled on a bug caused by the fact that a code path read
target_waitstatus::value::sig (expecting it to contain a gdb_signal
value) while target_waitstatus::kind was TARGET_WAITKIND_FORKED. This
meant that the active union field was in fact
target_waitstatus::value::related_pid, and contained a ptid. The read
signal value was therefore garbage, and that caused GDB to crash soon
after. Or, since that GDB was built with ubsan, this nice error
message:
/home/simark/src/binutils-gdb/gdb/linux-nat.c:1271:12: runtime error: load of value
2686365, which is not a valid value for type 'gdb_signal'
Despite being a large-ish change, I think it would be nice to make
target_waitstatus safe against that kind of bug. As already done
elsewhere (e.g. dynamic_prop), validate that the type of value read from
the union matches what is supposed to be the active field.
- Make the kind and value of target_waitstatus private.
- Make the kind initialized to TARGET_WAITKIND_IGNORE on
target_waitstatus construction. This is what most users appear to do
explicitly.
- Add setters, one for each kind. Each setter takes as a parameter the
data associated to that kind, if any. This makes it impossible to
forget to attach the associated data.
- Add getters, one for each associated data type. Each getter
validates that the data type fetched by the user matches the wait
status kind.
- Change "integer" to "exit_status", "related_pid" to "child_ptid",
just because that's more precise terminology.
- Fix all users.
That last point is semi-mechanical. There are a lot of obvious changes,
but some less obvious ones. For example, it's not possible to set the
kind at some point and the associated data later, as some users did.
But in any case, the intent of the code should not change in this patch.
This was tested on x86-64 Linux (unix, native-gdbserver and
native-extended-gdbserver boards). It was built-tested on x86-64
FreeBSD, NetBSD, MinGW and macOS. The rest of the changes to native
files was done as a best effort. If I forgot any place to update in
these files, it should be easy to fix (unless the change happens to
reveal an actual bug).
Change-Id: I0ae967df1ff6e28de78abbe3ac9b4b2ff4ad03b7