H.J. Lu [Wed, 3 May 2017 14:40:51 +0000 (07:40 -0700)]
Adjust testsuite/ld-elf/pr21384.d
Adjust testsuite/ld-elf/pr21384.d to accommodate additional dynamic
symbols on some targets.
* testsuite/ld-elf/pr21384.d: Adjusted to accommodate
additional dynamic symbols on some targets.
Alan Hayward [Wed, 3 May 2017 13:51:40 +0000 (14:51 +0100)]
Remove MAX_REGISTER_SIZE from frv-linux-tdep.c
gdb/
* frv-linux-tdep.c (frv_linux_supply_gregset): Use raw_supply_zeroed.
* regcache.c (regcache::raw_supply_zeroed): New function.
* regcache.h (regcache::raw_supply_zeroed): New declaration.
Simon Marchi [Wed, 3 May 2017 13:21:27 +0000 (09:21 -0400)]
gdbarch.sh: Remove commented out TARGET_CHAR_BIT definition
As Pedro commented on the patch "Change field separator in gdbarch.sh",
this commented out definition is probably not useful and should be
removed. It has been commented out for basically forever, and it
probably serves the same intent as addressable_memory_unit_size.
gdb/ChangeLog:
* gdbarch.sh: Remove commented out definition of
TARGET_CHAR_BIT.
* gdbarch.h: Re-generate.
Sergio Durigan Junior [Wed, 3 May 2017 13:13:15 +0000 (09:13 -0400)]
Regenerate gdb/{,gdbserver/}configure (for commit
be628ab814f1c90e185d7482d27aa8a991ab5837)
On commit
be628ab814f1c90e185d7482d27aa8a991ab5837, both
common/common.m4 was modified in order to check for the presence of
'termios.h', 'termio.h' and 'sgtty.h'. However, I forgot to
regenerate both gdb/configure and gdb/gdbserver/configure. This
commit does that.
gdb/ChangeLog:
2017-05-03 Sergio Durigan Junior <sergiodj@redhat.com>
* configure: Regenerate.
gdb/gdbserver/ChangeLog:
2017-05-03 Sergio Durigan Junior <sergiodj@redhat.com>
* configure: Regenerate.
Nick Clifton [Wed, 3 May 2017 08:52:01 +0000 (09:52 +0100)]
Prevent a seg-fault in the assembler when provided with a bogus input source file.
PR gas/20941
* symbols.c (snapshot_symbol): Handle the case where
resolve_expression returns a local symbol.
GDB Administrator [Wed, 3 May 2017 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in
Maciej W. Rozycki [Tue, 2 May 2017 23:05:15 +0000 (00:05 +0100)]
MIPS16/GAS: Fix absolute references with PC-relative synthetic instructions
Complement commit
88a7ef168927 ("MIPS16/GAS: Restore unsupported
relocation diagnostics") and also propagate constant expressions, either
already reduced from absolute symbol references or created from literals
in the first place, used as a PC-relative operand with the MIPS16 LA,
LW, DLA and LD synthetic instructions to relaxation, matching the way
forward absolute symbol references have been handled as from the commit
referred and letting relaxation produce any necessary relocations, if
possible, for the absolute value requested to be reproduced at the run
time.
Call `symbol_append' for any expression symbol created for the purpose
of MIPS16 relaxation as with constant expressions now propagated from
earlier on such symbols may make it through and have R_MIPS16_PC16_S1
relocations emitted against, and therefore need to appear in the symbol
table produced.
gas/
* config/tc-mips.c (append_insn): Call `symbol_append' for any
expression symbol created for MIPS16 relaxation.
(match_mips16_insn): Don't encode a constant value as an
immediate with a PC-relative operand.
* testsuite/gas/mips/mips16-pcrel-absolute-1.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-1.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-2.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-addend-1.d: New
test.
* testsuite/gas/mips/mips16-branch-absolute-n32-1.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-n32-2.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-addend-n32-1.d: New
test.
* testsuite/gas/mips/mips16-branch-absolute-n64-1.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-n64-2.d: New test.
* testsuite/gas/mips/mips16-branch-absolute-addend-n64-1.d: New
test.
* testsuite/gas/mips/mips16-pcrel-absolute-1.l: New stderr
output.
* testsuite/gas/mips/mips16-pcrel-absolute-1.s: New test source.
* testsuite/gas/mips/mips16-branch-absolute-1.s: New test
source.
* testsuite/gas/mips/mips16-branch-absolute-2.s: New test
source.
* testsuite/gas/mips/mips16-branch-absolute-addend-1.s: New test
source.
* testsuite/gas/mips/mips.exp: Run the new tests.
ld/
* testsuite/ld-mips-elf/mips16-branch-absolute-1.d: New test.
* testsuite/ld-mips-elf/mips16-branch-absolute-2.d: New test.
* testsuite/ld-mips-elf/mips16-branch-absolute-addend-1.d: New
test.
* testsuite/ld-mips-elf/mips16-branch-absolute-n32-1.d: New
test.
* testsuite/ld-mips-elf/mips16-branch-absolute-n32-2.d: New
test.
* testsuite/ld-mips-elf/mips16-branch-absolute-addend-n32-1.d:
New test.
* testsuite/ld-mips-elf/mips16-branch-absolute-n64-1.d: New
test.
* testsuite/ld-mips-elf/mips16-branch-absolute-n64-2.d: New
test.
* testsuite/ld-mips-elf/mips16-branch-absolute-addend-n64-1.d:
New test.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
H.J. Lu [Tue, 2 May 2017 23:00:49 +0000 (16:00 -0700)]
x86: Add -Wl,--no-as-needed to some TLS tests
* testsuite/ld-i386/tls.exp: Add -Wl,--no-as-needed to
"TLS without PLT (1)" and "TLS without PLT (3)".
* testsuite/ld-x86-64/tls.exp: Add -Wl,--no-as-needed to
to "TLS without PLT (3)".
Michael Clark [Thu, 27 Apr 2017 04:08:46 +0000 (16:08 +1200)]
RISC-V: Change CALL macro to use ra as the temporary address register
e.g.
1: auipc ra, %pcrel_hi(symbol)
jalr ra, %pcrel_lo(1b)(ra)
The use of ra instead of t1 for address construction provides an
opportunity for a microarchitecture to elide the write of the
destination address, and instead read the target address as an
immediate spread across the fused auipc+jalr pair. The link
register ra in the jalr overwrites the target address temporary.
2017-05-01 Michael Clark <michaeljclark@mac.com>
* riscv-opc.c (riscv_opcodes) <call>: Use RA not T1 as a temporary
register.
Palmer Dabbelt [Mon, 1 May 2017 17:26:32 +0000 (10:26 -0700)]
RISC-V: Allow 32-bit BFD to handle 64-bit objects
We've been telling people that the riscv32-* and riscv64-* toolchains
are exactly the same, but it turns out we were lying: the riscv32-* BFD
doesn't handle 64-bit objects. This fixes that difference, so the ports
are actually the same.
bfd/ChangeLog
2017-05-01 Palmer Dabbelt <palmer@dabbelt.com>
* config.bfd (riscv32-*): Enable rv64.
H.J. Lu [Tue, 2 May 2017 20:54:22 +0000 (13:54 -0700)]
Add a test for PR ld/21384
PR ld/21384
* testsuite/ld-elf/pr21384.d: New file.
* testsuite/ld-elf/pr21384.dl: Likewise.
* testsuite/ld-elf/pr21384.ld: Likewise.
* testsuite/ld-elf/pr21384.s: Likewise.
H.J. Lu [Tue, 2 May 2017 19:16:26 +0000 (12:16 -0700)]
Cast relcount to unsigned long when comparing with sec->reloc_count
The type of relcount is long and the type of sec->reloc_count is
unsigned int. On 32-bit hosts, GCC issues an error:
objcopy.c:2144:20: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
if (relcount > sec->reloc_count)
Cast relcount to unsigned long to silence GCC.
* objcopy.c (merge_gnu_build_notes): Cast relcount to unsigned
long when comparing with sec->reloc_count.
Simon Marchi [Tue, 2 May 2017 18:25:43 +0000 (14:25 -0400)]
solib-target: Remove local variables
Now that we use std::vector, these local variables are not very useful.
They're not much shorter than the expressions they stand for.
gdb/ChangeLog:
* solib-target.c (solib_target_relocate_section_addresses):
Remove num_section_bases, num_bases, segment_bases variables.
Simon Marchi [Tue, 2 May 2017 17:30:09 +0000 (13:30 -0400)]
Remove definition of VEC (CORE_ADDR)
gdb/ChangeLog:
* common/gdb_vecs.h (DEF_VEC_I (CORE_ADDR)): Remove.
Simon Marchi [Tue, 2 May 2017 17:30:08 +0000 (13:30 -0400)]
Use std::vector in lm_info_target
Replace the two VEC fields with std::vector.
gdb/ChangeLog:
* solib-target.c: Include <vector>
(struct lm_info_target) <~lm_info_target>: Remove.
<segment_bases, section_bases>: Change type to
std::vector<CORE_ADDR>.
(library_list_start_segment, library_list_start_section,
library_list_end_library,
solib_target_relocate_section_addresses): Adjust.
Simon Marchi [Tue, 2 May 2017 17:30:07 +0000 (13:30 -0400)]
Change return type of gdbarch_software_single_step to vector<CORE_ADDR>
This is a relatively straightforward patch that changes
gdbarch_software_single_step so it returns an std::vector<CORE_ADDR>
instead of a VEC (CORE_ADDR).
gdb/ChangeLog:
* gdbarch.sh (software_single_step): Change return type to
std::vector<CORE_ADDR>.
* gdbarch.c, gdbarch.h: Re-generate.
* arch/arm-get-next-pcs.c (thumb_deal_with_atomic_sequence_raw):
Adjust.
(arm_deal_with_atomic_sequence_raw): Adjust.
(thumb_get_next_pcs_raw): Adjust.
(arm_get_next_pcs_raw): Adjust.
(arm_get_next_pcs): Adjust.
* arch/arm-get-next-pcs.h (arm_get_next_pcs): Adjust.
* aarch64-tdep.c (aarch64_software_single_step): Adjust.
* alpha-tdep.c (alpha_deal_with_atomic_sequence): Adjust.
(alpha_software_single_step): Adjust.
* alpha-tdep.h (alpha_software_single_step): Adjust.
* arm-linux-tdep.c (arm_linux_software_single_step): Adjust.
* arm-tdep.c (arm_software_single_step): Adjust.
(arm_breakpoint_kind_from_current_state): Adjust.
* arm-tdep.h (arm_software_single_step): Adjust.
* breakpoint.c (insert_single_step_breakpoint): Adjust.
* cris-tdep.c (cris_software_single_step): Adjust.
* mips-tdep.c (mips_deal_with_atomic_sequence): Adjust.
(micromips_deal_with_atomic_sequence): Adjust.
(deal_with_atomic_sequence): Adjust.
(mips_software_single_step): Adjust.
* mips-tdep.h (mips_software_single_step): Adjust.
* moxie-tdep.c (moxie_software_single_step): Adjust.
* nios2-tdep.c (nios2_software_single_step): Adjust.
* ppc-tdep.h (ppc_deal_with_atomic_sequence): Adjust.
* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
* s390-linux-tdep.c (s390_software_single_step): Adjust.
* sparc-tdep.c (sparc_software_single_step): Adjust.
* spu-tdep.c (spu_software_single_step): Adjust.
* tic6x-tdep.c (tic6x_software_single_step): Adjust.
gdb/gdbserver/ChangeLog:
* linux-arm-low.c (arm_gdbserver_get_next_pcs): Adjust to
software_single_step change of return type to
std::vector<CORE_ADDR>.
* linux-low.c (install_software_single_step_breakpoints):
Likewise.
* linux-low.h (install_software_single_step_breakpoints):
Likewise.
Simon Marchi [Tue, 2 May 2017 17:30:07 +0000 (13:30 -0400)]
Change field separator in gdbarch.sh
The fields in the description of the gdbarch interface are separated
using colons. That becomes a problem if we want to use things like
std::vector in it. This patch changes the field separator to use
semicolons instead.
I think there's very little chance we'll ever want to use a semicolon in
one of the fields, but if you think another character would be more
appropriate, let me know.
gdb/ChangeLog:
* gdbarch.sh: Use semi-colon as field separator instead of colon.
* gdbarch.h: Re-generate.
Nick Clifton [Tue, 2 May 2017 15:54:53 +0000 (16:54 +0100)]
Don't merge notes when the relocs associated with them cannot be reliably deleted.
* objcopy.c (merge_gnu_build_notes): Disable merge if there are
more internal relocs than external relocs.
Alan Modra [Tue, 2 May 2017 12:26:43 +0000 (21:56 +0930)]
PR 21384, --dynamic-list regression with
f02cb058
The commit to "Always descend into output section statements in
lang_do_assignments" meant that linker script symbols were not
bfd_link_hash_new when ld called bfd_elf_record_link_assignment.
This patch corrects that problem by testing h->non_elf instead.
PR 21384
* elflink.c (bfd_elf_link_mark_dynamic_symbol): Test h->non_elf
rather than h->root.type == bfd_link_hash_new.
(bfd_elf_record_link_assignment): Similarly, call
bfd_elf_link_mark_dynamic_symbol when h->non_elf.
Maciej W. Rozycki [Tue, 2 May 2017 10:53:30 +0000 (11:53 +0100)]
MIPS16/opcodes: Keep the LSB of PC-relative offsets in disassembly
Correct the disassembly of the PC-relative immediate argument of the
MIPS16 synthetic LA, LW, DLA and LD instructions and do not mask the
LSB, which in this case is a part of the data address rather than the
ISA bit and has to be fully presented.
opcodes/
* mips-dis.c (print_insn_arg): Only clear the ISA bit for jumps
and branches and not synthetic data instructions.
binutils/
* testsuite/binutils-all/mips/mips16-undecoded.d: Adjust the
disassembly of PC-relative LA and LW synthetic instructions.
Nick Clifton [Tue, 2 May 2017 10:54:53 +0000 (11:54 +0100)]
Prevent memory exhaustion from a corrupt PE binary with an overlarge number of relocs.
PR 21440
* objdump.c (dump_relocs_in_section): Check for an excessive
number of relocs before attempting to dump them.
Tim Wiederhake [Tue, 2 May 2017 09:35:54 +0000 (11:35 +0200)]
Python: Introduce gdb.Instruction class
This adds a generic instruction class to Python and has gdb.RecordInstruction
inherit from it.
Tim Wiederhake [Tue, 2 May 2017 09:35:54 +0000 (11:35 +0200)]
Python: Move and rename gdb.BtraceFunction
Remove gdb.BtraceFunctionCall and replace by gdb.FunctionSegment. Additionally,
rename prev_segment and next_segment to prev and next.
Tim Wiederhake [Tue, 2 May 2017 09:35:54 +0000 (11:35 +0200)]
Python: Move and rename gdb.BtraceInstruction
Remove gdb.BtraceInstruction and replace by gdb.RecordInstruction.
Tim Wiederhake [Tue, 2 May 2017 09:35:54 +0000 (11:35 +0200)]
Python: Introduce gdb.RecordGap class
As discussed here: https://sourceware.org/ml/gdb-patches/2017-04/msg00157.html
A gap is not an instruction and it should not pretend to be one.
gdb.Record.instruction_history is now a list of gdb.RecordInstruction and
gdb.RecordGap objects. This allows the user to deal with Gaps in the record
in a more sane way.
Tim Wiederhake [Tue, 2 May 2017 09:35:54 +0000 (11:35 +0200)]
Python: Remove ptid from gdb.Record interface
As discussed here: https://sourceware.org/ml/gdb-patches/2017-04/msg00166.html
Tim Wiederhake [Tue, 2 May 2017 09:35:54 +0000 (11:35 +0200)]
Python: Use correct ptid in btrace recording
The user would always get the instruction_history and function_call_history
objects of the current thread, not the thread for which the gdb.Record object
was created.
The attached testcase fails without this patch and passes with the patch.
Tim Wiederhake [Tue, 2 May 2017 09:35:54 +0000 (11:35 +0200)]
Python: Fix indentation in py-record-btrace.c
Bernd Edlinger [Tue, 2 May 2017 09:28:09 +0000 (10:28 +0100)]
Fix value in comment of disassembled ARM type A opcodes.
* arm-dis.c (print_insn_thumb32): Fix value_in_comment.
GDB Administrator [Tue, 2 May 2017 00:00:39 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Mon, 1 May 2017 18:02:55 +0000 (11:02 -0700)]
x86: Run GNU2 TLS tests with working GNU2 TLS support
Check if GNU2 TLS really works before running GNU2 TLS tests.
* testsuite/ld-i386/tls.exp: Run GNU2 TLS tests only if there
is working GNU2 TLS support.
* testsuite/ld-x86-64/tls.exp: Likewise.
* testsuite/lib/ld-lib.exp (check_gnu2_tls_available): New proc.
Joel Brobecker [Mon, 1 May 2017 16:59:15 +0000 (09:59 -0700)]
gdb/MAINTAINERS: Move Daniel J and Mark to the Past Maintainers section.
gdb/ChangeLog:
* MAINTAINERS: Move Daniel Jacobowitz and Mark Kettenis to
the past maintainers section.
Alan Modra [Mon, 1 May 2017 04:41:27 +0000 (14:11 +0930)]
merge_gnu_build_notes reloc deletion
If moving relocs, the next reloc to look at is at the same location.
* objcopy.c (merge_gnu_build_notes): Correct code deleting
relocs.
GDB Administrator [Mon, 1 May 2017 00:00:35 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 30 Apr 2017 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Sat, 29 Apr 2017 05:18:16 +0000 (14:48 +0930)]
PR21432, buffer overflow in perform_relocation
The existing reloc offset range tests didn't catch small negative
offsets less than the size of the reloc field.
PR 21432
* reloc.c (reloc_offset_in_range): New function.
(bfd_perform_relocation, bfd_install_relocation): Use it.
(_bfd_final_link_relocate): Likewise.
Sergio Durigan Junior [Fri, 31 Mar 2017 17:24:36 +0000 (13:24 -0400)]
Make environ.exp run on all platforms (and create info-program.exp)
This has been on my TODO list for a while. There's a really old bug
about this (PR testsuite/8595), and there was no reason for
environ.exp to be specific for hppa* targets. So this patch removes
this constraint, modernizes the testcase, and cleans up some things.
Most of the tests remained, and some were rewritten (especially the
one that checks if "show environment" works, which is something kind
of hard to do).
As a bonus, I'm adding a separated info-program.exp file containing
all the tests related to "info program" that were present on
environ.exp.
Tested locally, everything still passes.
gdb/testsuite/ChangeLog:
2017-04-28 Sergio Durigan Junior <sergiodj@redhat.com>
PR testsuite/8595
* gdb.base/environ.exp: Make test available in all architectures.
Move bits related to "info program" testing to
gdb.base/info-program.exp. Rewrite tests to use the two new
procedures mentione below.
(test_set_show_env_var) New procedure.
(test_set_show_env_var_equal): Likewise.
* gdb.base/info-program.exp: New file.
GDB Administrator [Sat, 29 Apr 2017 00:00:38 +0000 (00:00 +0000)]
Automatic date update in version.in
Yao Qi [Fri, 28 Apr 2017 21:48:42 +0000 (22:48 +0100)]
Remove cleanup in get_return_value
With regcache ctor, we can use it to create local object in
get_return_value (), so that the cleanup can be removed.
gdb:
2017-04-28 Yao Qi <yao.qi@linaro.org>
* infcmd.c (get_return_value): Use regcache ctor, and remove
cleanup.
Yao Qi [Fri, 28 Apr 2017 21:48:42 +0000 (22:48 +0100)]
Use tag dispatch regcache ctor in regcache_dup
This patch adds a tag dispatch ctor to create read-only regcache from
a write-through regcache, also this patch deletes copy ctor and
assignment operator.
gdb:
2017-04-28 Yao Qi <yao.qi@linaro.org>
Pedro Alves <palves@redhat.com>
* regcache.c (regcache::regcache): New tag dispatch ctor.
(do_cooked_read): Moved above.
(regcache_dup): Use the tag dispatch ctor..
* regcache.h (regcache): Declare ctor, delete copy ctor and
assignment operator, remove friend regcache_dup.
Yao Qi [Fri, 28 Apr 2017 21:48:42 +0000 (22:48 +0100)]
Simplify regcache_dup
regcache_dup, in fact, is to create a readonly regcache from a
non-readonly regcache. This patch adds an assert that src is not
readonly.
gdb:
2017-04-28 Yao Qi <yao.qi@linaro.org>
* regcache.c (regcache_dup): Assert !src->m_readonly_p and
call method save instead of regcache_cpy.
* regcache.h (struct regcache): Make regcache_dup a friend.
Yao Qi [Fri, 28 Apr 2017 21:48:42 +0000 (22:48 +0100)]
Class-fy regcache
This patch moves regcache declaration to regcache.h, and converts
regcache apis to member functions, for example, regcache_invalidate
is changed to regcache::invalidate.
This patch also add "m_" prefix to these private fields.
gdb:
2017-04-28 Yao Qi <yao.qi@linaro.org>
* regcache.c (struct regcache): Move to regcache.h
(regcache::arch): New method.
(regcache_get_ptid): Update.
(get_regcache_arch): Call arch method.
(get_regcache_aspace): Call method aspace.
(register_buffer): Change it to method.
(regcache_save): Change it to regcache::save.
(regcache_restore): Likewise.
(regcache_cpy_no_passthrough): Remove the declaration.
(regcache_cpy): Call methods restore and cpy_no_passthrough.
(regcache_cpy_no_passthrough): Change it to method
cpy_no_passthrough.
(regcache_register_status): Change it to method
get_register_status.
(regcache_invalidate): Change it to method invalidate.
(regcache_thread_ptid_changed): Use methods ptid and set_ptid.
(regcache_raw_update): Change it to method raw_update.
(regcache_raw_read): Likewise.
(regcache_raw_read_signed): Likewise.
(regcache_raw_read_unsigned): Likewise.
(regcache_raw_write_signed): Likewise.
(regcache_raw_write_unsigned): Likewise.
(regcache_cooked_read): Likewise.
(regcache_cooked_read_value): Likewise.
(regcache_cooked_read_signed): Likewise.
(regcache_cooked_read_unsigned): Likewise.
(regcache_cooked_write_signed): Likewise.
(regcache_cooked_write_unsigned): Likewise.
(regcache_raw_set_cached_value): Likewise.
(regcache_raw_write): Likewise.
(regcache_cooked_write): Likewise.
(regcache_xfer_part): Likewise.
(regcache_raw_read_part): Likewise.
(regcache_raw_write_part): Likewise.
(regcache_cooked_read_part): Likewise.
(regcache_cooked_write_part): Likewise.
(regcache_raw_supply): Likewise.
(regcache_raw_collect): Likewise.
(regcache_transfer_regset): Likewise.
(regcache_supply_regset): Likewise.
(regcache_collect_regset): Likewise.
(regcache_debug_print_register): Likewise.
(enum regcache_dump_what): Move it to regcache.h.
(regcache_dump): Change it to method dump.
* regcache.h (enum regcache_dump_what): New.
(class regcache): New.
* target.c (target_fetch_registers): Call method
debug_print_register.
(target_store_registers): Likewise.
Simon Marchi [Fri, 28 Apr 2017 21:16:18 +0000 (17:16 -0400)]
Class-ify lm_info_windows
This patch makes lm_info_windows a "real" class. It initializes the field
and replaces XCNEW/xfree with new/delete.
gdb/ChangeLog:
* windows-nat.c (struct lm_info_windows): Initialize field.
(windows_make_so): Allocate lm_info_windows with new.
(windows_free_so): Free lm_info_windows with delete.
Simon Marchi [Fri, 28 Apr 2017 21:16:18 +0000 (17:16 -0400)]
Class-ify lm_info_darwin
This patch makes lm_info_darwin a "real" class. It initializes the
field and replaces XCNEW/xfree with new/delete.
gdb/ChangeLog:
* solib-darwin.c (struct lm_info_darwin): Initialize field.
(darwin_current_sos): Allocate lm_info_darwin with new, remove
cleanup.
(darwin_free_so): Free lm_info_darwin with delete.
Simon Marchi [Fri, 28 Apr 2017 21:16:17 +0000 (17:16 -0400)]
Class-ify lm_info_svr4
This patch makes lm_info_svr4 a "real" class. It initializes fields,
uses bool and replaces XCNEW/xfree with new/delete.
The memcpy in svr4_copy_library_list is replaced by a usage of the
default copy constructor.
gdb/ChangeLog:
* solib-svr4.h (struct lm_info_svr4): Initialize fields.
<l_addr_p>: Change type to bool.
* solib-svr4.c (lm_info_read): Allocate lm_info_svr4 with new.
(svr4_free_so): Free lm_info_svr4 with delete.
(svr4_copy_library_list): Replace memcpy with call to copy
constructor.
(library_list_start_library, svr4_default_sos): Allocate
lm_info_svr4 with new.
Simon Marchi [Fri, 28 Apr 2017 21:16:16 +0000 (17:16 -0400)]
Class-ify lm_info_target
This patch makes lm_info_target a "real" class. It adds a destructor,
uses std::string, initializes the fields and replaces XCNEW/xfree with
new/delete.
gdb/ChangeLog:
* solib-target.c (struct lm_info_target): Add destructor,
initialize fields.
<name>: Change type to std::string.
(library_list_start_library): Allocate lm_info_target with new.
(solib_target_free_library_list): Free lm_info_target with
delete.
(solib_target_current_sos): Adapt to std::string.
(solib_target_free_so): Free lm_info_target with delete.
Simon Marchi [Fri, 28 Apr 2017 21:16:16 +0000 (17:16 -0400)]
Class-ify lm_info_frv
This patches makes lm_info_frv a "real" class. It adds a destructor,
initializes the fields and replaces XCNEW/xfree with new/delete.
gdb/ChangeLog:
* solib-frv.c (struct lm_info_frv): Add destructor, initialize
fields.
(frv_current_sos): Allocate lm_info_frv with new.
(frv_relocate_main_executable): Free lm_info_frv with delete,
allocate with new.
(frv_clear_solib, frv_free_so): Free lm_info_frv with delete.
Simon Marchi [Fri, 28 Apr 2017 21:16:15 +0000 (17:16 -0400)]
Fix indentation of lm_info_frv
This patch fixes the indentation of lm_info_frv, so that the real
changes of the following patch are not lost in the reformatting.
gdb/ChangeLog:
* solib-frv.c (struct lm_info_frv): Fix indentation.
Simon Marchi [Fri, 28 Apr 2017 21:16:14 +0000 (17:16 -0400)]
Class-ify lm_info_dsbt
This patches makes lm_info_dsbt a "real" class. It introduces a
destructor, initializes the field and replaces XCNEW/xfree with
new/delete.
gdb/ChangeLog:
* solib-dsbt.c (struct lm_info_dsbt): Add destructor, initialize
map field.
(dsbt_current_sos): Allocate lm_info_dsbt with new.
(dsbt_relocate_main_executable): Free lm_info_dsbt with delete
and allocate with new.
(dsbt_clear_solib, dsbt_free_so): Free lm_info_dsbt with delete.
Simon Marchi [Fri, 28 Apr 2017 21:16:14 +0000 (17:16 -0400)]
Class-ify lm_info_aix
This patch makes lm_info_aix a "real" class. It uses std::string,
initializes fields in-class and replaces XCNEW/xfree with new/delete.
The solib_aix_new_lm_info can be replaced by using the default copy
constructor.
gdb/ChangeLog:
* solib-aix.c (struct lm_info_aix): Initialize fields in-class.
<filename, member_name>: Change type to std::string.
(solib_aix_new_lm_info, solib_aix_xfree_lm_info): Remove.
(library_list_start_library): Allocate lm_info_aix with new.
(solib_aix_free_library_list, solib_aix_free_so): Free with delete.
(solib_aix_current_sos): Adapt to std::string, copy lm_info_aix
with copy constructor.
Simon Marchi [Fri, 28 Apr 2017 21:16:13 +0000 (17:16 -0400)]
Make various lm_info implementations inherit from a base class
The lm_info structure is used to store target specific information about
mapped libraries. It is currently defined as an opaque type in solist.h
and a pointer to it is included in solist, the target-agnostic object
representing a loaded shared library. Multiple targets define their own
implementation of lm_info.
In anticipation of using C++ stuff (e.g. vector) in the lm_info objects,
we first need to avoid different definitions of classes with the same
name (which violates the one definition rule). This patch does it by
having a base class (lm_info_base) from which all the specific lm_info
derive. Each implementation is renamed to something that makes sense
(e.g. lm_info_aix for AIX). The next logical step would probably be to
derive directly from so_list, it's not really obvious, so I'll keep that
for another day.
One special case is the Neutrino (nto) support. It uses SVR4-style
libraries, but overrides some methods. To do that, it needed to have
its own copy of SVR4's lm_info structure in nto-tdep.c, because it was
just not possible to put it in solib-svr4.h and include that file. Over
time, that copy got out of sync, which is still the case today. I can
only assume that the lm_addr function in nto-tdep.c is broken right now.
The first field of the old lm_info was a pointer (gdb_byte *), whereas
in the new lm_info it's an address in the inferior (CORE_ADDR). Trying
to use that field today probably results in a crash. With this
refactor, it's now possible to put lm_info_svr4 in solib-svr4.h and just
include it. I have adapted the code in nto-tdep.c to that it builds,
but it's probably not correct. Since I don't have the knowledge nor
setup to try this on Neutrino, somebody else would have to fix it. But
I am confident that I am not making things worse than they already are.
gdb/ChangeLog:
* solist.h (struct lm_info): Remove.
(struct lm_info_base): New class.
(struct so_list) <lm_info>: Change type to lm_info_base *.
* nto-tdep.c (struct lm_info): Remove.
(lm_addr): Adjust.
* solib-aix.c (struct lm_info): Rename to ...
(struct lm_info_aix): ... this. Extend lm_info_base.
(lm_info_p): Rename to ...
(lm_info_aix_p): ... this, and adjust.
(solib_aix_new_lm_info, solib_aix_xfree_lm_info,
solib_aix_parse_libraries, library_list_start_library,
solib_aix_free_library_list, solib_aix_parse_libraries,
solib_aix_get_library_list,
solib_aix_relocate_section_addresses, solib_aix_free_so,
solib_aix_get_section_offsets,
solib_aix_solib_create_inferior_hook, solib_aix_current_sos):
Adjust.
(struct solib_aix_inferior_data) <library_list>: Adjust.
* solib-darwin.c (struct lm_info): Rename to ...
(struct lm_info_darwin): ... this. Extend lm_info_base.
(darwin_current_sos, darwin_relocate_section_addresses): Adjust.
* solib-dsbt.c (struct lm_info): Rename to ...
(struct lm_info_dsbt): ... this. Extend lm_info_base.
(struct dsbt_info) <main_executable_lm_info): Adjust.
(dsbt_current_sos, dsbt_relocate_main_executable, dsbt_free_so,
dsbt_relocate_section_addresses): Adjust.
* solib-frv.c (struct lm_info): Rename to ...
(struct lm_info_frv): ... this. Extend lm_info_base.
(main_executable_lm_info): Adjust.
(frv_current_sos, frv_relocate_main_executable, frv_free_so,
frv_relocate_section_addresses, frv_fdpic_find_global_pointer,
find_canonical_descriptor_in_load_object,
frv_fdpic_find_canonical_descriptor): Adjust.
* solib-svr4.c (struct lm_info): Move to solib-svr4.h, renamed
to lm_info_svr4.
(lm_info_read, lm_addr_check, svr4_keep_data_in_core,
svr4_clear_so, svr4_copy_library_list,
library_list_start_library, svr4_default_sos, svr4_read_so_list,
svr4_current_sos, svr4_fetch_objfile_link_map,
solist_update_incremental): Adjust.
* solib-svr4.h (struct lm_info_svr4): Move here from
solib-svr4.c.
* solib-target.c (struct lm_info): Rename to ...
(struct lm_info_target): ... this. Extend lm_info_base.
(lm_info_p): Rename to ...
(lm_info_target_p): ... this.
(solib_target_parse_libraries, library_list_start_segment,
library_list_start_section, library_list_start_library,
library_list_end_library, solib_target_free_library_list,
solib_target_current_sos, solib_target_free_so,
solib_target_relocate_section_addresses): Adjust.
* windows-nat.c (struct lm_info): Rename to ...
(struct lm_info_windows): ... this. Extend lm_info_base.
(windows_make_so, handle_load_dll, handle_unload_dll,
windows_xfer_shared_libraries): Adjust.
Simon Marchi [Fri, 28 Apr 2017 21:16:12 +0000 (17:16 -0400)]
Standardize darwin's lm_info
Darwin's lm_info structure is used a little bit differently than the
other solib implementations. The other implementations first allocate
an so_list object, then instanciate their specific lm_info structure,
and assign it to so_list::lm_info.
The Darwin implementation allocates both at the same time
(darwin_so_list). This patch changes it to be like the others, so that
we'll be able to do some generalizations later.
gdb/ChangeLog:
* solib-darwin.c (struct darwin_so_list): Remove.
(darwin_current_sos): Allocate an so_list object instead of a
darwin_so_list, separately allocate an lm_info object.
(darwin_free_so): Free lm_info.
H.J. Lu [Fri, 28 Apr 2017 19:42:05 +0000 (12:42 -0700)]
x86: Add run-time tests for -mtls-dialect=gnu2
* testsuite/config/default.exp (GNU2_CFLAGS): New. Set
to -mtls-dialect=gnu2 if target compiler supports it.
* testsuite/ld-i386/tls.exp: Run -mtls-dialect=gnu2 tests.
* testsuite/ld-x86-64/tls.exp: Likewise.
* testsuite/ld-i386/tlsdesc1a.c: New file.
* testsuite/ld-i386/tlsdesc1b.c: Likewise.
* testsuite/ld-x86-64/tlsdesc1a.c: Likewise.
* testsuite/ld-x86-64/tlsdesc1b.c: Likewise.
H.J. Lu [Fri, 28 Apr 2017 19:29:29 +0000 (12:29 -0700)]
ELF: Add run-time tests for -z now
* testsuite/ld-elf/shared.exp: Add run-time tests for -z now.
* testsuite/ld-i386/tls.exp: Likewise.
* testsuite/ld-ifunc/ifunc.exp: Likewise.
* testsuite/ld-x86-64/tls.exp: Likewise.
John Baldwin [Fri, 28 Apr 2017 16:34:52 +0000 (09:34 -0700)]
Consistently use fprintf_filtered when displaying MIPS registers.
One line was using printf_filtered instead of fprintf_filtered
to the requested file.
gdb/ChangeLog:
* mips-tdep.c (print_gp_register_row): Replace printf_filtered
with fprintf_filtered.
H.J. Lu [Fri, 28 Apr 2017 14:26:45 +0000 (07:26 -0700)]
x86: Check plt_got before using .plt.got
Since the GOT procedure linkage table is supported only if plt_got
isn't NULL, we need to check plt_got before using it.
* elf32-i386.c (elf_i386_allocate_dynrelocs): Check plt_got
before using .plt.got.
* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Likewise.
Yao Qi [Fri, 28 Apr 2017 13:43:13 +0000 (14:43 +0100)]
Add constructor and destructor to regcache
This patch adds ctor and dtor to regcache.
gdb:
2017-04-28 Yao Qi <yao.qi@linaro.org>
* regcache.c (regcache::regcache): New function.
(regcache::~regcache): New function.
(regcache_xmalloc_1): Remove.
(regcache_xmalloc): Call new regcache.
(regcache_xfree): Call delete regcache.
(get_thread_arch_aspace_regcache): Call new regcache.
Nick Clifton [Fri, 28 Apr 2017 11:09:14 +0000 (12:09 +0100)]
Fix off by one error when checking for empty note names.
PR binutils/21439
* readelf.c (print_gnu_build_attribute_name): Allow for an empty
name field.
Nick Clifton [Fri, 28 Apr 2017 10:21:53 +0000 (11:21 +0100)]
Fix heap-buffer address violation when reading version data from a corrupt binary.
PR binutils/21437
* readelf.c (process_version_sections): Check for underflow when
computing the start address of the auxillary version data.
Nick Clifton [Fri, 28 Apr 2017 09:28:04 +0000 (10:28 +0100)]
Fix heap-buffer overflow bugs caused when dumping debug information from a corrupt binary.
PR binutils/21438
* dwarf.c (process_extended_line_op): Do not assume that the
string extracted from the section is NUL terminated.
(fetch_indirect_string): If the string retrieved from the section
is not NUL terminated, return an error message.
(fetch_indirect_line_string): Likewise.
(fetch_indexed_string): Likewise.
Yao Qi [Fri, 28 Apr 2017 08:50:51 +0000 (09:50 +0100)]
Use ptid method lwp in mips_linux_new_thread
gdb:
2017-04-28 Yao Qi <yao.qi@linaro.org>
* mips-linux-nat.c (mips_linux_new_thread): Use ptid method
lwp instead of ptid_get_lwp.
Yao Qi [Fri, 28 Apr 2017 08:33:16 +0000 (09:33 +0100)]
[MIPS] Use lwpid from lwp_info instead of inferior_ptid
RAJESH reported that GDB gets "Couldn't write debug register: No such
process." on mips64 when GDB attaches to a multi threaded application.
Looks GDB nows PTRACE_GET_WATCH_REGS for inferior_ptid but
PTRACE_SET_WATCH_REGS for lwp->ptid, they may be different.
gdb:
2017-04-28 Yao Qi <yao.qi@linaro.org>
* mips-linux-nat.c (mips_linux_new_thread): Get lwpid from
lwp_info instead of getting from inferior_ptid.
GDB Administrator [Fri, 28 Apr 2017 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in
Keith Seitz [Thu, 27 Apr 2017 22:55:26 +0000 (15:55 -0700)]
Fix overload resolution involving rvalue references and cv qualifiers.
The following patch fixes several outstanding overload resolution problems
with rvalue references and cv qualifiers in the test suite. The tests for
these problems typically passed with one compiler version and failed with
another. This behavior occurs because of the ordering of the overloaded
functions in the debug info. So the first best match "won out" over the
a subsequent better match.
One of the bugs addressed by this patch is the failure of rank_one_type to
account for type equality of two overloads based on CV qualifiers. This was
leading directly to problems evaluating rvalue reference overload quality,
but it is also highlighted in gdb.cp/oranking.exp, where two test KFAIL as
a result of this shortcoming.
I found the overload resolution code committed with the rvalue reference
patch (
f9aeb8d49) needlessly over-complicated, and I have greatly simplified
it. This fixes some KFAILing tests in gdb.exp/rvalue-ref-overload.exp.
gdb/ChangeLog
* gdbtypes.c (LVALUE_REFERENCE_TO_RVALUE_BINDING_BADNESS)
DIFFERENT_REFERENCE_TYPE_BADNESS): Remove.
(CV_CONVERSION_BADNESS): Define.
(rank_one_type): Remove overly restrictive rvalue reference
rank checks.
Add cv-qualifier checks and subranks for type equality.
* gdbtypes.h (REFERENCE_CONVERSION_RVALUE,
REFERENCE_CONVERSION_CONST_LVALUE, CV_CONVERSION_BADNESS,
CV_CONVERSION_CONST, CV_CONVERSION_VOLATILE): Declare.
gdb/testsuite/ChangeLog
* gdb.cp/oranking.cc (test15): New function.
(main): Call test15 and declare additional variables for testing.
* gdb.cp/oranking.exp: Remove kfail status for "p foo4(&a)" and
"p foo101('abc')" tests.
* gdb.cp/rvalue-ref-overloads.exp: Remove kfail status for
"lvalue reference overload" test.
* gdb.cp/rvalue-ref-params.exp: Remove kfail status for
"print value of f1 on Child&& in f2" test.
H.J. Lu [Thu, 27 Apr 2017 22:24:08 +0000 (15:24 -0700)]
x86-64: Use "=" instead of "+=" to update 0
Use
if (htab->elf.splt->size == 0)
htab->elf.splt->size = GET_PLT_ENTRY_SIZE (output_bfd);
instead of
if (htab->elf.splt->size == 0)
htab->elf.splt->size += GET_PLT_ENTRY_SIZE (output_bfd);
* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Use "="
instead of "+=" to update 0.
Simon Marchi [Thu, 27 Apr 2017 21:03:20 +0000 (17:03 -0400)]
Add missing incref when creating Inferior Python object
The test py-inferior.exp fails when using a debug build of Python 3.6. I don't
see it failing with my system's default Python, but it might be related to the
different memory allocation scheme used when doing a build with pydebug.
The issue is that we are missing a Py_INCREF in
inferior_to_inferior_object. The PyObject_New function initializes the
object with a refcount of 1. If we assume that this refcount
corresponds to the reference we are returning, then we are missing an
incref for the reference in the inferior data.
The counterpart for the incref that corresponds to the reference in the
inferior data is in py_free_inferior, in the form the gdbpy_ref instance.
Here's how I can get it to crash (with some debug output):
$ ./gdb -nx -ex "set debug python 1"
(gdb) add-inferior
Added inferior 2
(gdb) python infs = gdb.inferiors()
Creating Python Inferior object inf = 1
Creating Python Inferior object inf = 2
(gdb) remove-inferiors 2
py_free_inferior inf = 2
infpy_dealloc inf = <unknown>
(gdb) python infs = None
Fatal Python error: Objects/tupleobject.c:243 object at 0x7f9cf1a568d8 has negative ref count -1
Current thread 0x00007f9cf1b68780 (most recent call first):
File "<string>", line 1 in <module>
[1] 408 abort (core dumped) ./gdb -nx -ex "set debug python 1"
After having created the inferiors object, their refcount is 1 (which
comes from PyObject_New), but it should be two. The gdb inferior object
has a reference and the "infs" list has a reference.
When invoking remove-inferiors, py_free_inferior gets called. It does
the decref that corresponds to the reference that the gdb inferior
object kept. At this moment, the refcount drops to 0 and the object
gets deallocated, even though the "infs" list still has a reference.
When we set "infs" to None, Python tries to decref the already zero
refcount and the assert triggers.
With this patch, it looks better:
(gdb) add-inferior
Added inferior 2
(gdb) python infs = gdb.inferiors()
Creating Python Inferior object inf = 1
Creating Python Inferior object inf = 2
(gdb) remove-inferiors 2
py_free_inferior inf = 2
(gdb) python infs = None
infpy_dealloc inf = <unknown>
gdb/ChangeLog:
* python/py-inferior.c (inferior_to_inferior_object): Increment reference
count when creating the object.
H.J. Lu [Thu, 27 Apr 2017 20:55:31 +0000 (13:55 -0700)]
x86: Create dynamic sections in create_dynamic_sections
This patch creates dynamic sections in i386/x86-64 create_dynamic_sections
instead of creating them on demend. Linker will strip them if they are
empty. It changes order in x86-64 .eh_frame section. The extra DW_CFA_nop
paddings is due to
https://sourceware.org/bugzilla/show_bug.cgi?id=21441
bfd/
* elf32-i386.c (elf_i386_create_dynamic_sections): Create the
.plt.got section here.
(elf_i386_check_relocs): Don't create the .plt.got section.
* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Create
the .plt.got and .plt.bnd sections here.
(elf_x86_64_check_relocs): Don't create the .plt.got nor
.plt.bnd sections.
ld/
* testsuite/ld-x86-64/pr21038a.d: Update DW_CFA_nop paddings
in .eh_frame section.
* testsuite/ld-x86-64/pr21038c.d: Update .eh_frame order.
H.J. Lu [Thu, 27 Apr 2017 16:32:35 +0000 (09:32 -0700)]
Remove has_bnd_reloc from elf_x86_64_link_hash_entry
has_bnd_reloc was added to elf_x86_64_link_hash_entry track BND
relocations by
commit
0ff2b86e7c14177ec7f9e1257f8e697814794017
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Nov 20 09:01:04 2013 -0800
Create the second PLT for BND relocations
Since BND relocations have been deprecated by
commit
d258b828287a863376af60a1ef7ceafbccc83d93
Author: Igor Zamyatin <igor.zamyatin@intel.com>
Date: Tue Nov 18 10:52:36 2014 +0300
Add -z bndplt to generate BND prefix in PLT entries
This patch removes has_bnd_reloc from elf_x86_64_link_hash_entry and
checks bndplt instead of has_bnd_reloc.
* elf64-x86-64.c (elf_x86_64_link_hash_entry): Remove
has_bnd_reloc.
(elf_x86_64_link_hash_newfunc): Don't clear has_bnd_reloc.
(elf_x86_64_copy_indirect_symbol): Don't copy has_bnd_reloc.
(elf_x86_64_check_relocs): Don't set has_bnd_reloc.
(elf_x86_64_finish_dynamic_symbol): Check bndplt instead of
has_bnd_reloc.
Remove has_bnd_reloc
H.J. Lu [Thu, 27 Apr 2017 16:07:23 +0000 (09:07 -0700)]
Change _bfd_elf_link_setup_gnu_properties to bfd *
Change setup_gnu_properties to return the first relocatable ELF input
with GNU properties so that a backend can make decision based on GNU
properties.
* elf-bfd.h (elf_backend_data): Change setup_gnu_properties
to return bfd *.
(_bfd_elf_link_setup_gnu_properties): Return bfd *.
* elf-properties.c (_bfd_elf_link_setup_gnu_properties): Return
the first relocatable ELF input with GNU properties.
H.J. Lu [Thu, 27 Apr 2017 15:55:36 +0000 (08:55 -0700)]
i386: Simplify VxWorks for non-PIC
Change
if (PIC)
{
#1
}
else
{
#2
if (VxWorks)
{
#3
}
}
#4
if (VxWorks && !PIC)
{
#5
}
to
#4
if (PIC)
{
#1
}
else
{
#2
if (VxWorks)
{
#3
#5
}
}
* elf32-i386.c (elf_i386_finish_dynamic_sections): Simplify
VxWorks for non-PIC.
Ulrich Weigand [Thu, 27 Apr 2017 13:57:08 +0000 (15:57 +0200)]
Read corrrect auxiliary entry in AIX
Fix handling of XCOFF function auxiliary entries, in particular when
the xlc -qfuncsect or gcc -ffunction-sections compiler option is used
in AIX. Also handle C_WEAKEXT storage class.
gdb/
2016-10-21 Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Ulrich Weigand <uweigand@de.ibm.com>
* xcoffread.c (read_xcoff_symtab): Read correct function auxiliary
entry if xlc -qfuncsect or gcc -ffunction-sections compiler option
is used in AIX.
(read_xcoff_symtab): Handle C_WEAKEXT storage class.
(process_xcoff_symbol): Likewise.
(scan_xcoff_symtab): Likewise.
Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Maciej W. Rozycki [Thu, 27 Apr 2017 01:25:33 +0000 (02:25 +0100)]
MIPS16/GAS: Factor out duplicate symbol value conversion code
Factor out and consolidate duplicate section-relative to PC-relative
symbol value conversion in `mips16_extended_frag' and `md_convert_frag'
used for MIPS16 relaxation, observing that the final calculation in the
latter function implies `stretch == 0'. Sanitize the formatting of code
moved.
gas/
* config/tc-mips.c (mips16_pcrel_val): New function, factored
out from...
(mips16_extended_frag): ... here.
(md_convert_frag): Use `mips16_pcrel_val' rather than repeated
code in MIPS16 relaxation, with `stretch' hardcoded to 0.
Maciej W. Rozycki [Thu, 27 Apr 2017 01:13:21 +0000 (02:13 +0100)]
MIPS16/GAS: Rename the LONG_BRANCH relaxation flag
Following commit
177b4a6ad004 ("infinite loop in mips16 assembler
relaxation"), <https://sourceware.org/ml/binutils/2002-03/msg00345.html>
the LONG_BRANCH flag used in MIPS16 relaxation has lost its use for
branches. Complement commit
88a7ef168927 ("MIPS16/GAS: Restore
unsupported relocation diagnostics") then, which has removed the remains
of code deactivated by the former commit, and rename the flag to
ALWAYS_EXTENDED, more accurately reflecting its current use to select
the extended form of PC-relative ADDIU, DADDIU, LD and LW instructions.
gas/
* config/tc-mips.c (RELAX_MIPS16_LONG_BRANCH): Rename to...
(RELAX_MIPS16_ALWAYS_EXTENDED): ... this.
(RELAX_MIPS16_MARK_LONG_BRANCH): Rename to...
(RELAX_MIPS16_MARK_ALWAYS_EXTENDED): ... this.
(RELAX_MIPS16_CLEAR_LONG_BRANCH): Rename to...
(RELAX_MIPS16_CLEAR_ALWAYS_EXTENDED): ... this.
(mips16_extended_frag): Adjust accordingly.
Alan Hayward [Thu, 27 Apr 2017 10:38:14 +0000 (11:38 +0100)]
Remove some MAX_REGISTER_SIZE uses in ia64-tdep.c
gdb/
* ia64-tdep.c (examine_prologue): Use get_frame_register_unsigned.
(ia64_sigtramp_frame_prev_register): Use read_memory_unsigned_integer.
(ia64_access_reg): Use get_frame_register_unsigned.
(ia64_access_rse_reg): Likewise.
(ia64_libunwind_frame_prev_register): Likewise.
Alan Modra [Thu, 27 Apr 2017 02:50:10 +0000 (12:20 +0930)]
Tidy S_FORCE_RELOC
Separate out symbol flag reasons from section reasons to force a
reloc. Yes, this adds another section test to the local symbol case
too.
* symbols.c (S_FORCE_RELOC): Separate section and symbol tests.
Alan Modra [Thu, 27 Apr 2017 02:33:39 +0000 (12:03 +0930)]
Constify elf_backend_eh_frame_address_size
* elf-bfd.h (struct elf_backend_data): Make asection param of
elf_backend_eh_frame_address_size const.
(_bfd_elf_eh_frame_address_size): Likewise.
* elf32-m32c.c (_bfd_m32c_elf_eh_frame_address_size): Likewise.
* elf32-msp430.c (elf32_msp430_eh_frame_address_size): Likewise.
* elfxx-mips.c (_bfd_mips_elf_eh_frame_address_size): Likewise.
* elfxx-mips.h (_bfd_mips_elf_eh_frame_address_size): Likewise.
* elf-eh-frame.c (_bfd_elf_eh_frame_address_size): Likewise.
(next_cie_fde_offset): Constify params.
(offset_adjust, adjust_eh_frame_local_symbols): Likewise.
Alan Modra [Thu, 27 Apr 2017 01:38:14 +0000 (11:08 +0930)]
Edit .eh_frame symbols
Experimental support for moving symbols defined in .eh_frame as their
CIEs/FDEs are edited or merged.
* elf-bfd.h (struct eh_cie_fde): Add aug_str_len and aug_data_len.
(_bfd_elf_adjust_eh_frame_global_symbol): Declare.
* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Set aug_str_len and
aug_data_len.
(offset_adjust): New function.
(_bfd_elf_adjust_eh_frame_global_symbol): Likewise.
(adjust_eh_frame_local_symbols): Likewise.
(_bfd_elf_discard_section_eh_frame): Call adjust_eh_frame_local_symbols
after changing anything. Return true if anything changed.
* elflink.c (bfd_elf_discard_info): If .eh_frame changed, call
_bfd_elf_adjust_eh_frame_global_symbol for globals.
Alan Modra [Thu, 27 Apr 2017 01:36:33 +0000 (11:06 +0930)]
Clear dynstr_index when forcing symbols local
This is really just cosmetic, but it does protect a little from
accidentally reading a stale value.
* elflink.c (_bfd_elf_link_hash_hide_symbol): Clear dynstr_index
when force_local.
Alan Modra [Wed, 26 Apr 2017 23:49:26 +0000 (09:19 +0930)]
PowerPC undefweak handling
This patch fixes a number of cases where -z nodynamic-undefined-weak
was not effective in preventing dynamic relocations or linkage stubs.
* elf32-ppc.c (UNDEFWEAK_NO_DYNAMIC_RELOC): Define.
(ppc_elf_select_plt_layout, ppc_elf_tls_setup): Use it.
(ppc_elf_adjust_dynamic_symbol, allocate_dynrelocs): Likewise.
(ppc_elf_relocate_section): Likewise. Delete silly optimisation
for undef and undefweak dyn_relocs.
* elf64-ppc.c (UNDEFWEAK_NO_DYNAMIC_RELOC): Define.
(ppc64_elf_adjust_dynamic_symbol, ppc64_elf_tls_setup): Use it.
(allocate_got, allocate_dynrelocs): Likewise.
(ppc64_elf_relocate_section): Likewise.
Alan Modra [Wed, 26 Apr 2017 23:38:09 +0000 (09:08 +0930)]
[GOLD] testsuite/plugin_section_order.c fix
* testsuite/plugin_section_order.c (onload): Add missing break.
GDB Administrator [Thu, 27 Apr 2017 00:00:56 +0000 (00:00 +0000)]
Automatic date update in version.in
Maciej W. Rozycki [Wed, 26 Apr 2017 23:47:15 +0000 (00:47 +0100)]
MIPS/GAS: Fix `.option picX' handling with relaxation
Correct the handling of `.option pic0' and `.option pic2' GAS pseudo-ops
in relaxation and use the setting of `mips_pic' (which these directives
control) as at the time a relaxed frag has been created rather than the
final `mips_pic' setting at the end of the source file processed.
To do so record whether `mips_pic' is NO_PIC or not in the frag itself
and use this information throughout relaxation instead of `mips_pic' to
decide which of NO_PIC or SVR4_PIC to produce machine code for, fixing
code generation and removing a possible fatal failure reproducible with:
$ as -32 --relax-branch -o option-pic-relax-3.o option-pic-relax-3.s
option-pic-relax-3.s: Assembler messages:
option-pic-relax-3.s:7: Warning: relaxed out-of-range branch into a jump
option-pic-relax-3.s: Internal error in cvt_frag_to_fill at .../gas/write.c:490.
Please report this bug.
$
using the test source included, due to a buffer overrun in filling the
variable part of a frag.
Likewise use the `fx_tcbit2' flag of a BFD_RELOC_16_PCREL_S2 fixup to
handle the simple case of substituting an out of range unconditional
branch with an equivalent absolute jump in NO_PIC code.
Retain the current way of VXWORKS_PIC use, which commit
41a1578ed17c
("MIPS/GAS: Sanitize `.option picX' pseudo-op") has forbidden the use of
`.option picX' with.
gas/
* config/tc-mips.c (RELAX_ENCODE): Add `PIC' flag.
(RELAX_PIC): New macro.
(RELAX_USE_SECOND, RELAX_SECOND_LONGER, RELAX_NOMACRO)
(RELAX_DELAY_SLOT, RELAX_DELAY_SLOT_16BIT)
(RELAX_DELAY_SLOT_SIZE_FIRST, RELAX_DELAY_SLOT_SIZE_SECOND):
Shift bits.
(RELAX_BRANCH_ENCODE): Add `pic' flag.
(RELAX_BRANCH_UNCOND, RELAX_BRANCH_LIKELY, RELAX_BRANCH_LINK)
(RELAX_BRANCH_TOOFAR): Shift bits.
(RELAX_BRANCH_PIC): New macro.
(RELAX_MICROMIPS_ENCODE): Add `pic' flag.
(RELAX_MICROMIPS_PIC): New macro.
(RELAX_MICROMIPS_UNCOND, RELAX_MICROMIPS_COMPACT)
(RELAX_MICROMIPS_LINK, RELAX_MICROMIPS_NODS)
(RELAX_MICROMIPS_RELAX32): Shift bits.
(relax_close_frag): Pass `mips_pic' setting to RELAX_ENCODE.
(append_insn): Pass `mips_pic' setting to RELAX_BRANCH_ENCODE
and RELAX_MICROMIPS_ENCODE, and record it in `fx_tcbit2' of the
first fixup created.
(md_apply_fix) <BFD_RELOC_16_PCREL_S2>: Use `fx_tcbit2' of the
fixup processed rather than `mips_pic' in choosing to relax an
out of range branch to a jump.
(relaxed_branch_length): Use the `pic' flag of the relaxed frag
rather than `mips_pic'.
(relaxed_micromips_32bit_branch_length): Likewise.
(md_estimate_size_before_relax): Likewise.
(md_convert_frag): Likewise.
* testsuite/gas/mips/option-pic-relax-0.d: New test.
* testsuite/gas/mips/option-pic-relax-1.d: New test.
* testsuite/gas/mips/option-pic-relax-2.d: New test.
* testsuite/gas/mips/option-pic-relax-3.d: New test.
* testsuite/gas/mips/option-pic-relax-3a.d: New test.
* testsuite/gas/mips/option-pic-relax-4.d: New test.
* testsuite/gas/mips/option-pic-relax-5.d: New test.
* testsuite/gas/mips/option-pic-relax-2.l: New stderr output.
* testsuite/gas/mips/option-pic-relax-3.l: New stderr output.
* testsuite/gas/mips/option-pic-relax-4.l: New stderr output.
* testsuite/gas/mips/option-pic-relax-5.l: New stderr output.
* testsuite/gas/mips/option-pic-relax-0.s: New test source.
* testsuite/gas/mips/option-pic-relax-1.s: New test source.
* testsuite/gas/mips/option-pic-relax-2.s: New test source.
* testsuite/gas/mips/option-pic-relax-3.s: New test source.
* testsuite/gas/mips/option-pic-relax-4.s: New test source.
* testsuite/gas/mips/option-pic-relax-5.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.
H.J. Lu [Wed, 26 Apr 2017 22:34:00 +0000 (15:34 -0700)]
x86: Add DT_PLTRELSZ/DT_PLTREL/DT_JMPREL for PLT relocation
x86, PLT relocation may contain R_386_TLS_DESC or R_X86_64_TLSDESC
even though there is no real PLT. We need to add DT_PLTRELSZ, DT_PLTREL
and DT_JMPREL if there is a .rel.plt/.rela.plt section.
bfd/
* elf32-i386.c (elf_i386_size_dynamic_sections): Alwasys add
DT_PLTRELSZ, DT_PLTREL and DT_JMPREL for .rel.plt section.
* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Alwasys
add DT_PLTRELSZ, DT_PLTREL and DT_JMPREL for .rela.plt section.
ld/
* testsuite/ld-i386/tlsdesc2.d: New test.
* testsuite/ld-x86-64/tlsdesc2.d: Likewise.
Nick Clifton [Wed, 26 Apr 2017 15:30:22 +0000 (16:30 +0100)]
Fix a seg-fault when processing a corrupt binary containing reloc(s) with negative addresses.
PR binutils/21434
* reloc.c (bfd_perform_relocation): Check for a negative address
in the reloc.
Nick Clifton [Wed, 26 Apr 2017 14:45:41 +0000 (15:45 +0100)]
Fix PR number in ChangeLog comment.
Nick Clifton [Wed, 26 Apr 2017 14:42:03 +0000 (15:42 +0100)]
Fix invocation of stat() on a NULL pointer.
PR binutils/21407
* bucomm.c (get_file_size): Return -1 if file_name is NULL.
* ar.c (main): Fail with usage() invocation if no file names are
provided.
Nick Clifton [Wed, 26 Apr 2017 13:23:26 +0000 (14:23 +0100)]
Improve decoding of corrupt/unrecognised gnu build attribute notes.
* readelf.c (process_section_headers): Warn about overlarge
sections.
(print_gnu_build_attribute_name): Print the number of unrecognised
note types. Fix formatting in the presence of errors.
(testsuite/binutils-all/note-2-32.s): Fix encoding of numeric notes.
(testsuite/binutils-all/note-2-64.s): Likewise.
Jiong Wang [Wed, 26 Apr 2017 13:05:03 +0000 (14:05 +0100)]
[gdbarch] New method "execute_dwarf_cfa_vendor_op" and migrate SPARC to it
Recently a feature called "return address signing" has been added to GCC to
prevent stack smash stack on AArch64. For details please refer:
https://gcc.gnu.org/ml/gcc-patches/2017-01/msg00376.html
GDB needs to be aware of this feature so it can restore the original return
address which is critical for unwinding.
On compiler side, whenever return address, i.e. LR register, is mangled or
restored by hardware instruction, compiler is expected to generate a
DW_CFA_AARCH64_negate_ra_state to toggle return address signing status.
DW_CFA_AARCH64_negate_ra_state is using the same CFI number and
therefore need to be multiplexed with DW_CFA_GNU_window_save which was designed
for SPARC.
A new gdbarch method "execute_dwarf_cfa_vendor_op" is introduced by this patch.
It's parameters has been restricted to those only needed by SPARC and AArch64
for multiplexing DW_CFA_GNU_window_save which is a CFI operation takes none
operand. Should any further DWARF CFI operation want to be multiplexed in the
future, the parameter list can be extended. Below is the current function
prototype.
typedef int (gdbarch_execute_dwarf_cfa_vendor_op_ftype)
(struct gdbarch *gdbarch, gdb_byte op, struct dwarf2_frame_state *fs);
DW_CFA_GNU_window_save support for SPARC is migrated to this new gdbarch
method by this patch.
gdb/
* gdbarch.sh: New gdbarch method execute_dwarf_cfa_vendor_op.
* gdbarch.c: Regenerated.
* gdbarch.h: Regenerated.
* dwarf2-frame.c (dwarf2_frame_state_alloc_regs): Made the
visibility external.
(execute_cfa_program): Call execute_dwarf_cfa_vendor_op for CFI
between DW_CFA_lo_user and DW_CFA_high_user inclusive.
(enum cfa_how_kind): Move to ...
(struct dwarf2_frame_state_reg_info): Likewise.
(struct dwarf2_frame_state): Likewise.
* dwarf2-frame.h: ... here.
(dwarf2_frame_state_alloc_regs): New declaration.
* sparc-tdep.c (sparc_execute_dwarf_cfa_vendor_op): New function.
(sparc32_gdbarch_init): Register execute_dwarf_cfa_vendor_op hook.
Maciej W. Rozycki [Mon, 24 Apr 2017 19:15:31 +0000 (20:15 +0100)]
PR ld/21334: Always call `_bfd_elf_link_renumber_dynsyms' if required
Complement commit
e17b0c351f0b ("MIPS/BFD: Respect the ELF gABI dynamic
symbol table sort requirement") and correct an inconsistency in dynamic
symbol accounting data causing an assertion failure in the MIPS backend:
ld: BFD (GNU Binutils) 2.28.51.
20170330 assertion fail
../../binutils-gdb/bfd/elfxx-mips.c:3860
in the course of making a GOT entry in a static binary to satisfy a GOT
relocation present in input, due to the local dynamic symbol count not
having been established.
To do so let backends request `_bfd_elf_link_renumber_dynsyms' to be
always called, rather than where a dynamic binary is linked only, and
then make this request in the MIPS backend.
bfd/
PR ld/21334
* elf-bfd.h (elf_backend_data): Add `always_renumber_dynsyms'
member.
* elfxx-target.h [!elf_backend_always_renumber_dynsyms]
(elf_backend_always_renumber_dynsyms): Define.
(elfNN_bed): Initialize `always_renumber_dynsyms' member.
* elfxx-mips.h (elf_backend_always_renumber_dynsyms): Define.
* elflink.c (bfd_elf_size_dynamic_sections): Also call
`_bfd_elf_link_renumber_dynsyms' if the backend has requested
it.
(bfd_elf_size_dynsym_hash_dynstr): Likewise.
ld/
PR ld/21334
* testsuite/ld-mips-elf/pr21334.dd: New test.
* testsuite/ld-mips-elf/pr21334.gd: New test.
* testsuite/ld-mips-elf/pr21334.ld: New test linker script.
* testsuite/ld-mips-elf/pr21334.s: New test source.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
Maciej W. Rozycki [Mon, 24 Apr 2017 19:13:28 +0000 (20:13 +0100)]
ELF/BFD: Limit `_bfd_elf_link_renumber_dynsyms' call in section GC
Consistently call `_bfd_elf_link_renumber_dynsyms' only if linking a
dynamic binary, complementing code in `bfd_elf_size_dynsym_hash_dynstr'
and commit
ccabcbe51e85 ("New attempt at fixing MIPS --gc-sections et
al."), <https://sourceware.org/ml/binutils/2005-08/msg00258.html>.
bfd/
* elflink.c (bfd_elf_size_dynamic_sections): Only call
`_bfd_elf_link_renumber_dynsyms' after section GC if dynamic
sections have been created.
Maciej W. Rozycki [Mon, 24 Apr 2017 19:41:33 +0000 (20:41 +0100)]
MIPS/readelf: With `-A' also dump GOT in static binaries
A static, non-relocated global offset table will be embedded in static
binaries produced from objects containing any kind of GOT relocations,
generally PIC code. All symbols will have been resolved in static link
in such binaries making all GOT entries local and their values final as
there is no run-time load processing further performed.
Dump such GOT with `readelf -A' like already done with regular GOT, to
make it easier to examine static code that uses accesses via the GOT
pointer. There will be no dynamic segment or section in a static binary
to get the GOT pointer (DT_PLTGOT) from, so use section headers to find
a `.got' section instead.
binutils/
* readelf.c (process_mips_specific): Add static GOT support.
Nick Clifton [Wed, 26 Apr 2017 12:07:49 +0000 (13:07 +0100)]
Fix seg-fault attempting to compress a debug section in a corrupt binary.
PR binutils/21431
* compress.c (bfd_init_section_compress_status): Check the return
value from bfd_malloc.
Alan Hayward [Wed, 26 Apr 2017 09:32:35 +0000 (10:32 +0100)]
xtensa_pseudo_register_read/write - Use regcache_raw_read_unsigned
gdb/
* xtensa-tdep.c (xtensa_pseudo_register_read): Use
regcache_raw_read_unsigned.
(xtensa_pseudo_register_write): Likewise.
Alan Hayward [Wed, 26 Apr 2017 08:57:15 +0000 (09:57 +0100)]
nds32: Abort instead of returning REG_UNKNOWN
gdb/
* nds32-tdep.c (nds32_pseudo_register_read): Abort on errors.
(nds32_pseudo_register_write): Likewise.
GDB Administrator [Wed, 26 Apr 2017 00:00:36 +0000 (00:00 +0000)]
Automatic date update in version.in
Yao Qi [Tue, 25 Apr 2017 20:32:05 +0000 (21:32 +0100)]
Change readonly_p to bool
This patch changes readonly_p type to bool.
gdb:
2017-04-25 Yao Qi <yao.qi@linaro.org>
* regcache.c (struct regcache) <readonly_p>: Change its type
to bool.
(regcache_xmalloc_1): Update parameter type and callers update.
Maciej W. Rozycki [Tue, 11 Apr 2017 23:03:41 +0000 (00:03 +0100)]
MIPS/readelf: Simplify GOT[1] data availability check
Unavailable data is handled gracefully in MIPS GOT processing done by
`print_mips_got_entry', so all that is needed in special GOT[1] handling
is to verify whether data can be retrieved for the purpose of the GNU
marker check done with `byte_get'. Remove the extra error reporting
code then, introduced with commit
75ec1fdbb797 ("Fix runtime seg-fault
in readelf when parsing a corrupt MIPS binary.") in the course of
addressing PR binutils/21344, and defer the error case to regular local
GOT entry processing.
binutils/
* readelf.c (process_mips_specific): Remove error reporting from
GOT[1] processing.
Maciej W. Rozycki [Tue, 11 Apr 2017 23:02:13 +0000 (00:02 +0100)]
MIPS/readelf: Remove extraneous null GOT data check
Null data is handled gracefully throughout in MIPS GOT processing, with
addresses printed normally and unavailable data shown as `<unknown>' by
`print_mips_got_entry', and special processing code for GOT[1] doing an
explicit check. Remove an unwanted null GOT data check then, introduced
with commit
592458412fb2 in the course of addressing PR binutils/12855.
binutils/
* readelf.c (process_mips_specific): Remove null GOT data check.
Claudiu Zissulescu [Tue, 25 Apr 2017 15:07:00 +0000 (17:07 +0200)]
[ARC] Enhance enter/leave mnemonics.
enter/leave mnemonics are enhanced to not only accept register ranges
but also single register (i.e., r13) or even no GPR register at all.
gas/
2017-04-25 Claudiu Zissulescu <claziss@synopsys.com>
* testsuite/gas/arc/leave_enter.d: Update test.
* testsuite/gas/arc/leave_enter.s: Likewise.
opcodes/
2017-04-25 Claudiu Zissulescu <claziss@synopsys.com>
* arc-dis.c (print_insn_arc): Smartly print enter/leave mnemonics.
* arc-opc.c (insert_r13el): New function.
(R13_EL): Define.
* arc-tbl.h: Add new enter/leave variants.
Claudiu Zissulescu [Tue, 25 Apr 2017 15:07:00 +0000 (17:07 +0200)]
[ARC] Prefer NOP instead of MOV 0,0
NOP and MOV 0,0 are having the same encoding. As MOV mnemonic is
located before NOP in the instruction table, the disassembler prints
MOV 0,0 for NOP. Reorder the instructions such that NOP is first.
gas/
2017-04-25 Claudiu Zissulescu <claziss@synopsys.com>
* testsuite/gas/arc/b.d: Update test.
* testsuite/gas/arc/noargs_hs.d: Likewise.
opcode/
2017-04-25 Claudiu Zissulescu <claziss@synopsys.com>
* arc-tbl.h: Reorder NOP entry to be before MOV instructions.