Commit Graph

82005 Commits

Author SHA1 Message Date
Joel Brobecker 0fa9473ff0 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.
2014-11-28 18:37:08 +04:00
Yao Qi 6a29c58ef8 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.
2014-11-28 18:38:21 +08:00
Yao Qi abbffc8924 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.
2014-11-28 18:38:16 +08:00
Yao Qi 9839978095 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.
2014-11-28 18:38:10 +08:00
Yao Qi 3332aaf289 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.
2014-11-28 18:38:02 +08:00
Yao Qi f45c62c4d5 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.
2014-11-28 18:37:57 +08:00
Yao Qi bdca27a2f5 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.
2014-11-28 18:37:52 +08:00
Yao Qi 2196f55f01 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.
2014-11-28 18:37:47 +08:00
Yao Qi 7014e923da Fix date in changelog 2014-11-28 17:23:26 +08:00
Alan Modra 25ff461f19 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.
2014-11-28 14:39:28 +10:30
Alan Modra 8514e4db84 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.
2014-11-28 14:34:10 +10:30
Alan Modra 8066deb11b 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.
2014-11-28 14:34:10 +10:30
Yao Qi 10e79639cc 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.
2014-11-28 11:21:48 +08:00
GDB Administrator e87e47787e Automatic date update in version.in 2014-11-28 00:00:09 +00:00
Espen Grindhaug c9c1d67440 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.
2014-11-27 15:49:23 +00:00
H.J. Lu 3a1cfc456f 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.
2014-11-27 06:44:29 -08:00
Simon Marchi f28a0564dd 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>
2014-11-27 09:27:08 -05:00
Nick Clifton 1036838a77 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.
2014-11-27 12:19:10 +00:00
GDB Administrator 608ce2f3c8 Automatic date update in version.in 2014-11-27 00:00:13 +00:00
Mark Wielaard 8bc106204c 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.
2014-11-27 00:35:18 +01:00
Doug Evans 3fe1ce1d5b gdb.dwarf2/dw2-op-out-param.S: Fix comment.
gdb/ChangeLog:

	* gdb.dwarf2/dw2-op-out-param.S: Fix comment.
2014-11-26 14:44:46 -08:00
Cary Coutant 982bbd97c5 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.
2014-11-26 14:41:46 -08:00
Han Shen bb779192ae 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.
2014-11-26 10:34:46 -08:00
Nick Clifton a11652892c 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.
2014-11-26 14:11:23 +00:00
Mark Wielaard 0cfd832fc7 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.
2014-11-26 12:47:29 +01:00
Alan Modra 601a03ba3d _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.
2014-11-26 13:29:29 +10:30
Alan Modra a3e60ddb0b 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.
2014-11-26 13:29:29 +10:30
Sandra Loosemore aa4893954a 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.
2014-11-25 18:40:28 -08:00
Sandra Loosemore 7f1659b587 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.
2014-11-25 18:37:41 -08:00
Sandra Loosemore d53c26c753 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.
2014-11-25 18:34:51 -08:00
Alan Modra a20605cf85 [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.
2014-11-26 10:50:33 +10:30
GDB Administrator 38bd618497 Automatic date update in version.in 2014-11-26 00:00:13 +00:00
Cary Coutant 43b64debe3 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.
2014-11-25 14:33:51 -08:00
Cary Coutant c924eb67e1 Fix corrupted .eh_frame section with LTO and --gc-sections.
When --gc-sections is turned on during an LTO link, the .eh_frame sections
from deferred files are processed before those from the replacement files.
As a result, the section end-cap from crtendS.o is placed ahead of
the .eh_frame data from the replacement files. This patch fixes the bug
by skipping the layout of the deferred sections during GC pass 2.

gold/
	PR gold/17639
	* object.cc (Sized_relobj_file): Initialize is_deferred_layout_.
	(Sized_relobj_file::do_layout): Handle deferred sections properly
	during GC pass 1. Don't add reloc sections to deferred list twice.
	* object.h (Sized_relobj_file::is_deferred_layout): New function.
	(Sized_relobj_file::is_deferred_layout_): New data member.
2014-11-25 13:56:21 -08:00
H.J. Lu 61e6682207 Update ld-alpha tests for secureplt
* ld-alpha/tlsbin.dd: Updated for secureplt.
	* ld-alpha/tlsbin.rd: Likewise.
	* ld-alpha/tlsbin.sd: Likewise.
	* ld-alpha/tlsbinr.dd: Likewise.
	* ld-alpha/tlsbinr.rd: Likewise.
	* ld-alpha/tlspic.dd: Likewise.
	* ld-alpha/tlspic.rd: Likewise.
	* ld-alpha/tlspic.sd: Likewise.
2014-11-25 13:41:30 -08:00
Max Filippov d92b6eece4 Fix trampolines search code for conditional branches
For conditional branches that need more than one trampoline to reach its
target assembler couldn't always find suitable trampoline because
post-loop condition check was placed inside the loop, resulting in
premature loop termination. Move check outside the loop.

This fixes the following build errors seen when assembling huge files
produced by gcc:
    Error: jump target out of range; no usable trampoline found
    Error: operand 1 of 'j' has out of range value '307307'

2014-11-25  Max Filippov  <jcmvbkbc@gmail.com>

gas/
	* config/tc-xtensa.c (search_trampolines): Move post-loop
	condition check outside the search loop.

gas/testsuite/
	* gas/xtensa/trampoline.d: Add expected output for branches.
	* gas/xtensa/trampoline.s: Add test case for branches.
2014-11-26 00:17:36 +03:00
H.J. Lu 60bb06bc89 Use get_symbol_version_string in BFD_JUMP_TABLE_SYMBOLS
This patch adds get_symbol_version_string to BFD_JUMP_TABLE_SYMBOLS so
that we can use bfd_get_symbol_version_string in objdump for non-ELF
targets.

bfd/

	* targets.c (BFD_JUMP_TABLE_SYMBOLS): Use
	NAME##_get_symbol_version_string.
	(bfd_get_symbol_version_string): New.
	* aout-adobe.c (aout_32_get_symbol_version_string): Define using
	_bfd_nosymbols define.
	* aout-target.h (MY_get_symbol_version_string): Likewise.
	* aout-tic30.c (MY_get_symbol_version_string): Likewise.
	* binary.c (binary_get_symbol_version_string): Likewise.
	* bout.c (aout_32_get_symbol_version_string): Likewise.
	* coff-rs6000.c (_bfd_xcoff_get_symbol_version_string): Likewise.
	* i386msdos.c (msdos_get_symbol_version_string): Likewise.
	* i386os9k.c (aout_32_get_symbol_version_string): Likewise.
	* ieee.c (ieee_get_symbol_version_string): Likewise.
	* ihex.c (ihex_get_symbol_version_string): Likewise.
	* libecoff.h (_bfd_ecoff_get_symbol_version_string): Likewise.
	* mach-o-target.c (bfd_mach_o_get_symbol_version_string): Likewise.
	* mmo.c (mmo_get_symbol_version_string): Likewise.
	* nlm-target.h (nlm_get_symbol_version_string): Likewise.
	* oasys.c (oasys_get_symbol_version_string): Likewise.
	* pef.c (bfd_pef_get_symbol_version_string): Likewise.
	* plugin.c (bfd_plugin_get_symbol_version_string): Likewise.
	* ppcboot.c (ppcboot_get_symbol_version_string): Likewise.
	* som.c (som_get_symbol_version_string): Likewise.
	* srec.c (srec_get_symbol_version_string): Likewise.
	* tekhex.c (tekhex_get_symbol_version_string): Likewise.
	* versados.c (versados_get_symbol_version_string): Likewise.
	* vms-alpha.c (alpha_vms_get_symbol_version_string): Likewise.
	* xsym.c (bfd_sym_get_symbol_version_string): Likewise.

	* coff64-rs6000.c (rs6000_xcoff64_vec): Use
	coff_get_symbol_version_string.
	(rs6000_xcoff64_aix_vec): Likewise.

	* elf-bfd.h (bfd_elf_get_symbol_version_string): Renamed to ...
	(_bfd_elf_get_symbol_version_string): This.
	* elf.c: Likewise.
	(bfd_elf_print_symbol): Updated.
	* elfxx-target.h (bfd_elfNN_get_symbol_version_string): Define.

	* libbfd-in.h (_bfd_nosymbols_get_symbol_version_string): Define.
	* libcoff-in.h (coff_get_symbol_version_string): Likewise.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.
	* libcoff.h: Likewise.

binutils/

	* objdump.c (objdump_print_symname): Replace
	bfd_elf_get_symbol_version_string with
	bfd_get_symbol_version_string.
2014-11-25 09:28:32 -08:00
H.J. Lu bb4d2ac2cc Display symbol version when dumping dynrelocs
Both readelf/objdump know how to get symbol version string for dynamic
symbols.  This patch extracts this functionality into a separate
function and uses it to add symbol version string to versioned symbol
names when dumping dynamic relocations.

bfd/

	PR binutils/16496
	* elf-bfd.h (bfd_elf_get_symbol_version_string): New.
	* elf.c (bfd_elf_get_symbol_version_string): New.  Extracted
	from bfd_elf_print_symbol.
	(bfd_elf_print_symbol): Use it.

binutils/

	PR binutils/16496
	* objdump.c (objdump_print_symname): Call
	bfd_elf_get_symbol_version_string to get ELF symbol version
	string.  Append version string if needed.

	* readelf.c (versioned_symbol_info): New enum.
	(get_symbol_version_string): New.  Extracted from
	process_symbol_table.
	(dump_relocations): Add a new argument to indicate if dynamic
	symbol table is used.  Use get_symbol_version_string to get
	symbol version string for dynamic symbol.  Append version string
	if needed.
	(process_relocs): Updated dump_relocations call.
	(process_symbol_table): Use get_symbol_version_string.

ld/testsuite/

	PR binutils/16496
	* ld-cris/weakref3.d: Add symbol version string to versioned
	symbol names in dynamic relocation.
	* ld-cris/weakref4.d: Likewise.
	* ld-elfvers/vers24.rd: Likewise.

	* ld-elf/pr16496a.c: New file.
	* ld-elf/pr16496a.map: Likewise.
	* ld-elf/pr16496b.c: Likewise.
	* ld-elf/pr16496b.od: Likewise.

	* ld-elf/shared.exp (build_tests): Add libpr16496a.so and
	libpr16496b.so tests.
2014-11-25 06:47:44 -08:00
H.J. Lu dd7e64d45b Optimize out i386/x86-64 JUMP_SLOT relocation
When there are both PLT and GOT references to the same function symbol,
linker will create a GOTPLT slot for PLT entry and a GOT slot for GOT
reference.  A run-time JUMP_SLOT relocation is created to update the
GOTPLT slot and a run-time GLOB_DAT relocation is created to update the
GOT slot.  Both JUMP_SLOT and GLOB_DAT relocations will apply the same
symbol value to GOTPLT and GOT slots, respectively, at run-time.

This optimization combines GOTPLT and GOT slots into a single GOT slot
and removes the run-time JUMP_SLOT relocation.  It replaces the regular
PLT entry:

	indirect jump	[GOTPLT slot]
	push		relocation index
	jump		PLT0

with an GOT PLT entry with an indirect jump via the GOT slot:

	indirect jump	[GOT slot]
	nop

and resolves PLT reference to the GOT PLT entry.

We must avoid this optimization if pointer equality is needed since
we don't clear symbol value in this case and the dynamic linker won't
update the GOT slot.  Otherwise, the resulting binary will get into an
infinite loop at run-time.

bfd/

	* elf32-i386.c (elf_i386_got_plt_entry): New.
	(elf_i386_pic_got_plt_entry): Likewise.
	(elf_i386_link_hash_entry): Add plt_got.
	(elf_i386_link_hash_table): Likewise.
	(elf_i386_link_hash_newfunc): Initialize plt_got.offset to -1.
	(elf_i386_get_local_sym_hash): Likewise.
	(elf_i386_check_relocs): Create the GOT PLT if there are both
	PLT and GOT references when the regular PLT is used.
	(elf_i386_allocate_dynrelocs): Use the GOT PLT if there are
	both PLT and GOT references unless pointer equality is needed.
	(elf_i386_relocate_section): Also check the GOT PLT when
	resolving R_386_PLT32.
	(elf_i386_finish_dynamic_symbol): Use the GOT PLT if it is
	available.

	* elf64-x86-64.c (elf_x86_64_link_hash_entry): Add plt_got.
	(elf_x86_64_link_hash_table): Likewise.
	(elf_x86_64_link_hash_newfunc): Initialize plt_got.offset to -1.
	(elf_x86_64_get_local_sym_hash): Likewise.
	(elf_x86_64_check_relocs): Create the GOT PLT if there are both
	PLT and GOT references when the regular PLT is used.
	(elf_x86_64_allocate_dynrelocs): Use the GOT PLT if there are
	both PLT and GOT references unless pointer equality is needed.
	(elf_x86_64_relocate_section): Also check the GOT PLT when
	resolving R_X86_64_PLT32.
	(elf_x86_64_finish_dynamic_symbol): Use the GOT PLT if it is
	available.

ld/

	* emulparams/elf_i386.sh (TINY_READONLY_SECTION): New.
	* emulparams/elf_x86_64.sh (TINY_READONLY_SECTION): Add .plt.got.

ld/testsuite/

	* ld-i386/i386.exp: Add run-time relocation tests for plt-main.
	* ld-i386/plt-main.rd: New file.
	* ld-x86-64/plt-main-bnd.dd: Likewise.
	* ld-x86-64/plt-main.rd: Likewise.
	* ld-x86-64/x86-64.exp: Add run-time relocation tests for
	plt-main.
2014-11-25 05:05:39 -08:00
GDB Administrator 07e94edf04 Automatic date update in version.in 2014-11-25 00:00:12 +00:00
H.J. Lu 6e733ccea9 Update libtool.m4 from GCC trunk
* libtool.m4: Updated from GCC trunk.

bfd/

	* configure: Regenerated.

binutils/

	* configure: Regenerated.

gas/

	* configure: Regenerated.

gprof/

	* configure: Regenerated.

ld/

	* configure: Regenerated.

opcodes/

	* configure: Regenerated.
2014-11-24 09:14:09 -08:00
Jan Kratochvil cac9b138f7 Reindent code (resolve_dynamic_type_internal).
gdb/ChangeLog
2014-11-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdbtypes.c (resolve_dynamic_type_internal): Reindent the code.
2014-11-24 18:05:04 +01:00
Jiong Wang 520c7b56ac [AArch64] Cortex-A53 Erratum 835769 -- sort maps
2014-11-24  Tejas Belagod  <tejas.belagod@arm.com>

  bfd/
    * elfnn-aarch64.c (elf_aarch64_compare_mapping): New.
    (erratum_835769_scan): Sort map list.
2014-11-24 13:43:39 +00:00
Samuel Thibault a441dfbc4e [Hurd] Fix deallocation after proc_getprocinfo call
2014-11-24  Samuel Thibault  <samuel.thibault@ens-lyon.org>

	* gdb/gnu-nat.c (inf_validate_procinfo): Multiply the number of
	elements pi_len by the size of the elements before calling
	vm_deallocate.
	(inf_validate_task_sc): Likewise, and properly deallocate the
	noise array.
2014-11-24 13:28:03 +04:00
Doug Evans 4c9e848275 Fix dumping of function arguments.
gdb/ChangeLog:

	* gdbtypes.c (print_args): Renamed from print_arg_types.  Print arg
	number and name if present.  All callers updated.
	(dump_fn_fieldlists): Fix indentation of args.
2014-11-23 20:31:18 -08:00
Alan Modra e05fa0bad2 PowerPC64 --plt-align
Alignment of plt stubs was broken, firstly because the option was
being dropped due to the alignment value not being set in the "params"
struct used in elf64-ppc.c, and secondly due to not calculating the
number of alignment boundary crossings correctly.

bfd/
	* elf64-ppc.c (plt_stub_pad): Correct.
ld/
	* ld.texinfo: Correct --plt-align documentation.
	* emultempl/ppc64elf.em (plt_stub_align): Delete.  Use and set
	params.plt_stub_align instead.
2014-11-24 12:56:59 +10:30
GDB Administrator 1ae92035c2 Automatic date update in version.in 2014-11-24 00:00:14 +00:00
Patrick Palka 15ee0bbdde Add myself as write-after-approval GDB maintainer
gdb/ChangeLog:
	* MAINTAINERS (Write After Approval): Add myself.
2014-11-23 11:18:22 -05:00
H.J. Lu 6db50b4cfe Assert size of elf_x86_64_{bnd|legacy}_plt2_entry
Assert size of elf_x86_64_bnd_plt2_entry and elf_x86_64_legacy_plt2_entry
only in elf_x86_64_check_relocs.

	* elf64-x86-64.c (elf_x86_64_check_relocs): Assert size of
	elf_x86_64_bnd_plt2_entry and elf_x86_64_legacy_plt2_entry.
	(elf_x86_64_allocate_dynrelocs): Don't assert size of
	elf_x86_64_bnd_plt2_entry and elf_x86_64_legacy_plt2_entry.
2014-11-23 05:54:02 -08:00
Joel Brobecker e8af5d7a5c Always consider infcall breakpoints as non-permanent.
A recent change...

    commit 1a853c5224
    Date:   Wed Nov 12 10:10:49 2014 +0000
    Subject: make "permanent breakpoints" per location and disableable

... broke function calls on sparc-elf when running over QEMU. Any
function call should demonstrate the problem.

For instance, seen from the debugger:

    (gdb) call pn(1234)
    [Inferior 1 (Remote target) exited normally]
    The program being debugged exited while in a function called from GDB.
    Evaluation of the expression containing the function

And seen from QEMU:

    qemu: fatal: Trap 0x02 while interrupts disabled, Error state
    [register dump removed]

What happens in this case is that GDB sets the inferior function call
by not only creating the dummy frame, but also writing a breakpoint
instruction at the return address for our function call. See infcall.c:

        /* Write a legitimate instruction at the point where the infcall
           breakpoint is going to be inserted.  While this instruction
           is never going to be executed, a user investigating the
           memory from GDB would see this instruction instead of random
           uninitialized bytes.  We chose the breakpoint instruction
           as it may look as the most logical one to the user and also
           valgrind 3.7.0 needs it for proper vgdb inferior calls.

           If software breakpoints are unsupported for this target we
           leave the user visible memory content uninitialized.  */

        bp_addr_as_address = bp_addr;
        bp_bytes = gdbarch_breakpoint_from_pc (gdbarch, &bp_addr_as_address,
                                               &bp_size);
        if (bp_bytes != NULL)
          write_memory (bp_addr_as_address, bp_bytes, bp_size);

This instruction triggers a change introduced by the commit above,
where we consider bp locations as being permanent breakpoints
if there is already a breakpoint instruction at that address:

        +  if (bp_loc_is_permanent (loc))
        +    {
        +      loc->inserted = 1;
        +      loc->permanent = 1;
        +    }

As a result, when resuming the program's execution for the inferior
function call, GDB decides that it does not need to insert a breakpoint
at this address, expecting the target to just report a SIGTRAP when
trying to execute that instruction.

But unfortunately for us, at least some versions of QEMU for SPARC
just terminate the execution entirely instead of reporting a breakpoint,
thus producing the behavior reported here.

Although it appears like QEMU might be misbehaving and should therefore
be fixed (to be verified) from the user's point of view, the recent
change does introduce a regression. So this patch tries to mitigate
a bit the damage by handling such infcall breakpoints as special and
making sure that they are never considered permanent, thus restoring
the previous behavior specifically for those breakpoints.

The option of not writing the breakpoint instructions in the first
place was considered, and would probably work also. But the comment
associated to it seems to indicate that there is still reason to
keep it.

gdb/ChangeLog:

        * breakpoint.c (bp_loc_is_permanent): Return 0 if LOC corresponds
        to a bp_call_dummy breakpoint type.

Tested on x86_64-linux. Also testing on sparc-elf/QEMU using
AdaCore's testsuite.
2014-11-23 14:34:52 +04:00