deliverable/binutils-gdb.git
9 years agoAdd _bfd_elf_ifunc_get_synthetic_symtab
H.J. Lu [Thu, 4 Dec 2014 22:19:41 +0000 (14:19 -0800)] 
Add _bfd_elf_ifunc_get_synthetic_symtab

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.

9 years agoAutomatic date update in version.in
GDB Administrator [Fri, 5 Dec 2014 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoNew python method gdb.Objfile.add_separate_debug_file.
Doug Evans [Thu, 4 Dec 2014 20:01:22 +0000 (12:01 -0800)] 
New python method gdb.Objfile.add_separate_debug_file.

gdb/ChangeLog:

* NEWS: Mention gdb.Objfile.add_separate_debug_file.
* python/py-objfile.c (objfpy_add_separate_debug_file): New function.
(objfile_getset): Add "add_separate_debug_file".

gdb/doc/ChangeLog:

* python.texi (Objfiles In Python): Document
Objfile.add_separate_debug_file.

gdb/testsuite/ChangeLog:

* gdb.python/py-objfile.exp: Add tests for
objfile.add_separate_debug_file.

9 years agoNew python attribute gdb.Objfile.build_id.
Doug Evans [Thu, 4 Dec 2014 19:32:24 +0000 (11:32 -0800)] 
New python attribute gdb.Objfile.build_id.

gdb/ChangeLog:

* NEWS: Mention gdb.Objfile.build_id.
* build-id.c (build_id_bfd_get): Make non-static.
* build-id.h (build_id_bfd_get): Add declaration.
* python/py-objfile.c: #include "build-id.h", "elf-bfd.h".
(OBJFPY_REQUIRE_VALID): New macro.
(objfpy_get_build_id): New function.
(objfile_getset): Add "build_id".
* utils.c (make_hex_string): New function.
* utils.h (make_hex_string): Add declaration.

gdb/doc/ChangeLog:

* python.texi (Objfiles In Python): Document Objfile.build_id.

gdb/testsuite/ChangeLog:

* lib/gdb.exp (get_build_id): New function.
(build_id_debug_filename_get): Rewrite to use it.
* gdb.python/py-objfile.exp: Add test for objfile.build_id.

9 years agoChangeLog typo fix
Alan Modra [Thu, 4 Dec 2014 11:50:14 +0000 (22:20 +1030)] 
ChangeLog typo fix

9 years agoPowerPC gold, fix 32-bit branch address arithmetic
Alan Modra [Thu, 4 Dec 2014 10:40:40 +0000 (21:10 +1030)] 
PowerPC gold, fix 32-bit branch address arithmetic

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.

9 years agoAccelerate lookup_symbol_aux_objfile 85x
Jan Kratochvil [Thu, 4 Dec 2014 07:26:26 +0000 (08:26 +0100)] 
Accelerate lookup_symbol_aux_objfile 85x

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.

9 years agoSort relocs output by ld -r
Alan Modra [Wed, 3 Dec 2014 11:30:18 +0000 (22:00 +1030)] 
Sort relocs output by ld -r

bfd/
PR 17666
* elflink.c: Include bfd_stdint.h.
(cmp_ext32l_r_offset, cmp_ext32b_r_offset,
cmp_ext64l_r_offset, cmp_ext64b_r_offset): New functions.
(elf_link_adjust_relocs): Sort relocs.  Free reloc hashes after
sorting invalidates.
ld/testsuite/
* ld-powerpc/vxworks-relax.rd: Update for reloc sorting.
* ld-powerpc/vxworks-relax-2.rd: Likewise.
* ld-sh/sh64/reldl32.rd: Likewise.
* ld-sh/sh64/reldl64.rd: Likewise.

9 years agoCorrect invalid assumptions made by (mostly) DWARF-2 tests
Maciej W. Rozycki [Thu, 4 Dec 2014 00:06:10 +0000 (00:06 +0000)] 
Correct invalid assumptions made by (mostly) DWARF-2 tests

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.

9 years agoAutomatic date update in version.in
GDB Administrator [Thu, 4 Dec 2014 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agopowerpc gold, work around pr17670
Alan Modra [Wed, 3 Dec 2014 05:47:23 +0000 (16:17 +1030)] 
powerpc gold, work around pr17670

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.

9 years agoMIPS: Add support for microMIPS Linux signal trampolines
Maciej W. Rozycki [Wed, 3 Dec 2014 19:19:41 +0000 (19:19 +0000)] 
MIPS: Add support for microMIPS Linux signal trampolines

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.

9 years agoFix memory access problems exposed by fuzzed binaries.
Nick Clifton [Wed, 3 Dec 2014 19:50:48 +0000 (19:50 +0000)] 
Fix memory access problems exposed by fuzzed binaries.

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.

9 years agoCompile pie_copyrelocs_test.cc with -fno-exceptions -fno-asynchronous-unwind-tables
H.J. Lu [Wed, 3 Dec 2014 18:59:46 +0000 (10:59 -0800)] 
Compile pie_copyrelocs_test.cc with -fno-exceptions -fno-asynchronous-unwind-tables

PR gold/17675
* testsuite/Makefile.am (pie_copyrelocs_test_CXXFLAGS): New.
* testsuite/Makefile.in: Regenerated.

9 years agoReplace copyreloc-main.c with copyreloc-main.S
H.J. Lu [Wed, 3 Dec 2014 16:40:19 +0000 (08:40 -0800)] 
Replace copyreloc-main.c with copyreloc-main.S

* ld-x86-64/copyreloc-main.c: Removed.
* ld-x86-64/copyreloc-main.S: New.
* ld-x86-64/x86-64.exp: Replace copyreloc-main.c with
copyreloc-main.S.

9 years agoReplace calls to abort (in readelf) with informative error messages.
Nick Clifton [Wed, 3 Dec 2014 16:33:33 +0000 (16:33 +0000)] 
Replace calls to abort (in readelf) with informative error messages.

PR binutils/17531
* readelf.c (get_machine_flags): Replace call to abort with a
warning message and a return value.
(get_elf_section_flags): Likewise.
(get_symbol_visibility): Likewise.
(get_ia64_symbol_other): Likewise.
(get_ia64_symbol_other): Likewise.
(is_32bit_abs_reloc): Likewise.
(apply_relocations): Likewise.
(display_arm_attribute): Likewise.

9 years agoReformat elf_x86_64_create_dynamic_sections
H.J. Lu [Wed, 3 Dec 2014 16:10:04 +0000 (08:10 -0800)] 
Reformat elf_x86_64_create_dynamic_sections

* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Reformat.

9 years agopowerpc gold, fix pr17566
Alan Modra [Wed, 3 Dec 2014 11:26:19 +0000 (21:56 +1030)] 
powerpc gold, fix pr17566

Code stolen from arm.cc.

PR 17566
* powerpc.cc (Target_powerpc::Scan::local): Use add_local_section
when adding dynamic relocations against section symbols.

9 years agoUse core regset iterators on Sparc Solaris
Ulrich Weigand [Wed, 3 Dec 2014 14:38:46 +0000 (15:38 +0100)] 
Use core regset iterators on Sparc Solaris

Remove native-only core file handling on Sparc Solaris.  Instead,
enable the sparc target generic core regset logic on Solaris by
providing appropriate register offset maps.

Thanks to Joel Brobecker for testing!

gdb/
* config/sparc/sol2.mh (NATDEPFILES): Remove core-regset.o.
* sparc-sol2-tdep.c: Include "regset.h".
(sparc32_sol2_supply_core_gregset): New function.
(sparc32_sol2_collect_core_gregset): Likewise.
(sparc32_sol2_supply_core_fpregset): Likewise.
(sparc32_sol2_collect_core_fpregset): Likewise.
(sparc32_sol2_gregset, sparc32_sol2_fpregset): New variables.
(sparc32_sol2_init_abi): Set tdep->gregset/sizeof_gregset and
tdep->fpregset/sizeof_fpregset.
* sparc64-sol2-tdep.c: Include "regset.h".
(sparc64_sol2_supply_core_gregset): New function.
(sparc64_sol2_collect_core_gregset): Likewise.
(sparc64_sol2_supply_core_fpregset): Likewise.
(sparc64_sol2_collect_core_fpregset): Likewise.
(sparc64_sol2_gregset, sparc64_sol2_fpregset): New variables.
(sparc64_sol2_init_abi): Set tdep->gregset/sizeof_gregset and
tdep->fpregset/sizeof_fpregset.

9 years agoFix make_cleanup_dtor signature to match declaration
Simon Marchi [Wed, 3 Dec 2014 13:56:10 +0000 (08:56 -0500)] 
Fix make_cleanup_dtor signature to match declaration

The definition does not use the typedef for the dtor function pointer
type that the declaration uses.  It's a cosmetic-only change.

ChangeLog:

* common/cleanups.c (make_cleanup_dtor): Use typedef for dtor
type.

9 years agocallback.h:struct host_callback_struct compilation error on Windows hosts.
Joel Brobecker [Wed, 3 Dec 2014 07:33:13 +0000 (02:33 -0500)] 
callback.h:struct host_callback_struct compilation error on Windows hosts.

On Windows, a recent gnulib update imported the lstat module, and
this caused a remote-sim.c build failure in struct host_callback_struct:

    In file included from /[...]/gdb/remote-sim.c:34:0:
    /[...]/gdb/../include/gdb/callback.h:93:9: error: duplicate member '_stati64'
       int (*lstat) (host_callback *, const char *, struct stat *);
             ^
What happens it that gnulib's stat.h makes the following defines:

     /* Large File Support on native Windows.  */
     #if 1
     # define stat _stati64
     #endif

and then:

    #if 1
    # if ! 0
    /* mingw does not support symlinks, therefore it does not have lstat.  But
       without links, stat does just fine.  */
    #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    #   define lstat stat
    #  endif

So, the following fields in struct host_callback_struct...

      int (*stat) (host_callback *, const char *, struct stat *);
      int (*fstat) (host_callback *, int, struct stat *);
      int (*lstat) (host_callback *, const char *, struct stat *);

... get translated to...

      int (*_stati64) (host_callback *, const char *, struct _stati64 *);
      int (*_fstati64) (host_callback *, int, struct _stati64 *);
      int (*_stati64) (host_callback *, const char *, struct _stati64 *);

... which causes two fields to have the same name.

This patch fixes the issue by renaming the stat-related fields
by adding a "to_" prefix, similar to what is done in GDB's
target_ops vector.

include/gdb/ChangeLog:

* callback.h (struct host_callback_struct) <to_stat>: Renamed
from "stat".
<to_fstat>: Renamed from "fstat".
<to_lstat>: Renamed from "lstat".

sim/common/ChangeLog:

* sim-io.c (sim_io_stat, sim_io_fstat): Adjust calls to "stat"
and "fstat" callbacks by calls to "to_stat" and "to_fstat" (resp)
callbacks following renaming in callback.h.
* syscall.c (cb_syscall): Likewise.  Adjust calls to "lstat"
callback by call to "to_lstat" callback

sim/cris/ChangeLog:

* traps.c (cris_break_13_handler): Adjust call to "fstat" callback
by call to "to_fstat" following renaming in callback.h.

sim/h8300/ChangeLog:

* compile.c (sim_resume):  Adjust calls to "stat" and "fstat"
callbacks by calls to "to_stat" and "to_fstat" (resp) callbacks
following renaming in callback.h.

9 years agoCheck info->executable for symbols which need copy relocs
H.J. Lu [Wed, 3 Dec 2014 00:57:45 +0000 (16:57 -0800)] 
Check info->executable for symbols which need copy relocs

* elf64-x86-64.c (elf_x86_64_relocate_section): Check
info->executable for symbols which need copy relocs.

9 years agoRemove cplus_specific from general_symbol_info.
Doug Evans [Wed, 3 Dec 2014 00:54:16 +0000 (16:54 -0800)] 
Remove cplus_specific from general_symbol_info.

This patch reverts the addition of cplus_specific added here:

2010-07-16  Sami Wagiaalla  <swagiaal@redhat.com>

* symtab.h (symbol_set_demangled_name): Now takes an optional objfile*
argument.
(cplus_specific): New struct.
* symtab.c (symbol_set_demangled_name): Updated.
Use cplus_specific for cplus symbols.
(symbol_get_demangled_name): Retrive the name from the cplus_specific
struct for cplus symbols.
(symbol_init_language_specific): Set cplus_specific for cplus symbols.
(symbol_set_names): Pass objfile to symbol_set_demangled_name.
* symtab.c (symbol_init_cplus_specific): New function.

It was added in anticipation of improved template support:

https://sourceware.org/ml/gdb-patches/2010-05/msg00594.html
https://sourceware.org/ml/gdb-patches/2010-07/msg00284.html

However, minsyms pay the price for this space too.
For my standard benchmark this patch gets back 44MB of memory
when gdb starts.  [There's still ~440MB of memory used
by the demangled ELF symbols of this benchmark, but that's another topic.]

When the improved templated support is added,
I wonder if this can be moved to struct symbol.
Hmmm, we already have a special version of
struct symbol for templates (struct template_symbol).

gdb/ChangeLog:

* symtab.c (symbol_init_cplus_specific): Delete.
(symbol_set_demangled_name): Remove special c++ support.
(symbol_get_demangled_name, symbol_set_language): Ditto.
* symtab.h (struct cplus_specific): Delete.
(struct general_symbol_info) <language_specific>: Remove
cplus_specific.

9 years agoDiscard space for relocs against symbols with copy relocs
H.J. Lu [Wed, 3 Dec 2014 00:50:14 +0000 (16:50 -0800)] 
Discard space for relocs against symbols with copy relocs

This patch reverts the change in elf_x86_64_check_relocs and the partial
change in elf_x86_64_adjust_dynamic_symbol.  Instead, we discard space
in PIE for relocs against symbols which turn out to need copy relocs.

* elf64-x86-64.c (elf_x86_64_check_relocs): Revert the last
change.
(elf_x86_64_adjust_dynamic_symbol): Don't check !info->shared
with ELIMINATE_COPY_RELOCS.
(elf_x86_64_allocate_dynrelocs): For PIE, discard space for
relocs against symbols which turn out to need copy relocs.

9 years agoPR symtab/17602
Doug Evans [Wed, 3 Dec 2014 00:40:38 +0000 (16:40 -0800)] 
PR symtab/17602

gdb/ChangeLog:

PR symtab/17602
* linespec.c (iterate_name_matcher): Fix arguments to symbol_name_cmp.

gdb/testsuite/ChangeLog:

        PR symtab/17602
* gdb.cp/anon-ns.cc: Move guts of this file to ...
* gdb.cp/anon-ns-2.cc: ... here.  New file.
* gdb.cp/anon-ns.exp: Update.

9 years agoPR symtab/17591
Doug Evans [Wed, 3 Dec 2014 00:24:37 +0000 (16:24 -0800)] 
PR symtab/17591

gdb/ChangeLog:

PR symtab/17591
* dwarf2read.c (find_slot_in_mapped_hash): Use cp_remove_params
to strip parameters.

9 years agodwarf2read.c (peek_die_abbrev): Improve error message text.
Doug Evans [Wed, 3 Dec 2014 00:22:18 +0000 (16:22 -0800)] 
dwarf2read.c (peek_die_abbrev): Improve error message text.

gdb/ChangeLog:

* dwarf2read.c (peek_die_abbrev): Improve error message text.

9 years agoRemove remnant of Chill support.
Doug Evans [Wed, 3 Dec 2014 00:15:53 +0000 (16:15 -0800)] 
Remove remnant of Chill support.

gdb/ChangeLog:

* valops.c (do_search_struct_field): Remove remnant of Chill support.
Ref: commit 4c2260aa5c261f7bfb26dcf3aa7c67876720b17e

9 years agoAutomatic date update in version.in
GDB Administrator [Wed, 3 Dec 2014 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoX86-64: Allow copy relocs for building PIE
H.J. Lu [Tue, 2 Dec 2014 23:14:28 +0000 (15:14 -0800)] 
X86-64: Allow copy relocs for building PIE

This patch allows copy relocs for non-GOT pc-relative relocation in PIE.

bfd/

* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Always
allow copy relocs for building executables.
(elf_x86_64_check_relocs): Allow copy relocs for non-GOT
pc-relative relocation in shared object.
(elf_x86_64_adjust_dynamic_symbol): Allocate copy relocs for
PIE.
(elf_x86_64_relocate_section): Don't copy a pc-relative
relocation into the output file if the symbol needs copy reloc.

ld/testsuite/

* ld-x86-64/copyreloc-lib.c: New file.
* ld-x86-64/copyreloc-main.c: Likewise.
* ld-x86-64/copyreloc-main.out: Likewise.
* ld-x86-64/copyreloc-main1.rd: Likewise.
* ld-x86-64/copyreloc-main2.rd: Likewise.

* ld-x86-64/x86-64.exp: Run copyreloc tests.

9 years agoFix comment typo
Simon Marchi [Tue, 2 Dec 2014 22:19:11 +0000 (17:19 -0500)] 
Fix comment typo

ChangeLog:

* common/cleanups.c (make_cleanup_dtor): Fix comment typo.

9 years agoNew python events: inferior call, register/memory changed.
Nick Bull [Tue, 2 Dec 2014 19:15:29 +0000 (11:15 -0800)] 
New python events: inferior call, register/memory changed.

gdb/ChangeLog:

* NEWS: Mention new Python events.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-infevents.o.
(SUBDIR_PYTHON_SRCS): Add py-infevents.c.
(py-infevents.o): New rule.
* doc/observer.texi (inferior_call_pre, inferior_call_post)
(memory_changed, register_changed): New observers.
* infcall.c (call_function_by_hand): Notify observer before and
after inferior call.
* python/py-event.h (inferior_call_kind): New enum.
(emit_inferior_call_event): New prototype.
(emit_register_changed_event): New prototype.
(emit_memory_changed_event): New prototype.
* python/py-events.h (events_object): New registries
inferior_call, memory_changed and register_changed.
* python/py-evts.c (gdbpy_initialize_py_events): Add the
inferior_call, memory_changed and register_changed registries.
* python/py-infevents.c: New.
* python/py-inferior.c (python_on_inferior_call_pre)
(python_on_inferior_call_post, python_on_register_change)
(python_on_memory_change): New functions.
(gdbpy_initialize_inferior): Attach python handler to new
observers.
* python/py-infthread.c(gdbpy_create_ptid_object): New.
(thpy_get_ptid) Use gdbpy_create_ptid_object.
* python/python-internal.h:
(gdbpy_create_ptid_object)
(gdbpy_initialize_inferior_call_pre_event)
(gdbpy_initialize_inferior_call_post_event)
(gdbpy_initialize_register_changed_event)
(gdbpy_initialize_memory_changed_event): New prototypes.
* python/python.c (_initialize_python): Initialize new events.
* valops.c (value_assign): Notify register_changed observer.

gdb/doc/ChangeLog:

* python.texi (Events In Python): Document new events
InferiorCallPreEvent, InferiorCallPostEvent, MemoryChangedEvent
and RegisterChangedEvent.

gdb/testsuite/ChangeLog:

* gdb.python/py-events.py (inferior_call_handler): New.
(register_changed_handler, memory_changed_handler): New.
(test_events.invoke): Register new handlers.
* gdb.python/py-events.exp: Add tests for inferior call,
memory_changed and register_changed events.

9 years agorevert previous patch so that I can re-commit with correct author
Doug Evans [Tue, 2 Dec 2014 19:12:49 +0000 (11:12 -0800)] 
revert previous patch so that I can re-commit with correct author

9 years agoNew python events: infcall, register/memory changed.
Doug Evans [Tue, 2 Dec 2014 18:59:08 +0000 (10:59 -0800)] 
New python events: infcall, register/memory changed.

gdb/ChangeLog:

* NEWS: Mention new Python events.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-infevents.o.
(SUBDIR_PYTHON_SRCS): Add py-infevents.c.
(py-infevents.o): New rule.
* doc/observer.texi (inferior_call_pre, inferior_call_post)
(memory_changed, register_changed): New observers.
* infcall.c (call_function_by_hand): Notify observer before and
after inferior call.
* python/py-event.h (inferior_call_kind): New enum.
(emit_inferior_call_event): New prototype.
(emit_register_changed_event): New prototype.
(emit_memory_changed_event): New prototype.
* python/py-events.h (events_object): New registries
inferior_call, memory_changed and register_changed.
* python/py-evts.c (gdbpy_initialize_py_events): Add the
inferior_call, memory_changed and register_changed registries.
* python/py-infevents.c: New.
* python/py-inferior.c (python_on_inferior_call_pre)
(python_on_inferior_call_post, python_on_register_change)
(python_on_memory_change): New functions.
(gdbpy_initialize_inferior): Attach python handler to new
observers.
* python/py-infthread.c(gdbpy_create_ptid_object): New.
(thpy_get_ptid) Use gdbpy_create_ptid_object.
* python/python-internal.h:
(gdbpy_create_ptid_object)
(gdbpy_initialize_inferior_call_pre_event)
(gdbpy_initialize_inferior_call_post_event)
(gdbpy_initialize_register_changed_event)
(gdbpy_initialize_memory_changed_event): New prototypes.
* python/python.c (_initialize_python): Initialize new events.
* valops.c (value_assign): Notify register_changed observer.

gdb/doc/ChangeLog:

* python.texi (Events In Python): Document new events
InferiorCallPreEvent, InferiorCallPostEvent, MemoryChangedEvent
and RegisterChangedEvent.

gdb/testsuite/ChangeLog:

* gdb.python/py-events.py (inferior_call_handler): New.
(register_changed_handler, memory_changed_handler): New.
(test_events.invoke): Register new handlers.
* gdb.python/py-events.exp: Add tests for inferior call,
memory_changed and register_changed events.

9 years agopython/py-infthread.c: Whitespace fixes.
Doug Evans [Tue, 2 Dec 2014 18:01:07 +0000 (10:01 -0800)] 
python/py-infthread.c: Whitespace fixes.

gdb/ChangeLog:

* python/py-infthread.c: Whitespace fixes.

9 years ago * MAINTAINERS: Fix my email address.
Denis Chertykov [Tue, 2 Dec 2014 16:45:59 +0000 (19:45 +0300)] 
* MAINTAINERS: Fix my email address.

9 years agoexecl-update-breakpoints.exp: Move whole segment instead of .text section
Andreas Arnez [Tue, 2 Dec 2014 15:35:47 +0000 (16:35 +0100)] 
execl-update-breakpoints.exp: Move whole segment instead of .text section

The test case builds two copies of the program, one with the compile
option "ldflags=-Wl,-Ttext=0x1000000" and the other with the address
changed to 0x2000000.  However, when linking with ld.bfd, the
resulting executables crash early in ld.so on S390 and i386.

Analysis of the crash: The default linker script establishes a certain
order of loadable sections, and the option "-Ttext" effectively splits
these into an "unaffected" lot (everything before .text) and an
"affected" lot.  The affected lot is placed at the given address,
whereas the unaffected lot stays at its default address.  The
unaffected lot starts at an aligned address plus Elf header sizes,
which is good if it is the first LOAD segment (like on AMD64).  But if
the affected lot comes first instead (like on S390 and i386), the PHDR
doesn't fit there and is placed *outside* any LOAD segments.  Then the
PHDR is not mapped when the loader gets control, and the loader runs
into a segmentation fault while trying to access it.

Since we are lucky about the order of segments on AMD64, the test
succeeds there, but the resulting binaries are unusually large -- 2.1M
each, with lots of padding within.

When replacing '-Ttext' by '-Ttext-segment', the linker moves all
segments consistently, the binaries have normal sizes, and the test
case succeeds on all mentioned platforms.

Since old versions of the gold linker don't support '-Ttext-segment',
the patch also adds logic for falling back to '-Ttext'.

gdb/testsuite/ChangeLog:

* gdb.base/execl-update-breakpoints.exp: Specify the link address
with '-Ttext-segment' instead of '-Ttext'.  Fall back to '-Ttext'
if the linker doesn't understand this.

9 years ago[MIPS] When calculating a relocation using an undefined weak symbol don't check for...
Andrew Bennett [Thu, 20 Nov 2014 15:40:16 +0000 (15:40 +0000)] 
[MIPS] When calculating a relocation using an undefined weak symbol don't check for overflow.

In MIPS the relocation calculation only ignores the overflow checks for undefined
weak symbols on relocations associated with j/jal.   This patch extends this to
the relocations used by the: b* instructions; pc/gp relative symbol offsets; and the
lwpc/ldpc MIPS r6 instructions.

bfd/
* elfxx-mips.c (mips_elf_calculate_relocation): Only check for overflow
on non-weak undefined symbols.

ld/testsuite/
* ld-mips-elf/mips-elf.exp: Add in undefined weak overflow tests for
o32, n32 and n64.
* ld-mips-elf/undefweak-overflow.s: New test.
* ld-mips-elf/undefweak-overflow.d: New test.
* ld-mips-elf/undefweak-overflow-n32.d: New test.
* ld-mips-elf/undefweak-overflow-n64.d: New test.

9 years agoppc64_elf_edit_opd revamp
Alan Modra [Tue, 2 Dec 2014 04:39:16 +0000 (15:09 +1030)] 
ppc64_elf_edit_opd revamp

This patch sorts .opd relocs (see pr17666) and allows .opd sections
with a mix of 16 and 24 byte entries to be edited.

* elf64-ppc.c (OPD_NDX): Define.  Use throughout for sizing/indexing
_opd_sec_data array, halving required memory.
(sort_r_offset): New function.
(ppc64_elf_edit_opd): Sort incoming relocs.  Accept .opd
sections with a mix of 16 and 24 byte OPD entries.  Don't
attempt to honour --non-overlapping-opd for .opd sections with
unexpected relocs.  Simplify opd entry size calculations by
first finding the reloc for the next entry.  Make edit loop
handle one opd entry per iteration, with an inner loop
handling relocs per entry.

9 years agoS390: Fix 'expedite' for s390-te-linux64
Andreas Arnez [Tue, 2 Dec 2014 09:47:30 +0000 (10:47 +0100)] 
S390: Fix 'expedite' for s390-te-linux64

Fix a typo in the expedited registers for s390-te-linux64.

gdb/ChangeLog:

* features/Makefile (s390-te-linux64-expedite): Replace
non-existant r14 and r15 by r14l and r15l, respectively.
* regformats/s390-te-linux64.dat: Regenerate.

9 years agoAutomatic date update in version.in
GDB Administrator [Tue, 2 Dec 2014 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoAdd support for -z global.
Dmitriy Ivanov [Mon, 1 Dec 2014 21:37:21 +0000 (13:37 -0800)] 
Add support for -z global.

gold/
* layout.cc (Layout::finish_dynamic_section): When '-z global'
is specified set DF_1_GLOBAL in DT_FLAGS_1 flags.
* options.h (General_options): New -z option (global).

9 years agoFix extraneous warning about executable stack.
Cary Coutant [Mon, 1 Dec 2014 21:21:49 +0000 (13:21 -0800)] 
Fix extraneous warning about executable stack.

PR gold/17578 notes that gold will print a warning about an executable stack
when the -z execstack option is given, even when there is no --warn_execstack
option. The warning is completely useless and unexpected, since the user
explicitly requested an executable stack, and did not even ask for warnings.

This patch fixes that, and adds an extra warning when --warn_execstack
and -z noexecstack are both given and an input file requires an executable
stack.

gold/
PR gold/17578
* layout.cc (Layout::layout_gnu_stack): Don't warn when -z execstack
is given.
(Layout::create_executable_stack_info): Warn when -z noexecstack is
given but some inputs require executable stack.

9 years agoProperly check for an out of range row index
H.J. Lu [Mon, 1 Dec 2014 17:11:57 +0000 (09:11 -0800)] 
Properly check for an out of range row index

* dwarf.c (process_cu_tu_index): Properly check for an out of
range row index.

9 years agoMore fixes for memory access violations exposed by fuzzed binaries.
Nick Clifton [Mon, 1 Dec 2014 16:43:46 +0000 (16:43 +0000)] 
More fixes for memory access violations exposed by fuzzed binaries.

PR binutils/17512
* dwarf.h (struct dwarf_section): Add user_data field.
* dwarf.c (frame_need_space): Check for an over large register
number.
(display_debug_frames): Check the return value from
frame_need_space.  Check for a CFA expression that is so long the
start address wraps around.
(debug_displays): Initialise the user_data field.
* objdump.c (load_specific_debug_section): Save the BFD section
pointer in the user_data field of the dwarf_section structure.
(free_debug_section): Update BFD section data when freeing section
contents.
* readelf.c (load_specific_debug_section): Initialise the
user_data field.

* archive.c (do_slurp_coff_armap): Add range checks to prevent
running off the end of the string table.
* compress.c (bfd_get_full_section_contents): Return a NULL
pointer for zero sized sections.  Do not attempt to copy a buffer
onto itself.
* elf-attrs.c (_bfd_elf_parse_attributes): Check for an empty
header.  Add range checks to avoid running off the end of the
section.
* elf.c (bfd_elf_get_str_section): Seek before allocating so that
if the seek fails, no memory is allocated.
(bfd_elf_string_from_elf_section): Do not allocate a string from a
non string section.  It only leads to trouble later on.
(_bfd_elf_print_private_bfd_data): Check for there being too
little external dynamic data.
(bfd_section_from_shdr): Replace assertion with a failure mode.
(bfd_section_from_shdr): When walking a loaded group section use
the internal structure size, not the external size.  Check for the
group section being empty.
* elf32-i386.c (elf_i386_rtype_to_howto): Replace assertion with a
failure mode.
* elfcode.h (elf_slurp_reloc_table): Likewise.
* reloc.c (bfd_perform_relocation): Avoid seg-fault if the howto
parameter is NULL.

9 years agoRemove duplicate comment
Simon Marchi [Mon, 1 Dec 2014 14:12:59 +0000 (09:12 -0500)] 
Remove duplicate comment

gdb/ChangeLog:

* objfiles.c (allocate_objfile): Remove duplicate comment.

9 years agoAdd tests for PR ld/16452 and PR ld/16457
H.J. Lu [Mon, 1 Dec 2014 14:06:21 +0000 (06:06 -0800)] 
Add tests for PR ld/16452 and PR ld/16457

PR ld/16452
PR ld/16457
* ld-elf/pr16452.map: New file.
* ld-elf/pr16452.od: Likewise.
* ld-elf/pr16452a.c: Likewise.
* ld-elf/pr16452b.c: Likewise.
* ld-elf/pr16457.od: Likewise.

* ld-elf/shared.exp (build_tests): Add tests for PR ld/16452 and
PR ld/16457.

9 years agoFix Python help() test for Python 3
Simon Marchi [Mon, 1 Dec 2014 13:08:06 +0000 (08:08 -0500)] 
Fix Python help() test for Python 3

The message displayed when using help() changed a bit with time, so this
adjusts the test accordingly.

gdb/testsuite/ChangeLog:

* gdb.python/python.exp: Change expected reply to help().

9 years agoUse core regset iterators on GNU Hurd
Ulrich Weigand [Mon, 1 Dec 2014 12:42:41 +0000 (13:42 +0100)] 
Use core regset iterators on GNU Hurd

Remove native-only core file handling on GNU Hurd.  Instead, enable the
x86 target generic core regset logic on the Hurd by providing an
appropriate register offset map.

Thanks to Samuel Thibault for testing!

gdb/

* config/i386/i386gnu.mh (NATDEPFILES): Remove core-regset.o.
* i386gnu-nat.c: Do not include <sys/procfs.h> or "gregset.h".
(CREG_OFFSET, creg_offset, CREG_ADDR): Remove.
(supply_gregset, supply_fpregset): Remove.
* i386gnu-tdep.c (i386gnu_gregset_reg_offset): New variable.
(i386gnu_init_abi): Set tdep->gregset_reg_offset, gregset_num_regs,
and sizeof_gregset.

9 years agoAdd checks for memory access violations exposed by fuzzed archives.
Nick Clifton [Mon, 1 Dec 2014 11:19:39 +0000 (11:19 +0000)] 
Add checks for memory access violations exposed by fuzzed archives.

PR binutils/17531
* dwarf.c (process_cu_tu_index): Check for an out of range row
index.
* elfcomm.c (adjust_relative_path): Change name_len parameter to
an unsigned long.  Check for path length overflow.
(process_archive_index_and_symbols): Check for invalid header
size.
(setup_archive): Add checks for invalid archives.
(get_archive_member_name): Add range checks.
* elfcomm.h (adjust_relative_path): Update prototyoe.
* readelf.c (process_archive): Add range checks.

9 years agoDon't enable gdbtk in testsuite
Yao Qi [Tue, 25 Nov 2014 08:07:45 +0000 (16:07 +0800)] 
Don't enable gdbtk in testsuite

When I skim configure.ac and Makefile.in in gdb/testsuite, I happen to
see that directory gdb.gdbtk is added to subdirs, however it doesn't
exist.  gdb/testsuite/gdb.gdbtk was removed by the patch below,

  [rfa] git repo fixup: delete gdb/testsuite/gdb.gdbtk
  http://thread.gmane.org/gmane.comp.gdb.patches/61489

and we should cleanup configure.ac accordingly.

gdb/testsuite:

2014-12-01  Yao Qi  <yao@codesourcery.com>

* configure.ac: Remove AC_ARG_ENABLE for gdbtk.  Don't invoke
AC_CONFIG_SUBDIRS(gdb.gdbtk).
* configure: Re-generated.

9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 1 Dec 2014 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoAdd add-auto-load-scripts-directory.
Jan Kratochvil [Sun, 30 Nov 2014 19:25:48 +0000 (20:25 +0100)] 
Add add-auto-load-scripts-directory.

There is already "add-auto-load-safe-path" which works
like "set auto-load safe-path" but in append mode.

There was missing an append equivalent for "set auto-load scripts-directory".

ABRT has directory /var/cache/abrt-di/ as an alternative one
to /usr/lib/debug/ . Therefore ABRT needs to use -iex parameters to add this
/var/cache/abrt-di/ directory as a first-class debuginfo directory.
Using absolute "set auto-load scripts-directory" would hard-code the path
possibly overriding local system directory additions; besides it would not be
nice anyway.

gdb/ChangeLog
2014-11-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

Add add-auto-load-scripts-directory.
* NEWS (Changes since GDB 7.8): Add add-auto-load-scripts-directory.
* auto-load.c (add_auto_load_dir): New function.
(_initialize_auto_load): Install it.

gdb/doc/ChangeLog
2014-11-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

Add add-auto-load-scripts-directory.
* gdb.texinfo (Auto-loading): Add add-auto-load-scripts-directory link.
(objfile-gdbdotext file): Add add-auto-load-scripts-directory.

9 years agoFix add-auto-load-safe-path typo.
Jan Kratochvil [Sun, 30 Nov 2014 19:22:24 +0000 (20:22 +0100)] 
Fix add-auto-load-safe-path typo.

gdb/doc/ChangeLog
2014-11-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.texinfo (Auto-loading safe path): Fix add-auto-load-safe-path
description typo.

9 years agoframe.c: Fix the check for FID_STACK_INVALID in frame_id_eq()
Martin Galvan [Sun, 30 Nov 2014 15:34:15 +0000 (19:34 +0400)] 
frame.c: Fix the check for FID_STACK_INVALID in frame_id_eq()

I noticed in frame_id_eq() we were checking for the "l" frame_id being
invalid twice instead of checking both "l" and "r", so this patch
corrects it.

gdb/ChangeLog:

* frame.c (frame_id_eq): Fix the check for FID_STACK_INVALID.

9 years agoPower4 should treat mftb as extended mfspr mnemonic
Alan Modra [Sat, 29 Nov 2014 08:43:17 +0000 (19:13 +1030)] 
Power4 should treat mftb as extended mfspr mnemonic

On further reading of ISA manual it appears gas should have been
treating mftb and mftbu as extended mnemonics for mfspr, for ISA 2.03
and later.

opcodes/
* ppc-opc.c (powerpc_opcodes): Make mftb* generate mfspr for
power4 and later.
gas/testsuite/
* gas/ppc/a2.d: Update for mftb change.
* gas/ppc/476.d: Likewise.

9 years agoDon't output symbol version definitions for non-DT_NEEDED libs
Alan Modra [Thu, 27 Nov 2014 04:46:49 +0000 (15:16 +1030)] 
Don't output symbol version definitions for non-DT_NEEDED libs

PR 16452, 16457
* elflink.c (_bfd_elf_link_find_version_dependencies): Exclude
symbols from libraries that won't be listed in DT_NEEDED.
(elf_link_output_extsym): Don't output verdefs for such symbols.

9 years agoAutomatic date update in version.in
GDB Administrator [Sun, 30 Nov 2014 00:00:11 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoCheck that thread stack temps are not already enabled before enabling them.
Siva Chandra [Sat, 29 Nov 2014 17:38:33 +0000 (09:38 -0800)] 
Check that thread stack temps are not already enabled before enabling them.

This fixes a regression introduced by 6c659fc2c7cd2da6d2b9a3d7c38597ad3821832a.

gdb/ChangeLog:

* eval.c (evaluate_subexp): Check that thread stack temporaries
are not already enabled before enabling them.

9 years ago[arm] compute framereg and framesize when needed
Yao Qi [Fri, 28 Nov 2014 08:17:37 +0000 (16:17 +0800)] 
[arm] compute framereg and framesize when needed

I find local variables framereg and framesize is only used when cache
isn't NULL.  This patch to move the code into "if (cache)" block.

gdb:

2014-11-29  Yao Qi  <yao@codesourcery.com>

* arm-tdep.c (arm_analyze_prologue): Move local variables
'framereg' and 'framesize' to inner block.  Move code to
inner block too.

9 years agoEnable chained function calls in C++ expressions.
Siva Chandra [Tue, 11 Nov 2014 13:43:03 +0000 (05:43 -0800)] 
Enable chained function calls in C++ expressions.

gdb/ChangeLog:

* eval.c: Include gdbthread.h.
(evaluate_subexp): Enable thread stack temporaries before
evaluating a complete expression and clean them up after the
evaluation is complete.
* gdbthread.h: Include common/vec.h.
(value_ptr): New typedef.
(VEC (value_ptr)): New vector type.
(value_vec): New typedef.
(struct thread_info): Add new fields stack_temporaries_enabled
and stack_temporaries.
(enable_thread_stack_temporaries)
(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
(get_last_thread_stack_temporary)
(value_in_thread_stack_temporaries): Declare.
* gdbtypes.c (class_or_union_p): New function.
* gdbtypes.h (class_or_union_p): Declare.
* infcall.c (call_function_by_hand): Store return values of class
type as temporaries on stack.
* thread.c (enable_thread_stack_temporaries): New function.
(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
(get_last_thread_stack_temporary): Likewise.
(value_in_thread_stack_temporaries): Likewise.
* value.c (value_force_lval): New function.
* value.h (value_force_lval): Declare.

gdb/testsuite/ChangeLog:

* gdb.cp/chained-calls.cc: New file.
* gdb.cp/chained-calls.exp: New file.
* gdb.cp/smartp.exp: Remove KFAIL for "p c2->inta".

9 years agoAutomatic date update in version.in
GDB Administrator [Sat, 29 Nov 2014 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoRemove broken nios2 assembler dwim support.
Sandra Loosemore [Fri, 28 Nov 2014 22:41:32 +0000 (14:41 -0800)] 
Remove broken nios2 assembler dwim support.

2014-11-28  Sandra Loosemore  <sandra@codesourcery.com>

include/opcode/
* nios2.h (NIOS2_INSN_ADDI, NIOS2_INSN_ANDI): Delete.
(NIOS2_INSN_ORI, NIOS2_INSN_XORI): Delete.
(NIOS2_INSN_OPTARG): Renumber.

opcodes/
* nios2-opc.c (nios2_r1_opcodes): Remove deleted attributes
from descriptors.

gas/
* config/tc-nios2.c (can_evaluate_expr, get_expr_value): Delete.
(output_addi, output_andi, output_ori, output_xori): Delete.
(md_assemble): Remove calls to deleted functions.

gas/testsuite/
* gas/nios2/nios2.exp: Make "movi" a list test.
* gas/nios2/movi.s: Adjust comments, add another case.
* gas/nios2/movi.l: New.
* gas/nios2/movi.d: Delete.

9 years agoFix prints in tests for Python 3
Simon Marchi [Fri, 28 Nov 2014 16:18:48 +0000 (11:18 -0500)] 
Fix prints in tests for Python 3

Python 3's print requires to use parentheses, so this patch adds them
where they were missing.

gdb/testsuite/ChangeLog:

* gdb.ada/py_range.exp: Add parentheses to calls to print.
* gdb.dwarf2/symtab-producer.exp: Same.
* gdb.gdb/python-interrupts.exp: Same.
* gdb.gdb/python-selftest.exp: Same.
* gdb.python/py-linetable.exp: Same.
* gdb.python/py-type.exp: Same.
* gdb.python/py-value-cc.exp: Same.
* gdb.python/py-value.exp: Same.

9 years agoCorrect fabs and fneg insns in simulator
Oleg Endo [Fri, 28 Nov 2014 15:39:39 +0000 (19:39 +0400)] 
Correct fabs and fneg insns in simulator

It seems that the implementation of the SH fabs and fneg insns in the
simulator is not correct.  They use the FP_UNARY macro which checks the
FPSCR.PR setting and raises an exception if PR = 1 (double precision)
and the register number is not even (i.e. a valid DF reg number).
For normal unary FP insns this is fine.  However, fneg and fabs perform
the same (integer) operations regardless of the FPSCR.PR setting.

This issue initially popped up here
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63260

I've checked some of the failing tests mentioned in GCC PR 63260 above
with the patch applied and the failures go away.

sim/sh/ChangeLog (tiny patch):

* gencode.c (fabs, fneg): Implement as integer operation
instead of using the FP_UNARY macro.

9 years agoFix amd64 dwarf register number mapping (MMX register and higher)
Pierre Muller [Fri, 28 Nov 2014 15:21:58 +0000 (19:21 +0400)] 
Fix amd64 dwarf register number mapping (MMX register and higher)

Dwarf register numbers are defined in "System V Application Binary
Interface AMD64 Architecture Processor Supplement Draft Version 0.99.6"

The amd64_dwarf_regmap array is missing the 8 MMX registers in Figure
3.36: DWARF Register Number Mapping page 57.  This leads to a wrong
value for the registers past this point.

gdb/ChangeLog:

        Pushed by Joel Brobecker  <brobecker@adacore.com>.
        * amd64-tdep.c (amd64_dwarf_regmap array): Add missing MMX
        registers.

Tested on x86_64-linux.

9 years agoRemove (dead-code) native core file sniffers on Linux targets
Ulrich Weigand [Fri, 28 Nov 2014 14:53:05 +0000 (15:53 +0100)] 
Remove (dead-code) native core file sniffers on Linux targets

Since Andreas Arnez' recent patch series, all Linux targets install
gdbarch_iterate_over_regset_sections routines.  This means that on
Linux native targets, old-style core sniffers are never used.

Most Linux targets haven't been using such sniffers for a long time
anyway, but a couple remain: ia64 and sparc use core-regset.o, and
m68k installs its own core_fns.  All this is now dead code, which
this commit removes.

gdb/
2014-11-28  Ulrich Weigand  <uweigand@de.ibm.com>

* config/ia64/linux.mh (NATDEPFILES): Remove core-regset.o.
* config/sparc/linux.mh (NATDEPFILES): Likewise.
* config/sparc/linux64.mh (NATDEPFILES): Likewise.
* m68klinux-nat.c (fetch_core_registers): Remove.
(linux_elf_core_fns): Remove.
(_initialize_m68k_linux_nat): Do not call deprecated_add_core_fns.

9 years agogdb_realpath: Rework comment about handling on Windows.
Joel Brobecker [Fri, 28 Nov 2014 14:37:08 +0000 (18:37 +0400)] 
gdb_realpath: Rework comment about handling on Windows.

Rework the comment to explain why we're still relying on GetFullPathName
even though gnulib ensures that canonicalize_file_name is now available
on all platforms, including Windows.

gdb/ChangeLog:

        * utils.c (gdb_realpath): Rework comment about handling on
        Windows.

9 years agoImport rename module
Yao Qi [Sun, 23 Nov 2014 14:19:49 +0000 (22:19 +0800)] 
Import rename module

This patch is to import rename module.

gdb:

2014-11-28  Yao Qi  <yao@codesourcery.com>

* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add
rename.
* gnulib/aclocal.m4: Re-generated.
* gnulib/config.in: Re-generated.
* gnulib/configure: Re-generated.
* gnulib/import/Makefile.am: Re-generated.
* gnulib/import/Makefile.in: Re-generated.
* gnulib/import/m4/gnulib-cache.m4: Re-generated.
* gnulib/import/m4/gnulib-comp.m4: Re-generated.
* import/basename-lgpl.c: New file.
* import/dirname-lgpl.c: New file.
* import/dirname.h: New file.
* import/m4/dirname.m4: New file.
* import/m4/malloc.m4: New file.
* import/m4/rename.m4: New file.
* import/m4/rmdir.m4: New file.
* import/m4/stdio_h.m4: New file.
* import/malloc.c: New file.
* import/rename.c: New file.
* import/rmdir.c: New file.
* import/same-inode.h: New file.
* import/stdio.c: New file.
* import/stdio.in.h: New file.
* import/stripslash.c: New file.

9 years agoUse canonicalize_file_name unconditionally
Yao Qi [Mon, 24 Nov 2014 06:09:43 +0000 (14:09 +0800)] 
Use canonicalize_file_name unconditionally

gdb:

2014-11-28  Yao Qi  <yao@codesourcery.com>

* configure.ac (AC_CHECK_FUNCS): Remove canonicalize_file_name
and realpath.
* config.in: Re-generated.
* configure: Re-generated.
* utils.c (gdb_realpath): Remove code calling realpath,
canonicalize_file_name and pathconf.
[!_WIN32]: Call canonicalize_file_name.

9 years agoImport canonicalize-lgpl
Yao Qi [Sun, 23 Nov 2014 14:02:50 +0000 (22:02 +0800)] 
Import canonicalize-lgpl

This patch is to import canonicalize-lgpl module, which provides
readlpath and canonicalize_file_name.

gdb:

2014-11-28  Yao Qi  <yao@codesourcery.com>

* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add
canonicalize-lgpl.
* aclocal.m4: Re-generated.
* config.in: Re-generated.
* configure: Re-generated.
* import/Makefile.am: Re-generated.
* import/Makefile.in: Re-generated.
* import/m4/gnulib-cache.m4: Re-generated.
* import/m4/gnulib-comp.m4: Re-generated.
* import/canonicalize-lgpl.c: New file.
* import/extra/snippet/_Noreturn.h: New file.
* import/m4/canonicalize.m4: New file.
* import/m4/double-slash-root.m4: New file.
* import/m4/eealloc.m4: New file.
* import/m4/malloca.m4: New file.
* import/m4/nocrash.m4: New file.
* import/m4/stdlib_h.m4: New file.
* import/malloca.c: New file.
* import/malloca.h: New file.
* import/malloca.valgrind: New file.

9 years agoUse lstat unconditionally
Yao Qi [Thu, 6 Nov 2014 12:34:28 +0000 (20:34 +0800)] 
Use lstat unconditionally

Since lstat gnulib module is imported, we can use it unconditionally.
lstat usage was introduced by this patch

https://sourceware.org/ml/gdb-patches/2012-01/msg00390.html

during the review, it was suggested to import gnulib lstat module, but
we didn't do that.

gdb:

2014-11-28  Yao Qi  <yao@codesourcery.com>

* configure.ac (AC_CHECK_FUNCS): Remove lstat.
* config.in, configure: Regenerate.
* symfile.c (find_separate_debug_file_by_debuglink): Remove
code checking HAVE_LSTAT is defined.

9 years agoImport lstat
Yao Qi [Sun, 23 Nov 2014 13:54:45 +0000 (21:54 +0800)] 
Import lstat

This patch is to import lstat gnulib module.

gdb:

2014-11-28  Yao Qi  <yao@codesourcery.com>

* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add
lstat.
* gnulib/aclocal.m4: Re-generated.
* gnulib/config.in: Re-generated.
* gnulib/configure: Re-generated.
* gnulib/import/Makefile.am: Re-generated.
* gnulib/import/Makefile.in: Re-generated.
* gnulib/import/m4/gnulib-cache.m4: Re-generated.
* gnulib/import/m4/gnulib-comp.m4: Re-generated.
* gnulib/import/lstat.c: New file.
* gnulib/import/m4/lstat.m4: New file.

9 years agoUse readlink unconditionally
Yao Qi [Tue, 4 Nov 2014 14:17:02 +0000 (22:17 +0800)] 
Use readlink unconditionally

Since readlink module is imported, we can use it unconditionally.
This patch is to remove configure checks and HAVE_READLINK checks in
code.  It was mentioned in the patch below

  [RFA/commit] gdbserver: return ENOSYS if readlink not supported.
  https://sourceware.org/ml/gdb-patches/2012-02/msg00148.html

to use readlink in gdbserver, but we chose something simple at that
moment.

gdb:

2014-11-28  Yao Qi  <yao@codesourcery.com>

* configure.ac (AC_CHECK_FUNCS): Remove readlink.
* config.in, configure: Re-generate.
* inf-child.c (inf_child_fileio_readlink): Don't check
HAVE_READLINK is defined.

gdb/gdbserver:

2014-11-28  Yao Qi  <yao@codesourcery.com>

* configure.ac(AC_CHECK_FUNCS): Remove readlink.
* config.in, configure: Re-generate.
* hostio.c (handle_unlink): Remove code checking HAVE_READLINK
is defined.

9 years agoImport readlink
Yao Qi [Sun, 23 Nov 2014 13:49:20 +0000 (21:49 +0800)] 
Import readlink

This patch is to import readlink gnulib module.  stat module is imported
too, but it isn't used by gdb.

gdb:

2014-11-28  Yao Qi  <yao@codesourcery.com>

* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add readlink.
* gnulib/aclocal.m4: Re-generated.
* gnulib/config.in: Likewise.
* gnulib/configure: Likewise.
* gnulib/import/Makefile.am: Likewise.
* gnulib/import/Makefile.in: Likewise.
* gnulib/import/m4/gnulib-cache.m4: Likewise.
* gnulib/import/m4/gnulib-comp.m4: Likewise.
* gnulib/import/dosname.h: New file
  * gnulib/import/m4/largefile.m4: New file.
* gnulib/import/m4/readlink.m4: New file.
* gnulib/import/m4/stat.m4: New file.
* gnulib/import/readlink.c: New file.
  * gnulib/import/stat.c: New file.

9 years agoFix date in changelog
Yao Qi [Fri, 28 Nov 2014 09:23:26 +0000 (17:23 +0800)] 
Fix date in changelog

9 years agoSanity checks on version section
Alan Modra [Thu, 27 Nov 2014 23:40:44 +0000 (10:10 +1030)] 
Sanity checks on version section

* elf.c (_bfd_elf_slurp_version_tables): Exit loops when vn_next/
vna_next/vd_next/vda_next is zero.  Correct counts.

9 years agoDon't deprecate powerpc mftb insn
Alan Modra [Fri, 28 Nov 2014 02:51:52 +0000 (13:21 +1030)] 
Don't deprecate powerpc mftb insn

mftb is marked phased out in the architecture manual, but we can keep
it as an extended mnemonic for mftbl.

* ppc-opc.c (powerpc_opcodes <mftb>): Don't deprecate for power7.
(TB): Delete.
(insert_tbr, extract_tbr): Validate tbr number.

9 years agoFix build breakage on 32-bit targets with 64-bit bfd
Alan Modra [Fri, 28 Nov 2014 03:59:23 +0000 (14:29 +1030)] 
Fix build breakage on 32-bit targets with 64-bit bfd

* readelf.c (get_32bit_elf_symbols): Cast bfd_size_type values to
unsigned long for %lx.
(get_64bit_elf_symbols, process_section_groups): Likewise.

9 years agoMatch library name prefixed with sysroot
Yao Qi [Fri, 28 Nov 2014 03:21:48 +0000 (11:21 +0800)] 
Match library name prefixed with sysroot

We enable systemtap probe in glibc recently, and see the following gdb fail,

(gdb) set solib-absolute-prefix /.
...
Stopped due to shared library event:^M
  Inferior loaded /./foo/bar/gdb.base/break-probes-solib.so
...
(gdb) FAIL: gdb.base/break-probes.exp: run til our library loads (the program exited)

$binfile_lib is /foo/bar/gdb.base/break-probes-solib.so, but the
sysroot is prefixed in solib.c:solib_find, as comments described:

   Global variable GDB_SYSROOT is used as a prefix directory
   to search for shared libraries if they have an absolute path.

so the output becomes "/./foo/bar/gdb.base/break-probes-solib.so", which
is still correct.  However, the test repeatedly continue the program
and tries to match $binfile_lib, finally, the program exits and the
test fails.

This patch is to adjust the pattern to match $sysroot$binfile_lib
instead of $binfile_lib.

gdb/testsuite:

2014-11-28  Yao Qi  <yao@codesourcery.com>

* gdb.base/break-probes.exp: Match library name prefixed with
sysroot.

9 years agoAutomatic date update in version.in
GDB Administrator [Fri, 28 Nov 2014 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoFixes an infinite loop in readelf parsing a corrupt binary, and other minor corrections.
Espen Grindhaug [Thu, 27 Nov 2014 15:49:23 +0000 (15:49 +0000)] 
Fixes an infinite loop in readelf parsing a corrupt binary, and other minor corrections.

PR binutils/17531
* readelf.c (get_data): Move excessive length check to earlier on
in the function and allow for wraparound in the arithmetic.
(get_32bit_elf_symbols): Terminate early if the section size is
zero.  Check for an invalid sh_entsize.  Check for an index
section with an invalid size.
(get_64bit_elf_symbols): Likewise.
(process_section_groups): Check for an invalid sh_entsize.

9 years agoUpdate mips tests with symbol version string
H.J. Lu [Thu, 27 Nov 2014 14:41:58 +0000 (06:41 -0800)] 
Update mips tests with symbol version string

* ld-mips-elf/got-vers-1.rd: Add symbol version string to
versioned symbol names in dynamic relocation.
* ld-mips-elf/reloc-estimate-1.d: Likewise.
* ld-mips-elf/tlsdyn-o32-1.got: Likewise.
* ld-mips-elf/tlsdyn-o32-2.got: Likewise.
* ld-mips-elf/tlsdyn-o32-3.got: Likewise.
* ld-mips-elf/tlslib-o32-ver.got: Likewise.

9 years agoFix test always passing in python/py-linetable.exp
Simon Marchi [Wed, 26 Nov 2014 18:03:57 +0000 (13:03 -0500)] 
Fix test always passing in python/py-linetable.exp

The following test is found in python/py-linetable.exp:

gdb_test "python print sorted(fset)" \
    "\[20L, 21L, 22L, 24L, 25L, 28L, 29L, 30L, 32L, 33L, 37L, 39L, 40L, 42L, 44L, 45L, 46L\].*" \
    "Test frozen set contains line numbers"

I noticed that it passed when using Python 3, even though it should fail
because of the missing parentheses for the call print.

There needs to be more escaping of the square brackets. Currently, it is
interpreted as "any one character from this big list of characters,
followed by .*". When adding the required amount of backslashes, the
test starts failing as it should.

Moreover, both in Python 2.7 and Python 3.3 the numbers don't have the L
suffix, so now the test fails because of that. Anybody knows why they
were there in the first place? I just tested with Python 2.4 and there
are no Ls.

gdb/testsuite/ChangeLog:

* gdb.python/py-linetable.exp: Escape properly sorted(fset)
test expected output.  Add parentheses for the call to print.
Remove L suffix from integers.

Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
9 years agoFixes a few more memory access violations exposed by fuzzed binaries.
Nick Clifton [Thu, 27 Nov 2014 12:19:10 +0000 (12:19 +0000)] 
Fixes a few more memory access violations exposed by fuzzed binaries.

PR binutils/17512
* ecoff.c (_bfd_ecoff_slurp_symbol_table): Warn about and correct
a discrepancy between the isymMax and ifdMax values in the
symbolic header.
* elf.c (_bfd_elf_print_private_bfd_data): Fix the range check
scanning the external dynamic entries.

9 years agoAutomatic date update in version.in
GDB Administrator [Thu, 27 Nov 2014 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agodwarf.c handle new DWARFv5 C11, C++11 and C++14 DW_LANG constants.
Mark Wielaard [Mon, 24 Nov 2014 20:24:25 +0000 (21:24 +0100)] 
dwarf.c handle new DWARFv5 C11, C++11 and C++14 DW_LANG constants.

binutils/ChangeLog

* dwarf.c (read_and_display_attr_value): Handle DW_LANG_C11,
DW_LANG_C_plus_plus_11 and DW_LANG_C_plus_plus_14.

9 years agogdb.dwarf2/dw2-op-out-param.S: Fix comment.
Doug Evans [Wed, 26 Nov 2014 22:44:46 +0000 (14:44 -0800)] 
gdb.dwarf2/dw2-op-out-param.S: Fix comment.

gdb/ChangeLog:

* gdb.dwarf2/dw2-op-out-param.S: Fix comment.

9 years agoUpdate list of debug sections for --strip-debug-xxx options.
Cary Coutant [Wed, 26 Nov 2014 22:41:46 +0000 (14:41 -0800)] 
Update list of debug sections for --strip-debug-xxx options.

Add .debug_gdb_scripts, .debug_gnu_pubnames, .debug_gnu_pubtypes,
and .debug_str_offsets to lists of sections to strip or keep
when stripping debug info.

gold/
* layout.cc (gdb_sections): Keep .debug_gdb_scripts and
.debug_str_offsets; strip .debug_gnu_pubnames and
.debug_gnu_pubtypes.
(lines_only_debug_sections): Strip all four new sections.

9 years agoFix for gold linking tlsdesc into an executable with -pie.
Han Shen [Wed, 26 Nov 2014 18:34:46 +0000 (10:34 -0800)] 
Fix for gold linking tlsdesc into an executable with -pie.
(Also included in this patch is a minor typo fix in gold/ChangeLog.)

When linking the following tlsdesc access sequence into an executable with -pie,

     adrp    x0, :tlsdesc:tls_gd
     ldr     x1, [x0, #:tlsdesc_lo12:tls_gd]
     add     x0, x0, :tlsdesc_lo12:tls_gd
     .tlsdesccall    tls_gd
     blr      x1
     mrs      x1, tpidr_el0
     add      x0, x1, x0
     ldr      w0, [x0]

current gold-aarch64 backend does tls-desc-gd-to-ie relaxation, into

       adrp    x0, 1000 <__FRAME_END__+0x720>
       ldr     x1, [x0,#4064]   ;; <=== the target register should be x0
       nop
       nop
       mrs x1, tpidr_el0
       add x0, x1, x0
       ldr w0, [x0]

This code is wrong. The fix changes ldr target register into x0.

9 years agoMore fixes for memory access errors triggered by attemps to examine corrupted binaries.
Nick Clifton [Wed, 26 Nov 2014 14:11:23 +0000 (14:11 +0000)] 
More fixes for memory access errors triggered by attemps to examine corrupted binaries.

PR binutils/17512
* dwarf.c (display_block): Do nothing if the block starts after
the end of the buffer.
(read_and_display_attr_value): Add range checks.
(struct Frame_Chunk): Make the ncols and ra fields unsigned.
(frame_need_space): Test for an ncols of zero.
(read_cie): Fail if the augmentation data extends off the end of
the buffer.
(display_debug_frames): Add checks for read_cie failing.  Add
range checks.
* coff-h8300.c (rtype2howto): Replace abort with returning a NULL
value.
* coff-h8500.c (rtype2howto): Likewise.
* coff-tic30.c (rtype2howto): Likewise.
* coff-z80.c (rtype2howto): Likewise.
* coff-z8k.c (rtype2howto): Likewise.
* coff-ia64.c (RTYPE2HOWTO): Always return a valid howto.
* coff-m68k.c (m68k_rtype2howto): Return a NULL howto if none
could be found.
* coff-mcore.c (RTYPE2HOWTO): Add range checking.
* coff-w65.c (rtype2howto): Likewise.
* coff-we32k.c (RTYPE2HOWTO): Likewise.
* pe-mips.c (RTYPE2HOWTO): Likewise.
* coff-x86_64.c (coff_amd64_reloc): Likewise.  Replace abort with
an error return.
* coffcode.h (coff_slurp_reloc_table): Allow the rel parameter to
be unused.
* coffgen.c (make_a_section_from_file): Check the length of a
section name before testing to see if it is a debug section name.
(coff_object_p): Zero out any uninitialised bytes in the opt
header.
* ecoff.c (_bfd_ecoff_slurp_symbolic_info): Test for the raw
source being empty when there are values to be processed.
(_bfd_ecoff_slurp_symbol_table): Add range check.
* mach-o.c (bfd_mach_o_canonicalize_one_reloc): Likewise.
(bfd_mach_o_mangle_sections): Move test for too many sections to
before the allocation of the section table.
(bfd_mach_o_read_symtab_strtab): If the read fails, free the
memory and nullify the symbol pointer.
* reloc.c (bfd_generic_get_relocated_section_contents): Add
handling of a bfd_reloc_notsupported return value.
* versados.c (EDATA): Add range checking.
(get_record): Likewise.
(process_otr): Check for contents being available before updating
them.
(versados_canonicalize_reloc): Add range check.

9 years agoRecognize new DWARFv5 C11, C++11 and C++14 DW_LANG constants.
Mark Wielaard [Mon, 24 Nov 2014 19:51:06 +0000 (20:51 +0100)] 
Recognize new DWARFv5 C11, C++11 and C++14 DW_LANG constants.

gdb/ChangeLog

* dwarf2read.c (set_cu_language): Recognize DW_LANG_C11,
DW_LANG_C_plus_plus_11, DW_LANG_C_plus_plus_14.

include/ChangeLog

* dwarf2.h: Add DW_LANG_C_plus_plus_11, DW_LANG_C11 and
DW_LANG_C_plus_plus_14.

9 years ago_bfd_elf_slurp_version_tables tidy
Alan Modra [Wed, 19 Nov 2014 08:40:49 +0000 (19:10 +1030)] 
_bfd_elf_slurp_version_tables tidy

The internal verref buffer is allocated with bfd_zalloc, based on a
count given in headers.  If the headers are broken/fuzzed and contain
an enormous count the alloc can result in OOM.  If we first read the
external verrefs (into a buffer that isn't zeroed on allocation) then
the read provides a sanity check on the headers.

Also prints an error for version info that fails other sanity checks.

* elf.c (_bfd_elf_slurp_version_tables): Delay allocation of
internal verref buffer.  Error for zero sh_info.  Print errors.
Check for zero vd_ndx.  Use bfd_zalloc for vd_auxptr buffer.

9 years agoRetry powerpc gold stub grouping when groups prove too large
Alan Modra [Wed, 26 Nov 2014 00:40:29 +0000 (11:10 +1030)] 
Retry powerpc gold stub grouping when groups prove too large

An unusually large number of stubs can result in the default section
group size being too large;  sections plus stubs exceed the range of a
branch.  Restarting the relaxation pass with a smaller group size can
sometimes help.

* powerpc.cc (struct Stub_table_owner): New.
(Powerpc_relobj): Rename stub_table_ to stub_table_index_, an
unsigned int vector.  Update all references.
(powerpc_relobj::set_stub_table): Take an unsigned int param
rather than a Stub_table.  Update callers.
(Powerpc_relobj::clear_stub_table): New function.
(Target_powerpc): Add relax_failed_, relax_fail_count_ and
stub_group_size_ vars.
(Target_powerpc::new_stub_table): Delete.
(max_branch_delta): New function, extracted from..
(Target_powerpc::Relocate::relocate): ..here..
(Target_powerpc::Branch_info::make_stub): ..and here.  Return
status on whether stub created successfully.
(Stub_control::Stub_control): Add "no_size_errors" param.  Move
default sizing to..
(Target_powerpc::do_relax): ..here.  Init stub_group_size_ and
reduce on relax failure.
(Target_powerpc::group_sections): Add "no_size_errors" param.
Use stub_group_size_.  Set up group info in a temp vector,
before building Stub_table vector.  Account for input sections
possibly already converted to relaxed sections.
(Stub_table::init): Delete.  Merge into..
(Stub_table::Stub_table): ..here.
(Stub_table::can_reach_stub): New function.
(Stub_table::add_plt_call_entry): Add "from" parameter and
return true iff stub could be reached.
(Stub_table::add_long_branch_entry): Similarly.  Add "r_type"
param too.
(Stub_table::clear_stubs): Add "all" param.

9 years agoFix Nios II prologue analyzer to handle multiple stack adjustments.
Sandra Loosemore [Wed, 26 Nov 2014 02:40:28 +0000 (18:40 -0800)] 
Fix Nios II prologue analyzer to handle multiple stack adjustments.

2014-11-25  Sandra Loosemore  <sandra@codesourcery.com>

gdb/
* nios2-tdep.c (nios2_analyze_prologue): Replace restriction
that there can be only one stack adjustment in the prologue
with tests to detect specific disallowed stack adjustments.

9 years agoFix Nios II GDB epilogue detection to handle multiple stack adjustments.
Sandra Loosemore [Wed, 26 Nov 2014 02:37:41 +0000 (18:37 -0800)] 
Fix Nios II GDB epilogue detection to handle multiple stack adjustments.

2014-11-25  Sandra Loosemore  <sandra@codesourcery.com>

gdb/
* nios2-tdep.c (nios2_in_epilogue_p): Handle multiple stack
adjustments.

9 years agoRefactor Nios II GDB support to use helper functions for disassembly and
Sandra Loosemore [Wed, 26 Nov 2014 02:34:51 +0000 (18:34 -0800)] 
Refactor Nios II GDB support to use helper functions for disassembly and
instruction matching.

2014-11-25  Sandra Loosemore  <sandra@codesourcery.com>

gdb/
* nios2-tdep.c (nios2_fetch_insn): Move up in file.  Disassemble
the instruction as well as reading it from memory.
(nios2_match_add): New.
(nios2_match_sub): New.
(nios2_match_addi): New.
(nios2_match_orhi): New.
(nios2_match_stw): New.
(nios2_match_ldw): New.
(nios2_match_rdctl): New.
(enum branch_condition): New.
(nios2_match_branch): New.
(nios2_match_jmpi): New.
(nios2_match_calli): New.
(nios2_match_jmpr): New.
(nios2_match_callr): New.
(nios2_match_break): New.
(nios2_match_trap): New.
(nios2_in_epilogue_p): Rewrite to use new functions.
(nios2_analyze_prologue): Likewise.
(nios2_skip_prologue): Delete unused local limit_pc.
(nios2_breakpoint_from_pc): Make R1-specific encodings explicit.
(nios2_get_next_pc): Rewrite to use new functions.

9 years ago[GOLD] PowerPC relaxation corner case
Alan Modra [Tue, 25 Nov 2014 23:36:07 +0000 (10:06 +1030)] 
[GOLD] PowerPC relaxation corner case

It's possible for the section grouping code to decide that the last
section looked at (the first section by address) doesn't fit into a
group.  In one case that section is already a group owner and that is
handled correctly.  In other cases the section should be put into its
own group.  Like this:

* powerpc.cc (Stub_control::set_output_and_owner): New function.
(Target_powerpc::group_sections): Use it.

9 years agoAutomatic date update in version.in
GDB Administrator [Wed, 26 Nov 2014 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 years agoAdd file size to ELF symbol labelling start of a binary file.
Cary Coutant [Tue, 25 Nov 2014 22:33:51 +0000 (14:33 -0800)] 
Add file size to ELF symbol labelling start of a binary file.

gold/
* binary.cc (Binary_to_elf::sized_convert): Add size to _start symbol.
(Binary_to_elf::write_symbol): Add st_size parameter.
* binary.h (Binary_to_elf::write_symbol): Add st_size parameter.

This page took 0.054914 seconds and 4 git commands to generate.