This fixes a segfault when macro definitions end on the last line of a
file, and that line isn't properly terminated with a newline. gas
used to throw away the last line in cases like this, whereas in other
cases gas added the missing newline. So I've also made gas
consistently provide a missing newline.
PR gas/18687
* input-scrub.c (input_scrub_next_buffer): Rearrange and simplify
loop. Don't drop lines at end of file lacking a newline, add a
newline instead. Ensure partial_size is zero whenever
partial_where is NULL. Adjust buffer size for extra char.
(input_scrub_push, input_scrub_begin): Adjust buffer size here too.
GCC 5 will fold symbol address comparison, assuming each symbol has a
different address, which leads to abort. We should use separate
functions to compare symbol address.
PR gold/18663
* testsuite/Makefile.am (script_test_1_SOURCES): Set to
script_test_1a.cc script_test_1b.cc.
(script_test_11_r.o): Replace script_test_11.o with
script_test_11a.o script_test_11b.o.
(script_test_11.o): Removed.
(script_test_11a.o): New.
(script_test_11b.o): Likewise.
* testsuite/Makefile.in: Regenerated.
* testsuite/script_test_1.h: New file.
* testsuite/script_test_1b.cc: Likewise.
* testsuite/script_test_11.h: Likewise.
* testsuite/script_test_11b.c: Likewise.
* testsuite/script_test_1.cc: Renamed to ...
* testsuite/script_test_1a.cc: This.
Include "script_test_1.h".
(main): Call check_int and check_ptr.
* testsuite/script_test_11.c: Renamed to ...
* testsuite/script_test_11a.c: This.
Include "script_test_11.h".
(main): Call ptr_equal.
GCC 5 will generate a relocation for protected symbol:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248
when compiling for a shared library. It is undefined to access protected
symbol in IFUNC selector function inside a shared library.
PR gold/18628
* testsuite/ifuncdep2.c (global): Change protected to hidden.
* testsuite/ifuncmod1.c (global): Likewise.
* testsuite/ifuncmod5.c (global): Likewise.
Bogus assembly can hit an assertion in opd_entry_value when the symbol
referenced by a function descriptor is undefined. Worse, the code
after the assert copies unitialised memory to return the code section.
This uninitialised pointer can later be dereferencd, possibly causing
a linker segmentation fault.
* elf64-ppc.c (opd_entry_value): Remove assertion. Instead,
return -1 if symbol referenced is not defined. Tidy.
When creating the special __start_ and __stop_ section symbols, gold
does not check the version script to see if they should be local
instead of global.
2015-07-21 Cary Coutant <ccoutant@gmail.com>
gold/
PR gold/18548
* symtab.cc (Symbol_table::do_define_in_output_data): Check for
forced local symbol even when oldsym != NULL.
(Symbol_table::do_define_in_output_segment): Likewise.
(Symbol_table::do_define_as_constant): Likewise.
Fix internal error when linking an archive library with no preceding objects.
gold/
PR gold/18698
* archive.cc (Library_base::should_include_member): Don't use entry
point for relocatable links, or if target is not yet valid.
* parameters.cc (Parameters::entry): Check target_valid().
gold/
PR gold/18696
* archive.cc (Library_base::should_include_member): Don't use entry
point for relocatable links, or if target is not yet valid.
* parameters.cc (Parameters::entry): Check target_valid().
There are also some duplication on getting HW watchpoint/breakpoint
registers info between GDB and GDBserver. This patch moves them
to nat/aarch64-linux-hw-point.c.
Note that ENABLE_NLS is not defined in GDBserver, so it should be OK
to use _( markup.
gdb:
2015-07-21 Yao Qi <yao.qi@linaro.org>
* aarch64-linux-nat.c (aarch64_linux_get_debug_reg_capacity):
Move it to nat/aarch64-linux-hw-point.c.
(aarch64_linux_child_post_startup_inferior): Update.
* nat/aarch64-linux-hw-point.c (aarch64_linux_get_debug_reg_capacity):
New function.
* nat/aarch64-linux-hw-point.h (aarch64_linux_get_debug_reg_capacity):
Declare it.
gdb/gdbserver:
2015-07-21 Yao Qi <yao.qi@linaro.org>
* linux-aarch64-low.c (aarch64_arch_setup): Remove code and call
aarch64_linux_get_debug_reg_capacity.
Since multi_line was moved to gdb.exp in a slightly stricter form,
The gdb.ada/info_exc.exp:info exceptions test has been failing.
This is because it now expects a new-line sequence at the end of
each argument given to multi_line, including ".*". But the intent
when writing the test was to signify "could-be-nothing-at-all".
As a result, the test fails on x86_64-linux with a runtime built as
recommended, because of that
extra new-line sequence.
gdb/testsuite/ChangeLog:
* gdb.ada/info_exc.exp: Adjust "info exceptions" expected output.
gold/ChangeLog:
* aarch64.cc (AArch64_insn_utilities::is_adr): New method.
(AArch64_insn_utilities::aarch64_adr_encode_imm): New method.
(AArch64_insn_utilities::aarch64_adrp_decode_imm): New method.
(E843419_stub): New sub-class of Erratum_stub.
(AArch64_relobj::try_fix_erratum_843419_optimized): New method.
(AArch64_relobj::section_needs_reloc_stub_scanning): Try optimized fix.
(AArch64_relobj::create_erratum_stub): Add 1 argument.
(Target_aarch64::scan_erratum_843419_span): Pass in adrp insn offset.
For relocatable link, we should clear the SHF_COMPRESSED flag bit from
input group section.
PR gold/18689
* layout.cc (Layout::layout): Clear the SHF_COMPRESSED flag bit
from input group section for relocatable link.
* testsuite/Makefile.am (check_SCRIPTS): Add pr18689.sh.
(check_DATA): Add pr18689.stdout.
(MOSTLYCLEANFILES): Add pr18689a.o pr18689b.o.
(pr18689.stdout): New rule.
(pr18689a.o): Likewise.
(pr18689b.o): Likewise.
(pr18689.o): Likewise.
* testsuite/pr18689.c: New file.
* testsuite/pr18689.sh: Likewise.
* testsuite/Makefile.in: Regenerated.
This patch is to fix two ARI warnings for nat/aarch64-linux-hw-point.{c,h}.
gdb:
2015-07-20 Yao Qi <yao.qi@linaro.org>
* nat/aarch64-linux-hw-point.c (aarch64_handle_unaligned_watchpoint):
Re-indent the code.
* nat/aarch64-linux-hw-point.h: Use ULONGEST rather than
"unsigned long long".
We used to generate abort messages like:
internal error, aborting at .../bfd/elf64-x86-64.c line 1554 in elf_x86_64_check_relocs
We can't cut and paste "file line ???" to GDB. This patch changes those
abort messages to
internal error, aborting at .../bfd/elf64-x86-64.c:1554 in elf_x86_64_check_relocs
so that we can cut and paste "file:???" to GDB.
bfd/
* bfd.c (_bfd_abort): Replace " line " with ":" in output
message.
gas/
* messages.c (as_assert): Replace " line " with ":" in output
message.
(as_abort): Likewise.
ld/
* ldmisc.c (ld_abort): Replace " line " with ":" in output
message.
More fallout from a2c59f28. This one could have been fixed by simply
using ". = ALIGN (ABSOLUTE (.), 2);" but it's nicer to align the
section.
* emulparams/criself.sh (INIT_ADDR, FINI_ADDR): Define.
(INIT_START, FINI_START): Don't ALIGN.
* scriptempl/elf.sc (.init, .fini): Apply INIT_ADDR/FINI_ADDR.
a2c59f28 changed the way the unary ALIGN behaved inside output sections,
resulting in cris-elf testsuite regressions. This patch pads out .bss
in the same manner as it was prior to the ALIGN change.
* scripttempl/elf.sc (.ldata, .bss): Align absolute value of dot.
* ldexp.c (is_align_conditional): Handle binary ALIGN.
(exp_fold_tree_1): Move code setting SEC_KEEP for assignments to
dot inside output sections. Handle absolute expressions.
GDB already allows statically initialized variables, located in
SEC_LOAD sections, to be placed at address 0. This change allows
uninitialized variables (which are in SEC_ALLOC sections) to be placed
address 0 as well.
gdb/ChangeLog:
* dwarf2read.c (dwarf2_locate_sections): Allow has_section_at_zero
to be set for SEC_ALLOC sections too.
When I look at test fails related to watchpoint on aarch64-linux,
I find there are some code duplicates between GDB and GDBserver.
This patch is to move some of them to a nat/aarch64-linux-hw-point.{h,c}.
The only change I do is about the dr_changed_t typedef, which was
ULONGEST in GDB and 'unsigned long long' in GDBserver. Each bit
of dr_changed_t represents a status of each HW breakpoint or
watchpoint register, and the max number of HW breakpoint or watchpoint
registers is 16, so the width of 'unsigned long long' is sufficient.
gdb:
2015-07-17 Yao Qi <yao.qi@linaro.org>
* Makefile.in (HFILES_NO_SRCDIR): Add
nat/aarch64-linux-hw-point.h.
(aarch64-linux-hw-point.o): New rule.
* nat/aarch64-linux-hw-point.h: New file.
* nat/aarch64-linux-hw-point.c: New file.
* aarch64-linux-nat.c: Include nat/aarch64-linux-hw-point.h.
(AARCH64_HBP_MAX_NUM): Move to nat/aarch64-linux-hw-point.h.
(AARCH64_HWP_MAX_NUM, AARCH64_HBP_ALIGNMENT): Likewise.
(AARCH64_HWP_ALIGNMENT): Likewise.
(AARCH64_HWP_MAX_LEN_PER_REG): Likewise.
(AARCH64_DEBUG_NUM_SLOTS, AARCH64_DEBUG_ARCH): Likewise.
(AARCH64_DEBUG_ARCH_V8, DR_MARK_ALL_CHANGED): Likewise.
(DR_MARK_N_CHANGED, DR_CLEAR_CHANGED): Likewise.
(DR_HAS_CHANGED, DR_N_HAS_CHANGE): Likewise.
(aarch64_num_bp_regs, aarch64_num_wp_regs): Likewise.
(struct aarch64_debug_reg_state): Likewise.
(struct arch_lwp_info): Likewise.
(aarch64_linux_set_debug_regs): Likewise.
(aarch64_notify_debug_reg_change): Remove static.
(aarch64_align_watchpoint): Likewise.
(DR_CONTROL_ENABLED, DR_CONTROL_LENGTH): Likewise.
(aarch64_watchpoint_length): Likewise.
(aarch64_point_encode_ctrl_reg): Likewise
(aarch64_point_is_aligned): Likewise.
(aarch64_dr_state_insert_one_point): Likewise.
(aarch64_dr_state_remove_one_point): Likewise.
(aarch64_handle_breakpoint): Likewise.
(aarch64_handle_aligned_watchpoint): Likewise.
(aarch64_handle_unaligned_watchpoint): Likewise.
(aarch64_handle_watchpoint): Likewise.
* config/aarch64/linux.mh (NAT_FILE): Add
aarch64-linux-hw-point.o.
gdb/gdbserver:
2015-07-17 Yao Qi <yao.qi@linaro.org>
* Makefile.in (aarch64-linux-hw-point.o): New rule.
* configure.srv (srv_tgtobj): Append aarch64-linux-hw-point.o.
* linux-aarch64-low.c: Include nat/aarch64-linux-hw-point.h.
(AARCH64_HBP_MAX_NUM): Move to nat/aarch64-linux-hw-point.h.
(AARCH64_HWP_MAX_NUM, AARCH64_HBP_ALIGNMENT): Likewise.
(AARCH64_HWP_ALIGNMENT): Likewise.
(AARCH64_HWP_MAX_LEN_PER_REG): Likewise.
(AARCH64_DEBUG_NUM_SLOTS, AARCH64_DEBUG_ARCH): Likewise.
(aarch64_num_bp_regs, aarch64_num_wp_regs): Likewise.
(AARCH64_DEBUG_ARCH_V8, DR_MARK_ALL_CHANGED): Likewise.
(DR_MARK_N_CHANGED, DR_CLEAR_CHANGED): Likewise.
(DR_HAS_CHANGED, DR_N_HAS_CHANGE): Likewise.
(struct aarch64_debug_reg_state): Likewise.
(struct arch_lwp_info): Likewise.
(aarch64_align_watchpoint): Likewise.
(DR_CONTROL_ENABLED, DR_CONTROL_LENGTH): Likewise.
(aarch64_watchpoint_length): Likewise.
(aarch64_point_encode_ctrl_reg): Likewise
(aarch64_point_is_aligned): Likewise.
(aarch64_align_watchpoint): Likewise.
(aarch64_linux_set_debug_regs):
(aarch64_dr_state_insert_one_point): Likewise.
(aarch64_dr_state_remove_one_point): Likewise.
(aarch64_handle_breakpoint): Likewise.
(aarch64_handle_aligned_watchpoint): Likewise.
(aarch64_handle_unaligned_watchpoint): Likewise.
(aarch64_handle_watchpoint): Likewise.
Some functions on handling HW watchpoint in GDB and GDBserver looks the
same except the code getting debug register state from current inferior.
In GDB, we get debug register state like this:
state = aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
while in GDBserver, we get debug register state like this:
state = aarch64_get_debug_reg_state ();
This patch is to move two lines above out of some functions, and pass
aarch64_debug_reg_state to these functions, in this way, these functions
are the same, and can be moved to a common place.
gdb:
2015-07-17 Yao Qi <yao.qi@linaro.org>
* aarch64-linux-nat.c (aarch64_handle_breakpoint): Add argument
state and don't call aarch64_get_debug_reg_state. All callers
update.
(aarch64_linux_insert_hw_breakpoint): Call
aarch64_get_debug_reg_state earlier.
(aarch64_linux_remove_hw_breakpoint): Likewise.
(aarch64_handle_aligned_watchpoint): Add argument state and
don't call aarch64_get_debug_reg_state. All callers update.
(aarch64_handle_unaligned_watchpoint): Likewise.
(aarch64_handle_watchpoint): Add argument state.
(aarch64_linux_insert_watchpoint): Call aarch64_get_debug_reg_state
earlier.
(aarch64_linux_remove_watchpoint): Likewise.
gdb/gdbserver:
2015-07-17 Yao Qi <yao.qi@linaro.org>
* linux-aarch64-low.c (aarch64_handle_breakpoint): Add argument state
and don't aarch64_get_debug_reg_state. All callers update.
(aarch64_handle_aligned_watchpoint): Likewise.
(aarch64_handle_unaligned_watchpoint): Likewise.
(aarch64_handle_watchpoint): Likewise.
(aarch64_insert_point): Call aarch64_get_debug_reg_state earlier.
(aarch64_remove_point): Likewise.
Some functions in aarch64-linux-nat.c and linux-aarch64-low.c looks
the same except for the code printing debug message. In GDB, we use
fprintf_unfiltered (gdb_stdlog, ...) while in GDBserver, we use
fprintf (stderr, ...). This patch is to change them to use debug_printf
so that these functions are the same, and I can move them to a common
place in the following patch.
gdb:
2015-07-17 Yao Qi <yao.qi@linaro.org>
* aarch64-linux-nat.c (aarch64_show_debug_reg_state): Use
debug_printf.
(aarch64_handle_unaligned_watchpoint): Likewise.
gdb/gdbserver:
2015-07-17 Yao Qi <yao.qi@linaro.org>
* linux-aarch64-low.c (aarch64_show_debug_reg_state): Use
debug_printf.
(aarch64_handle_unaligned_watchpoint): Likewise.
This patch is to use 'enum target_hw_bp_type' instead of int for
breakpoint type, in order to make some functions in GDB and
GDBserver looks similar.
gdb:
2015-07-17 Yao Qi <yao.qi@linaro.org>
* aarch64-linux-nat.c (aarch64_dr_state_insert_one_point): Change
argument type's type to 'enum target_hw_bp_type'.
(aarch64_dr_state_remove_one_point): Likewise.
(aarch64_handle_breakpoint): Likewise.
(aarch64_linux_insert_hw_breakpoint): Likewise.
(aarch64_linux_remove_hw_breakpoint): Likewise.
(aarch64_handle_aligned_watchpoint): Likewise.
aarch64_linux_get_debug_reg_capacity is called by
aarch64_linux_child_post_startup_inferior, and argument ptid is created in
inf-ptrace.c:inf_ptrace_create_inferior,
/* On some targets, there must be some explicit actions taken after
the inferior has been started up. */
target_post_startup_inferior (pid_to_ptid (pid));
so in aarch64_linux_get_debug_reg_capacity, we can get pid by ptid_get_pid,
and don't need to use get_thread_id.
gdb:
2015-07-17 Yao Qi <yao.qi@linaro.org>
* aarch64-linux-nat.c (aarch64_linux_get_debug_reg_capacity): Call
ptid_get_pid instead of get_thread_id.
We did a code refacotr here
https://sourceware.org/ml/gdb-patches/2013-11/msg00063.html
> (get_current_thread): New function, factored out from ...
> (add_current_inferior_and_thread): ... this. Adjust.
>
>@@ -3332,18 +3371,8 @@ add_current_inferior_and_thread (char *wait_status)
>
> inferior_ptid = null_ptid;
>
>- /* Now, if we have thread information, update inferior_ptid. First
>- if we have a stop reply handy, maybe it's a T stop reply with a
>- "thread" register we can extract the current thread from. If
>- not, ask the remote which is the current thread, with qC. The
>- former method avoids a roundtrip. Note we don't use
>- remote_parse_stop_reply as that makes use of the target
>- architecture, which we haven't yet fully determined at this
>- point. */
>- if (wait_status != NULL)
>- ptid = stop_reply_extract_thread (wait_status);
>- if (ptid_equal (ptid, null_ptid))
>- ptid = remote_current_thread (inferior_ptid);
>+ /* Now, if we have thread information, update inferior_ptid. */
>+ ptid = get_current_thread (wait_status);
but after the refactor, local variable ptid is used without
initialisation. However, before this change, ptid is initialised to
null_ptid. This error can be found by valgrind too...
==3298== at 0x6B99BA: ptid_equal (ptid.c:80)
==3298== by 0x4C67FF: get_current_thread (remote.c:3484)
==3298== by 0x4C6951: add_current_inferior_and_thread (remote.c:3511)
==3298== by 0x4C762C: extended_remote_create_inferior (remote.c:8506)
==3298== by 0x5A5312: run_command_1 (infcmd.c:606)
==3298== by 0x68B4FB: execute_command (top.c:463)
==3298== by 0x5C7214: command_handler (event-top.c:494)
==3298== by 0x5C78A3: command_line_handler (event-top.c:692)
==3298== by 0x6DEB57: rl_callback_read_char (callback.c:220)
==3298== by 0x5C7278: rl_callback_read_char_wrapper (event-top.c:171)
==3298== by 0x5C72C2: stdin_event_handler (event-top.c:432)
==3298== by 0x5C6194: gdb_wait_for_event (event-loop.c:834)
This patch initialises local variable ptid to null in get_current_thread.
We don't need to initialise ptid in add_current_inferior_and_thread,
so this patch also removes the ptid initialisation.
gdb:
2015-07-17 Yao Qi <yao.qi@linaro.org>
* remote.c (get_current_thread): Initialise ptid to null_ptid.
(add_current_inferior_and_thread): Don't initialise ptid.
This new test fails on i686 buildbot slaves,
(gdb) core-file /home/gdb-buildbot-2/fedora-x86-64-2/fedora-i686/build/gdb/testsuite/gdb.arch/i386-biarch-core.core
"/home/gdb-buildbot-2/fedora-x86-64-2/fedora-i686/build/gdb/testsuite/gdb.arch/i386-biarch-core.core"
is not a core dump: File format not recognized
(gdb) FAIL: gdb.arch/i386-biarch-core.exp: core-file
There are two problems:
(1) The testcase did not really test if elf64-i386 is supported by GDB (BFD).
That was OK for a Fedora testcase but I forgot about it when submitting it
upstream.
I haven't really verified if the GNU target is elf64-little but it seems so,
no other one seems suitable from:
elf32-x86-64
elf64-big
elf64-k1om
elf64-l1om
elf64-little
elf64-x86-64
pei-x86-64
(2) The output of the "core-file" command itself can be arbitrary as the
elf64-i386 file with x86_64 registers is really broken; but that does not
matter much, important is the following test whether core file memory is
readable.
./configure --enable-64-bit-bfd
(gdb) core-file /home/jkratoch/redhat/gdb-test-build32-plus64/gdb/testsuite/gdb.arch/i386-biarch-core.core^M
warning: Couldn't find general-purpose registers in core file.^M
Failed to read a valid object file image from memory.^M
warning: Couldn't find general-purpose registers in core file.^M
#0 <unavailable> in ?? ()^M
(gdb) FAIL: gdb.arch/i386-biarch-core.exp: core-file
x/i 0x400078^M
0x400078: hlt ^M
(gdb) PASS: gdb.arch/i386-biarch-core.exp: .text is readable
I do not know much dejagnu but I expect 'istarget' tests against the site.exp
'target_triplet' content which is set to the primary GDB target
(--target=...).
GDB is normally never configured for primary target elf64-i386, I think BFD
does not know such explicit target, it gets recognized as elf64-little.
In fact many testfiles of the GDB testsuite are wrong as they require
'istarget' (therefore primary GDB target) even for just loading arch specific
files which would be sufficient with secondary target (--enable-targets=...)
support.
This my new patch removes this 'istarget' check as it is IMO unrelated to what
we need to test. Although you are right we do 'x/i' and test for 'hlt' so
I think we should test also for available 'set architecture i386'.
We could also test by 'x/bx' instead of 'x/i' to avoid such additional
test/requirement.
This testcase comes from a different bug from 2009:
https://bugzilla.redhat.com/show_bug.cgi?id=457187http://pkgs.fedoraproject.org/cgit/gdb.git/commit/?id=94cd124608bf0dd359cb48a710800d72c21b30c3
That bug has been fixed in the meantime but the same testcase was reproducing
this new different bug - internal error regression - so I submitted it.
We can remove the "x/bx $address" test but it was useful for the previous bug
from 2009 as that time the internal error regression did not happen, just the
core file was not recognized (which would not be detected by the proposed
ignoring of the "core-file" command output) and so the core file was not
available. That can be tested by the "x/bx $address" test.
gdb/testsuite/ChangeLog
2015-07-16 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.arch/i386-biarch-core.exp: Replace istarget
by "complete set gnutarget". Remove expectation for the "core-file"
command.
opcodes * arm-dis.c (print_insn_coprocessor): Added support for quarter
float bitfield format.
(coprocessor_opcodes): Changed VFP vmov reg,immediate to use new
quarter float bitfield format.
tests * gas/arm/vfpv3-const-conv.d: Update expected result due to change
of comment for vmov reg,immediate with VFP coprocessor.
I noticed two failure in gdb.trace/mi-trace-frame-collected.exp:
FAIL: gdb.trace/mi-trace-frame-collected.exp: live:
-trace-frame-collected (register)
FAIL: gdb.trace/mi-trace-frame-collected.exp: tfile:
-trace-frame-collected (register)
In these cases, we are not collecting registers so the MI command
-trace-frame-collected should only give us the value of the PC.
However, it also gives us all of the single precision pseudo registers,
initialized with 0x0.
We can reproduce this error by simply issuing the
'maint print cooked-register' when no inferior is connected:
~~~
...
(gdb) maint print cooked-register
Name Nr Rel Offset Size Type Cooked value
x0 0 0 0 8 long <unavailable>
x1 1 1 8 8 long <unavailable>
...
d30 130 62 1540 8 *1 <unavailable>
d31 131 63 1548 8 *1 <unavailable>
s0 132 64 1556 4 *1 0x00000000
s1 133 65 1560 4 *1 0x00000000
s2 134 66 1564 4 *1 0x00000000
...
s28 160 92 1668 4 *1 0x00000000
s29 161 93 1672 4 *1 0x00000000
s30 162 94 1676 4 *1 0x00000000
s31 163 95 1680 4 *1 0x00000000
h0 164 96 1684 2 *1 <unavailable>
h1 165 97 1686 2 *1 <unavailable>
h2 166 98 1688 2 *1 <unavailable>
...
~~~
It turns out GDB does not check if S registers are valid before returning
a value for them. It should return <unavailable> in this case.
gdb/ChangeLog:
* aarch64-tdep.c (aarch64_pseudo_read_value): Mark S register as
unavailable if invalid.