_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.
That's right, block_lookup_symbol_primary()'s additional requirement over
block_lookup_symbol() is:
Function is useful if one iterates all global/static blocks of an
objfile.
Which is satisfied both in lookup_symbol_in_objfile_symtabs() and in
lookup_global_symbol_from_objfile() thanks to their's ALL_OBJFILE_COMPUNITS.
In fact after reverting that ba715d7fe4 above
the lines of code were exactly the same.
So instead of accelerating both lookup_symbol_in_objfile_symtabs() and
lookup_global_symbol_from_objfile() I just accelerated
lookup_symbol_in_objfile_symtabs() and I am proposing to reuse
lookup_symbol_in_objfile_symtabs() in lookup_global_symbol_from_objfile()
instead. In fact such unification would already save some lines of code even
before the checked-in acceleration patch above.
gdb/ChangeLog
2014-12-05 Jan Kratochvil <jan.kratochvil@redhat.com>
* symtab.c (lookup_symbol_in_objfile_symtabs): New declaration.
(lookup_global_symbol_from_objfile): Call it.
I am just not sure if we should go the route of
struct objfile * -> const struct objfile *
or the other way of:
const struct objfile * -> struct objfile *
Normally const adding is better but here I do not see much useful to have any
struct objfile * const and then it just causes pointer compatibility problems.
On Wed, 03 Dec 2014 18:18:44 +0100, Doug Evans wrote:
struct objfile is one case where I've decided to just leave the const
out and not worry about it.
gdb/ChangeLog
2014-12-05 Jan Kratochvil <jan.kratochvil@redhat.com>
Remove const from struct objfile *.
* solib-darwin.c, solib-spu.c, solib-svr4.c, solib.c, solist.h,
symtab.c, symtab.h: In these files.
This patch is to revert my previous commit, because we shouldn't remove
gdbtk bits from gdb/testsuite/configure.ac while keep gdbtk bits in
gdb/configure.ac.
gdb/testsuite:
2014-12-05 Yao Qi <yao@codesourcery.com>
Revert:
* configure.ac: Remove AC_ARG_ENABLE for gdbtk. Don't invoke
AC_CONFIG_SUBDIRS(gdb.gdbtk).
* configure: Re-generated.
Some gdb.guile tests such as scm-error.exp copies .scm file to
${subdir}/, how ${subdir} doesn't exist in parallel testing
(outputs/${subdir} exists).
$ make -j3 check TESTS='gdb.guile/scm-section-script.exp gdb.guile/scm-error.exp gdb.guile/scm-frame-args.exp'
ERROR: remote_download to host of ../../../../git/gdb/testsuite/gdb.guile/scm-section-script.scm to gdb.guile/t-scm-section-script.scm: cp: cannot create regular file 'gdb.guile/t-scm-section-script.scm': No such file or directory
ERROR: remote_download to host of ../../../../git/gdb/testsuite/gdb.guile/scm-frame-args.scm to gdb.guile/t-scm-frame-args.scm: cp: cannot create regular file
'gdb.guile/t-scm-frame-args.scm': No such file or directory
ERROR: remote_download to host of ../../../../git/gdb/testsuite/gdb.guile/scm-error-1.scm to gdb.guile/t-scm-error-1.scm: cp: cannot create regular file 'gdb.guile/t-scm-error-1.scm': No such file or directory
This patch is to remove the third argument of gdb_remote_download, so
that gdb_remote_download can return the correct location.
Further, these tests only copy .scm files to a different name. From what
I can tell from the comments, looks we do this to avoid clobbering file
in in-tree build. However, if source and dest of copy are the same, the
operation is no-op. So it makes few sense to copy .scm files to a
different names. I tried in-tree build/test with this patch, test
result isn't changed.
gdb/testsuite:
2014-12-05 Yao Qi <yao@codesourcery.com>
* gdb.guile/scm-error.exp: Remove the third argument to
gdb_remote_download.
* gdb.guile/scm-frame-args.exp: Likewise.
* gdb.guile/scm-section-script.exp: Likewise.
This patch causes regressions in ada's operator_bp.exp test.
That's because it uses wild_match which expects arguments in
the original order.
There is still a bug here. It's hard to see because either minsyms
save the day, or the needed symtab gets expanded before linespecs
need it because of the call to cp_canonicalize_string_no_typedefs
in linespec.c:find_linespec_symbols.
But if you disable both of those things, then the bug is visible.
bash$ ./gdb -D ./data-directory testsuite/gdb.cp/anon-ns
(gdb) b doit(void)
Function "doit(void)" not defined.
gdb/ChangeLog:
Revert:
PR symtab/17602
* linespec.c (iterate_name_matcher): Fix arguments to symbol_name_cmp.
This patch is to use standard_testfile in i386-bp_permanent.exp to replace
existing setting to testfile, srcfile and binfile. So it fixes a problem
in i386-bp_permanent.exp in parallel testing.
$ make -j3 check TESTS='gdb.guile/scm-section-script.exp gdb.arch/i386-bp_permanent.exp'
....
gdb compile failed, /usr/bin/ld: cannot open output file x86/gdb/testsuite/gdb.arch/i386-bp_permanent: No such file or directory
collect2: error: ld returned 1 exit status
gdb/testsuite:
2014-12-05 Yao Qi <yao@codesourcery.com>
* gdb.arch/i386-bp_permanent.exp: Use standard_testfile.
In i386 and x86-64 binaries with ifunc, relocations against .got.plt
section may not be in the same order as entries in PLT section. This
patch adds _bfd_elf_ifunc_get_synthetic_symtab. It takes a function
pointer which returns an array of PLT entry symbol values. It calls
the function pointer to get the PLT entry symbol value array indexed
by relocation index, instead of calling plt_sym_val on each relocation
index.
PR binutils/17677
* elf-bfd.h (_bfd_elf_ifunc_get_synthetic_symtab): New prototype.
* elf-ifunc.c (_bfd_elf_ifunc_get_synthetic_symtab): New
function.
* elf32-i386.c (elf_i386_plt_sym_val): Removed.
(elf_backend_plt_sym_val): Likewise.
(elf_i386_get_plt_sym_val): New.
(elf_i386_get_synthetic_symtab): Likewise.
(bfd_elf32_get_synthetic_symtab): Likewise.
* elf64-x86-64.c (elf_x86_64_plt_sym_val): Removed.
(elf_x86_64_plt_sym_val_offset_plt_bnd): Likewise.
(elf_backend_plt_sym_val): Likewise.
(elf_x86_64_get_plt_sym_val): New.
(elf_x86_64_get_synthetic_symtab): Use
_bfd_elf_ifunc_get_synthetic_symtab.
(bfd_elf64_get_synthetic_symtab): Don't undefine for NaCl.
Mixing 64-bit and 32-bit types led to the wrong promotions. Keep
calculation in same type. Also fix a case where PLTREL25 reloc addend
should be ignored.
* Powerpc.cc (Target_powerpc::Branch_info::make_stub): Ignore
addend of PLTREL24 reloc when not generating a plt stub. Make
max_branch_offset an "Address".
(Stub_table::can_read_stub): Make max_branch_offset an "Address".
(Target_powerpc::Relocate::relocate): Likewise.
During debugging I get 10-30 seconds for a response to simple commands like:
(gdb) print vectorvar.size()
With this patch the performance gets to 1-2 seconds which is somehow
acceptable. The problem is that dwarf2_gdb_index_functions.lookup_symbol
(quick_symbol_functions::lookup_symbol) may return (and returns) NULL even for
symbols which are present in .gdb_index but which can be found in already
expanded symtab. But searching in the already expanded symtabs is just too
slow when there are 400000+ expanded symtabs. There would be needed some
single global hash table for each objfile so that one does not have to iterate
all symtabs. Which .gdb_index could perfectly serve for, just its
lookup_symbol() would need to return authoritative yes/no answers.
Even after such fix these two simple patches are useful for example for
non-.gdb_index files.
One can reproduce the slugging interactive GDB performance with:
#include <string>
using namespace std;
string var;
class C {
public:
void m() {}
};
int main() {
C c;
c.m();
return 0;
}
g++ -o slow slow.C -Wall -g $(pkg-config --libs gtkmm-3.0)
gdb ./slow -ex 'b C::m' -ex 'maintenance set per-command space' -ex 'maintenance set per-command symtab' -ex 'maintenance set per-command
time' -ex r
[...]
(gdb) p <tab><tab>
Display all 183904 possibilities? (y or n) n
(gdb) p/r var
$1 = {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No
data fields>}, _M_p = 0x3a4db073d8 <std::string::_Rep::_S_empty_rep_storage+24> ""}}
Command execution time: 20.023000 (cpu), 20.118665 (wall)
^^^^^^^^^
Space used: 927997952 (+0 for this command)
Without DWZ there are X global blocks for X primary symtabs for X CUs of
objfile. With DWZ there are X+Y global blocks for X+Y primary symtabs for
X+Y CUs where Y are 'DW_TAG_partial_unit's.
For 'DW_TAG_partial_unit's (Ys) their blockvector is usually empty. But not
always, I have found there typedef symbols, there can IMO be optimized-out
static variables etc.
Neither of the patches should cause any visible behavior change.
gdb/ChangeLog
2014-12-04 Jan Kratochvil <jan.kratochvil@redhat.com>
* block.c (block_lookup_symbol_primary): New function.
* block.h (block_lookup_symbol_primary): New declaration.
* symtab.c (lookup_symbol_in_objfile_symtabs): Assert BLOCK_INDEX.
Call block_lookup_symbol_primary.
Address issues triggered by the MIPS ISA bit handling change, usually in
tests that make artificial DWARF-2 records:
* gdb.cp/expand-psymtabs-cxx.exp -- this test is debugging an object file
and assuming addresses will be 0; with the ISA bit set code addresses
are 1 instead:
(gdb) PASS: gdb.cp/expand-psymtabs-cxx.exp: set language c++
p 'method(long)'
$1 = {void (long)} 0x1 <method(long)>
(gdb) FAIL: gdb.cp/expand-psymtabs-cxx.exp: before expand
p method
$2 = {void (long)} 0x1 <method(long)>
(gdb) FAIL: gdb.cp/expand-psymtabs-cxx.exp: force expand
p 'method(long)'
$3 = {void (long)} 0x1 <method(long)>
(gdb) FAIL: gdb.cp/expand-psymtabs-cxx.exp: after expand
Fix by matching any hex number, there's no value AFAICT for the test
in matching 0 exactly, and I suppose the method's offset within
section can be non-zero for some other reasons on other targets too.
* gdb.cp/nsalias.exp -- this assumes instructions can be aligned
arbitrarily and places code labels at odd addreses, setting the ISA
bit and wreaking havoc:
(gdb) PASS: gdb.cp/nsalias.exp: print outer::inner::innermost::x
list outer::inner::innermost::foo
Function "outer::inner::innermost::foo" not defined.
(gdb) FAIL: gdb.cp/nsalias.exp: list outer::inner::innermost::foo
break *outer::inner::innermost::foo
No symbol "foo" in namespace "outer::inner::innermost".
(gdb) FAIL: gdb.cp/nsalias.exp: setting breakpoint at
*outer::inner::innermost::foo
delete $bpnum
No breakpoint number 6.
(gdb) FAIL: gdb.cp/nsalias.exp: (outer::inner::innermost): delete $bpnum
-- etc., etc... Fix by aligning labels to 4; required by many
processors.
* gdb.dwarf2/dw2-canonicalize-type.exp, gdb.dwarf2/dw2-empty-pc-range.exp,
gdb.dwarf2/pr11465.exp -- these assume an instruction and consequently
a function can take as little as 1 byte, which makes it impossible to
look up a code symbol by an address with the ISA bit set as the
address is already beyond the end of the function:
(gdb) ptype f
No symbol "f" in current context.
(gdb) FAIL: gdb.dwarf2/dw2-canonicalize-type.exp: ptype f
(gdb) PASS: gdb.dwarf2/dw2-empty-pc-range.exp: empty range before CU load
ptype realrange
No symbol "realrange" in current context.
(gdb) FAIL: gdb.dwarf2/dw2-empty-pc-range.exp: valid range after CU load
(gdb) p N::c.C
Cannot take address of method C.
(gdb) FAIL: gdb.dwarf2/pr11465.exp: p N::c.C
-- fix by increasing the size of the function to 4 (perhaps code in
gdb/mips-tdep.c could look up code symbols up to twice, with and
failing that without the ISA bit set, but it seems wrong to me to
implement specific handling for invalid code just to satisfy test
cases that assume too much about the target).
* gdb.dwarf2/dw2-case-insensitive.exp -- an artificial code label is
created, but does not work because data (a `.align' pseudo-op in this
case) follows and as a result the label has no MIPS16 or microMIPS
annotation in the symbol table:
(gdb) PASS: gdb.dwarf2/dw2-case-insensitive.exp: set case-sensitive off
info functions fUnC_lang
All functions matching regular expression "fUnC_lang":
File file1.txt:
foo FUNC_lang(void);
Non-debugging symbols:
0x004006e0 FUNC_lang_start
(gdb) FAIL: gdb.dwarf2/dw2-case-insensitive.exp: regexp case-sensitive off
-- fix by adding a `.insn' pseudo-op on MIPS targets; the pseudo-op
marks data as instructions.
* gdb.dwarf2/dw2-stack-boundary.exp -- the test case enables complaints
and assumes none will be issued beyond ones explicitly arranged by the
test case, however overlapping sections are noticed while minimal
symbols are looked up by `mips_adjust_dwarf2_addr' in DWARF-2 record
processing:
(gdb) set complaints 100
(gdb) PASS: gdb.dwarf2/dw2-stack-boundary.exp: set complaints 100
file ./dw2-stack-boundary
Reading symbols from ./dw2-stack-boundary...location description stack
underflow...location description stack overflow...unexpected overlap
between:
(A) section `.reginfo' from `.../gdb.dwarf2/dw2-stack-boundary' [0x0, 0x18)
(B) section `*COM*' from `.../gdb.dwarf2/dw2-stack-boundary' [0x0, 0x0).
Will ignore section B...unexpected overlap between:
(A) section `.reginfo' from `.../gdb.dwarf2/dw2-stack-boundary' [0x0, 0x18)
(B) section `*UND*' from `.../gdb.dwarf2/dw2-stack-boundary' [0x0, 0x0).
Will ignore section B...unexpected overlap between:
(A) section `.reginfo' from `.../gdb.dwarf2/dw2-stack-boundary' [0x0, 0x18)
(B) section `*ABS*' from `.../gdb.dwarf2/dw2-stack-boundary' [0x0, 0x0).
Will ignore section B...done.
(gdb) FAIL: gdb.dwarf2/dw2-stack-boundary.exp: check partial symtab errors
-- fix by ignoring any extra noise as long as what we look for is
found.
* gdb.cp/expand-psymtabs-cxx.exp: Accept any address of
`method(long)', not just 0x0.
* gdb.cp/nsalias.exp: Align code labels to 4.
* gdb.dwarf2/dw2-canonicalize-type.S (main): Expand to 4-bytes.
* gdb.dwarf2/dw2-empty-pc-range.S (main): Likewise.
* gdb.dwarf2/pr11465.S (_ZN1N1cE): Likewise.
* gdb.dwarf2/dw2-case-insensitive.c (START_INSNS): New macro.
(cu_text_start, FUNC_lang_start): Use `START_INSNS'.
* gdb.dwarf2/dw2-stack-boundary.exp: Accept noise in complaints.
pr17670 is about an assert triggering on a branch to an undefined
weak symbol, the symbol being undefined due to dropping its comdat
group section. (Well sort of. The symbol is actually defined in
an .opd section which isn't part of the group, but the code section
the opd entry points at is dropped.) So don't assert.
Also, don't make long branch stubs to such symbols, and arrange to
have target-reloc.h code warn when applying relocs that use the sym.
PR 17670
* symtab.cc (Symbol::set_undefined): Remove assertion.
* powerpc.cc (Target_powerpc::symval_for_branch): Don't assert
on symbols defined in discarded sections, instead return false.
Rearrange params, update all callers.
(Target_powerpc::Branch_info::make_stub): Don't make stubs for
branches to syms in discarded sections.
(Global_symbol_visitor_opd::operator()): Set discarded opd syms
undefined and flag as discarded.
(Target_powerpc::Relocate::relocate): Localize variable.
The necessity for this change has been revealed in the course of
investigation related to proposed changes in the treatment of the ISA
bit encoded in function symbols on the MIPS target. This change adds
support for Linux signal trampolines encoded with the microMIPS
instruction set. Such trampolines are used by the Linux kernel if
compiled as a microMIPS binary (even if the binary run/debugged itself
contains no microMIPS code at all).
To see if we need to check whether the execution mode selected matches
the given trampoline I have checked what the bit patterns of all the
trampoline sequences decode to in the opposite instruction set. This
produced useless or at least unusual code in most cases, for example:
microMIPS/EB, o32 sigreturn, decoded as MIPS code:
30401017 andi zero,v0,0x1017
00008b7c dsll32 s1,zero,0xd
MIPS/EL, o32 sigreturn, decoded as microMIPS code:
1017 2402 addi zero,s7,9218
000c 0000 sll zero,t0,0x0
However in some corner cases reasonable code can mimic a trampoline, for
example:
MIPS/EB, n32 rt_sigreturn, decoded as microMIPS code:
2402 sll s0,s0,1
1843 0000 sb v0,0(v1)
000c 0f3c jr t0
-- here the first instruction is a 16-bit one, making things nastier
even as there are some other microMIPS instructions whose first 16-bit
halfword is 0x000c and therefore matches this whole trampoline pattern.
To overcome this problem I have decided the signal trampoline unwinder
has to ask the platform backend whether it can apply a given trampoline
pattern to the code location being concerned or not. Anticipating the
acceptance of the ISA bit proposal I decided the handler not to merely
be a predicate, but also to be able to provide an adjusted PC if
required. I decided that returning zero will mean that the trampoline
pattern is not applicable and any other value is the adjusted PC to use;
a handler may return the value requested if the trampoline pattern and
the PC requested as-is are both accepted.
This changes the semantics of the trampoline unwinder a bit in that the
zero PC now has a special value. I think this should be safe as a NULL
pointer is generally supposed to be invalid.
* tramp-frame.h (tramp_frame): Add `validate' member.
* tramp-frame.c (tramp_frame_start): Validate trampoline before
scanning.
* mips-linux-tdep.c (MICROMIPS_INST_LI_V0): New macro.
(MICROMIPS_INST_POOL32A, MICROMIPS_INST_SYSCALL): Likewise.
(mips_linux_o32_sigframe): Initialize `validate' member.
(mips_linux_o32_rt_sigframe): Likewise.
(mips_linux_n32_rt_sigframe): Likewise.
(mips_linux_n64_rt_sigframe): Likewise.
(micromips_linux_o32_sigframe): New variable.
(micromips_linux_o32_rt_sigframe): Likewise.
(micromips_linux_n32_rt_sigframe): Likewise.
(micromips_linux_n64_rt_sigframe): Likewise.
(mips_linux_o32_sigframe_init): Handle microMIPS trampolines.
(mips_linux_n32n64_sigframe_init): Likewise.
(mips_linux_sigframe_validate): New function.
(micromips_linux_sigframe_validate): Likewise.
(mips_linux_init_abi): Install microMIPS trampoline unwinders.
PR binutils/17512
* objdump.c (free_debug_section): Reset the compress_status as
well.
* compress.c (bfd_get_full_section_contents): Fail if there are no
section contents available when the compress_status is
COMPRESS_SECTION_DONE.
* libbfd.c (bfd_malloc): Refuse to allocate a negative size.
(bfd_malloc2): Use bfd_malloc.
(bfd_realloc): Refuse to reallocate a negative size.
(bfd_realloc2): Use bfd_realloc.
(bfd_realloc_or_free): Use bfd_realloc.
(bfd_zmalloc): Use bfd_malloc.
(bfd_zmalloc): Use bfd_malloc2.
* opncls.c (bfd_alloc): Refuse to allocate a negative size.