binutils-gdb.git
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.

10 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".

10 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

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

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

10 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.

10 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.

10 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.

10 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.

10 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

10 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.

10 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.

10 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>
10 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.

10 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

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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.

10 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

10 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.

10 years agoFix corrupted .eh_frame section with LTO and --gc-sections.
Cary Coutant [Tue, 25 Nov 2014 21:55:42 +0000 (13:55 -0800)]
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.

10 years agoUpdate ld-alpha tests for secureplt
H.J. Lu [Tue, 25 Nov 2014 21:40:19 +0000 (13:40 -0800)]
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.

10 years agoFix trampolines search code for conditional branches
Max Filippov [Tue, 25 Nov 2014 18:33:21 +0000 (21:33 +0300)]
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.

10 years agoUse get_symbol_version_string in BFD_JUMP_TABLE_SYMBOLS
H.J. Lu [Tue, 25 Nov 2014 17:28:32 +0000 (09:28 -0800)]
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.

10 years agoDisplay symbol version when dumping dynrelocs
H.J. Lu [Tue, 25 Nov 2014 14:47:44 +0000 (06:47 -0800)]
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.

10 years agoOptimize out i386/x86-64 JUMP_SLOT relocation
H.J. Lu [Tue, 25 Nov 2014 13:05:39 +0000 (05:05 -0800)]
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.

10 years agoAutomatic date update in version.in
GDB Administrator [Tue, 25 Nov 2014 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in

10 years agoUpdate libtool.m4 from GCC trunk
H.J. Lu [Mon, 24 Nov 2014 17:14:09 +0000 (09:14 -0800)]
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.

10 years agoReindent code (resolve_dynamic_type_internal).
Jan Kratochvil [Mon, 24 Nov 2014 17:05:04 +0000 (18:05 +0100)]
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.

10 years ago[AArch64] Cortex-A53 Erratum 835769 -- sort maps
Jiong Wang [Mon, 24 Nov 2014 13:43:39 +0000 (13:43 +0000)]
[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.

10 years ago[Hurd] Fix deallocation after proc_getprocinfo call
Samuel Thibault [Sun, 23 Nov 2014 15:19:46 +0000 (16:19 +0100)]
[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.

10 years agoFix dumping of function arguments.
Doug Evans [Mon, 24 Nov 2014 04:30:34 +0000 (20:30 -0800)]
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.

10 years agoPowerPC64 --plt-align
Alan Modra [Mon, 24 Nov 2014 02:11:33 +0000 (12:41 +1030)]
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.

10 years agoAutomatic date update in version.in
GDB Administrator [Mon, 24 Nov 2014 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

10 years agoAdd myself as write-after-approval GDB maintainer
Patrick Palka [Sun, 23 Nov 2014 16:14:13 +0000 (11:14 -0500)]
Add myself as write-after-approval GDB maintainer

gdb/ChangeLog:
* MAINTAINERS (Write After Approval): Add myself.

10 years agoAssert size of elf_x86_64_{bnd|legacy}_plt2_entry
H.J. Lu [Sun, 23 Nov 2014 13:54:02 +0000 (05:54 -0800)]
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.

10 years agoAlways consider infcall breakpoints as non-permanent.
Joel Brobecker [Thu, 20 Nov 2014 16:41:25 +0000 (20:41 +0400)]
Always consider infcall breakpoints as non-permanent.

A recent change...

    commit 1a853c5224e2b8fedfac6d029365522b83080b40
    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.

10 years agoSpecify SA_RESTART when registering the SIGWINCH signal handler
Patrick Palka [Sat, 30 Aug 2014 19:33:08 +0000 (15:33 -0400)]
Specify SA_RESTART when registering the SIGWINCH signal handler

SA_RESTART allows system calls to be restarted across a signal handler.
By specifying this flag we fix the issue where if the user is being
prompted to answer yes or no, and the terminal gets resized in the
meantime, the prompt will think that the user sent an EOF and so it will
take the default action for that prompt (in the case of the quit prompt,
it will quit GDB).

gdb/ChangeLog:

* tui/tui-win.c (tui_initialize_win): Specify SA_RESTART when
registering the signal handler.

10 years agoFix the processing of Meta-key commands in TUI
Patrick Palka [Sun, 23 Nov 2014 10:03:39 +0000 (14:03 +0400)]
Fix the processing of Meta-key commands in TUI

This patch fixes the annoying bug where key sequences such as Alt_F or
Alt_B (go forward or backwards by a word) do not behave promptly in TUI.
You have to press a third key in order for the key sequence to register.

This is mostly ncurses' fault.  Calling wgetch() normally causes ncurses
to read only a single key from stdin.  However if the key read is the
start-sequence key (^[ a.k.a. ESC) then wgetch() reads TWO keys from
stdin, storing the 2nd key into an internal FIFO buffer and returning
the start-sequence key.  The extraneous read of the 2nd key makes us
miss its corresponding stdin event, so the event loop blocks until a
third key is pressed.  This explains why such key sequences do not
behave promptly in TUI.

To fix this issue, we must somehow compensate for the missed stdin event
corresponding to the 2nd byte of a key sequence.  This patch achieves
this by hacking  up the stdin event handler to conditionally execute the
readline callback multiple times in a row.  This is done via a new
global variable, call_stdin_event_handler_again_p, which is set from
tui_getc() when we receive a start-sequence key and notice extra pending
input in the ncurses buffer.

Tested on x86_64-unknown-linux-gnu.

gdb/ChangeLog:

* event-top.h (call_stdin_event_handler_again_p): Declare.
* event-top.c (call_stdin_event_handler_again_p): Define.
(stdin_event_handler): Use it.
* tui/tui-io.c (tui_getc): Prepare to call the stdin event
handler again if there is pending input following a
start sequence.

10 years agocheckpoint: print index of new checkpoint in response message
Patrick Palka [Fri, 14 Nov 2014 19:04:50 +0000 (14:04 -0500)]
checkpoint: print index of new checkpoint in response message

This way the user can know the index of the latest checkpoint without
having to run "info checkpoints" afterwards.

gdb/ChangeLog:

* linux-fork.c (checkpoint_command): Print index of new
checkpoint in response message.

10 years agoRefine read_string
Yao Qi [Sun, 23 Nov 2014 05:57:00 +0000 (13:57 +0800)]
Refine read_string

In read_string, we have this line

  chunksize = (len == -1 ? min (8, fetchlimit) : fetchlimit);

but chunksize is only used in the block that lne == -1, so IWBN to
move chunksize to the block in which it is used, and simplify the
condition setting chunksize.  This patch also moves 'found_nul' to
inner block.  This patch also splits a paragraph of comment into two,
and move them to different condition blocks (len > 0 and len == -1)
respectively.

gdb:

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

* valprint.c (read_string): Move local variables 'found_nul',
'chunksize' and 'limit' to inner scope.  Update comments.

10 years agosim/ppc/*: Change immediatly to immediately
Joel Sherrill [Sun, 23 Nov 2014 03:11:39 +0000 (07:11 +0400)]
sim/ppc/*: Change immediatly to immediately

sim/ppc/ChangeLog:

* ChangeLog, ChangeLog.00, hw_com.c, ld-cache.h, ppc-instructions:
Change immediatly to immediately.

10 years agosim/igen/: Change immediatly to immediately
Joel Sherrill [Sun, 23 Nov 2014 03:09:16 +0000 (07:09 +0400)]
sim/igen/: Change immediatly to immediately

sim/igen/ChangeLog:

        * igen/ld-cache.h, igen/table.h: Change immediatly to immediately.

10 years agos/immediatly/immediately/ in sim/sh/ChangeLog entry.
Joel Sherrill [Sun, 23 Nov 2014 02:59:54 +0000 (06:59 +0400)]
s/immediatly/immediately/ in sim/sh/ChangeLog entry.

10 years agoAutomatic date update in version.in
GDB Administrator [Sun, 23 Nov 2014 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

10 years agosymtab.c: Comment and whitespace improvements.
Doug Evans [Sat, 22 Nov 2014 19:29:08 +0000 (11:29 -0800)]
symtab.c: Comment and whitespace improvements.

gdb/ChangeLog:

* symtab.c (lookup_symbol_in_objfile_from_linkage_name): Improve
function comment.
(search_symbols): Fix comments and whitespace.

10 years agocp-namespace.c (cp_lookup_symbol_nonlocal): Fix comment.
Doug Evans [Sat, 22 Nov 2014 18:46:52 +0000 (10:46 -0800)]
cp-namespace.c (cp_lookup_symbol_nonlocal): Fix comment.

gdb/ChangeLog:

* cp-namespace.c (cp_lookup_symbol_nonlocal): Fix comment.

10 years agoCheck branch displacement overflow in x86-64 PLT entry
H.J. Lu [Sat, 22 Nov 2014 16:58:07 +0000 (08:58 -0800)]
Check branch displacement overflow in x86-64 PLT entry

Displacement of branch to PLT0 in x86-64 PLT entry is signed 32-bit.
This patch adds a sanity check.  We will only see the failure when PLT
size is > 2GB.

* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Check
branch displacement overflow in PLT entry.

10 years agoUse MACRO_AT_func in entry-values.exp
Yao Qi [Sat, 22 Nov 2014 13:28:31 +0000 (21:28 +0800)]
Use MACRO_AT_func in entry-values.exp

MACRO_AT_func can be used in gdb.trace/entry-values.exp to correctly
get function's address in generated debug info.  As a result, the test
is more friendly to clang.  Currently, there are some fails in
entry-values.exp when the test is compiled by clang.  With this patch
applied, all fails go away.

gdb/testsuite:

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

* gdb.trace/entry-values.c: Remove asms.
(foo): Add foo_label.
(bar): Add bar_label.
* gdb.trace/entry-values.exp: Remove code computing  foo's
length and bar's length.
(Dwarf::assemble): Invoke function_range for bar and use
MACRO_AT_func for foo.

10 years ago[arm] Fix fails in dw2-compdir-oldgcc.exp
Yao Qi [Sat, 22 Nov 2014 13:22:01 +0000 (21:22 +0800)]
[arm] Fix fails in dw2-compdir-oldgcc.exp

This patch fixes two fails in dw2-compdir-oldgcc.exp I've seen on arm
target thumb mode.

  FAIL: gdb.dwarf2/dw2-compdir-oldgcc.exp: info source gcc42
  FAIL: gdb.dwarf2/dw2-compdir-oldgcc.exp: info source gcc43

When fill in DW_AT_low_pc, the label should be used rather than the
function, otherwise, the LSB bit of the address in DW_AT_low_pc is
set and the debug info is wrong.  This patch is to add two labels for
functions gcc42 and gcc43 respectively, and use them.  These two
fails are fixed.

gdb/testsuite:

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

* gdb.dwarf2/dw2-compdir-oldgcc.S: Define label .Lgcc42_procstart
and .Lgcc43_procstart.  Use .Lgcc42_procstart instead of gcc42.
Use .Lgcc43_procstart instead of gcc43.

10 years agoAutomatic date update in version.in
GDB Administrator [Sat, 22 Nov 2014 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in

10 years agoMerge include/* files from GCC commit 69a2f316d3.
Andrew Burgess [Tue, 18 Nov 2014 23:41:15 +0000 (23:41 +0000)]
Merge include/* files from GCC commit 69a2f316d3.

include/ChangeLog:

* dwarf2.def (DW_AT_APPLE_optimized, DW_AT_APPLE_flags)
(DW_AT_APPLE_isa, DW_AT_APPLE_block)
(DW_AT_APPLE_major_runtime_vers, DW_AT_APPLE_runtime_class)
(DW_AT_APPLE_omit_frame_ptr, DW_AT_APPLE_property_name)
(DW_AT_APPLE_property_getter, DW_AT_APPLE_property_setter)
(DW_AT_APPLE_property_attribute, DW_AT_APPLE_objc_complete_type)
(DW_AT_APPLE_property): New macros.

10 years agoMerge include/* files from GCC commit 77cab4753.
Andrew Burgess [Tue, 18 Nov 2014 23:37:52 +0000 (23:37 +0000)]
Merge include/* files from GCC commit 77cab4753.

include/ChangeLog:

PR debug/63239
* dwarf2.def (DW_AT_GNU_deleted): New attribute.

10 years agoFixes for memory access violations exposed by fuzzinf various binaries.
Nick Clifton [Fri, 21 Nov 2014 21:44:04 +0000 (21:44 +0000)]
Fixes for memory access violations exposed by fuzzinf various binaries.

PR binutils/17512
* dwarf.c (get_encoded_value): Check for an encoded size of 0.
(display_debug_lines_raw): Check for an invalid line range value.
(display_debug_frames): Check for corrupt augmentation data.

* coffgen.c (coff_get_normalized_symtab): Check for an excessive
number of auxillary entries.
* ieee.c (next_byte): Convert to a function.  Return FALSE if the
next byte is beyond the end of the buffer.
(parse_int): Test the return value of next_byte.
(parse_expression): Convert to boolean.  Return FALSE if the
parsing failed.  Test the return value of next_byte.
(ieee_seek): Convert to a function.  Return FALSE if the seek goes
beyond the end of the buffer.
(ieee_slurp_external_symbols): Test the return value of ieee_seek
and next_byte.
(ieee_slurp_sections): Convert to boolean.  Return FALSE if the
operation failed.  Test the return value of ieee_seek and
next_byte.
(ieee_archive_p): Test the return value of ieee_seek and
next_byte.
(do_one): Likewise.
(ieee_slurp_section_data): Likewise.
(ieee_object_p): Likewise.  Store the size of the buffer in the
total_amt field in the header.
* libieee.h (common_header_type): Add amt field.
* mach-o.c (bfd_mach_o_canonicalize_one_reloc): Check that the
reloc's value is within range.
(bfd_mach_o_read_symtab_symbols): Nullify the symbols field if the
operation fails.
* pei-x86_64.c (pex64_xdata_print_uwd_codes): Replace abort with
an error message.
(pex64_dump_xdata): Check for buffer overflows.
* versados.c (process_otr): Check that the section exists before
taking its size.
(versados_object_p): Make sure that enough data was read for the
header to be checked.
* vms-alpha.c (vms_get_remaining_object_record): Change
read_so_far parameter to an unsigned int.  Check that the amount
read is in range.

10 years agoOptimize PC-relative offset overflow check
H.J. Lu [Fri, 21 Nov 2014 20:12:30 +0000 (12:12 -0800)]
Optimize PC-relative offset overflow check

* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Optimize
PC-relative offset overflow check.

10 years agoCheck PC-relative offset overflow in PLT entry
H.J. Lu [Tue, 18 Nov 2014 19:34:11 +0000 (11:34 -0800)]
Check PC-relative offset overflow in PLT entry

PR gold/17619
* x86_64.cc (Output_data_plt_x86_64_standard<size>::do_fill_plt_entry):
Check PC-relative offset overflow in PLT entry.