This makes gas .cfi output to .debug_frame match register numbering
emitted by gcc. md_reg_eh_frame_to_debug_frame follows the ABI,
targets not using it, notably Linux, don't.
* config/tc-ppc.h (md_reg_eh_frame_to_debug_frame): Match current
gcc behaviour.
* config/te-aix.h: New file.
* configure.tgt: Use em=aix for powerpc-aix.
This makes gdbserver actually provide values for the TDB registers
when the inferior was stopped in a transaction. The change in
linux-low.c is needed to suppress the warning for an unavailable TDB.
The test case 's390-tdbregs.exp' passes with this patch and fails
without.
gdb/gdbserver/ChangeLog:
* linux-low.c (regsets_fetch_inferior_registers): Suppress the
warning upon ENODATA from ptrace.
* linux-s390-low.c (s390_store_tdb): New.
(s390_regsets): Add regset for NT_S390_TDB.
For GNU/Linux targets using the regsets interface, this change
supports regsets that can be read but not written. The S390 "last
break" regset is an example. So far it had been defined with
regset->set_request == PTRACE_GETREGSET, such that the respective
ptrace call does not cause any harm. Now we just skip the whole
read/modify/write sequence for regsets that do not define a
fill_function.
gdb/gdbserver/ChangeLog:
* linux-low.c (regsets_store_inferior_registers): Skip regsets
without a fill_function.
* linux-s390-low.c (s390_fill_last_break): Remove.
(s390_regsets): Set fill_function to NULL for NT_S390_LAST_BREAK.
(s390_arch_setup): Use regset's size instead of fill_function for
loop end condition.
When fetch_inferior_registers does not update all registers, this
patch assures that no stale register values remain in the register
cache. On Linux platforms using the regsets interface, when one of
the ptrace calls used for fetching the register values returns an
error, this patch also avoids copying the random data returned from
ptrace into the register cache. All unfetched registers are marked
"unavailable" instead.
gdb/gdbserver/ChangeLog:
* linux-low.c (regsets_fetch_inferior_registers): Do not invoke
the regset's store function when ptrace returned an error.
* regcache.c (get_thread_regcache): Invalidate register cache
before fetching inferior's registers.
Replace the while-loops in linux-low.c that iterate over regsets by
for-loops. This makes it clearer what is iterated over. Also, since
"continue" now moves on to the next iteration without having to
increment the regset pointer first, the code is slightly reduced.
In case of EIO the old code did not increment the regset pointer, but
iterated over the same (now disabled) regset again. This extra
iteration is now avoided.
gdb/gdbserver/ChangeLog:
* linux-low.c (regsets_fetch_inferior_registers): Rephrase
while-loop as for-loop.
(regsets_store_inferior_registers): Likewise.
Copy relocs are used in a scheme to avoid dynamic text relocations in
non-PIC executables that refer to variables defined in shared
libraries. The idea is to have the linker define any such variable in
the executable, with a copy reloc copying the initial value, then have
both the executable and shared library refer to the executable copy.
If the shared library defines the variable as protected then we have
two copies of the variable being used.
PR 15228
* elflink.c (_bfd_elf_adjust_dynamic_copy): Add "info" param.
Error on copy relocs against protected symbols.
(elf_merge_st_other): Set h->protected_def.
* elf-bfd.h (struct elf_link_hash_entry): Add "protected_def".
(_bfd_elf_adjust_dynamic_copy): Update prototype.
* elf-m10300.c (_bfd_mn10300_elf_adjust_dynamic_symbol): Update
_bfd_elf_adjust_dynamic_copy call.
* elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Likewise.
* elf32-cr16.c (_bfd_cr16_elf_adjust_dynamic_symbol): Likewise.
* elf32-cris.c (elf_cris_adjust_dynamic_symbol): Likewise.
* elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Likewise.
* elf32-i370.c (i370_elf_adjust_dynamic_symbol): Likewise.
* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Likewise.
* elf32-lm32.c (lm32_elf_adjust_dynamic_symbol): Likewise.
* elf32-m32r.c (m32r_elf_adjust_dynamic_symbol): Likewise.
* elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise.
* elf32-metag.c (elf_metag_adjust_dynamic_symbol): Likewise.
* elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Likewise.
* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise.
* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
* elf32-sh.c (sh_elf_adjust_dynamic_symbol): Likewise.
* elf32-tic6x.c (elf32_tic6x_adjust_dynamic_symbol): Likewise.
* elf32-tilepro.c (tilepro_elf_adjust_dynamic_symbol): Likewise.
* elf32-vax.c (elf_vax_adjust_dynamic_symbol): Likewise.
* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.
* elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
* elf64-sh64.c (sh64_elf64_adjust_dynamic_symbol): Likewise.
* elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_adjust_dynamic_symbol): Likewise.
* elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_adjust_dynamic_symbol): Likewise.
* elfxx-tilegx.c (tilegx_elf_adjust_dynamic_symbol): Likewise.
Hi,
I see many fails in dw2-dir-file-name.exp on arm target when test
case is compiled with -marm, however, these fails are disappeared when
test case is compiled with -mthumb.
The difference of pass and fail shown below is that "0x000085d4 in" isn't
printed out, but test case expects to see it.
-Breakpoint 2, compdir_missing__ldir_missing__file_basename () at tmp-dw2-dir-file-name.c:999^M
-(gdb) FAIL: gdb.dwarf2/dw2-dir-file-name.exp: compdir_missing__ldir_missing__file_basename: continue to breakpoint: compdir_missing__ldir_missing__file_basename
+Breakpoint 2, 0x000085d4 in compdir_missing__ldir_missing__file_basename () at tmp-dw2-dir-file-name.c:999^M
+(gdb) PASS: gdb.dwarf2/dw2-dir-file-name.exp: compdir_missing__ldir_missing__file_basename: continue to breakpoint: compdir_missing__ldir_missing__file_basename
This difference is caused by setting breakpoint at the first instruction
in the function (actually, the first instruction in prologue, at [1]),
so that frame_show_address returns false, and print_frame doesn't print the
address.
0x00008620 <+0>: push {r11} ; (str r11, [sp, #-4]!) <--[1]
0x00008624 <+4>: add r11, sp, #0
0x00008628 <+8>: ldr r3, [pc, #24] ; 0x8648 <compdir_missing__ldir_missing__file_basename+40>
0x0000862c <+12>: ldr r3, [r3]
0x00008630 <+16>: add r3, r3, #1
0x00008634 <+20>: ldr r2, [pc, #12] ; 0x8648 <compdir_missing__ldir_missing__file_basename+40>
Then, it must be the arm_skip_prologue's fault that unable to skip
instructions in prologue. At the end of arm_skip_prologue, it matches
several instructions, such as "str r(0123),[r11,#-nn]" and
"str r(0123),[sp,#nn]", but "push {r11}" isn't handled.
These instruction matching code in arm_skip_prologue, which can be regarded
as leftover of development for many years, should be merged to
arm_analyze_prologue and use arm_analyze_prologue in arm_skip_prologue.
Here is the something like the history of arm_{skip,scan,analyze}_prologue.
Around 2002, there are arm_skip_prologue and arm_scan_prologue, but code are
duplicated to some extent. When match an instruction, both functions should
be modified, for example in Michael Snyder's patch
https://sourceware.org/ml/gdb-patches/2002-05/msg00205.html and Michael
expressed the willingness to merge both into one. Daniel added code call
thumb_analyze_prologue in arm_skip_prologue in 2006, but didn't handle its
counterpart arm_analyze_prologue, which is added in 2010
<https://sourceware.org/ml/gdb-patches/2010-03/msg00820.html>
however, the instructions matching at the bottom of arm_skip_prologue wasn't
cleaned up. This patch is to merge them into arm_analyze_prologue.
gdb:
2014-12-12 Yao Qi <yao@codesourcery.com>
PR tdep/14261
* arm-tdep.c (arm_skip_prologue): Remove unused local variable
'skip_pc'. Remove code skipping prologue instructions, use
arm_analyze_prologue instead.
(arm_analyze_prologue): Stop the scanning for unrecognized
instruction when skipping prologue.
This patch is to stop prologue analysis past epilogue in for arm mode,
while we've already had done the same to thumb mode (see
thumb_instruction_restores_sp). This is useful to parse functions
with empty body (epilogue follows prologue).
gdb:
2014-12-12 Yao Qi <yao@codesourcery.com>
* arm-tdep.c (arm_instruction_restores_sp): New function.
(arm_analyze_prologue): Call arm_instruction_restores_sp.
(arm_in_function_epilogue_p): Move code to
arm_instruction_restores_sp.
commit f64e188b58
Author: Nick Clifton <nickc@redhat.com>
Date: Tue Dec 9 12:42:18 2014 +0000
More fixes for memory access violations triggered by fuzzed binaries.
[snip]
* elf.c (elf_parse_notes): Check that the namedata is long enough
for the string comparison that is about to be performed.
(elf_read_notes): Zero-terminate the note buffer.
This change to elf_parse_notes is the culprit:
+ for (i = ARRAY_SIZE (grokers); i--;)
+ if (in.namesz >= sizeof grokers[i].string - 1
+ && strncmp (in.namedata, grokers[i].string,
+ sizeof (grokers[i].string) - 1) == 0)
Note how this applies sizeof to grokers[i].string...
bfd/ChangeLog
* elf.c (elf_parse_notes): Define convenience macro
GROKER_ELEMENT to add elements to 'grokers'.
Use grokers.len instead of sizeof in string comparisons.
Also fix a place where %lld was wrongly used to print a dwarf_vma.
* configure.ac: Check for long long and sizes of long long and long.
* elfcomm.h (HOST_WIDEST_INT): Test HAVE_LONG_LONG in place of
__STDC_VERSION__ and __GNUC__.
* strings.c (print_strings): Likewise.
* dwarf.c (DWARF_VMA_FMT, DWARF_VMA_FMT_LONG): Likewise.
(read_debug_line_header): Use dwarf_vmatoa to print warning.
* configure: Regenerate.
* config.in: Regenerate.
This patch gives current stub-group-size in error message when stub
is too far away.
* aarch64.cc (Target_aarch64): Add new variable: stub_group_size_.
(AArch64_relocate_functions::maybe_apply_stub): Add new parameter.
Update error message.
(Target_aarch64::do_relax): Use absolute value of option
stub_group_size. Replace local variable with class member
stub_group_size_.
On Linux native, if dprintfs are inserted when detaching, they are left
in the inferior which causes it to crash from a SIGTRAP. It also happens
with dprintfs on remote targets, when set disconnected-dprintf is off.
The rationale of the line modified by the patch was to leave dprintfs
inserted in order to support disconnected dprintfs. However, not all
dprintfs are persistent. Also, there's no reason other kinds of
breakpoints can't be persistent either. So this replaces the bp_dprintf
check with a check on whether the location is persistent.
bl->target_info.persist will be 1 only if disconnected-dprintf is on and
we are debugging a remote target. On native, it will always be 0,
regardless of the value of disconnected-dprintf. This makes sense, since
disconnected dprintfs are not supported by the native target.
One issue about the test is that it does not pass when using
--target_board=native-extended-gdbserver, partly due to bug 17302 [1].
One quick hack I tried for this was to add a useless "next" between the
call to getpid() and detach, which avoids the bug. There is still one
case where the test fails, and that is with:
- breakpoint always-inserted on
- dprintf-style agent
- disconnected-dprintf on
What happens is that my detach does not actually detach the process,
because some persistent commands (the disconnected dprintf) is present.
However since gdbserver is ran with --once, when gdb disconnects,
gdbserver goes down and takes with it all the processes it spawned and
that are still under its control (which includes my test process).
When the test checks if the test process is still alive, it obvisouly
fails. Investigating about that led me to ask a question on the ML [2]
about the behavior of detach.
Until the remote case is sorted out, the problematic test is marked as
KFAIL.
[1] https://sourceware.org/bugzilla/show_bug.cgi?id=17302
[2] https://sourceware.org/ml/gdb/2014-08/msg00115.html
gdb/Changelog:
PR breakpoints/17012
* breakpoint.c (remove_breakpoints_pid): Skip removing
breakpoint if it is marked as persistent.
gdb/testsuite/ChangeLog:
PR breakpoints/17012
* gdb.base/dprintf-detach.c: New file.
* gdb.base/dprintf-detach.exp: New file.
This patch introduces a function in gdbserver-support.exp to find out
whether the current target is GDBserver.
The code was inspired from gdb.trace/qtro.exp, so it replaces the code
there by a call to the new function.
gdb/testsuite/ChangeLog:
* gdb.trace/qtro.exp: Replace gdbserver detection code by...
* lib/gdb.exp (target_is_gdbserver): New
procedure.
When a thread exits, the terminal is left in mode "terminal_is_ours"
while the target executes. This patch fixes that.
We need to manually restore the terminal setting in this particular
observer. In the case of the other MI observers that call
target_terminal_ours, gdb will end up resuming the inferior later in the
execution and call target_terminal_inferior. In the case of the thread
exit event, we still need to call target_terminal_ours to be able to
print something, but there is nothing that gdb will need to resume after
that. We therefore need to call target_terminal_inferior ourselves.
gdb/ChangeLog:
PR gdb/17627
* target.c (cleanup_restore_target_terminal): New function.
(make_cleanup_restore_target_terminal): New function.
* target.h (make_cleanup_restore_target_terminal): New
declaration.
* mi/mi-interp.c (mi_thread_exit): Use the new cleanup.
Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
DW_AT_name for functions typically just contains the base function
name, so lacks namespace, class and parameter information. It would
be possible to extract all these from the DWARF, but at a considerable
complication of the parser in dwarf2.c, and then you'd need to mangle
it all together. Much simpler is to look up the actual symbol. This
patch does that, avoiding the extra symbol lookup when the language
doesn't do name mangling.
PR 17541
* dwarf2.c (struct comp_unit): Add "lang".
(non_mangled): New function.
(struct funcinfo): Add "is_linkage". Reorder for better packing.
Make "name" a const char*.
(lookup_address_in_function_table): Delete functionname_ptr param.
(find_abstract_instance_name): Add is_linkage param. Set if we
have DW_AT_linkage_name or non_mangled DW_AT_name.
(scan_unit_for_symbols): Similarly set func->is_linkage.
(parse_comp_unit): Stash DW_AT_language.
(comp_unit_find_nearest_line): Replace functionname_ptr param
with function_ptr param.
(_bfd_dwarf2_find_nearest_line): Adjust above calls. Set
functionname_ptr from function->name. Call _bfd_elf_find_function
to retrieve symbol for function if not linkage name.
(_bfd_elf_find_function): Add bfd_target_elf_flavour test, moved from..
* elf.c (elf_find_function): ..here.
(_bfd_elf_find_nearest_line): Adjust calls.
* elf-bfd.h (_bfd_elf_find_function): Declare.
_bfd_dwarf2_find_nearest_line may be called on a COFF bfd.
* dwarf2.c (read_address): Check bfd_target_elf_flavour before
calling get_elf_backend_data.
(_bfd_dwarf2_find_nearest_line): Fix parens.
HI16/LO16 are deliberately put adjacent, which might mean relocs are
then not sorted by r_offset. See tc-mips.c:mips_frob_file. Don't undo
the HI16/LO16 sorting.
PR 17666
* elf-bfd.h (struct elf_backend_data): Add sort_relocs_p.
* elfxx-target.h (elf_backend_sort_relocs_p): Define.
(elfNN_bed): Init new field.
* elflink.c (elf_link_adjust_relocs): Conditionally sort.
(bfd_elf_final_link): Control sorting of relocs.
* elfxx-mips.c (_bfd_mips_elf_sort_relocs_p): New function.
* elfxx-mips.h (_bfd_mips_elf_sort_relocs_p): Declare.
* elf32-mips.c (elf_backend_sort_relocs_p): Define.
* elf64-mips.c (elf_backend_sort_relocs_p): Define.
PR binutils/17512
* objdump.c (display_any_bfd): Avoid infinite loop closing and
opening the same archive again and again.
* archive64.c (bfd_elf64_archive_slurp_armap): Add range checks.
* libbfd.c (safe_read_leb128): New function.
* libbfd-in.h (safe_read_leb128): Add prototype.
* libbfd.h: Regenerate.
* elf-attrs.c (_bfd_elf_parse_attributes): Use safe_read_leb128.
Check for an over-long subsection length.
* elf.c (elf_parse_notes): Check that the namedata is long enough
for the string comparison that is about to be performed.
(elf_read_notes): Zero-terminate the note buffer.
Now that ld -r relocs are sorted by the pr17666 fix, there isn't so
much need to sort incoming relocs.
* elf64-ppc.c (sort_r_offset): Delete.
(ppc64_elf_edit_opd): Don't sort input relocs.
PR binutils/17531
* dwarf.c (display_debug_frames): Check for a negative
augmentation data length.
(display_gdb_index): Check for invalid offsets.
* elfcomm.c (process_archive_index_and_symbols): Check for an
index number that overflows when multiplied by the ar index size.
* readelf.c (dump_ia64_unwind): Add range checks.
(slurp_ia64_unwind_table): Change to a boolean function. Add
range checks.
(process_version_sections): Add range checks.
(get_symbol_version_string): Add check for missing section
headers.