Alan Modra [Wed, 2 Sep 2020 00:35:52 +0000 (10:05 +0930)]
ubsan: objdump.c:3009 negation of -
2147483648
* objdump.c (disassemble_bytes): Use an unsigned type for "addend".
Alan Modra [Wed, 2 Sep 2020 00:33:14 +0000 (10:03 +0930)]
ubsan elfnn-aarch64.c:7142 shift exponent 32 is too large
* elfnn-aarch64.c (elfNN_aarch64_relocate_section): Correct type
of constant shifted left.
Alan Modra [Wed, 2 Sep 2020 00:29:16 +0000 (09:59 +0930)]
ubasn: elf32-pru.c:570 left shift of negative value
* elf32-pru.c (pru_elf32_do_ldi32_relocate): Use an unsigned
type for "relocation".
Alan Modra [Tue, 1 Sep 2020 11:53:52 +0000 (21:23 +0930)]
32-bit host pdp11 breakage
If bfd_vma is 32 bits, gcc complains about shift counts exceeding
width of the type.
* config/tc-pdp11.c (md_number_to_chars): Condition nbytes=8 code
on BFD64.
Cooper Qu [Wed, 2 Sep 2020 06:06:03 +0000 (14:06 +0800)]
CSKY: Add CPU CK803r3.
Move divul and divsl to CSKYV2_ISA_3E3R3 instruction set, which is
enabled by ck803r3, and it's still a part of enhance DSP instruction
set.
gas/
* config/tc-csky.c (csky_cpus): Add ck803r3.
(CSKY_ISA_803R3): Define.
(CSKY_ISA_803R2): Refine, use CSKY_ISA_803R1.
include/
* opcode/csky.h (CSKYV2_ISA_3E3R3): Define.
opcodes/
* csky-opc.h (csky_v2_opcodes): Move divul and divsl
to CSKYV2_ISA_3E3R3 instruction set.
Cooper Qu [Wed, 2 Sep 2020 06:05:49 +0000 (14:05 +0800)]
CSKY: Fix Encode of mulsws.
gas/
* testsuite/gas/csky/cskyv2_dsp.d : Fix Encode of mulsws.
opcodes/
* csky-opc.h (csky_v2_opcodes): Fix Encode of mulsws.
Cooper Qu [Wed, 2 Sep 2020 06:04:52 +0000 (14:04 +0800)]
CSKY: Refine literals pool dump process and float register parser.
gas/
* config/tc-csky.c (struct literal): New member bignum.
(dump_literals): Handle big constant.
(enter_literal): Likewise.
(parse_type_freg): Handle vector register.
GDB Administrator [Wed, 2 Sep 2020 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Tue, 1 Sep 2020 16:54:38 +0000 (12:54 -0400)]
gdb: change bcache::insert `added` parameter to bool
It is currently an int, but it is used as a bool.
gdb/ChangeLog:
* bcache.h (struct bcache) <insert>: Change type of `added` to
pointer to bool.
* bcache.c (bcache::insert): Likewise.
* gdbtypes.c (check_types_worklist): Adjust.
* psymtab.c (add_psymbol_to_bcache): Adjust.
Change-Id: I06b1041636c656782a89cb6106c9ae2593f61616
H.J. Lu [Tue, 1 Sep 2020 14:10:56 +0000 (07:10 -0700)]
ELF: Document the .tls_common directive
Document the .tls_common directive added by
commit
b8871f357fdfa9c0c06d2d3e5600391d8c994f37
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Feb 22 09:18:52 2016 -0800
Properly implement STT_COMMON
* doc/as.texi: Document the .tls_common directive.
Alan Modra [Mon, 31 Aug 2020 22:18:02 +0000 (07:48 +0930)]
mep: ubsan: mep-ibld.c:1635,1645,1652 left shift of negative value
cpu/
* mep-core.cpu (f-8s8a2, f-12s4a2, f-17s16a2): Multiply signed
value by two rather than shifting left.
(f-24s5a2n): Similarly multiply signed f-24s5a2n-hi to extract.
opcodes/
* mep-ibld.c: Regenerate.
Alan Modra [Tue, 1 Sep 2020 03:08:03 +0000 (12:38 +0930)]
arm: ubsan: shift exponent 4G
* reloc.c (N_ONES): Handle N=0.
* elf32-arm.c (elf32_arm_howto_table_1): Set complain_overflow_dont
for R_ARM_TLS_DESCSEQ and R_ARM_THM_TLS_DESCSEQ.
Alan Modra [Tue, 1 Sep 2020 02:05:37 +0000 (11:35 +0930)]
PR26420, PR26421, PR26425, PR26427 UBSAN: tc-arm.c left shifts
PR 26420
PR 26421
PR 26425
PR 26427
* config/tc-arm.c (struct arm_it): Make size, size_req, cond and
uncond_value unsigned.
(parse_vfp_reg_list): Make setmask unsigned, vpr_str_len size_t.
(parse_big_immediate): Cast generic_bignum elements to unsigned.
(encode_thumb32_immediate): Shift left 0xffU.
(double_to_single): Make sign unsigned. Tidy.
(move_or_literal_pool): Cast LITTLE_NUM elements to uint64_t or
valueT.
(vfp_or_neon_is_neon): Adjust inst.uncond_value expression.
(md_assemble): Likewise.
(handle_pred_state): Make cond unsigned.
(thumb32_negate_data_op): Make variables unsigned.
(md_apply_fix): Make value and newval unsigned, adjust uses.
Alan Modra [Mon, 31 Aug 2020 23:29:05 +0000 (08:59 +0930)]
PR26429 UBSAN: elf32-arm.c load /store misaligned address
PR 26429
* elf32-arm.c (elf32_arm_allocate_local_sym_info): Allocate arrays
in descending order of alignment.
Alan Modra [Mon, 31 Aug 2020 22:33:52 +0000 (08:03 +0930)]
PR26423 UBSAN: elf32-arm.c:10237 left shift cannot be represented
PR 26423
* elf32-arm.c (calculate_group_reloc_mask): Use 3u in shift.
Kevin Buettner [Tue, 11 Aug 2020 16:36:12 +0000 (09:36 -0700)]
corefile.exp: XFAIL warning-free test when testing on docker
When testing on docker using the AUFS storage driver, loading a core
file will often print a number of warnings. Here's an example (with
the pathname shortened somewhat):
warning: Can't open file /var/lib/docker/aufs/diff/d07..e21/lib/x86_64-linux-gnu/libc-2.27.so during file-backed mapping note processing
The "warning-free" test in gdb.base/corefile.exp will fail if any
warnings are printed, but this particular warning is unavoidable when
running in the docker environment. Fortunately, the path mentions
both "docker" and "aufs", making it easy to XFAIL this case.
gdb/testsuite/ChangeLog:
* gdb.base/corefile.exp (warning-free): XFAIL test when running
on docker w/ AUFS storage driver.
Kevin Buettner [Fri, 7 Aug 2020 20:07:44 +0000 (13:07 -0700)]
Work around incorrect/broken pathnames in NT_FILE note
Luis Machado reported some regressions after I pushed recent core file
related patches fixing BZ 25631:
FAIL: gdb.base/corefile.exp: backtrace in corefile.exp
FAIL: gdb.base/corefile.exp: core-file warning-free
FAIL: gdb.base/corefile.exp: print func2::coremaker_local
FAIL: gdb.base/corefile.exp: up in corefile.exp
FAIL: gdb.base/corefile.exp: up in corefile.exp (reinit)
This commit fixes these regressions. Thanks to Luis for testing
an earlier version of the patch. (I was unable to reproduce these
regressions in various test environments that I created.)
Luis is testing in a docker container which is using the AUFS storage
driver. It turns out that the kernel is placing docker host paths in
the NT_FILE note instead of paths within the container.
I've made a similar docker environment (though apparently not similar
enough to reproduce the regressions). This is one of the paths that
I see mentioned in the warning messages printed while loading the
core file during NT_FILE note processing - note that I've shortened
the path component starting with "d07c4":
/var/lib/docker/aufs/diff/d07c4...21/lib/x86_64-linux-gnu/ld-2.27.so
This is a path on the docker host; it does not exist in the
container. In the docker container, this is the path:
/lib/x86_64-linux-gnu/ld-2.27.so
My first thought was to disable all NT_FILE mappings when any path was
found to be bad. This would have caused GDB to fall back to accessing
memory using the file stratum as it did before I added the NT_FILE
note loading code. After further consideration, I realized that we
could do better than this. For file-backed memory access, we can
still use the NT_FILE mappings when available, and then attempt to
access memory using the file stratum constrained to those address
ranges corresponding to the "broken" mappings.
In order to test it, I made some additions to corefile2.exp in which
the test case's executable is renamed. The core file is then loaded;
due to the fact that the executable has been renamed, those mappings
will be unavailable. After loading the core file, the executable is
renamed back to its original name at which point it is loaded using
GDB's "file" command. The "interesting" tests are then run. These
tests will print out values in file-backed memory regions along with
mmap'd regions placed within/over the file-backed regions. Despite
the fact that the executable could not be found during the NT_FILE
note processing, these tests still work correctly due to the fact that
memory is available from the file stratum combined with the fact that
the broken NT_FILE mappings are used to prevent file-backed access
outside of the "broken" mappings.
gdb/ChangeLog:
* corelow.c (unordered_set): Include.
(class core_target): Add field 'm_core_unavailable_mappings'.
(core_target::build_file_mappings): Print only one warning
per inaccessible file. Add unavailable/broken mappings
to m_core_unavailable_mappings.
(core_target::xfer_partial): Call...
(core_target::xfer_memory_via_mappings): New method.
gdb/testsuite/ChangeLog:
* gdb.base/corefile2.exp (renamed binfile): New tests.
Simon Marchi [Tue, 1 Sep 2020 01:06:06 +0000 (21:06 -0400)]
gdb: change type of field_info::non_public_fields to bool
gdb/ChangeLog:
* dwarf2/read.c (struct field_info) <non_public_fields>: Change
type to bool.
(dwarf2_add_field): Use true instead of 1.
Change-Id: I7e9c86429402c28d4f15861d17976b9c50049f94
Simon Marchi [Tue, 1 Sep 2020 01:05:37 +0000 (21:05 -0400)]
gdb: fix indentation of struct field_info
The indentation is off, fix it before doing other changes.
gdb/ChangeLog:
* dwarf2/read.c (struct field_info): Fix indentation.
Change-Id: Ife6a3d017abcf0a33e49e47e51429e95d504343c
GDB Administrator [Tue, 1 Sep 2020 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Mon, 31 Aug 2020 17:31:01 +0000 (13:31 -0400)]
gdb: fix nits in previous patches
I forgot to fix some nits pointed out in review before merging the
"frame inlined in outer frame series", this patch fixes them.
gdb/ChangeLog:
* frame-unwind.h (frame_prev_register_ftype): Fix adjective
ordering in comment.
* frame.c (frame_id_eq): Fix indentation.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-reg-undefined.exp: Remove spurious #.
Change-Id: Iaddde9677fc3f68382558d1a16f5a0b4beb78bac
Scott Linder [Mon, 31 Aug 2020 17:24:20 +0000 (13:24 -0400)]
gdb: support frames inlined into the outer frame
Remove the restriction (gdb_assert) that prevents creating frames
inlined in the outer frame. Like for frames inlined in a standard frame
(FID_STACK_VALID), a frame inlined into the outer frame will have:
- artificial_depth greater than 0
- code_addr equal to the first executed instruction in the block
corresponding to the inlined function
It will however have its stack_status set to FID_STACK_OUTER, like the
outer frame.
This is not typically seen on your everyday system (e.g. a Linux /
x86-64 process), because the outer frame would be for instance the
_start function, probably written in assembly and very unlikely to have
anything inlined in it. However this could happen in more "bare-metal"
scenarios. In particular, this was seen in ROCm GDB [1], where the
compiler does inline functions in the top-level kernel functions (kernel
in the sense of compute kernel, not userspace vs kernel).
I however wrote a test that replicates the issue on x86-64 and a few
other arches I had access to. Since we need to control precisely the
emitted DWARF CFI, I didn't find another way than to write it in
assembly. The DWARF is generated using the testsuite's DWARF assembler,
except the unwind information, which is written using CFI directives
(and therefore generated by the actual assembler). I think the test is
adequately commented, but if anything is unclear, just ask and I'll add
more info.
[1] https://github.com/ROCm-Developer-Tools/ROCgdb/
gdb/ChangeLog:
YYYY-MM-DD Scott Linder <scott@scottlinder.com>
YYYY-MM-DD Simon Marchi <simon.marchi@efficios.com>
* inline-frame.c (inline_frame_this_id): Remove assert that prevents
inline frame ids in outer frame.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/frame-inlined-in-outer-frame.exp: New file.
* gdb.dwarf2/frame-inlined-in-outer-frame.S: New file.
Change-Id: I8aa129c667dccc31590ffdf426586418493a6ebe
Simon Marchi [Mon, 31 Aug 2020 17:23:12 +0000 (13:23 -0400)]
gdb: introduce explicit outer frame id kind
In the following patch, we'll need to easily differentiate the frame_id
of the outer frame (or the frame id of a frame inlined into the outer
frame) from a simply invalid frame id.
Currently, the frame id of the outer frame has `stack_status` set to
FID_STACK_INVALID plus special_addr_p set. A frame inlined into the
outer frame would also have `artificial_depth` set to greater than one.
That makes the job of differntiating the frame id of the outer frame (or a
frame inlined into the outer frame) cumbersome.
To make it easier, give the outer frame id its own frame_id_stack_status
enum value. outer_frame_id then becomes very similar to
sentinel_frame_id, another "special" frame id value.
In frame_id_p, we don't need a special case for the outer frame id, as
it's no long a special case of FID_STACK_INVALID. Same goes for
frame_id_eq.
So in the end, FID_STACK_OUTER isn't even used (except in
fprint_frame_id). But that's expected: all the times we wanted to
identify an outer frame was to differentiate it from an otherwise
invalid frame. Since their frame_id_stack_status value is different
now, that is done naturally.
gdb/ChangeLog:
* frame.h (enum frame_id_stack_status) <FID_STACK_OUTER>: New.
* frame.c (fprint_frame_id): Handle FID_STACK_OUTER.
(outer_frame_id): Use FID_STACK_OUTER instead of
FID_STACK_INVALID.
(frame_id_p): Don't check for outer_frame_id.
Change-Id: I654e7f936349debc4f04f7f684b15e71a0c37619
Simon Marchi [Mon, 31 Aug 2020 17:22:54 +0000 (13:22 -0400)]
gdb: make frame_unwind_got_optimized return a not_lval value
TLDR: frame_unwind_got_optimized uses wrong frame id value, trying to
fix it makes GDB sad, return not_lval value and don't use frame id value
instead.
Longer version:
The `prev_register` method of the `frame_unwind` interface corresponds
to asking the question: "where did this frame - passed as a parameter -
save the value this register had in its caller frame?". When "this
frame" did not save that register value (DW_CFA_undefined in DWARF), the
implementation can use the `frame_unwind_got_optimized` function to
create a struct value that represents the optimized out / not saved
register.
`frame_unwind_got_optimized` marks the value as fully optimized out,
sets the lval field to lval_register and assigns the required data for
lval_register: the next frame id and the register number. The problem
is that it uses the frame id from the wrong frame (see below for in
depth explanation). In practice, this is not problematic because the
frame id is never used: the value is already not lazy (and is marked as
optimized out), so the value is never fetched from the target.
When trying to change it to put the right next frame id in the value, we
bump into problems: computing the frame id for some frame requires
unwinding some register, if that register is not saved / optimized out,
we try to get the frame id that we are currently computing.
This patch addresses the problem by changing
`frame_unwind_got_optimized` to return a not_lval value instead. Doing
so, we don't need to put a frame id, so we don't hit that problem. It
may seem like an unnecessary change today, because it looks like we're
fixing something that is not broken (from the user point of view).
However, the bug becomes user visible with the following patches, where
inline frames are involved. I put this change in its own patch to keep
it logically separate.
Let's now illustrate how we are putting the wrong frame id in the value
returned by `frame_unwind_got_optimized`. Let's assume this stack:
frame #0
frame #1
frame #2
frame #3
Let's suppose that we are calling `frame_unwind_register_value` with
frame #2 as the "next_frame" parameter and some register number X as the
regnum parameter. That is like asking the question "where did frame #2
save frame #3's value for register X".
`frame_unwind_register_value` calls the frame unwinder's `prev_register`
method, which in our case is `dwarf2_frame_prev_register`. Note that in
`dwarf2_frame_prev_register`, the parameter is now called `this_frame`,
but its value is still frame #2, and we are still looking for where
frame #2 saved frame #3's value of register X.
Let's now suppose that frame #2's CFI explicitly indicates that the
register X is was not saved (DW_CFA_undefined). We go into
`frame_unwind_got_optimized`.
In `frame_unwind_got_optimized`, the intent is to create a value that
represents register X in frame #3. An lval_register value requires that
we specify the id of the _next_ frame, that is the frame from which we
would need to unwind in order to get the value. Therefore, we would
want to put the id of frame #2 in there.
However, `frame_unwind_got_optimized` does:
VALUE_NEXT_FRAME_ID (val)
= get_frame_id (get_next_frame_sentinel_okay (frame));
where `frame` is frame #2. The get_next_frame_sentinel_okay call
returns frame #1, so we end up putting frame #1's id in the value.
Let's now pretend that we try to "fix" it by placing the right frame id,
in other words doing this change:
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -260,8 +260,7 @@ frame_unwind_got_optimized (struct frame_info *frame, int regnum)
mark_value_bytes_optimized_out (val, 0, TYPE_LENGTH (type));
VALUE_LVAL (val) = lval_register;
VALUE_REGNUM (val) = regnum;
- VALUE_NEXT_FRAME_ID (val)
- = get_frame_id (get_next_frame_sentinel_okay (frame));
+ VALUE_NEXT_FRAME_ID (val) = get_frame_id (frame);
return val;
}
This makes some tests fails, such as gdb.dwarf2/dw2-undefined-ret-addr.exp,
like so:
...
#9 0x0000557a8ab15a5d in internal_error (file=0x557a8b31ef80 "/home/simark/src/binutils-gdb/gdb/frame.c", line=623, fmt=0x557a8b31efe0 "%s: Assertion `%s' failed.") at /home/simark/src/binutils-gdb/gdbsupport/errors.cc:55
#10 0x0000557a87f816d6 in get_frame_id (fi=0x62100034bde0) at /home/simark/src/binutils-gdb/gdb/frame.c:623
#11 0x0000557a87f7cac7 in frame_unwind_got_optimized (frame=0x62100034bde0, regnum=16) at /home/simark/src/binutils-gdb/gdb/frame-unwind.c:264
#12 0x0000557a87a71a76 in dwarf2_frame_prev_register (this_frame=0x62100034bde0, this_cache=0x62100034bdf8, regnum=16) at /home/simark/src/binutils-gdb/gdb/dwarf2/frame.c:1267
#13 0x0000557a87f86621 in frame_unwind_register_value (next_frame=0x62100034bde0, regnum=16) at /home/simark/src/binutils-gdb/gdb/frame.c:1288
#14 0x0000557a87f855d5 in frame_register_unwind (next_frame=0x62100034bde0, regnum=16, optimizedp=0x7fff5f459070, unavailablep=0x7fff5f459080, lvalp=0x7fff5f4590a0, addrp=0x7fff5f4590b0, realnump=0x7fff5f459090, bufferp=0x7fff5f459150 "") at /home/simark/src/binutils-gdb/gdb/frame.c:1191
#15 0x0000557a87f860ef in frame_unwind_register (next_frame=0x62100034bde0, regnum=16, buf=0x7fff5f459150 "") at /home/simark/src/binutils-gdb/gdb/frame.c:1247
#16 0x0000557a881875f9 in i386_unwind_pc (gdbarch=0x621000190110, next_frame=0x62100034bde0) at /home/simark/src/binutils-gdb/gdb/i386-tdep.c:1971
#17 0x0000557a87fe58a5 in gdbarch_unwind_pc (gdbarch=0x621000190110, next_frame=0x62100034bde0) at /home/simark/src/binutils-gdb/gdb/gdbarch.c:3062
#18 0x0000557a87a6267b in dwarf2_tailcall_sniffer_first (this_frame=0x62100034bde0, tailcall_cachep=0x62100034bee0, entry_cfa_sp_offsetp=0x7fff5f4593f0) at /home/simark/src/binutils-gdb/gdb/dwarf2/frame-tailcall.c:387
#19 0x0000557a87a70cdf in dwarf2_frame_cache (this_frame=0x62100034bde0, this_cache=0x62100034bdf8) at /home/simark/src/binutils-gdb/gdb/dwarf2/frame.c:1198
#20 0x0000557a87a711c2 in dwarf2_frame_this_id (this_frame=0x62100034bde0, this_cache=0x62100034bdf8, this_id=0x62100034be40) at /home/simark/src/binutils-gdb/gdb/dwarf2/frame.c:1226
#21 0x0000557a87f81167 in compute_frame_id (fi=0x62100034bde0) at /home/simark/src/binutils-gdb/gdb/frame.c:587
#22 0x0000557a87f81803 in get_frame_id (fi=0x62100034bde0) at /home/simark/src/binutils-gdb/gdb/frame.c:635
#23 0x0000557a87f7efef in scoped_restore_selected_frame::scoped_restore_selected_frame (this=0x7fff5f459920) at /home/simark/src/binutils-gdb/gdb/frame.c:320
#24 0x0000557a891488ae in print_frame_args (fp_opts=..., func=0x621000183b90, frame=0x62100034bde0, num=-1, stream=0x6030000caa20) at /home/simark/src/binutils-gdb/gdb/stack.c:750
#25 0x0000557a8914e87a in print_frame (fp_opts=..., frame=0x62100034bde0, print_level=0, print_what=SRC_AND_LOC, print_args=1, sal=...) at /home/simark/src/binutils-gdb/gdb/stack.c:1394
#26 0x0000557a8914c2ae in print_frame_info (fp_opts=..., frame=0x62100034bde0, print_level=0, print_what=SRC_AND_LOC, print_args=1, set_current_sal=1) at /home/simark/src/binutils-gdb/gdb/stack.c:1119
...
We end up calling get_frame_id (in the hunk above, frame #10) while we are
computing it (frame #21), and that's not good.
Now, the question is how do we fix this. I suggest making the unwinder
return a not_lval value in this case.
The reason why we return an lval_register here is to make sure that this
is printed as "not saved" and not "optimized out" down the line. See
these two commits:
1.
901461f8eb40 ("Print registers not saved in the frame as "<not saved>"
instead of "<optimized out>".").
2.
6bd273ae450b ("Make "set debug frame 1" output print <not saved> instead of
<optimized out>.")
The current design (introduced by the first commit) is to check the
value's lval to choose which one to print (see val_print_optimized_out).
Making the unwinder return not_lval instead of lval_register doesn't
break "not saved" when doing "print $rax" or "info registers", because
value_fetch_lazy_register only consumes the contents and optimized-out
property from the value the unwinder returned. The value being
un-lazified stays an lval_register.
I believe that this is a correct technical solution (and not just
papering over the problem), because what we expect of unwinders is to
tell us where a given register's value is saved. If the value is saved
in memory, -> lval_memory. If the value is saved in some other register
of the next frame, -> lval_register. If the value is not saved, it
doesn't really make sense to return an lval_register value. not_lval
would be more appropriate. If the code then wants to represent an
optimized out register value (like value_fetch_lazy_register does), then
it's a separate concern which shouldn't involve the unwinder.
This change breaks the output of "set debug frame 1" though (introduced
by the second commit), since that logging statement consumes the return
value of the unwinder directly. To keep the correct behavior, just make
`frame_unwind_register_value` call `val_print_not_saved` directly,
instead of `val_print_optimized_out`. This is fine because we know in
this context that we are always talking about a register value, and that
we want to show "not saved" for those.
I augmented the gdb.dwarf2/dw2-reg-undefined.exp test case to test some
cases I stumbled on while working on this, which I think are not tested
anywhere:
- the "set debug frame 1" debug output mentioned above. It's just debug
output, but if we want to make sure it doesn't change, it should be
tested
- printing not-saved register values from the history (should print not
saved)
- copying a not-saved register value in a convenience variable. In this
case, we expect that printing the convenience variable shows
"optimized out", because we copied the value, not the property of
where the value came from.
gdb/ChangeLog:
* frame-unwind.c (frame_unwind_got_optimized): Don't set
regnum/frame in value. Call allocate_value_lazy.
* frame.c (frame_unwind_register_value): Use
val_print_not_saved.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-reg-undefined.exp: Test "set debug frame 1"
output, printing a "not saved" value from history and printing a
convenience variable created from a "not saved" value.
Change-Id: If451739a3ef7a5b453b1f50707e21ce16d74807e
Simon Marchi [Mon, 31 Aug 2020 14:44:33 +0000 (10:44 -0400)]
gdb: remove NULL_TYPE
The NULL_TYPE macro is not very useful... remove it and just use
nullptr.
gdb/ChangeLog:
* gdbtypes.h (NULL_TYPE): Remove, change all uses to nullptr.
Change-Id: Ic6215921413dad5649192b012f1a41d0a650a644
Alan Modra [Mon, 31 Aug 2020 08:04:39 +0000 (17:34 +0930)]
PR26510 UBSAN: tc-z8k.c left shift of negative value
This also fixes the packing of the nibble buffer, which contains
rubbish in the top 4 bits of each element.
PR 26510
* config/tc-z8k.c (buffer): Use unsigned char.
(apply_fix): Use unsigned char* pointers.
(build_bytes): Likewise and mask nibbles when packing.
Alan Modra [Mon, 31 Aug 2020 07:51:06 +0000 (17:21 +0930)]
PR26503 UBSAN: tc-v850.c:1447 left shift cannot be represented
PR 26503
* config/tc-v850.c (parse_register_list): Shift 1u left.
Alan Modra [Mon, 31 Aug 2020 07:46:21 +0000 (17:16 +0930)]
PR26502 UBSAN: tc-tic6x.c left shift of negative value
PR 26502
* config/tc-tic6x.c (md_apply_fix): Use unsigned variables.
Alan Modra [Mon, 31 Aug 2020 07:12:42 +0000 (16:42 +0930)]
PR26497 UBSAN: tc-sh.c:2467 left shift cannot be represented
PR 26497
* config/tc-sh.c (assemble_ppi): Use unsigned variables.
Alan Modra [Mon, 31 Aug 2020 07:00:45 +0000 (16:30 +0930)]
PR26495 UBSAN: tc-score.c, tc-score7.c left shift of negative value
PR 26495
* config/tc-score.c (s3_apply_fix): Use unsigned variables.
* config/tc-score7.c (s7_apply_fix): Likewise.
Alan Modra [Mon, 31 Aug 2020 06:25:20 +0000 (15:55 +0930)]
PR26480 UBSAN: tc-nios2.c:1634 left shift cannot be represented
PR 26480
* config/tc-nios2.c (nios2_parse_reglist): Shift 1UL left.
Alan Modra [Mon, 31 Aug 2020 06:21:24 +0000 (15:51 +0930)]
PR26479 UBSAN: tc-nios2.c:244 left shift cannot be represented
PR 26479
* config/tc-nios2.c (md_chars_to_number): Cast buf[i] before shifting.
Alan Modra [Mon, 31 Aug 2020 06:08:25 +0000 (15:38 +0930)]
PR26472, PR26473, PR26474 UBSAN: tc-mips.c shift left UB
PR 26472
PR 26473
PR 26474
* config/tc-mips.c (operand_reg_mask): Shift 1u left.
(load_register): Shift 0xffffU left.
Alan Modra [Mon, 31 Aug 2020 05:06:34 +0000 (14:36 +0930)]
PR26471 UBSAN: tc-metag.c:7038 left shift cannot be represented
PR 26471
* config/tc-metag.c (md_chars_to_number): Make retval unsigned.
Alan Modra [Mon, 31 Aug 2020 05:01:55 +0000 (14:31 +0930)]
PR26468 UBSAN: tc-mep.c:1684 left shift of negative value
PR 26468
* config/tc-mep.c (md_convert_frag): Use uint32_t for addend and
other variables.
Alan Modra [Mon, 31 Aug 2020 08:35:54 +0000 (18:05 +0930)]
PR26493 UBSAN: tc-riscv.c left shift negative and not representable
PR 26493
* config/tc-riscv.c (riscv_ip): Cast X_add_number passed to
VALID_* macros to unsigned.
Alan Modra [Mon, 31 Aug 2020 03:47:06 +0000 (13:17 +0930)]
PR26493 UBSAN: elfnn-riscv.c left shift of negative value
include/
PR 26493
* opcode/riscv.h (OP_MASK_CSR, OP_MASK_CUSTOM_IMM)
(OP_MASK_FUNCT7, OP_MASK_RS3): Make unsigned.
bfd/
PR 26493
* elfnn-riscv.c (riscv_make_plt_header): Cast PLT_HEADER_SIZE to
unsigned when using with RISCV_ITYPE.
(_bfd_riscv_relax_call): Use an unsigned foff.
Alan Modra [Mon, 31 Aug 2020 02:08:05 +0000 (11:38 +0930)]
PR26476, PR26477 UBSAN: elfxx-mips.c:2695,5370 cannot be represented
PR 26476
PR 26477
* elfxx-mips.c (CRINFO_CTYPE, CRINFO_RTYPE, CRINFO_DIST2TO),
(CRINFO_RELVADDR): Make unsigned.
(mips_elf_nullify_got_load): Use unsigned constant when shifting
into sign bit.
Alan Modra [Mon, 31 Aug 2020 01:44:31 +0000 (11:14 +0930)]
PR26466 UBSAN: elf32-mep.c:300 left shift of negative value
PR 26466
* mep-relocs.pl (emit_apply): Handle HI16S adjustment. Use "u"
variable and rewrite signed overflow check.
* elf32-mep.c: Regenerate.
(mep_final_link_relocate): Delete "s".
Alan Modra [Mon, 31 Aug 2020 00:45:34 +0000 (10:15 +0930)]
PR26461 UBSAN: elfxx-ia64.c:747 cannot be represented
PR 26461
* elfxx-ia64.c (ia64_elf_install_value): Make expressions unsigned
that might shift values into sign bit.
Alan Modra [Mon, 31 Aug 2020 00:33:59 +0000 (10:03 +0930)]
PR26457 UBSAN: som.c:1794 left shift cannot be represented
PR 26457
* som/aout.h (SOM_SUBSPACE_ACCESS_CONTROL_BITS_MASK): Make unsigned.
(SOM_SUBSPACE_MEMORY_RESIDENT, SOM_SUBSPACE_DUP_COMMON)
(SOM_SUBSPACE_IS_COMMON, SOM_SUBSPACE_IS_LOADABLE)
(SOM_SUBSPACE_QUADRANT_MASK, SOM_SUBSPACE_INITIALLY_FROZEN)
(SOM_SUBSPACE_IS_FIRST, SOM_SUBSPACE_CODE_ONLY)
(SOM_SUBSPACE_SORT_KEY_MASK, SOM_SUBSPACE_REPLICATE_INIT)
(SOM_SUBSPACE_CONTINUATION, SOM_SUBSPACE_IS_TSPECIFIC)
(SOM_SUBSPACE_IS_COMDAT): Likewise.
Alan Modra [Mon, 31 Aug 2020 00:20:49 +0000 (09:50 +0930)]
PR26445 UBSAN: elf32-csky.c:4115 left shift of negative value
PR 26445
* elf32-csky.c (csky_relocate_contents): Make relocation a bfd_vma,
and similarly for variables dealing with overflow.
Alan Modra [Sun, 30 Aug 2020 23:37:03 +0000 (09:07 +0930)]
crx: ubsan: cannot be represented
* config/tc-crx.c: Formatting.
(CRX_PRINT): Wrap params in parentheses. Remove parens from uses
throughout file.
(reset_vars, get_register, get_copregister, get_optype, get_opbits),
(get_opflags, get_number_of_operands, parse_operand, gettrap),
(handle_LoadStor, getconstant, check_range, getreg_image),
(parse_operands, parse_insn, print_operand, print_constant),
(exponent2scale, mask_reg, process_label_constant, set_operand),
(assemble_insn, print_insn): Delete unnecessary forward declaration.
(print_insn): Make static.
(print_constant): Make "constant" unsigned.
(assemble_insn): Tidy REVERSE_MATCH index calc.
* expr.c (generic_bignum_to_int32): Cast elements to valueT.
Alan Modra [Sun, 30 Aug 2020 23:02:32 +0000 (08:32 +0930)]
PR26442 UBSAN: elf32-crx.c:512 cannot be represented in int
PR 26442
* elf32-crx.c (crx_elf_final_link_relocate): Calculate reloc_bits
without undefined behaviour. Tidy excess casts.
Alan Modra [Sun, 30 Aug 2020 22:43:19 +0000 (08:13 +0930)]
PR26509 UBSAN: tc-z80.c:3656 shift exponent is too large
PR 26509
* config/tc-z80.c (is_overflow): Use 1UL in mask shift expression.
Alan Modra [Sun, 30 Aug 2020 22:39:23 +0000 (08:09 +0930)]
mn10300: ubsan: shift exponent too large
* elf-m10300.c (mn10300_elf_relax_delete_bytes): Calculate
alignment from reloc addend after reloc type R_MN10300_ALIGN is
found.
Alan Modra [Sun, 30 Aug 2020 14:13:54 +0000 (23:43 +0930)]
tic4x-coff: ubsan: various shift UB
* config/tc-tic4x.c (tic4x_gen_to_words): Rewrite mantissa
overflow test without UB. Avoid other UB shifts by making them
unsigned.
Tom de Vries [Mon, 31 Aug 2020 08:42:01 +0000 (10:42 +0200)]
[gdb/testsuite] Add nopie to gdb.base/eh_return.exp
When running test-case gdb.base/eh_return.exp with target board
unix/-fPIE/-pie, we run into:
...
(gdb) break *0x88e^M
Breakpoint 1 at 0x88e: file eh_return.c, line 54.^M
(gdb) PASS: gdb.base/eh_return.exp: setting breakpoint at *0x88e
run ^M
Starting program: eh_return ^M
Warning:^M
Cannot insert breakpoint 1.^M
Cannot access memory at address 0x88e^M
^M
(gdb) FAIL: gdb.base/eh_return.exp: hit breakpoint
...
The problem is that gdb does not support setting breakpoints on unrelocated
addresses.
Fix this by using nopie for the test-case.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-08-31 Tom de Vries <tdevries@suse.de>
* gdb.base/eh_return.exp: Use nopie.
Cooper Qu [Mon, 31 Aug 2020 03:27:54 +0000 (11:27 +0800)]
CSKY: Refine operand format error reporting.
Rename SET_ERROR_NUMBER to SET_ERROR_STRING, and add SET_ERROR_INTEGER
to report error message which pass an integer argument.
gas/
* config/tc-csky.c (csky_error_state): New member 'arg_int'.
(SET_ERROR_NUMBER): Rename to SET_ERROR_STRING.
(SET_ERROR_INTEGER): New.
(err_formats): Add error format for ERROR_FREG_OVER_RANGE and
ERROR_VREG_OVER_RANGE.
(csky_show_error): Pass an integer argument for some error
numbers.
(parse_exp): Call SET_ERROR_STRING instead of SET_ERROR_NUMBER.
(parse_rt): Likewise.
(parse_type_ctrlreg): Likewise.
(csky_get_reg_val): Likewise.
(is_reglist_legal): Likewise.
(is_freglist_legal): Likewise.
(is_reglist_dash_comma_legal): Likewise.
(is_reg_lshift_illegal): Likewise.
(is_psr_bit): Likewise.
(parse_type_cpreg): Likewise.
(parse_type_cpcreg): Likewise.
(parse_type_areg): Likewise.
(parse_type_freg): Likewise.
(parse_ldst_imm): Likewise and call SET_ERROR_INTEGER.
(get_operand_value): Likewise.
(parse_operands_op): Likewise and call is_imm_within_range,
is_imm_within_range_ext and is_oimm_within_range.
(md_assemble): Likewise.
(is_imm_within_range): New.
(is_imm_within_range_ext): Rename from is_imm_over_range.
(is_oimm_within_range): Rename from is_oimm_over_range.
(v2_work_add_sub): Call SET_ERROR_INTEGER.
(csky_rolc): call is_imm_within_range instead of
is_imm_over_range.
opcodes/
* csky-dis.c (csky_output_operand): Assign dis_info.value for
OPRND_TYPE_VREG.
Cooper Qu [Mon, 31 Aug 2020 02:55:06 +0000 (10:55 +0800)]
CSKY: Add warning when -mdsp and -mcpu=ck803ern are both added.
gas/
* config/tc-csky.c (md_begin): Add warning when -mdsp and
-mcpu=ck803ern are both added.
(parse_ldst_imm): Fix error message.
GDB Administrator [Mon, 31 Aug 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sun, 30 Aug 2020 14:27:02 +0000 (07:27 -0700)]
ld: Add $NOSANTIZE_CFLAGS to more linker tests
* testsuite/ld-elf/dwarf.exp: Append $NOSANTIZE_CFLAGS to CFLAGS.
* testsuite/ld-elf/shared.exp: Likewise.
* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
* testsuite/ld-shared/shared.exp: Likewise.
* testsuite/ld-size/size.exp: Likewise.
Alan Modra [Sun, 30 Aug 2020 13:29:13 +0000 (22:59 +0930)]
changelog PR fix
for the lack of a space
Alan Modra [Sun, 30 Aug 2020 10:57:27 +0000 (20:27 +0930)]
readelf: ubsan: shift exponent 32 is too large
When compiled on a 32-bit host, a temp var is too small for possible
64-bit values to be calculated.
* readelf.c (print_gnu_build_attribute_name): Make "bytes"
unsigned long long.
Alan Modra [Sun, 30 Aug 2020 10:10:31 +0000 (19:40 +0930)]
cr16 disassembly error of disp20 fields
When looking at the UB errors, I noticed that cbitb_test.d disassembly
wasn't reproducing the input assembly. That turned out to be an error
in make_argument case arg_cr. This fixes that and makes some general
tidies.
opcodes/
* cr16-dis.c: Formatting.
(parameter): Delete struct typedef. Use dwordU instead
throughout file.
(make_argument <arg_idxr>): Simplify detection of cbitb, sbitb
and tbitb.
(make_argument <arg_cr>): Extract 20-bit field not 16-bit.
gas/
* testsuite/gas/cr16/cbitb_test.d: Update expected output.
* testsuite/gas/cr16/cbitw_test.d: Likewise.
* testsuite/gas/cr16/sbitb_test.d: Likewise.
* testsuite/gas/cr16/sbitw_test.d: Likewise.
* testsuite/gas/cr16/storb_test.d: Likewise.
* testsuite/gas/cr16/storw_test.d: Likewise.
* testsuite/gas/cr16/tbitb_test.d: Likewise.
* testsuite/gas/cr16/tbitw_test.d: Likewise.
Alan Modra [Sun, 30 Aug 2020 10:07:57 +0000 (19:37 +0930)]
PR26437, PR26438 UBSAN: tc-cr16.c left shifts and overflows
Always use unsigned constants in expressions generating masks. The
following trys mightily to avoid UB (but hits it anyway with bits=32
and 0x7fffffff << 1), and worse, for 32-bit int, 64-bit long, bits=32
doesn't generate 0xffffffff.
max = ((((1 << (bits - 1)) - 1) << 1) | 1);
results in -1, or max = 0xffffffffffffffff.
This patch fixes that problem, a possible shift exponent of -1U,
removes some dead code, and makes general tidies.
PR26437
PR26438
* config/tc-cr16.c: Include limits.h, formatting.
(CR16_PRINT): Wrap params in parentheses. Remove parens from uses
throughout file.
(getconstant): Handle zero nbits.
(print_operand): Simplify handling of index regs.
(check_range): Use int32_t variables. Correct range checks.
Alan Modra [Sun, 30 Aug 2020 10:07:15 +0000 (19:37 +0930)]
PR26435, PR26436 UBSAN: elf32-cr16.c:928 left shift
PR 26435
PR 26436
* elf32-cr16.c (cr16_elf_final_link_relocate): Calculate reloc_bits
without undefined behaviour.
GDB Administrator [Sun, 30 Aug 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
Nick Clifton [Sat, 29 Aug 2020 07:03:15 +0000 (08:03 +0100)]
Include members in the variable table used when resolving DW_AT_specification tags.
PR 26520
* dwarf2.c (scan_unit_for_symbols): Add member entries to the
variable table.
Alan Modra [Sat, 29 Aug 2020 04:27:27 +0000 (13:57 +0930)]
correct pr number in changelog
Alan Modra [Sat, 29 Aug 2020 01:40:54 +0000 (11:10 +0930)]
PR26446 UBSAN: tc-csky.c:2618,4022 index out of bounds
PR 26446
* csky-opc.h (MAX_OPRND_NUM): Define to 5.
(union csky_operand): Use MAX_OPRND_NUM to size oprnds array.
Alan Modra [Sat, 29 Aug 2020 01:16:59 +0000 (10:46 +0930)]
PR26481 UBSAN: tc-pj.c:281 index out of bounds
PR 26481
* config/tc-pj.c (md_assemble): Don't loop past end of
opcode->arg array.
Alan Modra [Sat, 29 Aug 2020 01:00:07 +0000 (10:30 +0930)]
PR26459 UBSAN: elfnn-ia64.c:1945 null pointer bsearch
PR 26495
* elfnn-ia64.c (get_dyn_sym_info): Don't bsearch or look at last
element when count is zero. bfd_realloc when shrinking.
GDB Administrator [Sat, 29 Aug 2020 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Fri, 28 Aug 2020 23:11:35 +0000 (00:11 +0100)]
Adjust "maint info program-spaces" to per-inferior target stack
By inspection, I noticed that print_program_space is calling
target_pid_to_str on the wrong target stack. Most targets print a
process pid the same way, so it isn't actually visible.
gdb/ChangeLog:
* progspace.c (print_program_space): Use all_inferiors. Switch to
the inferior before calling target_pid_to_str.
Pedro Alves [Fri, 28 Aug 2020 17:44:39 +0000 (18:44 +0100)]
Fix gdb.base/advance-until-multiple-locations.exp with some compilers
The tests in gdb.base/advance-until-multiple-locations.exp that expect
the program to stop at a caller fail on some systems, depending on
compiler. E.g., with Clang 10, I see:
advance ovld_func
0x00000000004011a3 in test () at /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.base/advance-until-multiple-locations.cc:51
51 ovld_func ();
(gdb) FAIL: gdb.base/advance-until-multiple-locations.exp: advance_overload: second advance stops at caller
And Tom de Vries saw:
...
(gdb) until ovld_func^M
main () at advance-until-multiple-locations.cc:61^M
61 }^M
(gdb) FAIL: gdb.base/advance-until-multiple-locations.exp:until_overload: until ovld_func
...
Which exact line the program stops is not important. All we care
about here is that the program stopped at the caller function.
So fix it by adjusting the patterns to match the frame header/function
reported by the breakpoint hits instead of the source lines text.
Tested against:
- gcc {4.8, 4.9, 7.3.1, 9.3.0, trunk-
20200828}
- clang {5.0.2, 10}
gdb/testsuite/ChangeLog:
* gdb.base/advance-until-multiple-locations.exp
(advance_overload, until_overload): Adjust to match the
frame/function header instead of the source line text.
Tom Tromey [Fri, 28 Aug 2020 17:07:36 +0000 (11:07 -0600)]
Fix two out-of-date comments
While looking at psymtabs again, I noticed a couple of outdated
comments. These days, psymtabs can be destroyed, as they are no
longer obstack-allocated.
gdb/ChangeLog
2020-08-28 Tom Tromey <tom@tromey.com>
* xcoffread.c (xcoff_end_psymtab): Update comment.
* dbxread.c (dbx_end_psymtab): Update comment.
Nick Clifton [Fri, 28 Aug 2020 15:04:49 +0000 (16:04 +0100)]
Fix a bogus error message from the DWARF LEB129 decoder when trying to read a signed LEB128 value containing the largest possible signed negative integer value.
PR 26548
* dwarf.c (read_leb128): When checking for overflow of a signed
read, use a signed shift.
Alan Modra [Fri, 28 Aug 2020 14:13:16 +0000 (23:43 +0930)]
PR26449, PR26450 UBSAN: frv-ibld.c:135 left shift
Eh well, I guess the code didn't quite live up to the comment.
PR 26449
PR 26450
* cgen-ibld.in (insert_1): Use 1UL in forming mask.
(extract_normal): Likewise.
(insert_normal): Likewise, and move past zero length test.
(put_insn_int_value): Handle mask for zero length, use 1UL.
* bpf-ibld.c, * epiphany-ibld.c, * fr30-ibld.c, * frv-ibld.c,
* ip2k-ibld.c, * iq2000-ibld.c, * lm32-ibld.c, * m32c-ibld.c,
* m32r-ibld.c, * mep-ibld.c, * mt-ibld.c, * or1k-ibld.c,
* xc16x-ibld.c, * xstormy16-ibld.c: Regenerate.
Alan Modra [Fri, 28 Aug 2020 13:39:29 +0000 (23:09 +0930)]
PR26460 UBSAN: tc-ia64.c:6107 index out of bounds
PR 26460
* config/tc-ia64.c (parse_operands): Don't access past end of
idesc->operands.
Alan Modra [Fri, 28 Aug 2020 13:36:47 +0000 (23:06 +0930)]
PR26418 UBSAN: cache.c:386 null pointer fwrite
And some more.
PR 26418
* ecofflink.c (bfd_ecoff_write_accumulated_debug): Don't write
zero size buffers.
Mark Wielaard [Wed, 26 Aug 2020 19:46:04 +0000 (21:46 +0200)]
gas: Handle bad -gdwarf options, just like bad --gdwarf options.
parse_args uses getopt_long_only so it can handle long options both
with double and single dash. But this means that some single dash
options like -gdwarf-1 don't generate an error (unlike --gdwarf-1).
This is especially confusing since there is also --gdwarf2, but no
--gdwarf4 (it is --gdwarf-4). When giving -gdwarf4 the option is
silently interpreted as -g (which set dwarf_version to 2). This causes
some confusion for people who don't expect this and suddenly get
DWARF2 instead of DWARF4 as they might expect.
So make it so that the -gdwarf<unknown> creates an error, just like
--gdwarf<unknown> would.
Jozef Lawrynowicz [Fri, 28 Aug 2020 12:56:53 +0000 (13:56 +0100)]
MSP430: Fix alignment of __*_array_start symbols in default linker script
__{preinit,init,fini}_array_start symbols must be word aligned in
linker scripts. If the section preceding the __*_array_start symbol
has an odd size, then a NULL byte will be present between the start
symbol and the .*_array section itself, when the section gets
automatically word-aligned.
This results in a branch to an invalid address when the CRT startup
code tries to run through the functions listed in the array sections.
Some MSP430 linker scripts do not align the __*_array start symbols, so
this added warning will catch that problem and help the user avoid
the potential incorrect execution of the program.
ld/ChangeLog:
* emultempl/msp430.em (input_section_exists): New.
(check_array_section_alignment): New.
(gld${EMULATION_NAME}_finish): New.
* scripttempl/elf32msp430.sc: Add ALIGN directives before the
definition of __*_array_start symbols.
* testsuite/ld-msp430-elf/finiarray-warn.ld: New test.
* testsuite/ld-msp430-elf/finiarray-warn.r: New test.
* testsuite/ld-msp430-elf/initarray-nowarn.ld: New test.
* testsuite/ld-msp430-elf/initarray-warn.ld: New test.
* testsuite/ld-msp430-elf/initarray-warn.r: New test.
* testsuite/ld-msp430-elf/initarray.s: New test.
* testsuite/ld-msp430-elf/msp430-elf.exp: Run new tests.
* testsuite/ld-msp430-elf/preinitarray-warn.ld: New test.
* testsuite/ld-msp430-elf/preinitarray-warn.r: New test.
Jozef Lawrynowicz [Fri, 28 Aug 2020 12:56:53 +0000 (13:56 +0100)]
LD: Add new %pU vfinfo format for printing linker script name
The %pT vfinfo format prints the linker script name with a line number,
however sometimes it may be necessary to print the linker script name
without any associated line number.
ld/ChangeLog:
* ldmisc.c (vfinfo): Support new "%pU" format specifier.
Alan Modra [Fri, 28 Aug 2020 12:15:49 +0000 (21:45 +0930)]
PR26418 UBSAN: cache.c:386 null pointer fwrite
The previous "fix" tested the wrong value.
PR 26418
* ecofflink.c (WRITE): Really don't write zero size chunks.
Tuckker [Fri, 28 Aug 2020 12:27:16 +0000 (13:27 +0100)]
Prevent the linker from overestimating the alignment requirement of common symbols on targets with octets that are larger than one byte.
PR 26543
* linker.c (bfd_generic_define_common_symbol): Force the alignment
to 1 if the section has now alignment requirement.
Tom de Vries [Fri, 28 Aug 2020 10:02:20 +0000 (12:02 +0200)]
[gdb/breakpoint] Handle setting breakpoint on label without address
Consider test-case test.c:
...
$ cat test.c
int main (void) {
return 0;
L1:
(void)0;
}
...
Compiled with debug info:
...
$ gcc test.c -g
...
When attempting to set a breakpoint at L1, which is a label without address:
...
<1><f4>: Abbrev Number: 2 (DW_TAG_subprogram)
<f5> DW_AT_name : main
<2><115>: Abbrev Number: 3 (DW_TAG_label)
<116> DW_AT_name : L1
<119> DW_AT_decl_file : 1
<11a> DW_AT_decl_line : 5
<2><11b>: Abbrev Number: 0
...
we run into an internal-error:
...
$ gdb -batch a.out -ex "b main:L1"
linespec.c:3233: internal-error: void \
decode_line_full(const event_location*, int, program_space*, symtab*, \
int, linespec_result*, const char*, const char*): \
Assertion `result.size () == 1 || canonical->pre_expanded' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
...
Fix this by detecting the error condition in decode_line_full instead, and
throwing an error, such that we have instead:
...
(gdb) b main:L1
Location main:L1 not available
(gdb)
...
Unfortunately, to call event_location_to_string, which is used to get the
location name in the error message, we need to pass a non-const struct
event_location, because the call may cache the string in the struct (See
EL_STRING). So, we change the prototype of decode_line_full accordingly, and
everywhere this propages to.
Tested on x86_64-linux.
gdb/ChangeLog:
2020-08-28 Tom de Vries <tdevries@suse.de>
PR breakpoint/26544
* breakpoint.c (parse_breakpoint_sals): Remove const from struct
event_location.
(create_breakpoint): Same.
(base_breakpoint_decode_location): Same.
(bkpt_create_sals_from_location): Same.
(bkpt_decode_location): Same.
(bkpt_probe_create_sals_from_location): Same.
(bkpt_probe_decode_location): Same.
(tracepoint_create_sals_from_location): Same.
(tracepoint_decode_location): Same.
(tracepoint_probe_decode_location): Same.
(strace_marker_create_sals_from_location): Same.
(strace_marker_decode_location): Same.
(create_sals_from_location_default): Same.
(decode_location_default): Same.
* breakpoint.h (struct breakpoint_ops): Same.
(create_breakpoint): Same.
* linespec.h (decode_line_full): Same.
* linespec.c (decode_line_full): Same. Throw error if
result.size () == 0.
gdb/testsuite/ChangeLog:
2020-08-28 Tom de Vries <tdevries@suse.de>
* gdb.base/label-without-address.c: New test.
* gdb.base/label-without-address.exp: New file.
Cooper Qu [Wed, 26 Aug 2020 03:21:14 +0000 (11:21 +0800)]
CSKY: Support attribute section.
bfd
* elf32-csky.c (csky_archs): Fix arch names.
(csky_find_arch_with_name): New.
(elf32_csky_merge_attributes): New.
(csky_elf_merge_private_bfd_data): Add process of merge
attribute section.
(elf32_csky_obj_attrs_arg_type): New.
(elf32_csky_obj_attrs_handle_unknown): New.
(elf_backend_obj_attrs_vendor): Define.
(elf_backend_obj_attrs_section): Define.
(elf_backend_obj_attrs_arg_type): Define.
(elf_backend_obj_attrs_section_type): Define.
binutils/
* readelf.c (get_csky_section_type_name): New.
(get_section_type_name): Add handler for CSKY.
(display_csky_attribute): New.
(process_arch_specific): Add handler for CSKY.
* testsuite/binutils-all/strip-3.d: Remove .csky.attributes
section.
elfcpp/
* elfcpp.h (enum SHT): New enum SHT_CSKY_ATTRIBUTES.
gas/
* gas/config/tc-csky.c (md_begin): Set attributes.
(isa_flag): Change type to unsigned 64 bits.
(struct csky_cpu_info): Likewise.
(struct csky_macro_info): Likewise.
(set_csky_attribute): New.
* testsuite/gas/csky/802j.d: Ignore .csky.attributes section.
* testsuite/gas/csky/all.d: Likewise.
* testsuite/gas/csky/bsr1.d: Likewise.
* testsuite/gas/csky/csky_vdsp.d: Likewise.
* testsuite/gas/csky/cskyv2_all.d: Likewise.
* testsuite/gas/csky/cskyv2_ck803r2.d: Likewise.
* testsuite/gas/csky/cskyv2_ck860.d: Likewise.
* testsuite/gas/csky/cskyv2_dsp.d: Likewise.
* testsuite/gas/csky/cskyv2_elrw.d: Likewise.
* testsuite/gas/csky/cskyv2_float.d: Likewise.
* testsuite/gas/csky/enhance_dsp.d: Likewise.
* testsuite/gas/csky/java.d: Likewise.
* testsuite/gas/csky/v1_float.d: Likewise.
* testsuite/gas/csky/v2_float_part1.d: Likewise.
* testsuite/gas/csky/v2_float_part2.d: Likewise.
* testsuite/gas/csky/v2_tls_gd.d: Likewise.
* testsuite/gas/csky/v2_tls_ie.d: Likewise.
* testsuite/gas/csky/v2_tls_ld.d: Likewise.
* testsuite/gas/csky/v2_tls_le.d: Likewise.
* testsuite/gas/elf/elf.exp: Add handler for CSKY.
* testsuite/gas/elf/section2.e-csky: New.
include/
* elf/csky.h (SHT_CSKY_ATTRIBUTES): Define.
(Tag_CSKY_ARCH_NAME): New enum constant.
(Tag_CSKY_CPU_NAME): Likewise.
(Tag_CSKY_ISA_FLAGS): Likewise.
(Tag_CSKY_DSP_VERSION): Likewise.
(Tag_CSKY_VDSP_VERSION): Likewise.
(Tag_CSKY_FPU_VERSION): Likewise.
(Tag_CSKY_FPU_ABI): Likewise.
(Tag_CSKY_FPU_ROUNDING): Likewise.
(Tag_CSKY_FPU_DENORMAL): Likewise.
(Tag_CSKY_FPU_Exception): Likewise.
(Tag_CSKY_FPU_NUMBER_MODULE): Likewise.
(Tag_CSKY_FPU_HARDFP): Likewise.
(Tag_CSKY_MAX): Likewise.
(VAL_CSKY_DSP_VERSION_EXTENSION): Likewise.
(VAL_CSKY_DSP_VERSION_2): Likewise.
(VAL_CSKY_VDSP_VERSION_1): Likewise.
(VAL_CSKY_VDSP_VERSION_2): Likewise.
(VAL_CSKY_FPU_ABI_SOFT): Likewise.
(VAL_CSKY_FPU_ABI_SOFTFP): Likewise.
(VAL_CSKY_FPU_ABI_HARD): Likewise.
(VAL_CSKY_FPU_HARDFP_HALF): Likewise.
(VAL_CSKY_FPU_HARDFP_SINGLE): Likewise.
(VAL_CSKY_FPU_HARDFP_DOUBLE): Likewise.
* opcode/csky.h (CSKY_ISA_VDSP_V2): Define.
CSKYV1_ISA_E1: Change to long constant type.
CSKYV2_ISA_E1: Likewise.
CSKYV2_ISA_1E2: Likewise.
CSKYV2_ISA_2E3: Likewise.
CSKYV2_ISA_3E7: Likewise.
CSKYV2_ISA_7E10: Likewise.
CSKYV2_ISA_3E3R1: Likewise.
CSKYV2_ISA_3E3R2: Likewise.
CSKYV2_ISA_10E60: Likewise.
CSKY_ISA_TRUST: Likewise.
CSKY_ISA_CACHE: Likewise.
CSKY_ISA_NVIC: Likewise.
CSKY_ISA_CP: Likewise.
CSKY_ISA_MP: Likewise.
CSKY_ISA_MP_1E2: Likewise.
CSKY_ISA_JAVA: Likewise.
CSKY_ISA_MAC: Likewise.
CSKY_ISA_MAC_DSP: Likewise.
CSKY_ISA_DSP: Likewise.
CSKY_ISA_DSP_1E2: Likewise.
CSKY_ISA_DSP_ENHANCE: Likewise.
CSKY_ISA_FLOAT_E1: Likewise.
CSKY_ISA_FLOAT_1E2: Likewise.
CSKY_ISA_FLOAT_1E3: Likewise.
CSKY_ISA_FLOAT_3E4: Likewise.
CSKY_ISA_VDSP: Likewise.
ld/
* emulparams/cskyelf.sh: Support attribute section.
* testsuite/ld-csky/tls-le-v1.d: Match .csky.attributes section.
* ld/testsuite/ld-csky/tls-le.d: Likewise.
* testsuite/ld-elf/non-contiguous.ld: Ignore .csky.attributes
section.
opcodes/
* csky-dis.c (CSKY_DEFAULT_ISA): Define.
(csky_dis_info): Add member isa.
(csky_find_inst_info): Skip instructions that do not belong to
current CPU.
(csky_get_disassembler): Get infomation from attribute section.
(print_insn_csky): Set defualt ISA flag.
* csky.h (CSKY_ISA_VDSP_2): Rename from CSKY_ISA_VDSP_V2.
* csky-opc.h (struct csky_opcode): Change isa_flag16 and
isa_flag32'type to unsigned 64 bits.
Nick Clifton [Fri, 28 Aug 2020 08:43:13 +0000 (09:43 +0100)]
Fixes for testsuite failures introduced by the changes made for PR 19011.
PR19011
bfd * cofflink.c (_bfd_coff_generic_relocate_section): Provide a value
for undefined symbols which will not generate extra warning
messages about truncated relocs.
ld * testsuite/lib/ld-lib.exp (ld_link_defsyms): For PE based targets
define the __main and ___main symbols in terms of the main symbol.
Alan Modra [Fri, 28 Aug 2020 01:21:28 +0000 (10:51 +0930)]
mingw plugin test regressions due to commit
514b4e191d5f
Fixes new failures due to image base change.
PR 19011
* testsuite/ld-plugin/plugin.exp: Use modified CFLAGS throughout
file. Add --image-base for pecoff.
Nelson Chu [Wed, 26 Aug 2020 08:19:13 +0000 (01:19 -0700)]
RISC-V: Treat R_RISCV_CALL and R_RISCV_CALL_PLT as the same in check_relocs.
In fact, we can treate these two relocation as the same one in the
riscv_elf_check_relocs. I have heard that RISC-V lld had made this
improvement, and so had GNU AARCH64, they only need R_AARCH64_CALL26
for calls rather than two seperate relocations.
Beside, the following PLT issue for RISC-V 32-bit glibc seems to be
fixed by applying at least this patch.
<https://sourceware.org/pipermail/libc-alpha/2020-August/117214.html>
I have ran the toolchain regression, and everything seems fine for now.
bfd/
* elfnn-riscv.c (riscv_elf_check_relocs): Treat R_RISCV_CALL
and R_RISCV_CALL_PLT as the same in the riscv_elf_check_relocs.
(riscv_elf_relocate_section): Remove the R_RISCV_CALL for the
unresolved reloc checks.
ld/
testsuite/ld-riscv-elf/lib-nopic-01a.s: Use R_RISCV_JAL rather
than R_RISCV_CALL.
testsuite/ld-riscv-elf/lib-nopic-01b.d: Likewise.
testsuite/ld-riscv-elf/lib-nopic-01b.s: Likewise.
GDB Administrator [Fri, 28 Aug 2020 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Thu, 27 Aug 2020 20:03:53 +0000 (21:03 +0100)]
Fix advance/until and multiple locations (PR gdb/26524)
If you do "advance LINESPEC", and LINESPEC expands to more than one
location, GDB just errors out:
if (sals.size () != 1)
error (_("Couldn't get information on specified line."));
For example, advancing to a line in an inlined function, inlined three
times:
(gdb) b 21
Breakpoint 1 at 0x55555555516f: advance.cc:21. (3 locations)
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
1.1 y 0x000055555555516f in inline_func at advance.cc:21
1.2 y 0x000055555555517e in inline_func at advance.cc:21
1.3 y 0x000055555555518d in inline_func at advance.cc:21
(gdb) advance 21
Couldn't get information on specified line.
(gdb)
Similar issue with the "until" command, as it shares the
implementation with "advance".
Since, as the comment in gdb.base/advance.exp says, "advance <location>"
is really just syntactic sugar for "tbreak <location>;continue",
fix this by making GDB insert a breakpoint at all the resolved
locations.
A new testcase is included, which exercises both "advance" and
"until", in two different cases expanding to multiple locations:
- inlined functions
- C++ overloads
This also exercises the inline frames issue fixed by the previous
patch.
gdb/ChangeLog:
PR gdb/26524
* breakpoint.c (until_break_fsm) <location_breakpoint,
caller_breakpoint>: Delete fields.
<breakpoints>: New field.
<until_break_fsm>: Adjust to save a breakpoint vector instead of
two individual breakpoints.
(until_break_fsm::should_stop): Loop over breakpoints in the
breakpoint vector.
(until_break_fsm::clean_up): Adjust to clear the breakpoints
vector.
(until_break_command): Handle location expanding into multiple
sals.
gdb/testsuite/ChangeLog:
PR gdb/26523
PR gdb/26524
* gdb.base/advance-until-multiple-locations.cc: New.
* gdb.base/advance-until-multiple-locations.exp: New.
Pedro Alves [Thu, 27 Aug 2020 20:03:53 +0000 (21:03 +0100)]
Fix advance/until and inline frames (PR gdb/26523)
If you do "tbreak LINENO; c" to advance to an inlined function, GDB
presents the stop at the inline frame instead of at the non-artificial
stack frame:
(gdb) list 21
18 static inline __attribute__ ((always_inline)) int
19 inline_func (int i)
20 {
21 return i + 1;
22 }
(gdb) tbreak 21
Temporary breakpoint 3 at 0x55555555516f: advance.cc:21.
(gdb) c
Continuing.
Temporary breakpoint 3, inline_func (i=0) at advance.cc:21
21 return i + 1;
The logic for this is in stopped_by_user_bp_inline_frame:
/* Loop over the stop chain and determine if execution stopped in an
inlined frame because of a breakpoint with a user-specified
location set at FRAME_BLOCK. */
static bool
stopped_by_user_bp_inline_frame (const block *frame_block, bpstat stop_chain)
If however, you do "advance LINENO" or "until LINENO" instead, GDB
presents the stop at the non-artificial frame:
(gdb) advance 21
main () at advance.cc:43
43 i = inline_func (i);
(gdb)
"advance" and "until" should really behave like user breakpoints here,
since their location is also user-specified. As the comment in
gdb.base/advance.exp says, "advance <location>" is really just
syntactic sugar for "tbreak <location>; continue".
Fix this by making stopped_by_user_bp_inline_frame also consider
advance/until breakpoints.
A testcase covering this will be included in the next patch.
gdb/ChangeLog:
PR gdb/26523
* inline-frame.c (stopped_by_user_bp_inline_frame): Also consider
bp_until breakpoints user-specified locations. Update intro
comment.
Jozef Lawrynowicz [Thu, 27 Aug 2020 19:48:35 +0000 (20:48 +0100)]
readelf: MSP430: Fix incorrect usage of "msp430x" in function names
The "X" in "MSP430X" indicates an extension to the original MSP430 ISA, but
these functions are generically used for all MSP430 ISAs, so the names should
not use the "X" suffix.
binutils/ChangeLog:
* readelf.c (get_msp430x_section_type_name): Rename to ...
(get_msp430_section_type_name): ... this.
(get_section_type_name): Use get_msp430_section_type_name.
(display_msp430x_attribute): Rename to ...
(display_msp430_attribute): ... this.
(process_arch_specific): Use display_msp430_attribute.
Jozef Lawrynowicz [Thu, 27 Aug 2020 17:17:43 +0000 (18:17 +0100)]
ld/emultempl/msp430.em: Remove unused variable
ld/ChangeLog:
* emultempl/msp430.em: Remove unused variable "buf".
Simon Marchi [Thu, 27 Aug 2020 18:42:12 +0000 (14:42 -0400)]
gdb/testsuite: use multi_line in gdb.dwarf2/dw2-reg-undefined.exp
Use multi_line to make the expected pattern more readable.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-reg-undefined.exp: Use multi_line.
Change-Id: Ia8e42d156c0c30265121eb890e1db17a692dbaf0
Simon Marchi [Thu, 27 Aug 2020 16:54:00 +0000 (12:54 -0400)]
gdb: fix whitespace issues in ChangeLog files
Change-Id: I423867477d4342673e629dac71a80592fd879ea1
Andrew Burgess [Wed, 26 Aug 2020 13:05:45 +0000 (14:05 +0100)]
gdb/testsuite: make test names unique in gdb.arch/*.exp
Make the test names unique in gdb.arch/*.exp by either modifying the
test names or using with_test_prefix.
I have also fixed a typo 'forth' -> 'fourth' throughout gdb.arch/*.
Finally, I replaced code like this:
gdb_test "break [gdb_get_line_number "first breakpoint here"]" \
"Breakpoint .* at .*${srcfile}.*" \
"set first breakpoint in main"
With this:
gdb_breakpoint [gdb_get_line_number "first breakpoint here"]
In those files that I was already modifying for the other reasons
given above.
gdb/testsuite/ChangeLog:
* gdb.arch/amd64-byte.exp: Make test names unique, use
gdb_breakpoint, and fix typo 'forth' -> 'fourth'.
* gdb.arch/amd64-dword.exp: Likewise.
* gdb.arch/amd64-pseudo.c: Fix typo 'forth' -> 'fourth'.
* gdb.arch/amd64-stap-special-operands.exp: Make test names
unique.
* gdb.arch/amd64-tailcall-ret.exp: Likewise.
* gdb.arch/amd64-word.exp: Make test names unique, use
gdb_breakpoint, and fix typo 'forth' -> 'fourth'.
* gdb.arch/i386-byte.exp: Make test names unique, use
gdb_breakpoint.
* gdb.arch/i386-word.exp: Likewise.
John David Anglin [Thu, 27 Aug 2020 15:25:03 +0000 (15:25 +0000)]
Fix PR binutils/26356 on hppa*-*-hpux*.
PR 26356
* som.c (som_bfd_copy_private_section_data): Issue error when a
subspace is specified without its containing space.
* testsuite/binutils-all/objcopy.exp (objcopy --reverse-bytes): Add
"-j $PRIVATE$" to command on hppa*-*-hpux*.
* testsuite/lib/utils-lib.exp (default_binutils_run): Remove existing
dollar-sign quotes before quoting. Do this prior to generating log
output.
Ralf Habacker [Thu, 27 Aug 2020 14:59:53 +0000 (15:59 +0100)]
Corrects the broken line number incrementation in the Windows resource parser
When the tokens MCLINE, MCENDLINE, and MCCOMMENT were created, the
line number was not increased, which led to an incorrect value in
the error output.
PR 26088
* mclex.c (skip_until_eol): if eol was found, increment line number
Simon Marchi [Thu, 27 Aug 2020 12:58:43 +0000 (08:58 -0400)]
gdb: add gdb_bfd_sections for range-based iteration
I wanted to make a nicer / type-safe interface for
bfd_map_over_sections, avoiding the `void *` data parameter.
My first shot was to make a wrapper for bfd_map_over_sections,
gdb_bfd_map_over_sections that took a gdb::function_view.
However, I think that a range adapter gives nicer and simpler code, as a
simple for loop is easier to read than a callback / lambda function. So
here it is, it uses next_iterator and next_adapter, so it's not much
code.
As an example, I ported maintenance_info_sections and friends to use it.
The maint_print_section_data type could probably be removed now, but I
didn't want to do too much in one patch.
gdb/ChangeLog:
* gdb_bfd.h (gdb_bfd_section_iterator, gdb_bfd_section_range,
gdb_bfd_sections): New.
* maint.c (print_bfd_section_info): Change param type to
maint_print_section_data.
(print_objfile_section_info): Likewise.
(print_bfd_section_info_maybe_relocated): Likewise.
(maintenance_info_sections): Use gdb_bfd_sections.
Change-Id: Ib496f6b0a0eb7aadb10da1dd381304014d934ea0
Nick Clifton [Thu, 27 Aug 2020 12:52:45 +0000 (13:52 +0100)]
Nick Clifton [Thu, 27 Aug 2020 12:47:02 +0000 (13:47 +0100)]
Fix linker testcase for alpha-linux affected by fix for PR 26416
PR 26416
* testsuite/ld-alpha/tlsbinr.rd: Update expected output.
* testsuite/ld-alpha/tlsbinr.dd: Likewise.
* testsuite/ld-alpha/tlsbinr.sd: Likewise.
Alan Modra [Thu, 27 Aug 2020 12:14:41 +0000 (21:44 +0930)]
PR26469 UBSAN: elflink.c:8742 shift exponent
6148914691236511722
PR 26469
* elflink.c: Include limits.h.
(CHAR_BIT): Provide fallback define.
(set_symbol_value): Correct complex reloc comment.
(undefined_reference): Set bfd_error.
(BINARY_OP_HEAD, BINARY_OP_TAIL): Split out from..
(BINARY_OP): ..this.
(eval_symbol): Limit shifts. Force unsigned for left shift.
Catch divide by zero.
* configure.ac (AC_CHECK_HEADERS): Combine, sort and add limits.h.
* configure: Regenerate.
* config.in: Regenerate.
Alan Modra [Thu, 27 Aug 2020 04:16:45 +0000 (13:46 +0930)]
PR26467 UBSAN: cgen.c:762 shift exponent
18446744073709551615
PR 26467
* cgen.c (weak_operand_overflow_check): Handle opmask for
operand length zero. Use 1UL constant.
Alan Modra [Thu, 27 Aug 2020 03:55:31 +0000 (13:25 +0930)]
PR26462 UBSAN: reloc.c:473 shift exponent
4294967295
PR 26462
* reloc.c (bfd_check_overflow): Return early if zero bitsize.
Alan Modra [Thu, 27 Aug 2020 03:20:20 +0000 (12:50 +0930)]
arm-symbianelf segfault
Yes, the target is marked obsolete due to this and other segfaults,
but this one is easy enough to fix.
* elf32-arm.c (elf32_arm_final_link_relocate): Don't segfault
on sym_sec not being output.
Alan Modra [Thu, 27 Aug 2020 12:24:16 +0000 (21:54 +0930)]
Re: commit
eae0b5c3b2d6b
PR 26416
* elf64-alpha.c (elf64_alpha_relax_tls_get_addr): Correct "dynamic".
Nick Alcock [Wed, 29 Jul 2020 12:50:10 +0000 (13:50 +0100)]
binutils, ld: dequote libctf error messages
These are not identifiers and should not be quoted. (Also, quoting them
just looks odd.)
Adjust diagnostics tests accordingly.
binutils/ChangeLog
2020-08-27 Nick Alcock <nick.alcock@oracle.com>
* objdump.c (dump_ctf_errs): Unquote CTF error messages.
* readelf.c (dump_ctf_errs): Likewise.
ld/ChangeLog
2020-08-27 Nick Alcock <nick.alcock@oracle.com>
* ldlang.c (dump_ctf_errs): Unquote CTF error messages.
(ldlang_open_ctf): Likewise.
(lang_merge_ctf): Likewise.
(lang_write_ctf): Likewise.
* testsuite/ld-ctf/diag-ctf-version-f.d: Adjust.
* testsuite/ld-ctf/diag-cttname-invalid.d: Adjust.
* testsuite/ld-ctf/diag-decompression-failure.d: Adjust.
* testsuite/ld-ctf/diag-parname.d: Adjust.
* testsuite/ld-ctf/diag-unsupported-flag.d: Adjust.
* testsuite/ld-ctf/diag-wrong-magic-number-mixed.d: Adjust.
* testsuite/ld-ctf/diag-wrong-magic-number.d: Adjust.