binutils-gdb.git
9 years agoFix a typo in comment in elf32-i386.c
H.J. Lu [Wed, 28 Oct 2015 16:03:59 +0000 (09:03 -0700)]
Fix a typo in comment in elf32-i386.c

* elf32-i386.c (elf_i386_relocate_section): Fix a typo in
comment.

9 years agoAdd tests for 16-bit versions of ARM teq, tst, cmp and cmn instructions.
Nick Clifton [Wed, 28 Oct 2015 15:30:05 +0000 (15:30 +0000)]
Add tests for 16-bit versions of ARM teq, tst, cmp and cmn instructions.

        * gas/arm/pinsn.s: New.
        * gas/arm/pinsn.d: Likewise.

9 years agoPass noaliases_p to aarch64_decode_insn
Yao Qi [Mon, 5 Oct 2015 10:15:58 +0000 (11:15 +0100)]
Pass noaliases_p to aarch64_decode_insn

Nowadays aarch64_decode_insn is a public interface used by both
opcodes and gdb.  However, its behaviour relies on a global variable
no_aliases, which isn't a good practise.  On the other hand, In default,
no_aliases is zero, but in GDB, we do want no alias when decoding
instructions for prologue analysis (patches to be posted), so that we
can handle both instructions "add" and "mov" (an alias of "add") as
"add".  The code in GDB can be simplified.

This patch adds a new argument in aarch64_decode_insn, and pass no_aliases
to it.  In GDB side, always pass 1 to it.

include/opcode:

2015-10-28  Yao Qi  <yao.qi@linaro.org>

* aarch64.h (aarch64_decode_insn): Update declaration.

opcodes:

2015-10-28  Yao Qi  <yao.qi@linaro.org>

* aarch64-dis.c (aarch64_decode_insn): Add one argument
noaliases_p.  Update comments.  Pass noaliases_p rather than
no_aliases to aarch64_opcode_decode.
(print_insn_aarch64_word): Pass no_aliases to
aarch64_decode_insn.

gdb:

2015-10-28  Yao Qi  <yao.qi@linaro.org>

* aarch64-tdep.c (aarch64_software_single_step): Pass 1 to
aarch64_decode_insn.

9 years agoFix recent STM324LXX patch to compile on 32-bit hosts.
Nick Clifton [Wed, 28 Oct 2015 13:52:11 +0000 (13:52 +0000)]
Fix recent STM324LXX patch to compile on 32-bit hosts.

* elf32-arm.c (create_instruction_branch_absolute): Replace
pointer parameters with a simple integer parameter.
(stm32l4xx_create_replacing_stub_ldmia): Update calls to
create_instruction_branch_absolute.
(stm32l4xx_create_replacing_stub_ldmdb): Likewise.
(stm32l4xx_create_replacing_stub_vldm): Likewise.
(elf32_arm_write_section): Use pointer type for veneer addresses.

9 years agoFix errors in the gas testsuite for the ARC target.
Cupertino Miranda [Wed, 28 Oct 2015 13:48:00 +0000 (13:48 +0000)]
Fix errors in the gas testsuite for the ARC target.

bfd * reloc.c (BFD_RELOC_ARC_32_PCREL): New entry.
(ARC_TLS_DTPOFF): Arrange it in order.
* elf32-arc.c (arc_elf_howto_ini): Update formula.
(get_middle_endian_relocation): New function.
(PDATA): Define.
* bfd-in2.h: Regenerate.
* libbfd.h: Likewise.

elf * arc-reloc.def (ARC_32_PCREL): New definition.

gas * config/tc-arc.c (tokenize_arguments): Avoid creating unused
symbols when parsing relocation types.
(md_apply_fix): Handle TLS relocations. Fix BFD_RELOC_ARC_32_PCREL
relocation.
(arc_check_reloc): Emit BFD_RELOC_ARC_32_PCREL relocation.

9 years agoAdd a test for PR ld/19162
H.J. Lu [Wed, 28 Oct 2015 10:20:55 +0000 (03:20 -0700)]
Add a test for PR ld/19162

PR ld/19162
* ld-x86-64/x86-64.exp: Run pr19162.
* ld-x86-64/pr19162.d: New file.
* ld-x86-64/pr19162a.s: Likewise.
* ld-x86-64/pr19162b.s: Likewise.

9 years agoOrphan output section with multiple input sections
Alan Modra [Wed, 28 Oct 2015 06:48:13 +0000 (17:18 +1030)]
Orphan output section with multiple input sections

If given input sections with differing flags, we'd like to place the
section according to the final output section flags.

bfd/
PR ld/19162
* elflink.c (_bfd_elf_gc_mark_reloc): Move code iterating over
linker input bfds..
* section.c (bfd_get_next_section_by_name): ..to here.  Add ibfd param.
(bfd_get_linker_section): Adjust bfd_get_next_section_by_name call.
* tekhex.c (first_phase): Likewise.
* elflink.c (bfd_elf_gc_sections): Likewise.
* bfd-in2.h: Regenerate.
ld/
PR ld/19162
* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Check flags
before calling _bfd_elf_match_sections_by_type.  Merge flags for
any other input sections that might match a new output section to
decide placement.

9 years agoAutomatic date update in version.in
GDB Administrator [Wed, 28 Oct 2015 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoPatch for PR gold/19042 - unsupported reloc 311/312.
Han Shen [Tue, 27 Oct 2015 22:17:54 +0000 (15:17 -0700)]
Patch for PR gold/19042 - unsupported reloc 311/312.

gold/

* aarch64.cc (Target_aarch64::Scan::local): Add support for
reloc 311/312.

9 years agoMake host_address_to_string/gdb_print_host_address cast parameter to 'void *'
Pedro Alves [Tue, 27 Oct 2015 17:25:09 +0000 (17:25 +0000)]
Make host_address_to_string/gdb_print_host_address cast parameter to 'void *'

Fixes a set of errors like:

 ../../src/gdb/symfile-debug.c: In function ‘int debug_qf_map_symtabs_matching_filename(objfile*, const char*, const char*, int (*)(symtab*, void*), void*)’:
 ../../src/gdb/symfile-debug.c:137:39: error: invalid conversion from ‘int (*)(symtab*, void*)’ to ‘const void*’ [-fpermissive]
host_address_to_string (callback),
^

Note this has to work with data and function pointers.  In C++11 we
may perhaps do something a bit safer, but we're not there yet, and I
don't think it really matters.  For now just always do a simple
C-style cast in host_address_to_string itself.  No point in adding a
void * cast to each and every caller.

gdb/ChangeLog:
2015-10-27  Pedro Alves  <palves@redhat.com>

* common/print-utils.c (host_address_to_string): Rename to ...
(host_address_to_string_1): ... this.
* common/print-utils.h (host_address_to_string): Reimplement as
wrapper around host_address_to_string_1.
* utils.c (gdb_print_host_address): Rename to ...
(gdb_print_host_address_1): ... this.
* utils.h (gdb_print_host_address): Reimplement as wrapper macro
around host_address_to_string_1.

9 years agotarget_read_memory&co: no longer return target_xfer_status
Pedro Alves [Tue, 27 Oct 2015 17:25:09 +0000 (17:25 +0000)]
target_read_memory&co: no longer return target_xfer_status

Years ago, these functions used to return errno/EIO.  Later, through a
series of changes that intended to remove native/remote differences,
they ended up returning a target_xfer_status in disguise.

Unlike target_xfer_partial&co, the point of target_read_memory&co is
to either fully succeed or fail.  On error, they always return
TARGET_XFER_E_IO.  So there's no real point in casting the return of
target_read_memory to a target_xfer_status to pass it to memory_error.
Instead, it results in clearer code to simply decouple
target_read_memory&co's return from target_xfer_status.

This fixes build errors like this in C++ mode:

 ../../src/gdb/corefile.c: In function ‘void read_stack(CORE_ADDR, gdb_byte*, ssize_t)’:
 ../../src/gdb/corefile.c:276:34: error: invalid conversion from ‘int’ to ‘target_xfer_status’ [-fpermissive]
      memory_error (status, memaddr);
   ^
 ../../src/gdb/corefile.c:216:1: error:   initializing argument 1 of ‘void memory_error(target_xfer_status, CORE_ADDR)’ [-fpermissive]

gdb/ChangeLog:
2015-10-27  Pedro Alves  <palves@redhat.com>

* alpha-tdep.c (alpha_read_insn): Always pass TARGET_XFER_E_IO to
memory_error.  Rename local 'status' to 'res'.
* c-lang.c (c_get_string): Always pass TARGET_XFER_E_IO to
memory_error.
* corefile.c (read_stack, read_code, write_memory): Always pass
TARGET_XFER_E_IO to memory_error.
* disasm.c (dis_asm_memory_error): Always pass TARGET_XFER_E_IO to
memory_error.  Rename parameter 'status' to 'err'.
(dump_insns): Rename local 'status' to 'err'.
* mips-tdep.c (mips_fetch_instruction): Rename parameter 'statusp'
to 'errp'.  Rename local 'status' to 'err'.  Always pass
TARGET_XFER_E_IO to memory_error.
(mips_breakpoint_from_pc): Rename local 'status' to 'err'.
* target.c (target_read_memory, target_read_raw_memory)
(target_read_stack, target_read_code, target_write_memory)
(target_write_raw_memory): Return -1 on error instead of
TARGET_XFER_E_IO.
* valprint.c (val_print_string): Rename local 'errcode' to 'err'.
Always pass TARGET_XFER_E_IO to memory_error.  Update comment.

9 years agoguile: Change return value of gdbscm_with_guile for const char *
Simon Marchi [Tue, 27 Oct 2015 17:11:45 +0000 (13:11 -0400)]
guile: Change return value of gdbscm_with_guile for const char *

The documentation of gdbscm_with_guile says that it returns a statically
allocated string (IOW, a const char *).  We can reflect that in its
return value type, and get rid of C++ build errors.

Initially fixes:

/home/simark/src/binutils-gdb/gdb/guile/scm-disasm.c: In function ‘void* gdbscm_disasm_read_memory_worker(void*)’:
/home/simark/src/binutils-gdb/gdb/guile/scm-disasm.c:93:12: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive]
     return "seek error";

gdb/ChangeLog:

* guile/guile-internal.h (gdbscm_with_guile): Change return
types to const char *.
* guile/scm-safe-call.c (gdbscm_with_guile): Likewise.
(struct c_data) <func>: Likewise.
(struct c_data) <result>: Change type to const char *.
(scscm_eval_scheme_string): Change return type to
const char *.
(scscm_source_scheme_script): Likewise.
(gdbscm_safe_eval_string): Change type of result variable to
const char * and remove cast.
(gdbscm_safe_source_script): Likewise.
* guile/scm-disasm.c (gdbscm_disasm_read_memory_worker):
Change return type to const char *.
(gdbscm_disasm_read_memory): Change type of status to
const char *.

9 years agosource.c:openp: save/restore errno
Pedro Alves [Tue, 27 Oct 2015 16:03:24 +0000 (16:03 +0000)]
source.c:openp: save/restore errno

openp's return is documented as:

~~~
   If a file is found, return the descriptor.
   Otherwise, return -1, with errno set for the last name we tried to open.  */
~~~

By inspection, I noticed that there are function calls after the ones
that first set errno, and those may clobber errno.  It's safer to save
errno when see an open fail, and restore it on exit.

Tested on x86_64 Fedora 20.

gdb/ChangeLog:
2015-10-27  Pedro Alves  <palves@redhat.com>

* source.c (openp): New local 'last_errno'.  Use it to
save/restore errno.

9 years agoFix RL78 disassembly of DE+offset addressing to always show the offset, even when...
Vinay Kumar [Tue, 27 Oct 2015 15:24:40 +0000 (15:24 +0000)]
Fix RL78 disassembly of DE+offset addressing to always show the offset, even when zero.

PR binutils/19159
opcodes * rl78-decode.opc (MOV): Added offset to DE register in index
addressing mode.
* rl78-decode.c: Regenerate.

test * gas/rl78/pr19159.s: New test source file.
* gas/rl78/pr19159.d: New test case.
* gas/rl78/rl78.exp: Run the new test.

9 years agopsymtab.c: Add casts
Pedro Alves [Tue, 27 Oct 2015 14:57:18 +0000 (14:57 +0000)]
psymtab.c: Add casts

... as needed for C++.

gdb/ChangeLog:
2015-10-27  Pedro Alves  <palves@redhat.com>

* psymtab.c (dump_psymtab_addrmap_1): Add casts.

9 years agoctf.c: Fix int/enum implicit cast
Simon Marchi [Tue, 27 Oct 2015 14:53:24 +0000 (10:53 -0400)]
ctf.c: Fix int/enum implicit cast

This patch was taken directly from Pedro's branch.

Right now, SET_INT32_FIELD is used to set enum fields.  This works in C,
but not C++.  Therefore, define the new SET_ENUM_FIELD, which casts the
value to the right enum type.

gdb/ChangeLog:

* ctf.c (SET_ENUM_FIELD): New macro.
(ctf_read_status): Use it.
(ctf_read_tp): Use it.

9 years agoDisplay system registers by their names when disassembling RL78 instructions.
Vinay Kumar [Tue, 27 Oct 2015 14:49:02 +0000 (14:49 +0000)]
Display system registers by their names when disassembling RL78 instructions.

PR binutils/19158
opcodes * rl78-decode.opc: Add 's' print operator to instructions that
access system registers.
* rl78-decode.c: Regenerate.
* rl78-dis.c (print_insn_rl78_common): Decode all system
registers.

tests * gas/rl78/pr19158.s: New test source file.
* gas/rl78/pr19158.d: New test case.
* gas/rl78/rl78.exp: Run the new test.

9 years agoFix RL78 disassembly so that SP+OFFSET addressing always shows the offset, even when...
Vinay Kumar [Tue, 27 Oct 2015 14:00:40 +0000 (14:00 +0000)]
Fix RL78 disassembly so that SP+OFFSET addressing always shows the offset, even when zero.

PR binutils/19157
opcodes * rl78-decode.opc: Add 'a' print operator to mov instructions
using stack pointer plus index addressing.
* rl78-decode.c: Regenerate.

tests * gas/rl78: New directory.
* gas/rl78/rl78.exp: New test driver.
* gas/rl78/pr19157.s: New test source file.
* gas/rl78/pr19157.d: New test case.

9 years agoAdd scm_t_dynwind_flags casts
Simon Marchi [Tue, 27 Oct 2015 13:34:30 +0000 (09:34 -0400)]
Add scm_t_dynwind_flags casts

There is a handful of calls to

  scm_dynwind_begin (0);

where the parameter is an enum, scm_t_dynwind_flags.  In C++, we have no
choice but to add an explicit cast, since there is no enum value that
represents 0 (no flags set).

gdb/ChangeLog:

* guile/scm-breakpoint.c (gdbscm_set_breakpoint_stop_x): Add
scm_t_dynwind_flags casts.
* guile/scm-cmd.c (gdbscm_parse_command_name): Likewise.
* guile/scm-ports.c (gdbscm_open_memory): Likewise.
* guile/scm-value.c (gdbscm_value_to_string): Likewise.

9 years agoIntroduce ax_raw_byte and use it
Simon Marchi [Tue, 27 Oct 2015 13:33:29 +0000 (09:33 -0400)]
Introduce ax_raw_byte and use it

This patch was taken directly from Pedro's branch.

ax_simple is used to append an agent expression operator to an agent
expression string.  Therefore, it takes an enum agent_op as input.
There is an instance where it's called to append a raw byte, unrelated
to the enum.  It makes the build fail in C++ mode.

This patch introduces ax_raw_byte for that purpose and uses it.

gdb/ChangeLog:

* ax.h (ax_raw_byte): New declaration.
* ax-general.c (ax_raw_byte): New function.
(ax_simple): Use ax_raw_byte.
* ax-gdb.c (gen_printf): Likewise.

9 years agoada-lang.h: Add cast in GROW_VECT
Simon Marchi [Tue, 27 Oct 2015 13:27:40 +0000 (09:27 -0400)]
ada-lang.h: Add cast in GROW_VECT

The assignment requires a cast in C++.  We only use this macro for
vectors of chars, so adding (char *) diretly will do for now.

gdb/ChangeLog:

* ada-lang.h (GROW_VECT): Add cast.

9 years agoAdd --fix-stm32l4xx-629360 to the ARM linker to enable a link-time workaround for...
Laurent Alfonsi [Tue, 27 Oct 2015 13:20:33 +0000 (13:20 +0000)]
Add --fix-stm32l4xx-629360 to the ARM linker to enable a link-time workaround for a bug in the bus matrix / memory controller for some of the STM32 Cortex-M4 based products (STM32L4xx).

bfd  * bfd-in2.h: Regenerate.
     * bfd-in.h (bfd_arm_stm32l4xx_fix): New enum. Specify how
     STM32L4XX instruction scanning should be done.
     (bfd_elf32_arm_set_stm32l4xx_fix)
     (bfd_elf32_arm_stm32l4xx_erratum_scan)
     (bfd_elf32_arm_stm32l4xx_fix_veneer_locations): Add prototypes.
     (bfd_elf32_arm_set_target_relocs): Add stm32l4xx fix type argument
     to prototype.
     * elf32-arm.c (STM32L4XX_ERRATUM_VENEER_SECTION_NAME)
     (STM32L4XX_ERRATUM_VENEER_ENTRY_NAME): Define macros.
     (elf32_stm32l4xx_erratum_type): New enum.
     (elf32_stm32l4xx_erratum_list): New struct. List of veneers or
     jumps to veneers.
     (_arm_elf_section_data): Add stm32l4xx_erratumcount,
     stm32l4xx_erratumlist.
     (elf32_arm_link_hash_table): Add stm32l4xx_erratum_glue_size,
     stm32l4xx_fix and num_stm32l4xx_fixes fields.
     (ctz): New function.
     (popcount): New function.
     (elf32_arm_link_hash_table_create): Initialize stm32l4xx_fix.
     (put_thumb2_insn): New function.
     (STM32L4XX_ERRATUM_LDM_VENEER_SIZE): Define. Size of a veneer for
     LDM instructions.
     (STM32L4XX_ERRATUM_VLDM_VENEER_SIZE): Define. Size of a veneer for
     VLDM instructions.
     (bfd_elf32_arm_allocate_interworking_sections): Initialise erratum
     glue section.
     (record_stm32l4xx_erratum_veneer) : New function. Create a single
     veneer, and its associated symbols.
     (bfd_elf32_arm_add_glue_sections_to_bfd): Add STM32L4XX erratum glue.
     (bfd_elf32_arm_set_stm32l4xx_fix): New function. Set the type of
     erratum workaround required.
     (bfd_elf32_arm_stm32l4xx_fix_veneer_locations): New function. Find
     out where veneers and branches to veneers have been placed in
     virtual memory after layout.
     (is_thumb2_ldmia): New function.
     (is_thumb2_ldmdb): Likewise.
     (is_thumb2_vldm ): Likewise.
     (stm32l4xx_need_create_replacing_stub): New function. Decide if a
     veneer must be emitted.
     (bfd_elf32_arm_stm32l4xx_erratum_scan): Scan the sections of an
     input BFD for potential erratum-triggering insns. Record results.
     (bfd_elf32_arm_set_target_relocs): Set stm32l4xx_fix field in
     global hash table.
     (elf32_arm_size_dynamic_sections): Collect glue information.
     (create_instruction_branch_absolute): New function.
     (create_instruction_ldmia): Likewise.
     (create_instruction_ldmdb): Likewise.
     (create_instruction_mov): Likewise.
     (create_instruction_sub): Likewise.
     (create_instruction_vldmia): Likewise.
     (create_instruction_vldmdb): Likewise.
     (create_instruction_udf_w): Likewise.
     (create_instruction_udf): Likewise.
     (push_thumb2_insn32): Likewise.
     (push_thumb2_insn16): Likewise.
     (stm32l4xx_fill_stub_udf): Likewise.
     (stm32l4xx_create_replacing_stub_ldmia): New function. Expands the
     replacing stub for ldmia instructions.
     (stm32l4xx_create_replacing_stub_ldmdb): Likewise for ldmdb.
     (stm32l4xx_create_replacing_stub_vldm): Likewise for vldm.
     (stm32l4xx_create_replacing_stub): New function. Dispatches the
     stub emission to the appropriate functions.
     (elf32_arm_write_section): Output veneers, and branches to veneers.

ld   * ld.texinfo: Description of the STM32L4xx erratum workaround.
     * emultempl/armelf.em (stm32l4xx_fix): New.
     (arm_elf_before_allocation): Choose the type of fix, scan for
     erratum.
     (gld${EMULATION_NAME}_finish): Fix veneer locations.
     (arm_elf_create_output_section_statements): Propagate
     stm32l4xx_fix value.
     (PARSE_AND_LIST_PROLOGUE): Define OPTION_STM32L4XX_FIX.
     (PARSE_AND_LIST_LONGOPTS): Add entry for handling
     --fix-stm32l4xx-629360.
     (PARSE_AND_LIST_OPTION): Add entry for helping on
     --fix-stm32l4xx-629360.
     (PARSE_AND_LIST_ARGS_CASES): Treat OPTION_STM32L4XX_FIX.

tests * ld-arm/arm-elf.exp (armelftests_common): Add STM32L4XX
       tests.
     * ld-arm/stm32l4xx-cannot-fix-far-ldm.d: New.
     * ld-arm/stm32l4xx-cannot-fix-far-ldm.s: Likewise.
     * ld-arm/stm32l4xx-cannot-fix-it-block.d: Likewise.
     * ld-arm/stm32l4xx-cannot-fix-it-block.s: Likewise.
     * ld-arm/stm32l4xx-fix-all.d: Likewise.
     * ld-arm/stm32l4xx-fix-all.s: Likewise.
     * ld-arm/stm32l4xx-fix-it-block.d: Likewise.
     * ld-arm/stm32l4xx-fix-it-block.s: Likewise.
     * ld-arm/stm32l4xx-fix-ldm.d: Likewise.
     * ld-arm/stm32l4xx-fix-ldm.s: Likewise.
     * ld-arm/stm32l4xx-fix-vldm.d: Likewise.
     * ld-arm/stm32l4xx-fix-vldm.s: Likewise.

9 years agoAdd support to readelf for reading NetBSD ELF core notes.
Stephen Fisher [Tue, 27 Oct 2015 11:32:38 +0000 (11:32 +0000)]
Add support to readelf for reading NetBSD ELF core notes.

binutils * binutils.c (process_netbsd_elf_note): New function.
(process_note): Call the new function for NetBSD core notes.

include * common.h (NT_NETBSD_MARCH): Define.

9 years agoAdd support for 32-bit and 64-bit PowerPC AIX core files.
Sangamesh Mallayya [Tue, 27 Oct 2015 10:30:29 +0000 (10:30 +0000)]
Add support for 32-bit and 64-bit PowerPC AIX core files.

* configure.ac (powerpc64-*-aix[5-9].*): Match powerpc64 running
aix for core file support.
* configure: Regenerate.
* rs6000-core.c: Check for __ld_info64 if compiling 64-bit gdb.
Added BFD64 check if we are using old core file format for 32-bit gdb.
Set sizeof CORE_COMMONSZ appropriately in case of either new or
old core file format.
(read_hdr): Added BFD64 check for 64-bit support.
(rs6000coff_core_p): Likewise.
(rs6000coff_core_file_matches_executable_p): Likewise.
(rs6000coff_core_file_failing_command): Likewise.
(rs6000coff_core_file_failing_signal): Likewise.
Add support for debugging core files generated by binaries in
Large Memory model.
(rs6000coff_core_p): If Large Memory Model is used, then the .data
segment should start from BDATAORG which has been defined in the
system header files.

9 years agoPrevent overflowing the selected_cpu_name buffer in the ARM assembler.
Jim Wilson [Tue, 27 Oct 2015 09:33:08 +0000 (09:33 +0000)]
Prevent overflowing the selected_cpu_name buffer in the ARM assembler.

* config/tc-arm.c (selected_cpu_name): Increase length of array to
accomodate "Samsung Exynos M1".
(arm_parse_cpu): Add assertion and length check to prevent
overfilling selected_cpu_name.

9 years agoxfail pr19161 test on hppa-linux
Alan Modra [Tue, 27 Oct 2015 07:33:24 +0000 (18:03 +1030)]
xfail pr19161 test on hppa-linux

HPPA linux needs libgcc.a for millicode routine $$dyncall.

* ld-gc/pr19161.d: xfail hppa-*-*.

9 years agoFix access_to_packed_array.exp typos/errors
Jan Kratochvil [Tue, 27 Oct 2015 05:08:45 +0000 (06:08 +0100)]
Fix access_to_packed_array.exp typos/errors

Running ./gdb.ada/access_to_packed_array.exp ...
ERROR: tcl error sourcing ./gdb.ada/access_to_packed_array.exp.
ERROR: extra characters after close-quote
    while executing
"gdb_test "print pack.a" "\\(0 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\)")"
    (file "./gdb.ada/access_to_packed_array.exp" line 29)
    invoked from within
"source ./gdb.ada/access_to_packed_array.exp"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 source ./gdb.ada/access_to_packed_array.exp"
    invoked from within
"catch "uplevel #0 source $test_file_name""

Unrelated to the typos I have changed the print expectations s/"x"/" = x"/
as for example expectation "3" should not match " = 43".

2015-10-27  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.ada/access_to_packed_array.exp: Fix typos erroring the testfile.

9 years agosymtab.h (struct general_symbol_info> <ada_mangled>: Update comment.
Doug Evans [Tue, 27 Oct 2015 03:24:16 +0000 (20:24 -0700)]
symtab.h (struct general_symbol_info> <ada_mangled>: Update comment.

gdb/ChangeLog:

* symtab.h (struct general_symbol_info> <ada_mangled>: Update comment.

9 years agoEvaluate __start_* and __stop_* symbol PROVIDE expressions early
Alan Modra [Tue, 27 Oct 2015 01:31:55 +0000 (12:01 +1030)]
Evaluate __start_* and __stop_* symbol PROVIDE expressions early

Makes these symbols defined before bfd_elf_size_dynamic_sections, to
avoid horrible hacks elsewhere.  The exp_fold_tree undefweak change
is necessary to define undefweak symbols early too.  The comment was
wrong.  PROVIDE in fact defines undefweak symbols, via
bfd_elf_record_link_assignment.

PR ld/19175
* ldlang.c (lang_insert_orphan): Evaluate __start_* and __stop_*
symbol PROVIDE expressions.
* ldexp.c (exp_fold_tree_1 <etree_provide>): Define undefweak
references.

9 years agotarget.c: Add a cast and change a type
Simon Marchi [Tue, 27 Oct 2015 02:07:27 +0000 (22:07 -0400)]
target.c: Add a cast and change a type

Fixes some errors in C++ build.

gdb/ChangeLog:

* target.c (memory_xfer_partial): Change type of buf to gdb_byte
pointer.
(simple_search_memory): Cast return of memmem.

9 years agostap-probe.c: Add casts
Simon Marchi [Tue, 27 Oct 2015 02:04:10 +0000 (22:04 -0400)]
stap-probe.c: Add casts

gdb/ChangeLog:

* stap-probe.c (handle_stap_probe): Add (const char *) casts.

9 years agoctf_xfer_partial: Return TARGET_XFER_E_IO instead of -1 on error
Simon Marchi [Tue, 27 Oct 2015 02:00:41 +0000 (22:00 -0400)]
ctf_xfer_partial: Return TARGET_XFER_E_IO instead of -1 on error

Use the enum value instead of the corresponding int value.

gdb/ChangeLog:

* ctf.c (ctf_xfer_partial): Return TARGET_XFER_E_IO instead of
-1 on error.

9 years agoAutomatic date update in version.in
GDB Administrator [Tue, 27 Oct 2015 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoCheck symbol defined by assignment in linker script
H.J. Lu [Mon, 26 Oct 2015 23:32:34 +0000 (16:32 -0700)]
Check symbol defined by assignment in linker script

Symbol symbol defined by an assignment in a linker script has type
bfd_link_hash_new.  elf_i386_convert_load and elf_x86_64_convert_load
should check bfd_link_hash_new to see if a symbol is defined by a linker
script.

bfd/

PR ld/19175
* elf32-i386.c (elf_i386_convert_load): Check bfd_link_hash_new
instead of calling bfd_link_get_defined_symbol.
* elf64-x86-64.c (elf_x86_64_convert_load): Likewise.  Skip
relocation overflow for bfd_link_hash_new.
* linker.c (bfd_link_get_defined_symbol): Removed.
* bfd-in2.h: Regenerated.

ld/testsuite/

PR ld/19175
* ld-i386/i386.exp: Run pr19175.
* ld-x86-64/x86-64.exp: Likewise.
* ld-i386/pr19175.d: New file.
* ld-i386/pr19175.s: Likewise.
* ld-i386/pr19175.t: Likewise.
* ld-x86-64/pr19175.d: Likewise.
* ld-x86-64/pr19175.s: Likewise.
* ld-x86-64/pr19175.t: Likewise.

9 years agoPR symtab/17391 gdb internal error: assertion fails in regcache.c:178
Doug Evans [Mon, 26 Oct 2015 23:05:21 +0000 (16:05 -0700)]
PR symtab/17391 gdb internal error: assertion fails in regcache.c:178

gdb/ChangeLog:

* dwarf2-frame.c (dwarf2_restore_rule): Call dwarf_reg_to_regnum
instead of gdbarch_dwarf2_reg_to_regnum.
(dwarf2_frame_cache): Ditto.
(read_addr_from_reg): Call dwarf_reg_to_regnum_or_error instead of
gdbarch_dwarf2_reg_to_regnum.
(get_reg_value): Ditto.
(dwarf2_fetch_cfa_info): Ditto.
(dwarf2_frame_prev_register): Ditto.
* dwarf2loc.c: #include "complaints.h".
(dwarf_expr_read_addr_from_reg): Call dwarf_reg_to_regnum_or_error
instead of gdbarch_dwarf2_reg_to_regnum.
(dwarf_expr_get_reg_value): Ditto.
(read_pieced_value): Ditto.
(write_pieced_value): Ditto.
(dwarf2_evaluate_loc_desc_full): Ditto.
(dwarf_reg_to_regnum): New function.
(throw_bad_regnum_error): New function.
(dwarf_reg_to_regnum_or_error): Renamed from
dwarf2_reg_to_regnum_or_errorChange to take a ULONGEST regnum.
All callers updated.  Call throw_bad_regnum_error.
(locexpr_regname): Improve text of bad register number.
* dwarf2loc.h (dwarf_reg_to_regnum): Declare.
(dwarf_reg_to_regnum_or_error): Update prototype.
* dwarf2expr.c: #include "dwarf2loc.h".
(dwarf_block_to_sp_offset): Call dwarf_reg_to_regnum instead of
gdbarch_dwarf2_reg_to_regnum.
* gdbarch.sh (dwarf2_reg_to_regnum): Add comment.
* gdbarch.h: Regenerate.
* amd64-tdep.c (amd64_dwarf_reg_to_regnum): Remove warning for bad
register.
* avr-tdep.c (avr_dwarf_reg_to_regnum): Ditto.
* cris-tdep.c (cris_dwarf2_reg_to_regnum): Ditto.
* bfin-tdep.c (bfin_reg_to_regnum): Fix error checking.
* hppa-linux-tdep.c (hppa_dwarf_reg_to_regnum): Improve error checking.
Remove warning for bad register.
* hppa-tdep.c (hppa64_dwarf_reg_to_regnum): Ditto.
* i386-tdep.c (i386_svr4_dwarf_reg_to_regnum): Renamed from
i386_svr4_reg_to_regnum.  Return -1 for bad registers.
(i386_svr4_reg_to_regnum): New function.
(i386_gdbarch_init): Update call to set_gdbarch_dwarf2_reg_to_regnum.
* microblaze-tdep.c (microblaze_dwarf2_reg_to_regnum): Don't assert
on bad registers, return -1.
* msp430-tdep.c (msp430_dwarf2_reg_to_regnum): Improve error checking.
Remove warning for bad register.
* nios2-tdep.c: Add static assert for NIOS2_NUM_REGS.
(nios2_dwarf_reg_to_regnum): Fix off-by-one error.
Remove warning for bad register.  Return -1 for bad register.
* rl78-tdep.c (rl78_dwarf_reg_to_regnum): Don't flag an internal error
for bad register, return -1.
* rx-tdep.c (rx_dwarf_reg_to_regnum): Ditto.
* m68k-tdep.c (m68k_dwarf_reg_to_regnum): Fix error result.
* mep-tdep.c (mep_debug_reg_to_regnum): Ditto.
* mips-tdep.c (mips_stab_reg_to_regnum): Ditto.
(mips_dwarf_dwarf2_ecoff_reg_to_regnum): Ditto.
* mn10300-tdep.c (mn10300_dwarf2_reg_to_regnum): Remove warning
for bad regs.
* xtensa-tdep.c (xtensa_reg_to_regnum): Remove internal error for
bad regs.  Fix error result.
* stabsread.c (stab_reg_to_regnum): Watch for negative regno.
(reg_value_complaint): Update complaint text.
* mdebugread.c (reg_value_complaint): New function.
(mdebug_reg_to_regnum): Rewrite to watch for bad reg numbers.

gdb/testsuite/ChangeLog:

* lib/dwarf.exp (_location): Add support for DW_OP_regx.
* gdb.dwarf2/bad-regnum.c: New file.
* gdb.dwarf2/bad-regnum.exp: New file.

9 years agoPR python/18938: source -s foo.py with foo.py a symlink to foo.notpy fails
Doug Evans [Mon, 26 Oct 2015 21:33:19 +0000 (14:33 -0700)]
PR python/18938: source -s foo.py with foo.py a symlink to foo.notpy fails

gdb/ChangeLog:

PR python/18938
* cli/cli-cmds (source_script_fron_sctream): New arg file_to_open.
All callers updated.

gdb/testsuite/ChangeLog:

* gdb.python/python.exp: Add test for symlink from .py file to .notpy
file.

9 years agoPrint address map in output of "mt print psymbols"
Doug Evans [Mon, 26 Oct 2015 21:12:51 +0000 (14:12 -0700)]
Print address map in output of "mt print psymbols"

gdb/ChangeLog:

* psymtab.c (struct dump_psymtab_addrmap_data): Define.
(dump_psymtab_addrmap_1, dump_psymtab_addrmap): New functions.
(maintenance_print_psymbols): Print address map.

9 years agoMove __SIGRTMIN.
Doug Evans [Mon, 26 Oct 2015 20:30:57 +0000 (13:30 -0700)]
Move __SIGRTMIN.

gdb/ChangeLog:

* nat/linux-nat.h (__SIGRTMIN): Move here from gdbserver/linux-low.c.

gdb/gdbserver/ChangeLog:

* linux-low.c (__SIGRTMIN): Move to nat/linux-nat.h.

9 years agomusl: Move W_STOPCODE to common/gdb_wait.h.
Doug Evans [Mon, 26 Oct 2015 20:24:01 +0000 (13:24 -0700)]
musl: Move W_STOPCODE to common/gdb_wait.h.

gdb/ChangeLog:

* common/gdb_wait.h (W_STOPCODE): Define, moved here from
gdbserver/linux-low.c.
(WSETSTOP): Simplify.

gdb/gdbserver/ChangeLog:

* linux-low.c (W_STOPCODE): Moved to common/gdb_wait.h.

9 years agoAdd some casts for building on musl.
Doug Evans [Mon, 26 Oct 2015 20:20:12 +0000 (13:20 -0700)]
Add some casts for building on musl.

gdb/ChangeLog:

* linux-thread-db.c (find_new_threads_callback): Cast ti.ti_tid to
unsigned long for debug_printf.
(thread_db_pid_to_str): Ditto.

gdb/gdbserver/ChangeLog:

* thread-db.c (find_one_thread): Cast ti.ti_tid to unsigned long
for debug_printf.
(attach_thread, find_new_threads_callback): Ditto.

9 years agoguile: Simplify ioscm_make_gdb_stdio_port
Simon Marchi [Mon, 26 Oct 2015 19:05:50 +0000 (15:05 -0400)]
guile: Simplify ioscm_make_gdb_stdio_port

As pointed out by Pedro, it's clearer to do it this way.  We can trust
that scm_mode_bits won't try to modify our string, even though it takes
a non-const char *.

gdb/ChangeLog:

* guile/scm-ports.c (ioscm_make_gdb_stdio_port): Do not pass a
local char array to scm_mode_bits, use a cast instead.

9 years agotui: Simplify tui_alloc_content
Simon Marchi [Mon, 26 Oct 2015 16:58:32 +0000 (12:58 -0400)]
tui: Simplify tui_alloc_content

I stumbled upon this while doing some cxx-conversion work.  Since the
x-family alloc functions throw on failure, it is useless to test their
result for failure.  The else branch of != NULL is basically dead code.

I changed the type of element_block_ptr to struct tui_win_element, which
seems obvious (this is actually what raised the flag, casting the result
of xmalloc to struct tui_win_element* wouldn't work).

gdb/ChangeLog:

* tui/tui-data.c (tui_alloc_content): Don't check xmalloc
result.  Change type of element_block_ptr.  Change allocation to
use XNEWVEC.

9 years agoProperly convert address load of __start_XXX/__stop_XXX
H.J. Lu [Mon, 26 Oct 2015 13:10:23 +0000 (06:10 -0700)]
Properly convert address load of __start_XXX/__stop_XXX

Since __start_XXX and __stop_XXX symbols aren't defined when address
load is being converted, we need to check if there is an XXX output
section to get their section and value.  This patch adds a new function,
bfd_link_get_defined_symbol, to search for the XXX output section to
check if __start_XXX and __stop_XXX symbols are defined.

bfd/

PR ld/19171
* elf32-i386.c (elf_i386_convert_load): Call
bfd_link_get_defined_symbol to check if a symbol is defined.
* elf64-x86-64.c (elf_x86_64_convert_load): Call
bfd_link_get_defined_symbol to get defined symbol section and
value.
* linker.c (bfd_link_get_defined_symbol): New function.
* bfd-in2.h: Regenerated.

ld/testsuite/

PR ld/19171
* ld-i386/lea1.s: Add tests for address load of __start_XXX
and __stop_XXX.
* ld-i386/mov1.s: Likewise.
* ld-x86-64/lea1.s: Likewise.
* ld-x86-64/mov1.s: Likewise.
* ld-i386/lea1a.d: Updated.
* ld-i386/lea1b.d: Likewise.
* ld-i386/lea1c.d: Likewise.
* ld-i386/mov1a.d: Likewise.
* ld-i386/mov1b.d: Likewise.
* ld-x86-64/lea1a.d: Likewise.
* ld-x86-64/lea1b.d: Likewise.
* ld-x86-64/lea1c.d: Likewise.
* ld-x86-64/lea1d.d: Likewise.
* ld-x86-64/lea1e.d: Likewise.
* ld-x86-64/lea1f.d: Likewise.
* ld-x86-64/mov1a.d: Likewise.
* ld-x86-64/mov1b.d: Likewise.
* ld-x86-64/mov1c.d: Likewise.
* ld-x86-64/mov1d.d: Likewise.

9 years agoDo not pass NULL for the string in catch_errors
Luis Machado [Mon, 26 Oct 2015 13:17:29 +0000 (11:17 -0200)]
Do not pass NULL for the string in catch_errors

I caught a segmentation fault while running gdb.reverse/sigall-reverse.exp,
in a mingw32 GDB, in this code path. It boils down to the code trying to
strlen () a NULL pointer. I tracked things down and it looks like
record_full_message_wrapper_safe is the only offender.

gdb/ChangeLog:

2015-10-26  Luis Machado  <lgustavo@codesourcery.com>

* record-full.c (record_full_message_wrapper_safe): Pass empty string to
catch_errors call instead of NULL.

9 years agoFix constness problem in ioscm_make_gdb_stdio_port
Simon Marchi [Mon, 26 Oct 2015 12:41:38 +0000 (08:41 -0400)]
Fix constness problem in ioscm_make_gdb_stdio_port

ioscm_make_gdb_stdio_port passes const char pointers (literal strings) to
scm_mode_bits, which takes a non-const char pointer.  Ideally, we would
change scm_mode_bits to take a const char pointer, but it's not part of
an API we control.

Instead, it's easy enough to build the string to pass to scm_mode_bits in
a (non-const) char array and pass that.

gdb/ChangeLog:

* guile/scm-ports.c (ioscm_make_gdb_stdio_port): Pass non-const
char pointer to scm_mode_bits.

9 years agosymtab.c: Add cast
Simon Marchi [Mon, 26 Oct 2015 12:41:38 +0000 (08:41 -0400)]
symtab.c: Add cast

gdb/ChangeLog:

* symtab.c (default_make_symbol_completion_list_break_on_1): Add
cast.

9 years agogdbscm_memory_port_write: use local variable to avoid adding casts
Simon Marchi [Mon, 26 Oct 2015 12:41:37 +0000 (08:41 -0400)]
gdbscm_memory_port_write: use local variable to avoid adding casts

By having a local variable of type (const gdb_byte *), we can avoid adding
two casts.

gdb/ChangeLog:

* guile/scm-ports.c (gdbscm_memory_port_write): Declare new
"data" local variable and use it.

9 years agoscm-symbol.c: Add (domain_enum) casts
Simon Marchi [Mon, 26 Oct 2015 12:41:36 +0000 (08:41 -0400)]
scm-symbol.c: Add (domain_enum) casts

We currently pass integers as domain_enums to lookup_symbol.  The
most obvious fix is to add casts there.

I first thought of changing the type of the domain variables to
domain_enum.  However, because we pass a pointer to them to
gdbscm_parse_function_args, which expects them to be integers (because
of the format string), I don't think it would be correct.  If the enum
does not have the same size as an int, gdbscm_parse_function_args could
write past the memory of domain, overwriting something else on the
stack.

gdb/ChangeLog:

* guile/scm-symbol.c (gdbscm_lookup_global_symbol): Add
domain_enum cast.
(gdbscm_lookup_symbol): Likewise.

9 years agoAutomatic date update in version.in
GDB Administrator [Mon, 26 Oct 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoFix compile.exp error message expectation
Jan Kratochvil [Sun, 25 Oct 2015 11:16:10 +0000 (12:16 +0100)]
Fix compile.exp error message expectation

commit cdaec3f3e7ea9118204f0e579bd3257234fbae63
Author: Luis Machado <lgustavo@codesourcery.com>
Date:   Thu Aug 27 02:00:16 2015 -0300
    Mention language in compile error message

regressed:

-PASS: gdb.compile/compile.exp: compile code globalvar
+FAIL: gdb.compile/compile.exp: compile code globalvar

Update the expected message.

gdb/testsuite/ChangeLog
2015-10-25  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.compile/compile.exp (compile code globalvar): Update expectation
for a change by "Mention language in compile error message".

9 years agoRe-apply change for handling non-local references in nested functions.
Iain Buclaw [Sun, 25 Oct 2015 08:17:24 +0000 (09:17 +0100)]
Re-apply change for handling non-local references in nested functions.

gdb/ChangeLog:

* d-exp.y: Remove an obsolete comment and propagate the block
information to the produced expression.

9 years agotui-data.c: Remove unnecessary casts
Simon Marchi [Sun, 25 Oct 2015 02:40:37 +0000 (22:40 -0400)]
tui-data.c: Remove unnecessary casts

The (void *) casts make the build fail in C++ mode and are unnecessary.

gdb/ChangeLog:

* tui/tui-data.c (tui_add_to_source_windows): Remove void *
cast.
(tui_add_content_elements): Likewise.

9 years agocli-setshow.c: Constify variable
Simon Marchi [Sun, 25 Oct 2015 02:28:56 +0000 (22:28 -0400)]
cli-setshow.c: Constify variable

Fixes:

/home/simark/src/binutils-gdb/gdb/cli/cli-setshow.c:390:13: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
  p = strchr (arg, ' ');
             ^
gdb/ChangeLog:

* cli/cli-setshow.c (do_set_command): Constify p.

9 years agoAutomatic date update in version.in
GDB Administrator [Sun, 25 Oct 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoReplace (void *) cast with (gdb_byte *)
Simon Marchi [Sat, 24 Oct 2015 22:36:26 +0000 (18:36 -0400)]
Replace (void *) cast with (gdb_byte *)

Fixes:

/home/simark/src/binutils-gdb/gdb/nat/linux-ptrace.c:207:6: error: invalid conversion from ‘void*’ to ‘gdb_byte* {aka unsigned char*}’ [-fpermissive]
   pc = (void *) (uintptr_t) l;
         ^

gdb/ChangeLog:

* nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Replace
(void *) cast with (gdb_byte *).

9 years agoproc-service.c: Add (gdb_byte *) cast
Simon Marchi [Sat, 24 Oct 2015 22:36:25 +0000 (18:36 -0400)]
proc-service.c: Add (gdb_byte *) cast

A cast here is necessary, just as it's necessary in ps_pdwrite just
below.  The type of buf can't be changed, since it's fixed in the ps_pd*
API.

gdb/ChangeLog:

* proc-service.c (ps_pdread): Add cast.

9 years agosparc64-tdep.c: Don't assign using memcpy return
Simon Marchi [Sat, 24 Oct 2015 22:36:24 +0000 (18:36 -0400)]
sparc64-tdep.c: Don't assign using memcpy return

This:

  valbuf = memcpy (buf, valbuf, len);

causes a build failure in C++, because memcpy returns the value of
"buf" as a void *.  Instead of adding a cast, we can just do the
assignment separately.

gdb/ChangeLog:

* sparc64-tdep.c (sparc64_store_arguments): Split assignment of
valbuf.

9 years agoia64-tdep.c: Remove (void *) casts
Simon Marchi [Sat, 24 Oct 2015 22:36:23 +0000 (18:36 -0400)]
ia64-tdep.c: Remove (void *) casts

Remove these (void *) casts, which cause a build failure in C++ mode.

gdb/ChangeLog:

* ia64-tdep.c (ia64_pseudo_register_write): Remove cast.
(ia64_push_dummy_call): Remove cast and change type of "to" to
array of gdb_byte.

9 years agoAutomatic date update in version.in
GDB Administrator [Sat, 24 Oct 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoAdd mmap casts in linux-btrace.c
Simon Marchi [Fri, 23 Oct 2015 23:48:48 +0000 (19:48 -0400)]
Add mmap casts in linux-btrace.c

gdb/ChangeLog:

* linux-btrace.c (linux_enable_pt): Add cast to mmap return.

9 years agoAdd cast to observer.sh
Simon Marchi [Fri, 23 Oct 2015 20:58:13 +0000 (16:58 -0400)]
Add cast to observer.sh

gdb/ChangeLog:

* observer.h (observer_${event}_notification_stub): Add cast.

9 years agoRemove set_breakpoint_data definition in GDBServer.
Antoine Tremblay [Fri, 23 Oct 2015 17:20:39 +0000 (13:20 -0400)]
Remove set_breakpoint_data definition in GDBServer.

This patch removes the now unused set_breakpoint_data function from mem_break.h

gdb/gdbserver/ChangeLog:

* mem-break.h (set_breakpoint_data): Remove.

9 years agoFix nto,spu and win32 builds of GDBServer.
Antoine Tremblay [Fri, 23 Oct 2015 17:20:39 +0000 (13:20 -0400)]
Fix nto,spu and win32 builds of GDBServer.

This patch fixes the build that was broken by :
https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html

It implements the sw_breakpoint_from_kind operation on these targets and removes
the calls to set_breakpoint_data.

Compiliation tested on win32.

Not tested : nto, spu.

gdb/gdbserver/ChangeLog:

* nto-low.c (nto_sw_breakpoint_from_kind): New function.
(struct target_ops) <sw_breakpoint_from_kind>: Initialize.
(initialize_low): Remove set_breakpoint_data call.
* spu-low.c (spu_sw_breakpoint_from_kind): New function.
(struct target_ops) <sw_breakpoint_from_kind>: Iniitalize.
(initialize_low): Remove set_breakpoint_data call.
* win32-low.c (win32_sw_breakpoint_from_kind): New function.
(struct target_ops) <sw_breakpoint_from_kind>: Initialize.
(initialize_low): Remove set_breakpoint_data call.

9 years agoRefactor default_breakpoint_kind_from_pc to be used by all targets in GDBServer.
Antoine Tremblay [Fri, 23 Oct 2015 17:20:39 +0000 (13:20 -0400)]
Refactor default_breakpoint_kind_from_pc to be used by all targets in GDBServer.

This patch moves default_breakpoint_kind_from_pc to target.c and creates a macro
so that all targets can easily use it.

This allows the breakpoint_kind_from_pc operation to be left unimplemented in
targets that do not need it.

This is preparation to fix the win32/nto/spu build that was broken by this
patch: https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html

No regression on Ubuntu 14.04 x86-64 with gdbserver-{native-extended}

gdb/gdbserver/ChangeLog:

* linux-low.c (default_breakpoint_kind_from_pc): Move to target.c.
* mem-break.c (set_breakpoint_at): Use target_breakpoint_kind_from_pc.
* target.c (default_breakpoint_kind_from_pc): Moved from linux-low.c
* target.h (target_breakpoint_kind_from_pc): New macro.

9 years agoHandle __start_* and __stop_* symbols in --gc-sections
Alan Modra [Fri, 23 Oct 2015 11:53:05 +0000 (22:23 +1030)]
Handle __start_* and __stop_* symbols in --gc-sections

PR ld/11133
PR ld/19161
PR ld/19167
* elflink.c (_bfd_elf_gc_mark_hook): Delete code handling __start_*
and __stop_* symbol refs.
(_bfd_elf_gc_mark_rsec): Add start_stop parameter.  Handle __start_*
and __stop_* symbol refs here..
(_bfd_elf_gc_mark_reloc): ..and here.
* elf-bfd.h (_bfd_elf_gc_mark_hook): Update prototype.
* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Update
_bfd_elf_gc_mark_rsec call.

9 years agoAdd a test for PR ld/19167
H.J. Lu [Fri, 23 Oct 2015 11:23:51 +0000 (04:23 -0700)]
Add a test for PR ld/19167

PR ld/19167
* ld-gc/gc.exp: Run pr19167 test.
* ld-gc/pr19167.d: New file.
* ld-gc/pr19167a.s: Likewise.
* ld-gc/pr19167b.s: Likewise.

9 years agoInitialize field insn_count correctly
Yao Qi [Wed, 21 Oct 2015 14:50:55 +0000 (15:50 +0100)]
Initialize field insn_count correctly

This patch initialize dsd.insn_count, otherwise, it triggers the assert
below on testings we did recently.

gdb:

2015-10-23  Yao Qi  <yao.qi@linaro.org>

* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Set
dsd.insn_count to zero.

9 years agoAutomatic date update in version.in
GDB Administrator [Fri, 23 Oct 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

9 years agoRe: Always keep sections marked with SEC_KEEP
Alan Modra [Thu, 22 Oct 2015 23:44:51 +0000 (10:14 +1030)]
Re: Always keep sections marked with SEC_KEEP

Revert bba037e0, it breaks the gc-sections model.  Instead fix the
underlying problem which is that _bfd_elf_gc_mark_hook is too late to
be setting SEC_KEEP.

PR ld/11133
PR ld/19161
* elflink.c (elf_gc_sweep): Revert last patch.
(_bfd_elf_gc_mark_hook): Don't set SEC_KEEP here.

9 years agoAlways keep sections marked with SEC_KEEP
H.J. Lu [Thu, 22 Oct 2015 19:17:43 +0000 (12:17 -0700)]
Always keep sections marked with SEC_KEEP

SEC_KEEP check in elf_gc_sweep was missing in commit:

commit bde6f3eb6dff94cea1d471e15c6154d55d49820f
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Jan 8 01:43:23 2010 +0000

    Set SEC_KEEP on section XXX for undefined __start_XXX/__stop_XXX

    bfd/

    2010-01-07  H.J. Lu  <hongjiu.lu@intel.com>

      PR ld/11133
      * elflink.c (_bfd_elf_gc_mark_hook): Check section XXX for
      undefined __start_XXX/__stop_XXX in all input files and set
      SEC_KEEP.

This patch adds SEC_KEEP check to elf_gc_sweep.

bfd/

PR ld/19161
* elflink.c (elf_gc_sweep): Always keep sections marked with
SEC_KEEP.

ld/testsuite/

PR ld/19161
* ld-gc/gc.exp: Run pr19161 test.
* ld-gc/pr19161-1.c: New file.
* ld-gc/pr19161-2.c: Likewise.
* ld-gc/pr19161.d: Likewise.

9 years agogarbage collect gdb/infrun.c:stop_after_trap
Pedro Alves [Sun, 18 Oct 2015 11:32:47 +0000 (12:32 +0100)]
garbage collect gdb/infrun.c:stop_after_trap

No longer used anywhere.

gdb/ChangeLog:
2015-10-22  Pedro Alves  <palves@redhat.com>

* infrun.c (stop_after_trap): Delete.
(clear_proceed_status, handle_signal_stop, struct
infcall_control_state, save_infcall_control_state)
(restore_infcall_control_state): Remove references to
stop_after_trap.

9 years agoFix inconsistent breakpoint kinds between breakpoints and tracepoints in GDBServer.
Antoine Tremblay [Thu, 22 Oct 2015 16:21:51 +0000 (12:21 -0400)]
Fix inconsistent breakpoint kinds between breakpoints and tracepoints in GDBServer.

This patch fixes a regression introduced by :
https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html

Tests : gdb.trace/trace-break.exp and gdb.trace/trace-mt.exp would fail on x86
with gdbserver-{native,extended}.

Before this patch, the breakpoint kind set by GDB with a Z packet and the one
set in the case of a tracepoint would be inconsistent on targets that did not
implement breakpoint_kind_from_pc. On x86 for example a breakpoint set by GDB
would have a kind of 1 but a breakpoint set by a tracepoint would have a kind of
0.

This created a missmatch when trying to insert a tracepoint and a breakpoint at
the same location. One of the two breakpoints would be removed with debug
message : "Inconsistent breakpoint kind".

This patch fixes the issue by changing the default 0 breakpoint kind to be
the size of the breakpoint according to sw_breakpoint_from_kind.

The default breakpoint kind must be the breakpoint length to keep consistency
between breakpoints set via GDB and the ones set internally by GDBServer.

No regression on Ubuntu 14.04 x86-64 with gdbserver-{native-extended}

gdb/gdbserver/ChangeLog:

* linux-low.c (default_breakpoint_kind_from_pc): New function.
(linux_breakpoint_kind_from_pc): Use default_breakpoint_kind_from_pc for
the default breakpoint kind.

9 years agoAdd cast in python.c
Simon Marchi [Thu, 22 Oct 2015 16:13:19 +0000 (12:13 -0400)]
Add cast in python.c

gdb/ChangeLog:

* python/python.c (_initialize_python): Add cast.

9 years agoAdd cast in nto-tdep.c
Simon Marchi [Thu, 22 Oct 2015 15:58:38 +0000 (11:58 -0400)]
Add cast in nto-tdep.c

gdb/ChangeLog:

* nto-tdep.c (nto_inferior_data): Add cast.

9 years agogdb/Windows: use windows_wait/windows_resume directly in initial startup
Pedro Alves [Thu, 22 Oct 2015 15:40:45 +0000 (16:40 +0100)]
gdb/Windows: use windows_wait/windows_resume directly in initial startup

Explation below based on what Joel wrote at:

  https://sourceware.org/ml/gdb-patches/2015-10/msg00274.html

The merge async/sync code paths patch broke attaching on Windows.

This is what we observe, after attaching to any process.  At first, it
seems like everything worked fine, since the process stops, and we get
the prompt back:

    (gdb) att 3156
    Attaching to program `C:\[...]\foo.exe', process 3156
    [New Thread 3156.0xcd8]
    [New Thread 3156.0xfe4]
    0x7770000d in ntdll!DbgBreakPoint () from C:\Windows\SysWOW64\ntdll.dll
    (gdb)

However, enter any commands at all, and GDB appears to be hanging.
For instance:

    (gdb) set lang ada
    [nothing happens]

Despite appearances, GDB is not reading from the prompt.  It is
blocked waiting for an event from the inferior.  And since our
inferior is stopped, there aren't going to be any events to read.

In chronological order, what happens is that windows_attach calls
do_initial_windows_stuff, which performs the inferior creation,
and repeatedly waits until we get the first SIGTRAP:

  while (1)
    {
      stop_after_trap = 1;
      wait_for_inferior ();
      tp = inferior_thread ();
      if (tp->suspend.stop_signal != GDB_SIGNAL_TRAP)
        resume (tp->suspend.stop_signal);
      else
        break;
    }

The call to wait_for_inferior triggers a call to do_target_wait to get
the event, followed by handle_inferior_event to process it.  However,
because the first couple of events are "spurious" events, GDB resumes
the execution, and prepares the inferior to wait again:

    case TARGET_WAITKIND_SPURIOUS:
      [...]
      resume (GDB_SIGNAL_0);
      prepare_to_wait (ecs);

And prepare_to_wait just does...

  ecs->wait_some_more = 1;
  if (!target_is_async_p ())
    mark_infrun_async_event_handler ();

... which as a result sets the infrun_async_event_handler "ready"
flag to 1.

We get a couple of spurious events before we get the initial SIGTRAP,
at which point we exit the "while (1)" loop above, after which we
reach the end of the attach_command, followed by the normal
end-of-command processing (normal_stop, bp handling, printing the GDB
prompt), back finally to the root of the event loop.

Notice that, at this point, nothing has unset the "ready" flag for the
infrun_async_event_handler.  So, when another cycle of
gdb_do_one_event from the event loop, we eventually call
check_async_event_handlers, which finds that the infrun async event
handler is "ready", and therefore calls it's associated "proc"
callback, which does...

      inferior_event_handler (INF_REG_EVENT, NULL);

... triggering a blocking call to target_wait, thus hanging forever.

The fix is to use windows_wait and windows_resume directly, similarly
to gdbserver.  This will also allow getting rid of 'stop_after_trap'.

gdb/ChangeLog:
2015-10-22  Pedro Alves  <palves@redhat.com>

* windows-nat.c (do_initial_windows_stuff): Rewrite loop using
windows_wait and windows_resume directly instead of
wait_for_inferior and resume.

9 years agoAdd support for MSP430 silicon errata to the assembler.
Nick Clifton [Thu, 22 Oct 2015 15:25:46 +0000 (16:25 +0100)]
Add support for MSP430 silicon errata to the assembler.

* config/tc-msp430.c (PUSH_1X_WORKAROUND): Delete.
(OPTION_SILICON_ERRATA): Define.
(OPTION_SILICON_WARN): Define.
(md_parse_opton): Handle silicon errata options.
(md_longopts): Add silicon errata options.
(ms_show_usage): Report silicon errata options.
(msp430_srcoperand): Handle silicon errata.
(msp430_operands): Likewise. Improve nop insertion.
(msp430_fix_adjustable): Update warning generation.
* doc/c-msp430.texi: Document silicon errata options.

tests * gas/msp430/errata_fixes.s: New test source file.
* gas/msp430/errata_fixes.d: New test control file.
* gas/msp430/errata_warns.s: New test source file.
* gas/msp430/errata_warns.d: New test control file.
* gas/msp430/errata_warns.l: New test message file.
* gas/msp430/msp430.exp: Run the new tests.
* gas/msp430/bad.l: Update expected warning messages
* gas/msp430/msp430.exp: Run the new tests.

9 years agoProperly check --enable-compressed-debug-sections={yes,all}
H.J. Lu [Thu, 22 Oct 2015 14:44:05 +0000 (07:44 -0700)]
Properly check --enable-compressed-debug-sections={yes,all}

gas/

* configure.ac: Properly check
--enable-compressed-debug-sections={yes,all}.
* configure: Regenerated.

ld/

* configure.ac: Properly check
--enable-compressed-debug-sections={yes,all}.
* configure: Regenerated.

9 years agobfd/mmo.c: handle "objcopy --extract-symbols" generating and reading back.
Hans-Peter Nilsson [Thu, 22 Oct 2015 07:32:30 +0000 (09:32 +0200)]
bfd/mmo.c: handle "objcopy --extract-symbols" generating and reading back.

bfd:
* mmo.c (struct mmo_data_struct): New members
symbol_consistency_override_calculated and ignore_symbol_consistency.
(mmo_section_has_contents, mmo_ignore_symbol_consistency): New
functions.
(mmo_create_symbol): Check with mmo_ignore_symbol_consistency if to
report an error for unexpected value of Main.
(mmo_write_symbols_and_terminator): Similar.

9 years agoAllow mmix-knuth-mmixware adjustments to objcopy --extract-symbols test.
Hans-Peter Nilsson [Thu, 22 Oct 2015 07:28:40 +0000 (09:28 +0200)]
Allow mmix-knuth-mmixware adjustments to objcopy --extract-symbols test.

* ld-scripts/script.exp (extract_symbol_test): Allow nm output of
objcopy --extract-symbols result to differ from original on
mmix-knuth-mmixware.

9 years agobinutils/objcopy.c (setup_section): missing extract_symbol part
Hans-Peter Nilsson [Thu, 22 Oct 2015 14:12:35 +0000 (16:12 +0200)]
binutils/objcopy.c (setup_section): missing extract_symbol part

* objcopy.c (setup_section): Don't omit bfd_copy_private_bfd_data
call when extract_symbol.

9 years agoxtensa: Fix implicit enum conversions
Simon Marchi [Thu, 22 Oct 2015 13:46:32 +0000 (09:46 -0400)]
xtensa: Fix implicit enum conversions

XTREG is used with raw numbers, like:

...
  XTREG( 78,312,32, 4, 4,0x02d7,0x0007,-2, 2,0x1000,excsave7,    0,0,0,0,0,0)
  XTREG( 79,316, 8, 4, 4,0x02e0,0x0007,-2, 2,0x1000,cpenable,    0,0,0,0,0,0)
  XTREG( 80,320,22, 4, 4,0x02e2,0x000b,-2, 2,0x1000,interrupt,   0,0,0,0,0,0)
  XTREG( 81,324,22, 4, 4,0x02e2,0x000d,-2, 2,0x1000,intset,      0,0,0,0,0,0)
...

So just add the explicit cast to the macro.

In file included from /home/pedro/gdb/mygit/src/gdb/xtensa-config.c:25:0:
/home/pedro/gdb/mygit/src/gdb/xtensa-tdep.h:289:2: error: invalid conversion from â€˜int’ to â€˜call_abi_t’ [-fpermissive]
  }
  ^

gdb/ChangeLog:

* xtensa-tdep.h (XTREG): Add casts.
(XTREG_END): Likewise.

9 years agosolib-spu: Add gdb_byte* cast
Simon Marchi [Thu, 22 Oct 2015 13:46:31 +0000 (09:46 -0400)]
solib-spu: Add gdb_byte* cast

Fixes this error:

/home/simark/src/binutils-gdb/gdb/solib-spu.c: In function â€˜file_ptr spu_bfd_iovec_pread(bfd*, void*, void*, file_ptr, file_ptr)’:
/home/simark/src/binutils-gdb/gdb/solib-spu.c:299:55: error: invalid conversion from â€˜void*’ to â€˜gdb_byte* {aka unsigned char*}’ [-fpermissive]
   ret = target_read_memory (addr + offset, buf, nbytes);
                                                       ^
In file included from /home/simark/src/binutils-gdb/gdb/target.h:65:0,
                 from /home/simark/src/binutils-gdb/gdb/exec.h:23,
                 from /home/simark/src/binutils-gdb/gdb/gdbcore.h:29,
                 from /home/simark/src/binutils-gdb/gdb/solib-spu.c:23:
/home/simark/src/binutils-gdb/gdb/target/target.h:35:12: note:   initializing argument 2 of â€˜int target_read_memory(CORE_ADDR, gdb_byte*, ssize_t)’
 extern int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr,

gdb/ChangeLog:

* solib-spu.c (spu_bfd_iovec_pread): Add (gdb_byte *) cast.

9 years agors6000: Add cast for int to enum conversion
Simon Marchi [Thu, 22 Oct 2015 13:46:29 +0000 (09:46 -0400)]
rs6000: Add cast for int to enum conversion

Fixes this error:

/home/pedro/gdb/mygit/src/gdb/rs6000-tdep.c:3091:1: error: invalid conversion from â€˜int’ to â€˜bfd_architecture’ [-fpermissive]
 };
 ^
/home/pedro/gdb/mygit/src/gdb/rs6000-tdep.c: In function â€˜void powerpc_set_vector_abi(char*, int, cmd_list_element*)’:
/home/pedro/gdb/mygit/src/gdb/rs6000-tdep.c:6063:28: error: invalid conversion from â€˜int’ to â€˜powerpc_vector_abi’ [-fpermissive]
  powerpc_vector_abi_global = vector_abi;
                            ^

gdb/ChangeLog:

* rs6000-tdep.c (variants): Add (enum bfd_architecture) cast.

9 years agomips: fix void*/gdb_byte* compilation errors
Simon Marchi [Thu, 22 Oct 2015 13:46:28 +0000 (09:46 -0400)]
mips: fix void*/gdb_byte* compilation errors

The error in mips64_linux_get_longjmp_target is fixed by changing "buf"
to be a gdb_byte*, as usual.  supply_32bit_reg and mips64_fill_gregset
do some more complicated things however, so it's safer just to add the
explicit cast and avoid changing the code too much.

gdb/ChangeLog:

* mips-linux-tdep.c (mips64_linux_get_longjmp_target): Change type of
buf to gdb_byte*.
(supply_32bit_reg): Add cast.
(mips64_fill_gregset): Likewise.

9 years agoHandle --enable-compressed-debug-sections=ld,gas
H.J. Lu [Thu, 22 Oct 2015 12:18:21 +0000 (05:18 -0700)]
Handle --enable-compressed-debug-sections=ld,gas

gas/

PR gas/19109
* configure.ac: Handle --enable-compressed-debug-sections=*,gas,*.
* configure: Regenerated.

ld/

PR gas/19109
* configure.ac: Handle --enable-compressed-debug-sections=*,ld,*.
* configure: Regenerated.

9 years agoGold: Don't fail on R_X86_64_[REX_]GOTPCRELX relocations
H.J. Lu [Thu, 22 Oct 2015 11:56:10 +0000 (04:56 -0700)]
Gold: Don't fail on R_X86_64_[REX_]GOTPCRELX relocations

This patch updates gold to treat the R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX relocations proposed in

https://groups.google.com/forum/#!topic/x86-64-abi/n9AWHogmVY0

the same as R_X86_64_GOTPCREL.  FIXME: Gold should perform the
transformations as suggested.

elfcpp/

* x86_64.h (R_X86_64_GOTPCRELX): New.
(R_X86_64_REX_GOTPCRELX): Likewise.

gold/

* x86_64.cc (Target_x86_64<size>::Scan::get_reference_flags):
Treat R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX the same
as R_X86_64_GOTPCREL.
(Target_x86_64<size>::Scan::local): Likewise.
(Target_x86_64<size>::Scan::possible_function_pointer_reloc):
Likewise.
(Target_x86_64<size>::Scan::global): Likewise.
(Target_x86_64<size>::Relocate::relocate): Likewise.
(Target_x86_64<size>::Relocatable_size_for_reloc::get_size_for_reloc):
Likewise.

9 years agoGold: Don't fail on R_386_GOT32X relocation
H.J. Lu [Thu, 22 Oct 2015 11:54:42 +0000 (04:54 -0700)]
Gold: Don't fail on R_386_GOT32X relocation

This patch updates gold to treat the R_386_GOT32X relocation proposed in

https://groups.google.com/forum/#!topic/ia32-abi/GbJJskkid4I

the same as R_386_GOT32.  FIXME: Gold should perform the transformations
as suggested.

elfcpp/

* i386.h (R_386_GOT32X): New.

gold/

* i386.cc (Target_i386::Scan::get_reference_flags(): Treat
R_386_GOT32X the same as R_386_GOT32.
(Target_i386::Scan::local): Likewise.
(Target_i386::Scan::possible_function_pointer_reloc): Likewise.
(Target_i386::Scan::global): Likewise.
(Target_i386::Relocate::relocate): Likewise.
(Target_i386::Relocatable_size_for_reloc::get_size_for_reloc):
Likewise.

9 years agoAdd "-z call-nop=PADDING" option to ld
H.J. Lu [Thu, 22 Oct 2015 11:53:04 +0000 (04:53 -0700)]
Add "-z call-nop=PADDING" option to ld

The ld linker can transform indirect call to a locally defined function,
foo, via its GOT slot, to either "NOP call foo" or "call foo NOP" where
NOP is a 1-byte NOP padding.  This patch adds a "-z call-nop=PADDING"
option to x86 ld to control 1-byte NOP padding for x86 call instruction.
PADDING is one of prefix-addr, prefix-nop, suffix-nop, prefix-NUMBER or
suffix-NUMBER.

bfd/

* elf32-i386.c (elf_i386_convert_load): Use call_nop_byte and
check call_nop_as_suffix for 1-byte NOP padding to pad call.
* elf64-x86-64.c (elf_x86_64_convert_load): Likewise.

include/

* bfdlink.h (bfd_link_info): Add call_nop_as_suffix and
call_nop_byte.

ld/

* ld/ld.texinfo: Document "-z call-nop=PADDING" option.
* emulparams/call_nop.sh: New file.
* emulparams/elf_i386_be.sh: Source
${srcdir}/emulparams/call_nop.sh.
* emulparams/elf_i386_chaos.sh: Likewise.
* emulparams/elf_i386_ldso.sh: Likewise.
* emulparams/elf_i386_vxworks.sh: Likewise.
* emulparams/elf_iamcu.sh: Likewise.
* emulparams/elf_k1om.sh: Likewise.
* emulparams/elf_l1om.sh: Likewise.
* emulparams/elf_x86_64.sh: Likewise.
* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set
link_info.call_nop_byte if $CALL_NOP_BYTE isn't empty.

ld/testsuite/

* ld-i386/call3.s: New file.
* ld-i386/call3a.d: Likewise.
* ld-i386/call3b.d: Likewise.
* ld-i386/call3c.d: Likewise.
* ld-i386/call3d.d: Likewise.
* ld-i386/call3e.d: Likewise.
* ld-i386/call3f.d: Likewise.
* ld-i386/call3g.d: Likewise.
* ld-i386/call3h.d: Likewise.
* ld-i386/load1-nacl.d: Likewise.
* ld-x86-64/call1.s: Likewise.
* ld-x86-64/call1a.d: Likewise.
* ld-x86-64/call1b.d: Likewise.
* ld-x86-64/call1c.d: Likewise.
* ld-x86-64/call1d.d: Likewise.
* ld-x86-64/call1e.d: Likewise.
* ld-x86-64/call1f.d: Likewise.
* ld-x86-64/call1g.d: Likewise.
* ld-x86-64/call1h.d: Likewise.
* ld-x86-64/call1i.d: Likewise.
* ld-x86-64/load1a-nacl.d: Likewise.
* ld-x86-64/load1b-nacl.d: Likewise.
* ld-x86-64/load1c-nacl.d: Likewise.
* ld-x86-64/load1d-nacl.d: Likewise.

9 years agoAdd R_X86_64_[REX_]GOTPCRELX support to gas and ld
H.J. Lu [Thu, 22 Oct 2015 11:49:20 +0000 (04:49 -0700)]
Add R_X86_64_[REX_]GOTPCRELX support to gas and ld

This patch adds support for the R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX relocations proposed in

https://groups.google.com/forum/#!topic/x86-64-abi/n9AWHogmVY0

to gas and ld.  It updates gas to generate R_X86_64_GOTPCRELX,
R_X86_64_REX_GOTPCRELX if there is a REX prefix, relocation for memory
operand, foo@GOTPCREL(%rip).  With the locally defined symbol, foo, we
convert

  mov foo@GOTPCREL(%rip), %reg

to

   lea foo(%rip), %reg

and convert

   call/jmp *foo@GOTPCREL(%rip)
to

   nop call foo/jmp foo nop

When PIC is false, convert

   test %reg, foo@GOTPCREL(%rip)
to

test $foo, %reg

and convert

   binop foo@GOTPCREL(%rip), %reg

to

   binop $foo, %reg

where binop is one of adc, add, and, cmp, or, sbb, sub, xor instructions.

bfd/

* elf64-x86-64.c: Include opcode/i386.h.
(x86_64_elf_howto_table): Add R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX.
(R_X86_64_standard): Replace R_X86_64_PLT32_BND with
R_X86_64_REX_GOTPCRELX.
(x86_64_reloc_map): Add BFD_RELOC_X86_64_GOTPCRELX and
BFD_RELOC_X86_64_REX_GOTPCRELX.
(need_convert_mov_to_lea): Renamed to ...
(need_convert_load): This.
(elf_x86_64_check_relocs): Handle R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX.  Replace need_convert_mov_to_lea with
need_convert_load.
(elf_x86_64_gc_sweep_hook): Handle R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX.
(elf_x86_64_size_dynamic_sections): Likewise.
(elf_x86_64_relocate_section): Likewise.
(elf_x86_64_convert_mov_to_lea): Renamed to ...
(elf_x86_64_convert_load): This.  Replace need_convert_mov_to_lea
with need_convert_load.  Support R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX transformations.
* reloc.c (BFD_RELOC_X86_64_GOTPCRELX): New.
(BFD_RELOC_X86_64_REX_GOTPCRELX): Likewise.
* bfd-in2.h: Regenerated.
* libbfd.h: Likewise.

gas/

* config/tc-i386.c (tc_i386_fix_adjustable): Handle
BFD_RELOC_X86_64_GOTPCRELX and BFD_RELOC_X86_64_REX_GOTPCRELX.
(tc_gen_reloc): Likewise.
(i386_validate_fix): Generate BFD_RELOC_X86_64_GOTPCRELX or
BFD_RELOC_X86_64_REX_GOTPCRELX if fx_tcbit2 is set.
* config/tc-i386.h (TC_FORCE_RELOCATION_LOCAL): Also return
true for BFD_RELOC_X86_64_GOTPCRELX and
BFD_RELOC_X86_64_REX_GOTPCRELX.

gas/testsuite/

* gas/i386/i386.exp: Run x86-64-gotpcrel.
* gas/i386/x86-64-gotpcrel.d: New file.
* gas/i386/x86-64-gotpcrel.s: Likewise.
* gas/i386/ilp32/x86-64-gotpcrel.d: Likewise.
* gas/i386/x86-64-localpic.d: Replace R_X86_64_GOTPCREL with
R_X86_64_REX_GOTPCRELX.
* gas/i386/ilp32/x86-64-localpic.d: Likewise.

include/elf/

* x86-64.h (R_X86_64_GOTPCRELX): New.
(R_X86_64_REX_GOTPCRELX): Likewise.

ld/testsuite/

* ld-ifunc/ifunc-5r-local-x86-64.d: Replace R_X86_64_GOTPCREL
with R_X86_64_REX_GOTPCRELX.
* ld-x86-64/plt-main1.rd: Likewise.
* ld-x86-64/plt-main3.rd: Likewise.
* ld-x86-64/plt-main4.rd: Likewise.
* ld-x86-64/gotpcrel1.dd: New file.
* ld-x86-64/gotpcrel1.out: Likewise.
* ld-x86-64/gotpcrel1a.S: Likewise.
* ld-x86-64/gotpcrel1b.c: Likewise.
* ld-x86-64/gotpcrel1c.c: Likewise.
* ld-x86-64/gotpcrel1d.S: Likewise.
* ld-x86-64/load1.s: Likewise.
* ld-x86-64/load1a.d: Likewise.
* ld-x86-64/load1b.d: Likewise.
* ld-x86-64/load1c.d: Likewise.
* ld-x86-64/load1d.d: Likewise.
* ld-x86-64/x86-64.exp: Run load1a, load1b, load1c and load1d
tests.  Run gotpcrel1 test.

9 years agoAdd R_386_GOT32X support to gas and ld
H.J. Lu [Thu, 22 Oct 2015 11:46:51 +0000 (04:46 -0700)]
Add R_386_GOT32X support to gas and ld

This patch adds support for the R_386_GOT32X relocation proposed in

https://groups.google.com/forum/#!topic/ia32-abi/GbJJskkid4I

to gas and ld.  It updates gas to generate R_386_GOT32X relocation for
memory operand, foo@GOT[(%reg)].  We must encode "mov foo@GOT, %eax"
with the 0x8b opcode, instead of the 0xb8 opcode, so that it can be
transformed to "lea foo, %eax".  With the locally defined symbol, foo,
we convert

   mov foo@GOT[(%reg1)], %reg2
to
   lea foo[@GOTOFF(%reg1)], %reg2

and convert

   call/jmp *foo@GOT[(%reg)]
to

   nop call foo/jmp foo nop

When PIC is false, convert

   test %reg1, foo@GOT[(%reg2)]
to
   test $foo, %reg1

and convert

binop foo@GOT[(%reg1)], %reg2

to

binop $foo, %reg2

where binop is one of adc, add, and, cmp, or, sbb, sub, xor instructions.

bfd/

* elf32-i386.c: Include opcode/i386.h.
(elf_howto_table): Add R_386_GOT32X.
(R_386_ext2): Replace R_386_IRELATIVE with R_386_GOT32X.
(elf_i386_reloc_type_lookup): Handle BFD_RELOC_386_GOT32X.
(need_convert_mov_to_lea): Renamed to ...
(need_convert_load): This.
(elf_i386_check_relocs): Handle R_386_GOT32X.  Replace
need_convert_mov_to_lea with need_convert_load.
(elf_i386_gc_sweep_hook): Handle R_386_GOT32X.
(elf_i386_size_dynamic_sections): Likewise.
(elf_i386_relocate_section): Likewise.
(elf_i386_convert_mov_to_lea): Renamed to ...
(elf_i386_convert_load): This.  Replace need_convert_mov_to_lea
with need_convert_load.  Support R_386_GOT32X transformations.
* reloc.c (BFD_RELOC_386_GOT32X): New.
* bfd-in2.h: Regenerated.
* libbfd.h: Likewise.

gas/

* config/tc-i386.c (tc_i386_fix_adjustable): Handle
BFD_RELOC_386_GOT32X.
(tc_gen_reloc): Likewise.
(match_template): Force 0x8b encoding for "mov foo@GOT, %eax".
(output_disp): Check for "call/jmp *mem", "mov mem, %reg",
"test %reg, mem" and "binop mem, %reg" where binop is one of
adc, add, and, cmp, or, sbb, sub, xor instructions.  Set
fx_tcbit if the REX prefix is generated.  Set fx_tcbit2 if
BFD_RELOC_386_GOT32X should be generated.
(i386_validate_fix): Generate BFD_RELOC_386_GOT32X if fx_tcbit2
is set.

gas/testsuite/

* gas/i386/got.d: New file.
* gas/i386/got.s: Likewise.
* gas/i386/i386.exp: Run got.
* gas/i386/localpic.d: Replace R_386_GOT32 with R_386_GOT32X.
* gas/i386/mixed-mode-reloc32.d: Likewise.
* gas/i386/reloc32.d: Likewise.

include/elf/

* i386.h (R_386_GOT32X): New relocation.

ld/testsuite/

* ld-i386/branch1.d: New file.
* ld-i386/branch1.s: Likewise.
* ld-i386/call1.d: Likewise.
* ld-i386/call1.s: Likewise.
* ld-i386/call2.d: Likewise.
* ld-i386/call2.s: Likewise.
* ld-i386/got1.dd: Likewise.
* ld-i386/got1.out: Likewise.
* ld-i386/got1a.S: Likewise.
* ld-i386/got1b.c: Likewise.
* ld-i386/got1c.c: Likewise.
* ld-i386/got1d.S: Likewise.
* ld-i386/jmp1.d: Likewise.
* ld-i386/jmp1.s: Likewise.
* ld-i386/jmp2.d: Likewise.
* ld-i386/jmp2.s: Likewise.
* ld-i386/load1.d: Likewise.
* ld-i386/load1.s: Likewise.
* ld-i386/load2.d: Likewise.
* ld-i386/load2.s: Likewise.
* ld-i386/load3.d: Likewise.
* ld-i386/load3.s: Likewise.
* ld-i386/load4.s: Likewise.
* ld-i386/load4a.d: Likewise.
* ld-i386/load4b.d: Likewise.
* ld-i386/load5.s: Likewise.
* ld-i386/load5a.d: Likewise.
* ld-i386/load5b.d: Likewise.
* ld-i386/load6.d: Likewise.
* ld-i386/load6.s: Likewise.
* ld-i386/i386.exp: Run branch1, call1, call2, jmp1, jmp2,
load1, load2, load3, load4a, load4b, load5a, load5b and load6
tests.  Run got1 test.

9 years agoS/390: ifunc: Redirect local function calls to the IPLT.
Andreas Krebbel [Mon, 19 Oct 2015 13:44:35 +0000 (15:44 +0200)]
S/390: ifunc: Redirect local function calls to the IPLT.

bfd/ChangeLog:

* elf32-s390.c (elf_s390_check_relocs): Set the non_got_ref marker
only when linking an executable.
(elf_s390_relocate_section): Redirect PC-relative relocs to a IPLT
slot.
* elf64-s390.c (elf_s390_check_relocs): Set the non_got_ref marker
only when linking an executable.
(elf_s390_relocate_section): Redirect PC-relative relocs to a IPLT
slot.

9 years agoS/390: ifunc: Fix function pointers to hidden ifunc symbols.
Andreas Krebbel [Fri, 16 Oct 2015 19:49:43 +0000 (21:49 +0200)]
S/390: ifunc: Fix function pointers to hidden ifunc symbols.

bfd/ChangeLog:
* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Set the PLT
reference counters for local IFUNC calls.
* elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.

9 years agoS/390: ifunc: Handle GOTOFF relocs on ifunc symbols.
Andreas Krebbel [Fri, 16 Oct 2015 19:07:17 +0000 (21:07 +0200)]
S/390: ifunc: Handle GOTOFF relocs on ifunc symbols.

Normally a GOTOFF reloc only uses the GOT pointer to address something
relativ to it without actually requiring a GOT or PLT slot.  Things
change if the target is an ifunc symbol though.

bfd/ChangeLog:

* elf32-s390.c (elf_s390_check_relocs): Fallthrough to the PLT
slot allocating code for GOTOFF relocs on ifunc symbols.
(elf_s390_gc_sweep_hook): Decrement plt refcount for GOTOFF relocs
on ifunc symbols.
(elf_s390_relocate_section): Redirect a GOTOFF reloc to an iplt
slot.

9 years agoS/390: ifunc: Fix PR18841.
Andreas Krebbel [Thu, 22 Oct 2015 08:11:07 +0000 (10:11 +0200)]
S/390: ifunc: Fix PR18841.

In order to get the ifunc relocs properly sorted the correct class
needs to be returned.  The code mimics what has been done for x86.

bfd/ChangeLog:

PR ld/18841
* elf32-s390.c (elf_s390_reloc_type_class): Return
reloc_class_ifunc for ifunc symbols.
* elf64-s390.c (elf_s390_reloc_type_class): Likewise.

9 years agoS/390: ifunc: Fix for undefined ifunc symbols.
Andreas Krebbel [Mon, 12 Oct 2015 15:33:28 +0000 (17:33 +0200)]
S/390: ifunc: Fix for undefined ifunc symbols.

bfd/ChangeLog:

* elf32-s390.c (elf_s390_finish_dynamic_symbol): Call
elf_s390_finish_ifunc_symbol only for actually defined symbols.
* elf64-s390.c (elf_s390_finish_dynamic_symbol): Likewise.

9 years agoS/390: ifunc: Enable the ifunc tests.
Andreas Krebbel [Mon, 12 Oct 2015 15:34:11 +0000 (17:34 +0200)]
S/390: ifunc: Enable the ifunc tests.

ld/testsuite/ChangeLog:

* ld-ifunc/ifunc.exp: Run ifunc tests on s390* targets.

9 years agoS/390: Get rid of superfluous parameter to s390_elf_allocate_ifunc_dyn_relocs.
Andreas Krebbel [Mon, 19 Oct 2015 11:08:27 +0000 (13:08 +0200)]
S/390: Get rid of superfluous parameter to s390_elf_allocate_ifunc_dyn_relocs.

bfd/ChangeLog:
* elf-s390-common.c (s390_elf_allocate_ifunc_dyn_relocs): Remove
`head' parameter.
* elf32-s390.c (allocate_dynrelocs): Don't use last parameter.
* elf64-s390.c (allocate_dynrelocs): Don't use last parameter.

9 years agoRun add-symbol test on mips
Alan Modra [Thu, 22 Oct 2015 02:14:24 +0000 (12:44 +1030)]
Run add-symbol test on mips

* binutils-all/add-symbol.d: Run test on mips.  Support either
order of NEW and NEWDATA symbols.

9 years agoFix tests for PR 18500, revisited
Alan Modra [Thu, 22 Oct 2015 00:28:47 +0000 (10:58 +1030)]
Fix tests for PR 18500, revisited

Correct commit a846e9c1.

PR gas/18500
* gas/arm/vfpv2-ldr_immediate.d: Use parentheses, not brackets,
to select alternatives.
* gas/arm/vfpv3-ldr_immediate.d: Likewise.
* gas/arm/vfpv3xd-ldr_immediate.d: Likewise.

9 years agoAutomatic date update in version.in
GDB Administrator [Thu, 22 Oct 2015 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in