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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

gdb/testsuite:

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

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

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

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

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

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

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

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

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

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

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

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

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

gdb/testsuite/ChangeLog:

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

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

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

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

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

binutils/ChangeLog

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

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

gdb/ChangeLog:

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

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

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

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

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

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

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

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

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

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

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

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

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

gdb/ChangeLog

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

include/ChangeLog

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

9 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

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

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

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

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

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

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

9 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

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

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

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

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

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

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

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

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

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

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

9 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

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

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

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

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

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

9 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

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

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

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

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

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

9 years agopsymtab.c (psymtab_search_name): Fix whitespace.
Doug Evans [Fri, 21 Nov 2014 17:50:56 +0000 (09:50 -0800)]
psymtab.c (psymtab_search_name): Fix whitespace.

gdb/ChangeLog:

* psymtab.c (psymtab_search_name): Fix whitespace.

9 years agoAdd function and function pointer tests for i386
H.J. Lu [Fri, 21 Nov 2014 16:45:02 +0000 (08:45 -0800)]
Add function and function pointer tests for i386

This patch adds tests for function and function pointer for i386.

* ld-i386/plt-lib.c: New file.
* ld-i386/plt-main.out: Likewise.
* ld-i386/plt-main1.c: Likewise.
* ld-i386/plt-main1.rd: Likewise.
* ld-i386/plt-main2.c: Likewise.
* ld-i386/plt-main2.rd: Likewise.
* ld-i386/plt-main3.c: Likewise.
* ld-i386/plt-main3.rd: Likewise.
* ld-i386/plt-main4.c: Likewise.
* ld-i386/plt-main4.rd: Likewise.
* ld-i386/plt-main5.c: Likewise.

* ld-i386/i386.exp: Run plt-main tests.

9 years agoRun plt-main test with -pie
H.J. Lu [Fri, 21 Nov 2014 15:57:38 +0000 (07:57 -0800)]
Run plt-main test with -pie

* ld-x86-64/x86-64.exp: Run plt-main test with -pie.

9 years agoImport errno explicitly
Yao Qi [Fri, 21 Nov 2014 14:05:42 +0000 (22:05 +0800)]
Import errno explicitly

errno.h is included in common/common-defs.h, and gnulib errno module
was imported to gdb.  This patch is to import it explicitly.

gdb:

* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add
errno.
* gnulib/import/Makefile.am: Re-generated.
* gnulib/import/Makefile.in: Likewise.
* gnulib/import/m4/gnulib-cache.m4: Likewise.

9 years agoInclude wchar.h and wctype.h unconditionally
Yao Qi [Fri, 21 Nov 2014 14:05:41 +0000 (22:05 +0800)]
Include wchar.h and wctype.h unconditionally

As gnulib modules wchar and wctype is imported, we can include wchar.h
and wctype.h unconditionally.  This patch is also to remove HAVE_WCHAR_H
check.

gdb:

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

* gdb_wchar.h: Include wchar.h and wctype.h.
[HAVE_ICONV && HAVE_BTOWC]: Don't check HAVE_WCHAR_T and don't
include wchar.h and wctype.h.
Don't check HAVE_WCHAR_H.

9 years agoImport wchar and wctype-h explicitly
Yao Qi [Fri, 21 Nov 2014 14:05:41 +0000 (22:05 +0800)]
Import wchar and wctype-h explicitly

gnulib module wchar and wctype-h was imported as a dependency, but
they are used by gdb_wchar.h too.  This patch is to import them
explicitly.

gdb:

* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add wchar
and wctype-h.
* gnulib/import/Makefile.am: Re-generated.
* gnulib/import/Makefile.in: Likewise.
* gnulib/import/m4/gnulib-cache.m4: Likewise.

9 years agoImport memchr explicitly
Yao Qi [Fri, 21 Nov 2014 14:05:41 +0000 (22:05 +0800)]
Import memchr explicitly

memchr has been used in gdb source and gnulib memchr module was
imported as a dependency.  This patch is to import it explicitly.

gdb:

* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add
memchr.
* gnulib/import/Makefile.am: Re-generated.
* gnulib/import/Makefile.in: Likewise.
* gnulib/import/m4/gnulib-cache.m4: Likewise.

9 years agoInclude alloca.h unconditionally
Yao Qi [Fri, 21 Nov 2014 14:05:41 +0000 (22:05 +0800)]
Include alloca.h unconditionally

Since gnulib alloca module was imported, we can include alloca.h in
both gdb and gdbserver unconditionally, so this patch adds inclusion
of alloca.h in common-defs.h.  This patch also removes AC_FUNC_ALLOCA
in configure.ac because we don't need to check alloca any more.

This patch below is removed in fact.

  [RFA/commit] include alloca.h if available.
  https://www.sourceware.org/ml/gdb-patches/2010-08/msg00566.html

Since alloca.h is from gnulib now, we don't have to check malloc.h in
configure and include malloc.h in code.  This patch also remove them
too.

gdb:

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

* common/common-defs.h: Include alloca.h
* configure.ac: Don't invoke AC_FUNC_ALLOCA.
* configure: Re-generated.
* defs.h: Remove code handling alloca.
* utils.c (gdb_realpath): Don't check HAVE_ALLOCA is defined
or not.

gdb/gdbserver:

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

* configure.ac: Don't invoke AC_FUNC_ALLOCA.
(AC_CHECK_HEADERS): Remove malloc.h.
* configure: Re-generated.
* config.in: Re-generated.
* server.h: Don't include alloca.h and malloc.h.
* gdbreplay.c: Don't check HAVE_ALLOCA_H is defined.
Don't include malloc.h.

9 years agoImport alloca explicitly
Yao Qi [Fri, 21 Nov 2014 14:05:41 +0000 (22:05 +0800)]
Import alloca explicitly

gnulib's alloca module was imported to gdb, and alloca is used.  This
patch is to explicitly import it.

gdb:

* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULE): Add
alloca.
* gnulib/import/Makefile.am: Re-generated.
* gnulib/import/Makefile.in: Likewise..
* gnulib/import/m4/gnulib-cache.m4: Likewise.

9 years agoMake IMPORTED_GNULIB_MODULES in alphabetical order
Yao Qi [Fri, 21 Nov 2014 14:05:41 +0000 (22:05 +0800)]
Make IMPORTED_GNULIB_MODULES in alphabetical order

Since we'll add more modules in this list, better to keep them in
alphabetical order.

gdb:

* gnulib/update-gnulib.sh: Make IMPORTED_GNULIB_MODULES in
alphabetical order.

9 years agoResolve more problems with readelf uncovered by fuzzing binary files.
Nick Clifton [Fri, 21 Nov 2014 13:37:39 +0000 (13:37 +0000)]
Resolve more problems with readelf uncovered by fuzzing binary files.

PR binutils/17531
* readelf.c (process_version_sections): Prevent an infinite loop
processing corrupt version need data.
(process_corefile_note_segment): Handle corrupt notes.

9 years agoFix a snafu setting up the string table read in from a COFF file.
Alexander Cherepanov [Fri, 21 Nov 2014 11:19:49 +0000 (11:19 +0000)]
Fix a snafu setting up the string table read in from a COFF file.

PR binutils/17512
* coffgen.c (_bfd_coff_read_string_table): Test allocation of
string table before clearing the first few bytes.

9 years agoCalculate ARM arch attribute after relaxation
Terry Guo [Fri, 21 Nov 2014 03:54:39 +0000 (11:54 +0800)]
Calculate ARM arch attribute after relaxation

gas/
2014-11-21  Terry Guo  <terry.guo@arm.com>

* config/tc-arm.c (md_assemble): Do not consider relaxation.
(md_convert_frag): Test and set target arch attribute accordingly.
(aeabi_set_attribute_string): Turn it into a global function.
* config/tc-arm.h (md_post_relax_hook): Enable it for ARM target.
(aeabi_set_public_attributes): Declare it.

gas/testsuite/
2014-11-21  Terry Guo  <terry.guo@arm.com>

* gas/arm/attr-arch-assumption.d: New file.
* gas/arm/attr-arch-assumption.s: Likewise.

ld/testsuite/
2014-11-21  Terry Guo  <terry.guo@arm.com>

* ld-arm/tls-longplt-lib.s: Require ARMv6T2.
* ld-arm/tls-longplt.s: Likewise.
* ld-arm/tls-longplt-lib.d: Updated.
* ld-arm/tls-longplt.d: Likewise.

9 years agoSupport ARM Cortex-M7
Terry Guo [Fri, 21 Nov 2014 03:31:37 +0000 (11:31 +0800)]
Support ARM Cortex-M7

include/ChangeLog:
2014-11-21  Terry Guo  <terry.guo@arm.com>

* opcode/arm.h (FPU_VFP_EXT_ARMV8xD): New macro.
(FPU_VFP_V5D16): Likewise.
(FPU_VFP_V5_SP_D16): Likewise.
(FPU_ARCH_VFP_V5D16): Likewise.
(FPU_ARCH_VFP_V5_SP_D16): Likewise.

bfd/ChangeLog:
2014-11-21  Terry Guo  <terry.guo@arm.com>

* elf32-arm.c (elf32_arm_merge_eabi_attributes): Support FPv5.

binutils/ChangeLog:
2014-11-21  Terry Guo  <terry.guo@arm.com>

* readelf.c (arm_attr_tag_FP_arch): Extended to support FPv5.

gas/ChangeLog:
2014-11-21  Terry Guo  <terry.guo@arm.com>

* config/tc-arm.c (fpu_vfp_ext_armv8xd): New.
(arm_cpus): Support cortex-m7.
(arm_fpus): Support fpv5-sp-d16 and fpv5-d16.
(do_vfp_nsyn_cvt_fpv8): Generate error when use D register for S
register only target like FPv5-SP-D16.
(do_neon_cvttb_1): Likewise.
(do_vfp_nsyn_fpv8): Likewise.
(do_vrint_1): Likewise.
(aeabi_set_public_attributes): Set proper FP arch for FPv5.
* doc/c-arm.texi: Document new cpu and fpu names for cortex-m7.

gas/testsuite/ChangeLog:
2014-11-21  Terry Guo  <terry.guo@arm.com>

* gas/arm/armv7e-m+fpv5-d16.s: New.
* gas/arm/armv7e-m+fpv5-d16.d: Likewise.
* gas/arm/armv7e-m+fpv5-sp-d16.s: Likewise.
* gas/arm/armv7e-m+fpv5-sp-d16.d: Likewise.

ld/testsuite/ChangeLog:
2014-11-21  Terry Guo  <terry.guo@arm.com>

* ld-arm/attr-merge-vfp-4-sp.s: New test source file.
* ld-arm/attr-merge-vfp-5-sp.s: Likewise.
* ld-arm/attr-merge-vfp-5.s: Likewise.
* ld-arm/attr-merge-vfp-8.d: New test.
* ld-arm/attr-merge-vfp-8r.d: Likewise.
* ld-arm/attr-merge-vfp-9.d: Likewise.
* ld-arm/attr-merge-vfp-9r.d: Likewise.
* ld-arm/attr-merge-vfp-10.d: Likewise.
* ld-arm/attr-merge-vfp-10r.d: Likewise.
* ld-arm/attr-merge-vfp-11.d: Likewise.
* ld-arm/attr-merge-vfp-11r.d: Likewise.
* ld-arm/attr-merge-vfp-12.d: Likewise.
* ld-arm/attr-merge-vfp-12r.d: Likewise.
* ld-arm/attr-merge-vfp-13.d: Likewise.
* ld-arm/attr-merge-vfp-13r.d: Likewise.
* ld-arm/attr-merge-vfp-14.d: Likewise.
* ld-arm/attr-merge-vfp-14r.d: Likewise.
* ld-arm/arm-elf.exp: Run the new tests.

9 years agoHandling of empty Ada ranges with a negative upper bound.
Joel Brobecker [Thu, 2 Oct 2014 22:17:49 +0000 (15:17 -0700)]
Handling of empty Ada ranges with a negative upper bound.

Consider the following variable declaration:

    type Array_Type is array (Integer range <>) of Integer;
    Var: Array_Type (0 .. -1);

"ptype var" prints the wrong upper bound for that array:

    (gdb) ptype var
    type = array (0 .. 4294967295) of integer

The debugging info for the type of variable "Var" is as follow:

  <2><cf>: Abbrev Number: 13 (DW_TAG_structure_type)
     <d0>   DW_AT_name        : foo__var___PAD
  <3><db>: Abbrev Number: 14 (DW_TAG_member)
     <dc>   DW_AT_name        : F
     <e0>   DW_AT_type        : <0xa5>

This is just an artifact from code generation, which is just
a wrapper that we should ignore. The real type is the type of
field "F" in that PAD type, which is described as:

  <2><a5>: Abbrev Number: 10 (DW_TAG_array_type)
     <a6>   DW_AT_name        : foo__TvarS
  <3><b6>: Abbrev Number: 11 (DW_TAG_subrange_type)
     <b7>   DW_AT_type        : <0xc1>
     <bb>   DW_AT_lower_bound : 0
     <bc>   DW_AT_upper_bound : 0xffffffff

Trouble occurs because DW_AT_upper_bound is encoded using
a DW_FORM_data4, which is ambiguous regarding signedness.
In that case, dwarf2read.c::dwarf2_get_attr_constant_value
reads the value as unsigned, which is not what we want
in this case.

As it happens, we already have code dealing with this situation
in dwarf2read.c::read_subrange_type which checks whether
the subrange's type is signed or not, and if it is, fixes
the bound's value by sign-extending it:

  if (high.kind == PROP_CONST
      && !TYPE_UNSIGNED (base_type) && (high.data.const_val & negative_mask))
    high.data.const_val |= negative_mask;

Unfortunately, what happens in our case is that the base type
of the array's subrange type is marked as being unsigned, and
so we never get to apply the sign extension. Following the DWARF
trail, the range's base type is described as another subrange type...

  <2><c1>: Abbrev Number: 12 (DW_TAG_subrange_type)
     <c7>   DW_AT_name        : foo__TTvarSP1___XDLU_0__1m
     <cb>   DW_AT_type        : <0x2d>

... whose base type is, (finally), a basic type (signed):

  <1><2d>: Abbrev Number: 2 (DW_TAG_base_type)
     <2e>   DW_AT_byte_size   : 4
     <2f>   DW_AT_encoding    : 5        (signed)
     <30>   DW_AT_name        : integer

The reason why GDB thinks that foo__TTvarSP1___XDLU_0__1m
(the base type of the array's range type) is an unsigned type
is found in gdbtypes.c::create_range_type.  We consider that
a range type is unsigned iff its lower bound is >= 0:

  if (low_bound->kind == PROP_CONST && low_bound->data.const_val >= 0)
    TYPE_UNSIGNED (result_type) = 1;

That is normally sufficient, as one would expect the upper bound to
always be greater or equal to the lower bound. But Ada actually
allows the declaration of empty range types where the upper bound
is less than the lower bound. In this case, the upper bound is
negative, so we should not be marking the type as unsigned.

This patch fixes the issue by simply checking the upper bound as well
as the lower bound, and clears the range type's unsigned flag when
it is found to be constant and negative.

gdb/ChangeLog:

        * gdbtypes.c (create_range_type): Unset RESULT_TYPE's
        flag_unsigned if HIGH_BOUND is constant and negative.

gdb/testsuite/ChangeLog:

        * gdb.ada/n_arr_bound: New testcase.

Tested on x86_64-linux.

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

9 years agoPPC gold doesn't check for overflow properly
Alan Modra [Thu, 20 Nov 2014 21:45:04 +0000 (08:15 +1030)]
PPC gold doesn't check for overflow properly

* powerpc.cc (Target_powerpc::Relocate::relocate): Correct test
for undefined weaks.

9 years agoDon't run pr17618 test on x32
H.J. Lu [Thu, 20 Nov 2014 21:35:29 +0000 (13:35 -0800)]
Don't run pr17618 test on x32

* ld-x86-64/pr17618.d: Don't run on x32.

9 years agoUpdate plt-main tests for x32
H.J. Lu [Thu, 20 Nov 2014 21:29:41 +0000 (13:29 -0800)]
Update plt-main tests for x32

* ld-x86-64/plt-main1.rd: Updated for x32.
* ld-x86-64/plt-main2.rd: Likewise.
* ld-x86-64/plt-main3.rd: Likewise.
* ld-x86-64/plt-main4.rd: Likewise.

9 years agoAdd function and function pointer tests
H.J. Lu [Thu, 20 Nov 2014 20:41:11 +0000 (12:41 -0800)]
Add function and function pointer tests

This patch adds tests for function and function pointer.

* ld-x86-64/plt-lib.c: New file.
* ld-x86-64/plt-main.out: Likewise.
* ld-x86-64/plt-main1.c: Likewise.
* ld-x86-64/plt-main1.rd: Likewise.
* ld-x86-64/plt-main2.c: Likewise.
* ld-x86-64/plt-main2.rd: Likewise.
* ld-x86-64/plt-main3.c: Likewise.
* ld-x86-64/plt-main3.rd: Likewise.
* ld-x86-64/plt-main4.c: Likewise.
* ld-x86-64/plt-main4.rd: Likewise.
* ld-x86-64/plt-main5.c: Likewise.

* ld-x86-64/x86-64.exp: Run plt-main tests.

9 years agoAlways load function pointer into a stack variable
H.J. Lu [Thu, 20 Nov 2014 19:29:45 +0000 (11:29 -0800)]
Always load function pointer into a stack variable

This patch makes sure that compiler won't optimize out loading function
into a stack variable.

* ld-ifunc/ifunc-main.c (get_bar): New function.
(main): Use it.

9 years agoAdd ifunc-main IFUNC tests
H.J. Lu [Thu, 20 Nov 2014 18:48:47 +0000 (10:48 -0800)]
Add ifunc-main IFUNC tests

* ld-ifunc/ifunc.exp: Run ifunc-main.
* ld-ifunc/ifunc-lib.c: New file.
* ld-ifunc/ifunc-main.c: Likewise.
* ld-ifunc/ifunc-main.out: Likewise.

9 years agoFix build breakage from previous commit
Sergio Durigan Junior [Thu, 20 Nov 2014 18:33:28 +0000 (13:33 -0500)]
Fix build breakage from previous commit

In the previous commit, I forgot to adjust the prototypes of the
functions inside gdb/xml-syscall.c for the case when GDB is compiled
without XML support.

gdb/
2014-11-20  Sergio Durigan Junior  <sergiodj@redhat.com>

PR breakpoints/10737
* xml-syscall.c (set_xml_syscall_file_name): Remove "const"
modifier from "struct gdbarch" when compiling without Expat (XML)
support.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.

9 years agoPartial fix for PR breakpoints/10737: Make syscall info be per-arch instead of global
Sergio Durigan Junior [Thu, 20 Nov 2014 17:28:18 +0000 (12:28 -0500)]
Partial fix for PR breakpoints/10737: Make syscall info be per-arch instead of global

This patch intends to partially fix PR breakpoints/10737, which is
about making the syscall information (for the "catch syscall" command)
be per-arch, instead of global.  This is not a full fix because of the
other issues pointed by Pedro here:

  <https://sourceware.org/bugzilla/show_bug.cgi?id=10737#c5>

However, I consider it a good step towards the real fix.  It will also
help me fix <https://sourceware.org/bugzilla/show_bug.cgi?id=17402>.

What this patch does, basically, is move the "syscalls_info"
struct to gdbarch.  Currently, the syscall information is stored in a
global variable inside gdb/xml-syscall.c, which means that there is no
easy way to correlate this info with the current target or
architecture being used, for example.  This causes strange behaviors,
because the syscall info is not re-read when the arch changes.  For
example, if you put a syscall catchpoint in syscall 5 on i386 (syscall
open), and then load a x86_64 program on GDB and put the same syscall
5 there (fstat on x86_64), you will still see that GDB tells you that
it is catching "open", even though it is not.  With this patch, GDB
correctly says that it will be catching fstat syscalls.

  (gdb) set architecture i386
  The target architecture is assumed to be i386
  (gdb) catch syscall 5
  Catchpoint 1 (syscall 'open' [5])
  (gdb) set architecture i386:x86-64
  The target architecture is assumed to be i386:x86-64
  (gdb) catch syscall 5
  Catchpoint 2 (syscall 'open' [5])

But with the patch:

  (gdb) set architecture i386
  The target architecture is assumed to be i386
  (gdb) catch syscall 5
  Catchpoint 1 (syscall 'open' [5])
  (gdb) set architecture i386:x86-64
  The target architecture is assumed to be i386:x86-64
  (gdb) catch syscall 5
  Catchpoint 2 (syscall 'fstat' [5])

As I said, there are still some problems on the "catch syscall"
mechanism, because (for example) the user should be able to "catch
syscall open" on i386, and then expect "open" to be caught also on
x86_64.  Currently, it doesn't work.  I intend to work on this later.

gdb/
2014-11-20  Sergio Durigan Junior  <sergiodj@redhat.com>

PR breakpoints/10737
* amd64-linux-tdep.c (amd64_linux_init_abi_common): Adjust call to
set_xml_syscall_file_name to provide gdbarch.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* bfin-linux-tdep.c (bfin_linux_init_abi): Likewise.
* breakpoint.c (print_it_catch_syscall): Adjust call to
get_syscall_by_number to provide gdbarch.
(print_one_catch_syscall): Likewise.
(print_mention_catch_syscall): Likewise.
(print_recreate_catch_syscall): Likewise.
(catch_syscall_split_args): Adjust calls to get_syscall_by_number
and get_syscall_by_name to provide gdbarch.
(catch_syscall_completer): Adjust call to get_syscall_names to
provide gdbarch.
* gdbarch.c: Regenerate.
* gdbarch.h: Likewise.
* gdbarch.sh: Forward declare "struct syscalls_info".
(xml_syscall_file): New variable.
(syscalls_info): Likewise.
* i386-linux-tdep.c (i386_linux_init_abi): Adjust call to
set_xml_syscall_file_name to provide gdbarch.
* mips-linux-tdep.c (mips_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* sparc-linux-tdep.c (sparc32_linux_init_abi): Likewise.
* sparc64-linux-tdep.c (sparc64_linux_init_abi): Likewise.
* xml-syscall.c: Include gdbarch.h.
(set_xml_syscall_file_name): Accept gdbarch parameter.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.
(my_gdb_datadir): Delete global variable.
(struct syscalls_info) <my_gdb_datadir>: New variable.
(struct syscalls_info) <sysinfo>: Rename variable to
"syscalls_info".
(sysinfo): Delete global variable.
(have_initialized_sysinfo): Likewise.
(xml_syscall_file): Likewise.
(sysinfo_free_syscalls_desc): Rename to...
(syscalls_info_free_syscalls_desc): ... this.
(free_syscalls_info): Rename "sysinfo" to "syscalls_info".  Adjust
code to the new layout of "struct syscalls_info".
(make_cleanup_free_syscalls_info): Rename parameter "sysinfo" to
"syscalls_info".
(syscall_create_syscall_desc): Likewise.
(syscall_start_syscall): Likewise.
(syscall_parse_xml): Likewise.
(xml_init_syscalls_info): Likewise.  Drop "const" from return value.
(init_sysinfo): Rename to...
(init_syscalls_info): ...this.  Add gdbarch as a parameter.
Adjust function to deal with gdbarch.
(xml_get_syscall_number): Delete parameter sysinfo.  Accept
gdbarch as a parameter.  Adjust code.
(xml_get_syscall_name): Likewise.
(xml_list_of_syscalls): Likewise.
(set_xml_syscall_file_name): Accept gdbarch as parameter.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.
* xml-syscall.h (set_xml_syscall_file_name): Likewise.
(get_syscall_by_number): Likewise.
(get_syscall_by_name): Likewise.
(get_syscall_names): Likewise.

gdb/testsuite/
2014-11-20  Sergio Durigan Junior  <sergiodj@redhat.com>

PR breakpoints/10737
* gdb.base/catch-syscall.exp (do_syscall_tests): Call
test_catch_syscall_multi_arch.
(test_catch_syscall_multi_arch): New function.

9 years ago* config/tc-arm.c (rotate_left): Avoid undefined behaviour when N = 0.
Richard Earnshaw [Thu, 20 Nov 2014 17:02:47 +0000 (17:02 +0000)]
* config/tc-arm.c (rotate_left): Avoid undefined behaviour when N = 0.

9 years agoRun IFUNC run-time tests only if IFUNC is supported
H.J. Lu [Thu, 20 Nov 2014 16:59:42 +0000 (08:59 -0800)]
Run IFUNC run-time tests only if IFUNC is supported

* lib/ld-lib.exp (check_ifunc_available): New.
* ld-ifunc/ifunc.exp: Run IFUNC run-time tests only if IFUNC
is supported.

9 years agoSplit struct symtab into two: struct symtab and compunit_symtab.
Doug Evans [Thu, 20 Nov 2014 15:42:48 +0000 (07:42 -0800)]
Split struct symtab into two: struct symtab and compunit_symtab.

Currently "symtabs" in gdb are stored as a single linked list of
struct symtab that contains both symbol symtabs (the blockvectors)
and file symtabs (the linetables).

This has led to confusion, bugs, and performance issues.

This patch is conceptually very simple: split struct symtab into
two pieces: one part containing things common across the entire
compilation unit, and one part containing things specific to each
source file.

Example.
For the case of a program built out of these files:

foo.c
  foo1.h
  foo2.h
bar.c
  foo1.h
  bar.h

Today we have a single list of struct symtabs:

objfile -> foo.c -> foo1.h -> foo2.h -> bar.c -> foo1.h -> bar.h -> NULL

where "->" means the "next" pointer in struct symtab.

With this patch, that turns into:

objfile -> foo.c(cu) -> bar.c(cu) -> NULL
            |            |
            v            v
           foo.c        bar.c
            |            |
            v            v
           foo1.h       foo1.h
            |            |
            v            v
           foo2.h       bar.h
            |            |
            v            v
           NULL         NULL

where "foo.c(cu)" and "bar.c(cu)" are struct compunit_symtab objects,
and the files foo.c, etc. are struct symtab objects.

So now, for example, when we want to iterate over all blockvectors
we can now just iterate over the compunit_symtab list.

Plus a lot of the data that was either unused or replicated for each
symtab in a compilation unit now lives in struct compunit_symtab.
E.g., the objfile pointer, the producer string, etc.
I thought of moving "language" out of struct symtab but there is
logic to try to compute the language based on previously seen files,
and I think that's best left as is for now.
With my standard monster benchmark with -readnow (which I can't actually
do, but based on my calculations), whereas today the list requires
77MB to store all the struct symtabs, it now only requires 37MB.
A modest space savings given the gigabytes needed for all the debug info,
etc.  Still, it's nice.  Plus, whereas today we create a copy of dirname
for each source file symtab in a compilation unit, we now only create one
for the compunit.

So this patch is basically just a data structure reorg,
I don't expect significant performance improvements from it.

Notes:

1) A followup patch can do a similar split for struct partial_symtab.
I have left that until after I get the changes I want in to
better utilize .gdb_index (it may affect how we do partial syms).

2) Another followup patch *could* rename struct symtab.
The term "symtab" is ambiguous and has been a source of confusion.
In this patch I'm leaving it alone, calling it the "historical" name
of "filetabs", which is what they are now: just the file-name + line-table.

gdb/ChangeLog:

Split struct symtab into two: struct symtab and compunit_symtab.
* amd64-tdep.c (amd64_skip_xmm_prologue): Fetch producer from compunit.
* block.c (blockvector_for_pc_sect): Change "struct symtab *" argument
to "struct compunit_symtab *".  All callers updated.
(set_block_compunit_symtab): Renamed from set_block_symtab.  Change
"struct symtab *" argument to "struct compunit_symtab *".
All callers updated.
(get_block_compunit_symtab): Renamed from get_block_symtab.  Change
result to "struct compunit_symtab *".  All callers updated.
(find_iterator_compunit_symtab): Renamed from find_iterator_symtab.
Change result to "struct compunit_symtab *".  All callers updated.
* block.h (struct global_block) <compunit_symtab>: Renamed from symtab.
hange type to "struct compunit_symtab *".  All uses updated.
(struct block_iterator) <d.compunit_symtab>: Renamed from "d.symtab".
Change type to "struct compunit_symtab *".  All uses updated.
* buildsym.c (struct buildsym_compunit): New struct.
(subfiles, buildsym_compdir, buildsym_objfile, main_subfile): Delete.
(buildsym_compunit): New static global.
(finish_block_internal): Update to fetch objfile from
buildsym_compunit.
(make_blockvector): Delete objfile argument.
(start_subfile): Rewrite to use buildsym_compunit.  Don't initialize
debugformat, producer.
(start_buildsym_compunit): New function.
(free_buildsym_compunit): Renamed from free_subfiles_list.
All callers updated.
(patch_subfile_names): Rewrite to use buildsym_compunit.
(get_compunit_symtab): New function.
(get_macro_table): Delete argument comp_dir.  All callers updated.
(start_symtab): Change result to "struct compunit_symtab *".
All callers updated.  Create the subfile of the main source file.
(watch_main_source_file_lossage): Rewrite to use buildsym_compunit.
(reset_symtab_globals): Update.
(end_symtab_get_static_block): Update to use buildsym_compunit.
(end_symtab_without_blockvector): Rewrite.
(end_symtab_with_blockvector): Change result to
"struct compunit_symtab *".  All callers updated.
Update to use buildsym_compunit.  Don't set symtab->dirname,
instead set it in the compunit.
Explicitly make sure main symtab is first in its list.
Set debugformat, producer, blockvector, block_line_section, and
macrotable in the compunit.
(end_symtab_from_static_block): Change result to
"struct compunit_symtab *".  All callers updated.
(end_symtab, end_expandable_symtab): Ditto.
(set_missing_symtab): Change symtab argument to
"struct compunit_symtab *".  All callers updated.
(augment_type_symtab): Ditto.
(record_debugformat): Update to use buildsym_compunit.
(record_producer): Update to use buildsym_compunit.
* buildsym.h (struct subfile) <dirname>: Delete.
<producer, debugformat>: Delete.
<buildsym_compunit>: New member.
(get_compunit_symtab): Declare.
* dwarf2read.c (struct type_unit_group) <compunit_symtab>: Renamed
from primary_symtab.  Change type to "struct compunit_symtab *".
All uses updated.
(dwarf2_start_symtab): Change result to "struct compunit_symtab *".
All callers updated.
(dwarf_decode_macros): Delete comp_dir argument.  All callers updated.
(struct dwarf2_per_cu_quick_data) <compunit_symtab>: Renamed from
symtab.  Change type to "struct compunit_symtab *".  All uses updated.
(dw2_instantiate_symtab): Change result to "struct compunit_symtab *".
All callers updated.
(dw2_find_last_source_symtab): Ditto.
(dw2_lookup_symbol): Ditto.
(recursively_find_pc_sect_compunit_symtab): Renamed from
recursively_find_pc_sect_symtab.  Change result to
"struct compunit_symtab *".  All callers updated.
(dw2_find_pc_sect_compunit_symtab): Renamed from
dw2_find_pc_sect_symtab.  Change result to
"struct compunit_symtab *".  All callers updated.
(get_compunit_symtab): Renamed from get_symtab.  Change result to
"struct compunit_symtab *".  All callers updated.
(recursively_compute_inclusions): Change type of immediate_parent
argument to "struct compunit_symtab *".  All callers updated.
(compute_compunit_symtab_includes): Renamed from
compute_symtab_includes.  All callers updated.  Rewrite to compute
includes of compunit_symtabs and not symtabs.
(process_full_comp_unit): Update to work with struct compunit_symtab.
(process_full_type_unit): Ditto.
(dwarf_decode_lines_1): Delete argument comp_dir.  All callers updated.
(dwarf_decode_lines): Remove special case handling of main subfile.
(macro_start_file): Delete argument comp_dir.  All callers updated.
(dwarf_decode_macro_bytes): Ditto.
* guile/scm-block.c (bkscm_print_block_syms_progress_smob): Update to
use struct compunit_symtab.
* i386-tdep.c (i386_skip_prologue): Fetch producer from compunit.
* jit.c (finalize_symtab): Build compunit_symtab.
* jv-lang.c (get_java_class_symtab): Change result to
"struct compunit_symtab *".  All callers updated.
* macroscope.c (sal_macro_scope): Fetch macro table from compunit.
* macrotab.c (struct macro_table) <compunit_symtab>: Renamed from
comp_dir.  Change type to "struct compunit_symtab *".
All uses updated.
(new_macro_table): Change comp_dir argument to cust,
"struct compunit_symtab *".  All callers updated.
* maint.c (struct cmd_stats) <nr_compunit_symtabs>: Renamed from
nr_primary_symtabs.  All uses updated.
(count_symtabs_and_blocks): Update to handle compunits.
(report_command_stats): Update output, "primary symtabs" renamed to
"compunits".
* mdebugread.c (new_symtab): Change result to
"struct compunit_symtab *".  All callers updated.
(parse_procedure): Change type of search_symtab argument to
"struct compunit_symtab *".  All callers updated.
* objfiles.c (objfile_relocate1): Loop over blockvectors in a
separate loop.
* objfiles.h (struct objfile) <compunit_symtabs>: Renamed from
symtabs.  Change type to "struct compunit_symtab *".  All uses updated.
(ALL_OBJFILE_FILETABS): Renamed from ALL_OBJFILE_SYMTABS.
All uses updated.
(ALL_OBJFILE_COMPUNITS): Renamed from ALL_OBJFILE_PRIMARY_SYMTABS.
All uses updated.
(ALL_FILETABS): Renamed from ALL_SYMTABS.  All uses updated.
(ALL_COMPUNITS): Renamed from ALL_PRIMARY_SYMTABS.  All uses updated.
* psympriv.h (struct partial_symtab) <compunit_symtab>: Renamed from
symtab.  Change type to "struct compunit_symtab *".  All uses updated.
* psymtab.c (psymtab_to_symtab): Change result type to
"struct compunit_symtab *".  All callers updated.
(find_pc_sect_compunit_symtab_from_partial): Renamed from
find_pc_sect_symtab_from_partial.  Change result type to
"struct compunit_symtab *".  All callers updated.
(lookup_symbol_aux_psymtabs): Change result type to
"struct compunit_symtab *".  All callers updated.
(find_last_source_symtab_from_partial): Ditto.
* python/py-symtab.c (stpy_get_producer): Fetch producer from compunit.
* source.c (forget_cached_source_info_for_objfile): Fetch debugformat
and macro_table from compunit.
* symfile-debug.c (debug_qf_find_last_source_symtab): Change result
type to "struct compunit_symtab *".  All callers updated.
(debug_qf_lookup_symbol): Ditto.
(debug_qf_find_pc_sect_compunit_symtab): Renamed from
debug_qf_find_pc_sect_symtab, change result type to
"struct compunit_symtab *".  All callers updated.
* symfile.c (allocate_symtab): Delete objfile argument.
New argument cust.
(allocate_compunit_symtab): New function.
(add_compunit_symtab_to_objfile): New function.
* symfile.h (struct quick_symbol_functions) <lookup_symbol>:
Change result type to "struct compunit_symtab *".  All uses updated.
<find_pc_sect_compunit_symtab>: Renamed from find_pc_sect_symtab.
Change result type to "struct compunit_symtab *".  All uses updated.
* symmisc.c (print_objfile_statistics): Compute blockvector count in
separate loop.
(dump_symtab_1): Update test for primary source symtab.
(maintenance_info_symtabs): Update to handle compunit symtabs.
(maintenance_check_symtabs): Ditto.
* symtab.c (set_primary_symtab): Delete.
(compunit_primary_filetab): New function.
(compunit_language): New function.
(iterate_over_some_symtabs): Change type of arguments "first",
"after_last" to "struct compunit_symtab *".  All callers updated.
Update to loop over symtabs in each compunit.
(error_in_psymtab_expansion): Rename symtab argument to cust,
and change type to "struct compunit_symtab *".  All callers updated.
(find_pc_sect_compunit_symtab): Renamed from find_pc_sect_symtab.
Change result type to "struct compunit_symtab *".  All callers updated.
(find_pc_compunit_symtab): Renamed from find_pc_symtab.
Change result type to "struct compunit_symtab *".  All callers updated.
(find_pc_sect_line): Only loop over symtabs within selected compunit
instead of all symtabs in the objfile.
* symtab.h (struct symtab) <blockvector>: Moved to compunit_symtab.
<compunit_symtab> New member.
<block_line_section>: Moved to compunit_symtab.
<locations_valid>: Ditto.
<epilogue_unwind_valid>: Ditto.
<macro_table>: Ditto.
<dirname>: Ditto.
<debugformat>: Ditto.
<producer>: Ditto.
<objfile>: Ditto.
<call_site_htab>: Ditto.
<includes>: Ditto.
<user>: Ditto.
<primary>: Delete
(SYMTAB_COMPUNIT): New macro.
(SYMTAB_BLOCKVECTOR): Update definition.
(SYMTAB_OBJFILE): Update definition.
(SYMTAB_DIRNAME): Update definition.
(struct compunit_symtab): New type.  Common members among all source
symtabs within a compilation unit moved here.  All uses updated.
(COMPUNIT_OBJFILE): New macro.
(COMPUNIT_FILETABS): New macro.
(COMPUNIT_DEBUGFORMAT): New macro.
(COMPUNIT_PRODUCER): New macro.
(COMPUNIT_DIRNAME): New macro.
(COMPUNIT_BLOCKVECTOR): New macro.
(COMPUNIT_BLOCK_LINE_SECTION): New macro.
(COMPUNIT_LOCATIONS_VALID): New macro.
(COMPUNIT_EPILOGUE_UNWIND_VALID): New macro.
(COMPUNIT_CALL_SITE_HTAB): New macro.
(COMPUNIT_MACRO_TABLE): New macro.
(ALL_COMPUNIT_FILETABS): New macro.
(compunit_symtab_ptr): New typedef.
(DEF_VEC_P (compunit_symtab_ptr)): New vector type.

gdb/testsuite/ChangeLog:

* gdb.base/maint.exp: Update expected output.

9 years ago[AArch64] Fix mis-detection of unpredictable load/store operations with FP regs.
Richard Earnshaw [Thu, 20 Nov 2014 15:28:52 +0000 (15:28 +0000)]
[AArch64] Fix mis-detection of unpredictable load/store operations with FP regs.

* config/tc-aarch64.c (warn_unpredictable_ldst): Check that transfer
registers are in the GP register set.  Adjust warnings.  Use correct
field member for address register.
* testsuite/gas/aarch64/diagnostic.l: Update.

9 years agoPPC gold doesn't check for overflow properly
Alan Modra [Thu, 20 Nov 2014 08:31:23 +0000 (19:01 +1030)]
PPC gold doesn't check for overflow properly

Corrects overflow test for rel14, addr14, rel24, addr24 branch relocs,
and prints an information message to give a hint as to how a branch
that can't reach a stub might be cured.

bfd/
* elf64-ppc.c (group_sections): Init stub14_group_size from
--stub-group-size parameter divided by 1024.
gold/
* powerpc.cc (Stub_control::Stub_control): Init stub14_group_size_
from --stub-group-size parameter divided by 1024.
(Powerpc_relocate_functions::rela, rela_ua): Add fieldsize
template parameter.  Update all uses.
(Target_powerpc::Relocate::relocate): Rename has_plt_value to
has_stub_value.  Set for long branches.  Don't report overflow for
branch to undefined weak symbols.  Print info message on
overflowing branch to stub.

9 years agoppc476 workaround sizing
Alan Modra [Thu, 20 Nov 2014 10:37:58 +0000 (21:07 +1030)]
ppc476 workaround sizing

* elf32-ppc.c (ppc_elf_relax_section): Correct ppc476 workaround
alignment calculation.

9 years ago[Ada] XA type is not redundant if the ranges' subtypes do not match
Joel Brobecker [Thu, 20 Nov 2014 08:10:41 +0000 (12:10 +0400)]
[Ada] XA type is not redundant if the ranges' subtypes do not match

Jan noticed that gdb.ada/arrayidx.exp regressed after I applied
the following patch:

    commit 8908fca5772fcff9f7766158ba2aa59f5a2b1f68
    Author: Joel Brobecker <brobecker@adacore.com>
    Date:   Sat Sep 27 09:09:34 2014 -0700
    Subject: [Ada] Ignore __XA types when redundant.

What happens is that we're trying to print the value of
r_two_three, which is defined as follow:

   type Index is (One, Two, Three);
   type RTable is array (Index range Two .. Three) of Integer;
   R_Two_Three : RTable := (2, 3);

The expected output is:

    (gdb) p r_two_three
    $1 = (two => 2, 3)

But after the patch above was applied, with the program program
compiled using gcc-gnat-4.9.2-1.fc21.x86_64 (x86_64-linux),
the output becomes:

    (gdb) p r_two_three
    $1 = (2, 3)

(the name of the first bound is missing). The problem comes from
the fact that the compiler described the array's index type as
a plain base type, instead of as a subrange of the enumerated type.
More particularly, this is what gcc-gnat-4.9.2-1.fc21.x86_64
generated:

 <3><7ce>: Abbrev Number: 9 (DW_TAG_array_type)
    <7cf>   DW_AT_name        : (indirect string, offset: 0xc13): p__rtable
    [...]
    <7d7>   DW_AT_GNAT_descriptive_type: <0x98a>
    [...]
 <4><7df>: Abbrev Number: 8 (DW_TAG_subrange_type)
    <7e0>   DW_AT_type        : <0xa79>

where DIE 0xa79 is:

 <1><a79>: Abbrev Number: 2 (DW_TAG_base_type)
    <a7a>   DW_AT_byte_size   : 8
    <a7b>   DW_AT_encoding    : 7       (unsigned)
    <a7c>   DW_AT_name        : (indirect string, offset: 0xfc): sizetype

The actual array subrange type can be found in the array's
parallel XA type (the DW_AT_GNAT_descriptive_type).

The recent commit correctly found that that bounds taken from
the descriptive type are the same as bounds of our array's index
type. But it failed to notice that ignoring this descriptive
type would make us lose the actual array index type, making us
think that we're printing an array indexed by integers.

I hadn't seen that problem, because the compiler I used produced
debugging info where the array's index type is correctly described:

 <3><79f>: Abbrev Number: 10 (DW_TAG_array_type)
    <7a0>   DW_AT_name        : (indirect string, offset: 0xb3d): p__rtable
    [...]
 <4><7b0>: Abbrev Number: 8 (DW_TAG_subrange_type)
    <7b1>   DW_AT_type        : <0x9b2>
    <7b5>   DW_AT_upper_bound : 2

... where DIE 0x9b2 leads us to ...

 <3><9b2>: Abbrev Number: 9 (DW_TAG_subrange_type)
    [...]
    <9b8>   DW_AT_type        : <0x962>

 <2><962>: Abbrev Number: 22 (DW_TAG_enumeration_type)
    <963>   DW_AT_name        : (indirect string, offset: 0xb34): p__index
    [...]

This patch fixes the issue by also making sure that the subtype
of the original range type does match the subtype found in the
descriptive type.

gdb/ChangeLog:

        * ada-lang.c (ada_is_redundant_range_encoding): Return 0
        if the TYPE_CODE of range_type's base type does not match
        the TYPE_CODE of encoding_type's base type.

9 years agoEnable to link ARM object file that hasn't attribute section.
Terry Guo [Thu, 20 Nov 2014 05:54:27 +0000 (13:54 +0800)]
Enable to link ARM object file that hasn't attribute section.

bfd/ChangeLog

2014-11-20  Terry Guo  <terry.guo@arm.com>

* elf32-arm.c (elf32_arm_merge_eabi_attributes): Skip if input bfd
hasn't attribute section.

ld/testsuite/ChangeLog:

2014-11-20  Terry Guo  <terry.guo@arm.com>

* ld-arm/attr-merge-nosection-1.d: New file.
* ld-arm/attr-merge-nosection-1a.s: Likewise.
* ld-arm/attr-merge-nosection-1b.s: Likewise.
* ld-arm/arm-elf.exp: Include the new test.

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

10 years agoDefault powerpc64 to --plt-thread-safe for Go
Alan Modra [Wed, 19 Nov 2014 22:22:46 +0000 (08:52 +1030)]
Default powerpc64 to --plt-thread-safe for Go

Go is multi-threaded, so use thread-safe plt stubs.  __go_go doesn't
actually start threads, but is a convenient libgo function with a
reasonably unique name that is called by all Go executables.  (Threads
are started by a static function of libgo, runtime_newosproc, called
by a whole lot of global functions, including runtime_starttheworld
and runtime_main.)

bfd/
* elf64-ppc.c (ppc64_elf_size_stubs): Add __go_go to thread_starters.
gold/
* powerpc.cc (Target_powerpc::do_relax): Add __go_go to thread_starters.

10 years agoFix date in ChangeLog entry
Jan-Benedict Glaw [Wed, 19 Nov 2014 13:18:17 +0000 (14:18 +0100)]
Fix date in ChangeLog entry

10 years agoFix signedness warning
Jan-Benedict Glaw [Wed, 19 Nov 2014 13:13:30 +0000 (14:13 +0100)]
Fix signedness warning

This is the updated version using uintptr_t as Alan Modra suggested.

2014-11-18  Jan-Benedict Glaw  <jbglaw@lug-owl.de>

* dwarf.c (process_extended_line_op): Fix signedness warning.

10 years ago[AArch64] Warn on load pair to same register
Jiong Wang [Wed, 19 Nov 2014 09:35:23 +0000 (09:35 +0000)]
[AArch64] Warn on load pair to same register

  2014-11-19  Ryan Mansfield  <rmansfield@qnx.com>

    * config/tc-aarch64.c (md_assemble): Call warn_unpredictable_ldst.
    (warn_unpredictable_ldst): New.

  2014-11-19  Ryan Mansfield <rmansfield@qnx.com>

    * gas/aarch64/diagnostic.s: Add new warnings test patterns.
    * gas/aarch64/diagnostic.l: Update expected diagnostic output.

10 years agoUse 2-byte instead of 4-byte NOP on S390 in 'bp-permanent' test case
Andreas Arnez [Mon, 17 Nov 2014 15:22:48 +0000 (15:22 +0000)]
Use 2-byte instead of 4-byte NOP on S390 in 'bp-permanent' test case

The bp-permanent test case assumes that a NOP is exactly as long as a
software breakpoint.  This is not the case for the S390 "nop"
instruction, which is 4 bytes long, while a software breakpoint is
just 2 bytes long.  The "nopr" instruction has the right size and can
be used instead.

Without this patch the test case fails on S390 when trying to continue
after SIGTRAP on the permanent breakpoint:

  ...
  Continuing.

  Program received signal SIGILL, Illegal instruction.
  test () at /home/arnez/src/binutils-gdb/gdb/testsuite/gdb.base/bp-permanent.c:40
  40   NOP; /* after permanent bp */
  (gdb)
  FAIL: gdb.base/bp-permanent.exp: always_inserted=off, sw_watchpoint=0:
    basics: stop at permanent breakpoint

With this patch the test case succeeds without any FAILs.

gdb/testsuite/ChangeLog:

* gdb.base/bp-permanent.c (NOP): Define as 2-byte instead of
4-byte instruction on S390.

10 years ago[Ada] gdb.ada/complete.exp failure on x86_64-windows
Joel Brobecker [Tue, 7 Oct 2014 00:22:21 +0000 (02:22 +0200)]
[Ada] gdb.ada/complete.exp failure on x86_64-windows

Using the example in gdb.ada/complete.exp, the following command
on x86_64-windows returns one unwanted completion choice :

    (gdb) complete p pck
    p <pck_E>>
    [all following completions entries snipped, all expected]

I tracked down this suprising entry to a minimal symbol whose name
is ".refptr.pck_E". The problem occurs while trying to see if
this symbol matches "pck" when doing wild-matching as we are doing
here:

  /* Second: Try wild matching...  */

  if (!match && wild_match_p)
    {
      /* Since we are doing wild matching, this means that TEXT
         may represent an unqualified symbol name.  We therefore must
         also compare TEXT against the unqualified name of the symbol.  */
      sym_name = ada_unqualified_name (ada_decode (sym_name));
      if (strncmp (sym_name, text, text_len) == 0)
        match = 1;
    }

What happens is that ada_decode correctly identifies the fact that
SYM_NAME (".refptr.pck_E") is not following any GNAT encoding, and
therefore returns that same name, but bracketed: "<.refptr.pck_E>".
This is the convention we use for telling GDB that the decoded name
is not a real Ada name - and therefore should not be encoded for
operations such as name matching, symbol lookups, etc. So far, so good.

Next is the call to ada_unqualified_name, which unfortunately does
not notice that the decoded name it is being given isn't a natural
symbol, and just blindly strips everything up to the last do, returning
"pck_E>". And of course, "pck_E>" matches "pck" now, and so we end
up accepting this symbol as a match.

This patch fixes the problem by making ada_unqualified_name a little
smarter by making sure that the given decoded symbol name does not
start with '<'.

gdb/ChangeLog:

        * ada-lang.c (ada_unqualified_name): Return DECODED_NAME if
        it starts with '<'.

Tested on x86_64-windows using AdaCore's testsuite as well as
on x86_64-linux.