Commit Graph

82288 Commits

Author SHA1 Message Date
Eric Botcazou b6605dddac Add Visium support to gas
gas/
	* configure.tgt: Add Visium support.
	* Makefile.am (TARGET_CPU_CFILES): Move config/tc-vax.c around
	and add config/tc-visium.c.
	(TARGET_CPU_HFILES): Move config/tc-vax.h around and add
	config/tc-visium.h.
	* Makefile.in: Regenerate.
	* config/tc-visium.c: New file.
	* config/tc-visium.h: Likewise.
	* po/POTFILES.in: Regenerate.
gas/testsuite/
	* gas/elf/elf.exp: Skip ifunc-1 for Visium.
	* gas/visium/: New directory.
2014-12-06 16:42:26 +01:00
Eric Botcazou 619ed72008 Add Visium support to binutils
binutils/
	* readelf.c: Include elf/visium.h.
	(guess_is_rela): Deal with EM_VISIUM.
	(dump_relocations): Likewise.
	(get_machine_name): Likewise.
	(get_machine_flags): Likewise.
	(get_osabi_name): Likewise.
	(is_32bit_abs_reloc): Likewise.
	(is_32bit_pcrel_reloc): Likewise.
	(is_16bit_abs_reloc): Likewise.
binutils/testsuite:
	* binutils-all/objcopy.exp: Skip strip-10 for Visium.
2014-12-06 16:39:24 +01:00
Eric Botcazou d924db559b Add Visium support to bfd
bfd/
	* config.bfd: Add Visium support.
	* configure.ac: Likewise.
	* configure: Regenerate.
	* Makefile.am (ALL_MACHINES): Add cpu-visium.lo.
	(ALL_MACHINES_CFILES): Add cpu-visium.c.
	(BFD32_BACKENDS): Add elf32-visium.lo.
	(BFD32_BACKENDS_CFILES): Add elf32-visium.c.
	* Makefile.in: Regenerate.
	* archures.c (DESCRIPTION): Add Visium support.
	(bfd_visium_arch): Declare.
	(bfd_archures_list): Add bfd_visium_arch.
	* reloc.c: Add Visium relocations.
	* targets.c (visium_elf32_vec): Declare.
	(_bfd_target_vector): Add visium_elf32_vec.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Likewise.
	* cpu-visium.c: New file.
	* elf32-visium.c: Likewise.
	* po/SRC-POTFILES.in: Regenerate.
include/elf/
	* common.h (EM_VISIUM): Define.
	* visium.h: New file.
2014-12-06 16:35:18 +01:00
Eric Botcazou 1945cfa59d Add Visium support to opcodes
include/
	* dis-asm.h (print_insn_visium): Declare.
include/opcode/
	* visium.h: New file.
opcodes/
	* configure.ac: Add Visium support.
	* configure: Regenerate.
	* Makefile.am (TARGET_LIBOPCODES_CFILES): Add visium-dis.c and
	visium-opc.c.
	* Makefile.in: Regenerate.
	* disassemble.c (ARCH_visium): Define if ARCH_all.
	(disassembler): Deal with bfd_arch_visium if ARCH_visium.
	* visium-dis.c: New file.
	* visium-opc.c: Likewise.
	* po/POTFILES.in: Regenerate.
2014-12-06 16:25:55 +01:00
Eric Botcazou bb5f769091 Update from upstream config repo
* config.sub: Update from upstream config repo.
2014-12-06 16:09:33 +01:00
GDB Administrator 8e309d07d2 Automatic date update in version.in 2014-12-06 00:00:10 +00:00
Andrew Burgess 343433dfd7 Add string representation of ELF e_flags for AVR.
binutils/ChangeLog:

	* readelf.c (decode_AVR_machine_flags): New function.
	(get_machine_flags): Add EM_AVR case.
2014-12-05 21:05:33 +00:00
Steve Ellcey 238309aab1 2014-12-05 Steve Ellcey <sellcey@mips.com>
* ecoff.c (_bfd_ecoff_slurp_symbol_table): Add cast.
2014-12-05 11:06:53 -08:00
Jan Kratochvil 6c1c7be347 Unify lookup_symbol_in_objfile_symtabs
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.
2014-12-05 19:39:12 +01:00
Jan Kratochvil efad9b6a7a Remove const from many struct objfile *
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.
2014-12-05 19:11:53 +01:00
Andreas From 069bb7eced Add myself as write after approval maintainer
gdb/ChangeLog:

	* MAINTAINERS (Write After Approval): Add "Andreas From".
2014-12-05 11:35:34 -05:00
H.J. Lu b7365e5df5 Define bfd_elf32_get_synthetic_symtab for x32
* elf64-x86-64.c (bfd_elf32_get_synthetic_symtab): New.
2014-12-05 04:52:47 -08:00
Yao Qi a13c5393d5 Revert: Don't enable gdbtk in testsuite
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.
2014-12-05 19:56:19 +08:00
Yao Qi df1b803ada Fix parallel testing issues in gdb.guile tests
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.
2014-12-05 19:45:04 +08:00
Doug Evans 642a8d8067 Revert: linespec.c (iterate_name_matcher): Fix arguments to symbol_name_cmp.
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.
2014-12-05 01:04:07 -08:00
Yao Qi ddb9f679fa Use standard_testfile in i386-bp_permanent.exp
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.
2014-12-05 15:32:00 +08:00
H.J. Lu 3972882e52 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.
2014-12-04 16:55:39 -08:00
GDB Administrator 82cf9cb265 Automatic date update in version.in 2014-12-05 00:00:08 +00:00
Doug Evans 86e4ed3959 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.
2014-12-04 12:01:22 -08:00
Doug Evans 7c50a93137 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.
2014-12-04 11:32:24 -08:00
Alan Modra fbad6518c1 ChangeLog typo fix 2014-12-04 22:20:53 +10:30
Alan Modra cbcb23fa01 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.
2014-12-04 21:17:54 +10:30
Jan Kratochvil ba715d7fe4 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.
2014-12-04 08:26:26 +01:00
Alan Modra 53df40a43c 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.
2014-12-04 17:37:58 +10:30
Maciej W. Rozycki 621661e3fa 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.
2014-12-04 00:06:10 +00:00
GDB Administrator e4429773bb Automatic date update in version.in 2014-12-04 00:00:10 +00:00
Alan Modra 1611bc4afb 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.
2014-12-04 09:23:59 +10:30
Maciej W. Rozycki 858339f2b7 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.
2014-12-03 20:57:06 +00:00
Nick Clifton db6b071a97 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.
2014-12-03 19:50:48 +00:00
H.J. Lu 4759c34e12 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.
2014-12-03 10:59:46 -08:00
H.J. Lu 01bbed2a55 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.
2014-12-03 08:52:00 -08:00
Nick Clifton bee0ee850e 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.
2014-12-03 16:33:33 +00:00
H.J. Lu 9d157cb9fe Reformat elf_x86_64_create_dynamic_sections
* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Reformat.
2014-12-03 08:10:04 -08:00
Alan Modra 1f98a0748c 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.
2014-12-04 01:09:55 +10:30
Ulrich Weigand ff1eb2b544 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.
2014-12-03 15:38:46 +01:00
Simon Marchi 75783939d7 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.
2014-12-03 08:56:10 -05:00
Joel Brobecker 2d7bb7580a 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.
2014-12-03 13:43:08 +04:00
H.J. Lu fd9edc9089 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.
2014-12-02 16:58:22 -08:00
Doug Evans 7c5fdd25eb 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.
2014-12-02 16:55:52 -08:00
H.J. Lu 31c0ebfe8b 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.
2014-12-02 16:52:12 -08:00
Doug Evans 29f0c3b7b2 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.
2014-12-02 16:40:38 -08:00
Doug Evans 72998fb37a PR symtab/17591
gdb/ChangeLog:

	PR symtab/17591
	* dwarf2read.c (find_slot_in_mapped_hash): Use cp_remove_params
	to strip parameters.
2014-12-02 16:24:37 -08:00
Doug Evans 422b9917ce dwarf2read.c (peek_die_abbrev): Improve error message text.
gdb/ChangeLog:

	* dwarf2read.c (peek_die_abbrev): Improve error message text.
2014-12-02 16:22:18 -08:00
Doug Evans 47c6ee4990 Remove remnant of Chill support.
gdb/ChangeLog:

	* valops.c (do_search_struct_field): Remove remnant of Chill support.
	Ref: commit 4c2260aa5c
2014-12-02 16:15:53 -08:00
GDB Administrator 01828971bc Automatic date update in version.in 2014-12-03 00:00:10 +00:00
H.J. Lu 9a926d55ab 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.
2014-12-02 15:19:25 -08:00
Simon Marchi 5da3ffc99d Fix comment typo
ChangeLog:

	* common/cleanups.c (make_cleanup_dtor): Fix comment typo.
2014-12-02 17:22:07 -05:00
Nick Bull 162078c893 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.
2014-12-02 11:15:29 -08:00
Doug Evans 71dd4b30a7 revert previous patch so that I can re-commit with correct author 2014-12-02 11:12:49 -08:00
Doug Evans dc6c87175b 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.
2014-12-02 10:59:08 -08:00