Simon Marchi [Sat, 21 Oct 2017 14:15:48 +0000 (10:15 -0400)]
Remove leftover declarations in interps.h
The corresponding definitions have already been removed.
gdb/ChangeLog:
* interps.h (interp_resume, interp_suspend, interp_set_temp):
Remove declarations.
GDB Administrator [Sat, 21 Oct 2017 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in
Sriraman Tallam [Fri, 20 Oct 2017 18:21:45 +0000 (11:21 -0700)]
Fix ChangeLog entry.
Sriraman Tallam [Fri, 20 Oct 2017 18:00:28 +0000 (11:00 -0700)]
New gold linker option -z,text-unlikely-segment.
2017-10-04 Sriraman Tallam <tmsriram@google.com>
* options.h (-z,text_unlikely_segment): New option.
* layout.cc (Layout::layout): Create new output section
for .text.unlikely sections with the new option.
(Layout::segment_precedes): Check for the new option
when segment flags match.
* testsuite/text_unlikely_segment.cc: New test source.
* testsuite/text_unlikely_segment.sh: New test script.
* testsuite/Makefile.am (text_unlikely_segment): New test.
* testsuite/Makefile.in: Regenerate.
H.J. Lu [Fri, 20 Oct 2017 16:47:08 +0000 (09:47 -0700)]
Add a compile-time test for PR ld/22269
This compile-time test requires a target C compiler to run. It fails
on many targets where ELF backend linkers fail to check undefined weak
symbol in static PIE via UNDEFWEAK_NO_DYNAMIC_RELOC.
PR ld/22269
* testsuite/ld-elf/pr22269-1.rd: New file.
* testsuite/ld-elf/pr22269-1.c: Likewise.
* testsuite/ld-elf/shared.exp: Run pr22269-1.
Tom Tromey [Sun, 15 Oct 2017 17:31:46 +0000 (11:31 -0600)]
Use std::vector in gdb_bfd_data
This changes gdb_bfd_data to use std::vector rather than VEC.
ChangeLog
2017-10-20 Tom Tromey <tom@tromey.com>
* gdb_bfd.c (struct gdb_bfd_data) <included_bfds>: Now a
std::vector.
(gdb_bfd_record_inclusion): Update.
(bfdp): Remove typedef.
Tom Tromey [Sun, 15 Oct 2017 17:23:22 +0000 (11:23 -0600)]
Use "new" to allocate gdb_bfd_data
This changes gdb_bfd_data to be allocated with new and destroyed with
delete.
ChangeLog
2017-10-20 Tom Tromey <tom@tromey.com>
* gdb_bfd.c (gdb_bfd_ref): Use new.
(struct gdb_bfd_data): Add constructor, destructor, and member
initializers.
(gdb_bfd_unref): Use delete.
Tom Tromey [Sun, 15 Oct 2017 17:13:29 +0000 (11:13 -0600)]
Introduce new_bfd_ref
This introduces a helper function, new_bfd_ref, that calls gdb_bfd_ref
and returns a gdb_bfd_ref_ptr. Then it updates several places to use
this.
ChangeLog
2017-10-20 Tom Tromey <tom@tromey.com>
* exec.c (exec_file_attach): Use new_bfd_ref.
* symfile-mem.c (symbol_file_add_from_memory): Use new_bfd_ref.
* gdb_bfd.c (gdb_bfd_open, gdb_bfd_fopen, gdb_bfd_openr)
(gdb_bfd_openw, gdb_bfd_openr_iovec, gdb_bfd_fdopenr): Use
new_bfd_ref.
* gdb_bfd.h (new_bfd_ref): New function.
Pedro Alves [Fri, 20 Oct 2017 14:33:57 +0000 (15:33 +0100)]
Fix 'gdb.base/quit.exp hangs forever' if the test fails
The [wait -i $gdb_spawn_id] in the test is dangerous in the sense that
it won't be subject to timeout logic. So if GDB fails quiting, this
testcase hangs forever, hanging the test run with it. See:
https://sourceware.org/ml/gdb-patches/2016-10/msg00728.html
Instead of 'wait'ing directly, use gdb_test_multiple and expect 'eof'.
Tested that the testcase no longer hangs by hacking the test to send
"info threads" instead of "quit".
Tested with
--target_board={unix, native-gdbserver,native-extended-gdbserver}
and tested with
--host_board=local-remote-host
as well.
gdb/testsuite/ChangeLog:
2017-10-20 Pedro Alves <palves@redhat.com>
* gdb.base/quit.exp: Use gdb_test_multiple and expect 'eof' before
'wait -i'. Use gdb_assert and remote_close.
Pedro Alves [Fri, 20 Oct 2017 13:47:24 +0000 (14:47 +0100)]
Fix gdb.gdb/ selftest tests when testing optimized GDB builds
After commit
bf4692711232 ("Eliminate catch_errors"), GCC started
inlining captured_command_loop in captured_main. And setting a
breakpoint on captured_command_loop makes the inferior GDB stop in
captured_main, _after_ captured_command_loop's call to
interp_pre_command_loop, which prints the inferior GDB's prompt, has
already executed, confusing the gdb.gdb/ selftest tests:
(gdb) FAIL: gdb.gdb/complaints.exp: run until breakpoint at captured_command_loop
WARNING: Couldn't test self
Debugging GDB with GDB manually, we see:
(top-gdb) b captured_command_loop
Breakpoint 1 at 0x71ee60: file src/gdb/main.c, line 324.
(top-gdb) r
[....]
(gdb) <<<<<< PROMPT HERE
Thread 1 "gdb" hit Breakpoint 1, captured_main (data=<optimized out>) at src/gdb/main.c:1147
1147 captured_command_loop ();
(top-gdb)
Note the stop at 'captured_main', and the "PROMPT HERE" line. That
prompt does not show up when debugging a non-optimized build of GDB.
Fix this by preventing inlining of captured_command_loop.
Ref: https://sourceware.org/ml/gdb-patches/2017-10/msg00522.html
gdb/ChangeLog:
2017-10-20 Pedro Alves <palves@redhat.com>
* main.c (captured_command_loop): Add attribute noinline.
Nick Clifton [Fri, 20 Oct 2017 10:45:19 +0000 (11:45 +0100)]
Improve handling of REPT pseudo op with a negative count.
PR 22324
* read.c (s_rept): Use size_t type for count parameter.
(do_repeat): Change type of count parameter to size_t.
Issue an error is the count parameter is negative.
(do_repeat_with_expression): Likewise.
* read.h: Update prototypes for do_repeat and
do_repeat_with_expression.
* doc/as.texinfo (Rept): Document that a zero count is allowed but
negative counts are not.
* config/tc-rx.c (rx_rept): Use size_t type for count parameter.
* config/tc-tic54x.c (tic54x_loop): Cast count parameter to size_t
type.
* testsuite/gas/macros/end.s: Add a test using a negative repeat
count.
* testsuite/gas/macros/end.l: Add expected error message.
Umesh Kalappa [Fri, 20 Oct 2017 03:53:14 +0000 (20:53 -0700)]
Implement BE8 support for ARM.
gold/
* arm.cc (Stub::do_fixed_endian_write):Far call stubs support for arm
in the be8 mode.
* testsuite/Makefile.am: New test cases.
* testsuite/Makefile.in: Regenerate.
* testsuite/arm_farcall_arm_arm_be8.sh: New script for arm to arm far
call stubs.
* testsuite/arm_farcall_thumb_thumb_be8.sh: New script for thumb to
thumb far call stubs.
Simon Marchi [Fri, 20 Oct 2017 02:07:15 +0000 (22:07 -0400)]
Get rid of VEC(interp_factory_p)
Replace it with an std::vector.
gdb/ChangeLog:
* interps.c (struct interp_factory): Add constructor.
(interp_factory_p): Remove typedef.
(DEF_VEC_P(interp_factory_p)): Remove.
(interpreter_factories): Change type to std::vector.
(interp_factory_register): Adjust.
(interp_lookup): Adjust.
(interpreter_completer): Adjust.
GDB Administrator [Fri, 20 Oct 2017 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Mon, 16 Oct 2017 23:36:32 +0000 (17:36 -0600)]
Remove cleanups from break-catch-syscall.c
This removes the remaining cleanups from break-catch-syscall.c by
storing temporary strings in a vector.
ChangeLog
2017-10-19 Tom Tromey <tom@tromey.com>
* break-catch-syscall.c (catch_syscall_completer): Use
std::string, gdb::unique_xmalloc_ptr.
Tom Tromey [Mon, 16 Oct 2017 23:27:21 +0000 (17:27 -0600)]
Remove cleanup from call_function_by_hand_dummy
This changes call_function_by_hand_dummy to use std::string, removing
a cleanup.
ChangeLog
2017-10-19 Tom Tromey <tom@tromey.com>
* infcall.c (call_function_by_hand_dummy): Use std::string.
Tom Tromey [Mon, 16 Oct 2017 23:26:09 +0000 (17:26 -0600)]
Remove cleanups from prepare_execute_command
This changes prepare_execute_command to return a scoped_value_mark
rather than a cleanup.
ChangeLog
2017-10-19 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (mi_cmd_execute): Update.
* top.h (prepare_execute_command): Return scoped_value_mark.
* value.h (class scoped_value_mark): Use DISABLE_COPY_AND_ASSIGN.
Add move constructor.
* top.c (prepare_execute_command): Return scoped_value_mark.
(execute_command): Update.
Andrew Burgess [Fri, 13 Oct 2017 14:22:17 +0000 (15:22 +0100)]
gdb: Remove hard-coded line number from test
Removes the use of a hard-coded line number from a test.
gdb/testsuite/ChangeLog:
* gdb.linespec/ls-errs.exp (do_test): Update comment, use line
number from variable rather than hard-coded.
Pedro Alves [Thu, 19 Oct 2017 17:12:03 +0000 (18:12 +0100)]
Fix build breakage in gdb/xml-support.c
The buildbots are showing that the previous change to
xml_fetch_content_from_file causes __wur warnings/errors:
../../binutils-gdb/gdb/xml-support.c: In function gdb::unique_xmalloc_ptr<char> xml_fetch_content_from_file(const char*, void*):
../../binutils-gdb/gdb/xml-support.c:1028:43: error: ignoring return value of size_t fread(void*, size_t, size_t, FILE*), declared with attribute warn_unused_result [-Werror=unused-result]
fread (text.get (), 1, len, file.get ());
^
This commit fixes it.
gdb/ChangeLog:
2017-10-19 Pedro Alves <palves@redhat.com>
* xml-support.c (xml_fetch_content_from_file): Check fread's
return.
Palmer Dabbelt [Fri, 19 May 2017 01:13:09 +0000 (18:13 -0700)]
RISC-V: Relax RISCV_PCREL_* to RISCV_GPREL_*
In the medany code model the compiler generates PCREL_HI20+PCREL_LO12
relocation pairs against local symbols because HI20+LO12 relocations
can't reach high addresses. We relax HI20+LO12 pairs to GPREL
relocations when possible, which is an important optimization for
Dhrystone. Without this commit we are unable to relax
PCREL_HI20+PCREL_LO12 pairs to GPREL when possible, causing a 10%
permormance hit on Dhrystone on Rocket.
Note that we'll now relax
la gp, __global_pointer$
to
mv gp, gp
which probably isn't what you want in your entry code. Users who want
gp-relative symbols to continue to resolve should add ".option norelax"
accordingly. Due to this, the assembler now pairs PCREL relocations
with RELAX relocations when they're expected to be relaxed just like
every other relaxable relocation.
bfd/ChangeLog
2017-10-19 Palmer Dabbelt <palmer@dabbelt.com>
* elfnn-riscv.c (riscv_pcgp_hi_reloc): New structure.
(riscv_pcgp_lo_reloc): Likewise.
(riscv_pcgp_relocs): Likewise.
(riscv_init_pcgp_relocs): New function.
(riscv_free_pcgp_relocs): Likewise.
(riscv_record_pcgp_hi_reloc): Likewise.
(riscv_record_pcgp_lo_reloc): Likewise.
(riscv_delete_pcgp_hi_reloc): Likewise.
(riscv_use_pcgp_hi_reloc): Likewise.
(riscv_record_pcgp_lo_reloc): Likewise.
(riscv_find_pcgp_lo_reloc): Likewise.
(riscv_delete_pcgp_lo_reloc): Likewise.
(_bfd_riscv_relax_pc): Likewise.
(_bfd_riscv_relax_section): Handle R_RISCV_PCREL_* relocations
via the new functions above.
gas/ChangeLog
2017-10-19 Palmer Dabbelt <palmer@dabbelt.com>
* config/tc-riscv.c (md_apply_fix): Mark
BFD_RELOC_RISCV_PCREL_HI20 as relaxable when relaxations are
enabled.
Palmer Dabbelt [Fri, 19 May 2017 01:08:25 +0000 (18:08 -0700)]
RISC-V: Add R_RISCV_DELETE, which marks bytes for deletion
We currently delete bytes by shifting an entire BFD backwards to
overwrite the bytes we no longer need. The result is that relaxing a
BFD is quadratic time.
This patch adds an additional relocation that specifies a byte range
that will be deleted from the final object file, and adds a relaxation
pass (between the existing passes that delete bytes and the alignment
pass) that actually deletes the bytes. Note that deletion is still
quadratic time, and nothing uses R_RISCV_DELETE yet.
I've been meaning to go convert all the other relaxations to use
R_RISCV_DELETE and then make it faster, but this patch has been sitting
around for months so it looks like that won't happen for a bit. The
PCREL->GPREL relaxation that comes next uses this, and since we've been
using these two patches out of tree since I wrote them months ago I
figure it's better to just get them in now. I (or someone else :)) can
convert all the relocations later...
R_RISCV_DELETE will never be emitted into ELF objects, so therefor isn't
exposed to the rest of binutils. As such, we're not considering this as
part of the ABI.
bfd/ChangeLog
2017-10-19 Palmer Dabbelt <palmer@dabbelt.com>
* elfnn-riscv (R_RISCV_DELETE): New define.
(_bfd_riscv_relax_delete): New function.
(perform_relocation): Handle R_RISCV_DELETE.
(_bfd_riscv_relax_section): Likewise.
ld/ChangeLog
2017-10-19 Palmer Dabbelt <palmer@dabbelt.com>
* emultempl/riscvelf.em (riscv_elf_before_allocation): Add a
third relaxation pass.
Nick Clifton [Thu, 19 Oct 2017 15:21:51 +0000 (16:21 +0100)]
Fix the AVR assembler so that it will correctly issue warnings about skipped instructions even if subsections are used.
PR 21621
* config/tc-avr.h (struct avr_frag_data): Add prev_opcode field.
(TC_FRAG_INIT): Define.
(avr_frag_init): Add prototype.
* config/tc-avr.c (avr_frag_init): New function.
(avr_operands): Replace static local 'prev' variable with
prev_opcode field in current frag.
* testsuite/gas/avr/pr21621.s: New test source file.
* testsuite/gas/avr/pr21621.d: New test driver file.
* testsuite/gas/avr/pr21621.s: New test error output file.
Pedro Alves [Thu, 19 Oct 2017 15:00:21 +0000 (16:00 +0100)]
Fix inferior deadlock with "target remote | CMD"
Comparing test results between
--target_board=native-gdbserver
--target_board=native-stdio-gdbserver
I noticed that gdb.base/bigcore.exp is failing with native-stdio-gdbserver:
Running src/gdb/testsuite/gdb.base/bigcore.exp ...
FAIL: gdb.base/bigcore.exp: continue (timeout)
...
The problem is that:
1. When debugging with "target remote | CMD", the inferior's
stdout/stderr streams are connected to a pipe.
2. The bigcore.c program prints a lot to the screen before it
reaches the breakpoint location that the "continue" shown above
wants to reach.
3. GDB is not flushing the inferior's output pipe while the inferior
is running.
4. The pipe becomes full.
5. The inferior thus deadlocks.
The bug is #3 above, which is what this commit fixes. A new test is
added, that specifically exercises this scenario. The test fails
before the fix, and passes after, and gdb.base/bigcore.exp also starts
passing.
gdb/ChangeLog:
2017-10-19 Pedro Alves <palves@redhat.com>
* ser-base.c (ser_base_read_error_fd): Delete the file handler if
async.
(handle_error_fd): New function.
(ser_base_async): Add/delete an event loop file handler for
error_fd.
gdb/testsuite/ChangeLog:
2017-10-19 Pedro Alves <palves@redhat.com>
* gdb.base/long-inferior-output.c: New file.
* gdb.base/long-inferior-output.exp: New file.
Pedro Alves [Thu, 19 Oct 2017 14:25:59 +0000 (15:25 +0100)]
xml_fetch_content_from_file: Read in whole file in one go
There doesn't seem to be a good reason we're reading the file one
chunk at a time.
gdb/ChangeLog:
2017-10-19 Pedro Alves <palves@redhat.com>
* xml-support.c (xml_fetch_content_from_file): Don't read in
chunks. Instead use fseek to determine the file's size, and read
it in one go.
H.J. Lu [Thu, 19 Oct 2017 12:22:23 +0000 (05:22 -0700)]
tilegx: Check bfd_link_executable for TLS check
Copied from x86, check bfd_link_executable, instead of bfd_link_pic,
for TLS transition check. Not sure if it works correctly. All usages
of bfd_link_pic should be audited.
PR ld/22263
* elfxx-tilegx.c (tilegx_elf_tls_transition): Replace
bfd_link_pic with !bfd_link_executable, !bfd_link_pic with
bfd_link_executable for TLS check.
(tilegx_elf_check_relocs): Likewise.
(allocate_dynrelocs): Likewise.
(tilegx_elf_relocate_section): Likewise.
H.J. Lu [Thu, 19 Oct 2017 12:20:44 +0000 (05:20 -0700)]
tilepro: Check bfd_link_executable for TLS check
Copied from x86, check bfd_link_executable, instead of bfd_link_pic,
for TLS transition check. Not sure if it works correctly. All usages
of bfd_link_pic should be audited.
PR ld/22263
* elf32-tilepro.c (tilepro_elf_tls_transition): Replace
bfd_link_pic with !bfd_link_executable, !bfd_link_pic with
bfd_link_executable for TLS check.
(tilepro_elf_check_relocs): Likewise.
(allocate_dynrelocs): Likewise.
(tilepro_elf_relocate_section): Likewise.
H.J. Lu [Thu, 19 Oct 2017 12:18:07 +0000 (05:18 -0700)]
sparc: Check bfd_link_executable for TLS check
Copied from x86, check bfd_link_executable, instead of bfd_link_pic,
for TLS transition check. Not sure if it works correctly. All usages
of bfd_link_pic should be audited.
PR ld/22263
* elfxx-sparc.c (sparc_elf_tls_transition): Replace
bfd_link_pic with !bfd_link_executable, !bfd_link_pic with
bfd_link_executable for TLS check.
(_bfd_sparc_elf_check_relocs): Likewise.
(allocate_dynrelocs): Likewise.
(_bfd_sparc_elf_relocate_section): Likewise.
Andreas Krebbel [Thu, 19 Oct 2017 07:02:15 +0000 (09:02 +0200)]
Fix fill-1 testcase
This fixes various issues with the fill-1 testcase causing fails on a
couple of targets.
gas/ChangeLog:
2017-10-19 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* testsuite/gas/all/fill-1.s: Use normal labels. Change .text to
.data. Pick different values. Use .dc.w instead of .word.
* testsuite/gas/all/fill-1.d: New objdump output check.
* testsuite/gas/all/gas.exp: Use run_dump_test to execute fill-1
testcase.
GDB Administrator [Thu, 19 Oct 2017 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Wed, 18 Oct 2017 22:46:57 +0000 (15:46 -0700)]
tile: Mark __tls_get_addr in gc_mark_hook
TLS_GD_CALL relocations implicitly reference __tls_get_addr. Since
elf_gc_mark_hook is called before check_relocs now, we need to call
_bfd_generic_link_add_one_symbol to mark __tls_get_addr for garbage
collection.
* elf32-tilepro.c (tilepro_elf_gc_mark_hook): Call
_bfd_generic_link_add_one_symbol to mark __tls_get_addr.
* elfxx-tilegx.c (tilegx_elf_gc_mark_hook): Likewise.
Palmer Dabbelt [Tue, 17 Oct 2017 17:51:38 +0000 (10:51 -0700)]
RISC-V: Mark unsupported gas testcases
There are individual comments that explain why each test isn't
supported, but the vast majority of them are due to RISC-V's aggressive
linker relaxation. The SLEB test cases should eventually be supported,
but the remaining ones probably won't ever be.
2017-10-18 Palmer Dabbelt <palmer@dabbelt.com>
* testsuite/gas/all/align.d: Mark as unsupported on RISC-V.
testsuite/gas/all/relax.d: Likewise.
testsuite/gas/all/sleb128-2.d: Likewise.
testsuite/gas/all/sleb128-4.d: Likewise.
testsuite/gas/all/sleb128-5.d: Likewise.
testsuite/gas/all/sleb128-7.d: Likewise.
testsuite/gas/elf/section11.d: Likewise.
testsuite/gas/all/gas.exp (diff1.s): Likewise.
Keith Seitz [Wed, 18 Oct 2017 18:05:45 +0000 (11:05 -0700)]
Canonicalize conversion operators
Consider a conversion operator such as:
operator foo const* const* ();
There are two small parser problems, highlighted by this test:
(gdb) p operator foo const* const*
There is no field named operatorfoo const* const *
GDB is looking up the symbol "operatorfoo const* const*" -- it is missing a
space between the keyword "operator" and the type name "foo const* const*".
Additionally, this input of the user-defined type needs to be canonicalized
so that different "spellings" of the type are recognized:
(gdb) p operator const foo* const *
There is no field named operator const foo* const *
gdb/ChangeLog:
* c-exp.y (oper): Canonicalize conversion operators of user-defined
types.
Add whitespace to front of type name.
gdb/testsuite/ChangeLog:
* gdb.cp/cpexprs.cc (base) <operator fluff const* const*>: New
method.
(main): Call it.
* gdb.cp/cpexprs.exp: Add new conversion operator to test matrix.
Add additional user-defined conversion operator tests.
Keith Seitz [Tue, 17 Oct 2017 21:15:36 +0000 (14:15 -0700)]
Issue complaint instead of assert for invalid/unhandled DW_AT_accessibility
A previous patch called gdb_assert_not_reached whenever reading
the accessibility of a nested typedef definition. Wisely, Pedro has asked me
not do this.
This patch changes the previous one so that it issues a complaint instead.
gdb/ChangeLog:
* dwarf2read.c (dwarf2_add_typedef): Issue a complaint on unhandled
DW_AT_accessibility.
Eric Botcazou [Wed, 18 Oct 2017 14:30:24 +0000 (16:30 +0200)]
[Visium] Disassemble the operands of the stop instruction.
binutils/
* MAINTAINERS: Add myself as Visium maintainer.
opcodes/
* visium-dis.c (disassem_class1) <case 0>: Print the operands.
Nick Clifton [Wed, 18 Oct 2017 14:07:36 +0000 (15:07 +0100)]
Update Cris assembler tests for checks that now pass where they used to fail.
PR gas/22304
* testsuite/gas/cris/range-err-1.s: Remove spurious xfails.
* testsuite/gas/cris/cris.exp: Expect the shexpr-1 test to pass.
Nick Clifton [Wed, 18 Oct 2017 13:50:49 +0000 (14:50 +0100)]
Update the Swedish translation in the GAS subdirectory.
* po/sv.po: Updated Swedish translation.
Nick Clifton [Wed, 18 Oct 2017 13:40:06 +0000 (14:40 +0100)]
Add a warning to the how-to-make-a-release notes to check the permissions on the files in the tarball.
* README-how-to-make-a-release: A note about checking file and
directory permissions.
Nick Clifton [Wed, 18 Oct 2017 13:36:48 +0000 (14:36 +0100)]
Move Svein Seldal to Past Maintainers section.
* MAINTAINERS: Move Svein Seldal to Past Maintainers section.
Yao Qi [Wed, 18 Oct 2017 11:48:12 +0000 (12:48 +0100)]
Remove features/tic6x-c62x-linux.c
c40c7bf (Remove features/tic6x-*.c files) doesn't remove
features/tic6x-c62x-linux.c. This patch removes it.
gdb:
2017-10-18 Yao Qi <yao.qi@linaro.org>
* features/tic6x-c62x-linux.c: Remove.
Alan Modra [Wed, 18 Oct 2017 01:35:39 +0000 (12:05 +1030)]
PR22303, print_core_note out of bounds read
The print_core_note change here fixes the PR, the rest is making
readelf a little more bombproof against maliciously crafted binaries.
PR 22303
* readelf.c (print_core_note): Ensure "count" sanity check
calculation doesn't overflow.
(process_notes_at): Perform note namesz and descsz checks
using unsigned comparisons against data remaining. Catch
alignment overflow of namesz and descsz too. Don't allocate a
temp for terminating "name" when there is space available
before descdata.
H.J. Lu [Wed, 18 Oct 2017 00:15:02 +0000 (17:15 -0700)]
microblaze: Check for indirect and warning symbols
Relocations against indirect and warning symbols should be applied to real
symbols.
* elf32-microblaze.c (microblaze_elf_check_relocs): Check for
indirect and warning symbols.
GDB Administrator [Wed, 18 Oct 2017 00:00:29 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Tue, 17 Oct 2017 14:03:05 +0000 (00:33 +1030)]
[GOLD] Fix powerpc64 optimization of TOC accesses
Fixes a thinko. Given code that puts variables into the TOC (a bad
idea, but some see the TOC as a small data section) this bug could
result in an attempt to optimize a sequence that should not be
optimized.
* powerpc.cc (Target_powerpc::Scan::local): Correct dst_off
calculation for TOC16 relocs.
(Target_powerpc::Scan::global): Likewise.
Pedro Alves [Tue, 17 Oct 2017 18:45:35 +0000 (19:45 +0100)]
Really make the native-stdio-gdbserver board non-remote
I've noticed now that due to a last-minute change, commit
739b3f1d8ff7
("Make native gdbserver boards no longer be "remote" (in DejaGnu
terms)") managed to miss loading "local-board" in the
native-stdio-gdbserver board...
gdb/testsuite/ChangeLog:
2017-10-17 Pedro Alves <palves@redhat.com>
* boards/native-stdio-gdbserver.exp: Load "local-board".
Tom Tromey [Tue, 17 Oct 2017 15:37:33 +0000 (09:37 -0600)]
Add myself as dwarf-mode.el maintainer
In https://sourceware.org/ml/binutils/2017-10/msg00160.html, Nick said I
should update MAINTAINERS to mention that I'm the dwarf-mode.el
maintainer. So, I'm checking this in.
2017-10-17 Tom Tromey <tom@tromey.com>
* MAINTAINERS: Add myself as dwarf-mode.el maintainer.
Pedro Alves [Tue, 17 Oct 2017 13:58:54 +0000 (14:58 +0100)]
Add several "quit with live inferior" tests
In my multi-target branch, I had managed to break GDB exiting
successfuly in response to "quit" or SIGHUP/SIGTERM when:
- you're debugging with "target extended-remote",
- have more than one inferior loaded in gdb, some running, and at
least one not running, and,
- quit gdb with the inferior that is not running yet selected.
The testsuite still passed cleanly anyway. I only noticed because I
was left with a bunch of core dumps in the gdb/testsuite/ directory --
the testsuite infrastructure closes GDB's pty after running each
testcase, which results in GDB getting a SIGHUP and should make GDB
exit gracefully. If GDB crashes at that point though, there's no
indication about it in gdb.sum/gdb.log.
This commit adds a multitude of tests exercising quitting GDB with
live inferiors, some of which would have caught the problem.
gdb/testsuite/ChangeLog:
2017-10-17 Pedro Alves <palves@redhat.com>
* gdb.base/quit-live.c: New file.
* gdb.base/quit-live.exp: New file.
Tom Tromey [Thu, 12 Oct 2017 21:07:35 +0000 (15:07 -0600)]
Remove cleanups from disasm.c
This changes the remaining spots in disasm.c to use the RAII ui-out
emitters, removing a few cleanups. This also fixes a regression that
Simon pointed out.
2017-10-17 Tom Tromey <tom@tromey.com>
* disasm.c (do_mixed_source_and_assembly_deprecated): Use
gdb::optional, ui_out_emit_list, ui_out_emit_tuple.
(do_mixed_source_and_assembly): Likewise.
Tom Tromey [Tue, 17 Oct 2017 12:40:22 +0000 (06:40 -0600)]
Remove obsolete assertion from regcache.c
When building I got:
../../binutils-gdb/gdb/regcache.c:935:24: error: the address of ‘ssize_t read(int, void*, size_t)’ will never be NULL [-Werror=address]
This happens because "read" used to be a parameter to this function,
which was then removed; but the assertion wasn't updated.
I don't think the assertion is relevant any more, to this removes it.
I'm checking it in as obvious.
2017-10-17 Tom Tromey <tom@tromey.com>
* regcache.c (regcache::xfer_part): Remove assertion.
Alan Modra [Tue, 17 Oct 2017 11:27:29 +0000 (21:57 +1030)]
PR22307, Heap out of bounds read in _bfd_elf_parse_gnu_properties
When adding an unbounded increment to a pointer, you can't just check
against the end of the buffer but also must check that overflow
doesn't result in "negative" pointer movement. Pointer comparisons
are signed. Better, check the increment against the space left using
an unsigned comparison.
PR 22307
* elf-properties.c (_bfd_elf_parse_gnu_properties): Compare datasz
against size left rather than comparing pointers. Reorganise loop.
Pedro Alves [Tue, 17 Oct 2017 11:41:00 +0000 (12:41 +0100)]
Fix double-free corruption
Fixes a double-free regression introduced by commit
b7b030adc405
("Return unique_xmalloc_ptr from target_read_stralloc"):
gdb.sum:
Running src/gdb/testsuite/gdb.base/catch-syscall.exp ...
ERROR: Process no longer exists
Valgrind shows:
(gdb) catch syscall
==3687== Thread 1:
==3687== Invalid free() / delete / delete[] / realloc()
==3687== at 0x4C29CF0: free (vg_replace_malloc.c:530)
==3687== by 0x610862: xfree(void*) (common-utils.c:101)
==3687== by 0x440D5D: gdb::xfree_deleter<char>::operator()(char*) const (gdb_unique_ptr.h:34)
==3687== by 0x446CC6: std::unique_ptr<char, gdb::xfree_deleter<char> >::reset(char*) (unique_ptr.h:344)
==3687== by 0x81BE50: xml_fetch_content_from_file(char const*, void*) (xml-support.c:1042)
==3687== by 0x81DA86: xml_init_syscalls_info(char const*) (xml-syscall.c:366)
==3687== by 0x81DBDD: init_syscalls_info(gdbarch*) (xml-syscall.c:398)
==3687== by 0x81E131: get_syscall_by_number(gdbarch*, int, syscall*) (xml-syscall.c:599)
==3687== by 0x5BE86F: catch_syscall_command_1(char*, int, cmd_list_element*) (break-catch-syscall.c:481)
==3687== by 0x4B46B1: do_sfunc(cmd_list_element*, char*, int) (cli-decode.c:138)
==3687== by 0x4B76B8: cmd_func(cmd_list_element*, char*, int) (cli-decode.c:1952)
==3687== by 0x7E91C7: execute_command(char*, int) (top.c:615)
==3687== Address 0x14332ae0 is 0 bytes inside a block of size 4,096 free'd
==3687== at 0x4C2AB8B: realloc (vg_replace_malloc.c:785)
==3687== by 0x610792: xrealloc (common-utils.c:62)
==3687== by 0x81BE3E: xml_fetch_content_from_file(char const*, void*) (xml-support.c:1042)
==3687== by 0x81DA86: xml_init_syscalls_info(char const*) (xml-syscall.c:366)
==3687== by 0x81DBDD: init_syscalls_info(gdbarch*) (xml-syscall.c:398)
==3687== by 0x81E131: get_syscall_by_number(gdbarch*, int, syscall*) (xml-syscall.c:599)
==3687== by 0x5BE86F: catch_syscall_command_1(char*, int, cmd_list_element*) (break-catch-syscall.c:481)
==3687== by 0x4B46B1: do_sfunc(cmd_list_element*, char*, int) (cli-decode.c:138)
==3687== by 0x4B76B8: cmd_func(cmd_list_element*, char*, int) (cli-decode.c:1952)
==3687== by 0x7E91C7: execute_command(char*, int) (top.c:615)
==3687== by 0x6A422D: command_handler(char*) (event-top.c:583)
==3687== by 0x6A45F2: command_line_handler(char*) (event-top.c:773)
[...]
The problem is that if xrealloc decides it needs a new memory block,
it frees the previous block/pointer, and then text.reset() frees it
again.
gdb/ChangeLog:
2017-10-17 Pedro Alves <palves@redhat.com>
* xml-support.c (xml_fetch_content_from_file): Call
unique_ptr::release() instead unique_ptr::get() when passing
through xrealloc.
Yao Qi [Tue, 17 Oct 2017 11:29:26 +0000 (12:29 +0100)]
Simplify regcache::xfer_part
Since xfer_part is already a class method, and only
{raw,cooked}_{read,write} are passed to it. We can remove these two
arguments, but add a bool argument is_raw, indicating raw registers or
cooked registers are accessed.
gdb:
2017-10-17 Yao Qi <yao.qi@linaro.org>
* regcache.c (regcache::xfer_part): Remove parameters read and
write, add parameter is_raw. All callers are updated.
Yao Qi [Tue, 17 Oct 2017 11:12:04 +0000 (12:12 +0100)]
[GDBserver] Move aarch64-insn.o to arch/ and remove one Makefile rule
gdb/gdbserver:
2017-10-17 Yao Qi <yao.qi@linaro.org>
* Makefile.in: Remove one rule.
* configure.srv: Rename aarch64-insn.o with arch/aarch64-insn.o.
Yao Qi [Tue, 17 Oct 2017 11:12:04 +0000 (12:12 +0100)]
[GDBserver] Move arm-linux.o and arm-get-next-pcs.o to arch/
gdb/gdbserver:
2017-10-17 Yao Qi <yao.qi@linaro.org>
* configure.srv: Rename arm-linux.o with arch/arm-linux.o.
Rename arm-get-next-pcs.o with arch/arm-get-next-pcs.o.
Yao Qi [Tue, 17 Oct 2017 11:12:04 +0000 (12:12 +0100)]
[GDBserver] Move arm.o to arch/arm.o
gdb/gdbserver:
2017-10-17 Yao Qi <yao.qi@linaro.org>
* configure.srv: Rename arm.o with arch/arm.o.
Yao Qi [Tue, 17 Oct 2017 11:12:04 +0000 (12:12 +0100)]
[GDBserver] Replicate src dir in build dir
Similar to
f38307f5 (Replicate src dir in build dir), this patch change
configure and Makefile to generate object files in arch/ directory.
gdb/gdbserver:
2017-10-17 Yao Qi <yao.qi@linaro.org>
* Makefile.in (CONFIG_SRC_SUBDIR): New variable.
(clean): Remove .o files in CONFIG_SRC_SUBDIR.
(distclean): Remove DEPDIR in CONFIG_SRC_SUBDIR.
(arch-i386.o, arch-amd64.o): Remove rules.
(arch/%.o): New rule.
Update POSTCOMPILE and COMPILE.pre.
* configure.ac: Invoke AC_CONFIG_COMMANDS.
* configure: Re-generated.
* configure.srv: Replace arch-i386.o with arch/i386.o.
Replace arch-amd64.o with arch/amd64.o.
Alan Modra [Tue, 17 Oct 2017 06:13:47 +0000 (16:43 +1030)]
PR22306, Invalid free() in slurp_symtab()
PR 22306
* aoutx.h (aout_get_external_symbols): Handle stringsize of zero,
and error for any other size that doesn't cover the header word.
Alan Modra [Tue, 17 Oct 2017 06:17:05 +0000 (16:47 +1030)]
Correct -z text and other -z documentation
-z text applies to all dynamic binaries, not just shared libraries.
A lot of the other options needed attention too.
* ld.texinfo (-z): Combine negative options with corresponding
positive option. Sort the table. Expand and correct "combreloc",
"common", "common-page-size", "interpose", "loadfltr",
"max-page-size", "muldefs", "nodefaultlib", "nodelete", "nodlopen",
"nodump", "noextern-protected-data", "now", "origin", and "text".
Keith Seitz [Tue, 17 Oct 2017 05:19:55 +0000 (22:19 -0700)]
Add missing ChangeLog entries.
Sandra Loosemore [Tue, 17 Oct 2017 03:45:55 +0000 (20:45 -0700)]
Fix segfault processing nios2 pseudo-instructions with too few arguments.
2017-10-16 Sandra Loosemore <sandra@codesourcery.com>
Henry Wong <henry@stuffedcow.net>
gas/
* config/tc-nios2.c (nios2_translate_pseudo_insn): Check for
correct number of arguments.
(md_assemble): Handle failure of nios2_translate_pseudo_insn.
* testsuite/gas/nios2/illegal_pseudoinst.l: New file.
* testsuite/gas/nios2/illegal_pseudoinst.s: New file.
* testsuite/gas/nios2/nios2.exp: Add illegal_pseudoinst test.
Keith Seitz [Tue, 17 Oct 2017 00:19:29 +0000 (17:19 -0700)]
Record and output access specifiers for nested typedefs
We currently do not record access information for typedefs defined inside
classes. Consider:
struct foo
{
typedef int PUBLIC;
private:
typedef int PRIVATE;
PRIVATE b;
};
(gdb) ptype foo
type = struct foo {
private:
PRIVATE b;
typedef int PRIVATE;
typedef int PUBLIC;
}
This patch fixes this:
(gdb) ptype foo
type = struct foo {
private:
PRIVATE b;
typedef int PRIVATE;
public:
typedef int PUBLIC;
}
gdb/ChangeLog:
* c-typeprint.c (enum access_specifier): Moved here from
c_type_print_base.
(output_access_specifier): New function.
(c_type_print_base): Consider typedefs when assessing
whether access labels are needed.
Use output_access_specifier as needed.
Output access specifier for typedefs, if needed.
* dwarf2read.c (dwarf2_add_typedef): Record DW_AT_accessibility.
* gdbtypes.h (struct typedef_field) <is_protected, is_private>: New
fields.
(TYPE_TYPEDEF_FIELD_PROTECTED, TYPE_TYPEDEF_FIELD_PRIVATE): New
accessor macros.
gdb/testsuite/ChangeLog:
* gdb.cp/classes.cc (class_with_typedefs, class_with_public_typedef)
(class_with_protected_typedef, class_with_private_typedef)
(struct_with_public_typedef, struct_with_protected_typedef)
(struct_with_private_typedef): New classes/structs.
* gdb.cp/classes.exp (test_ptype_class_objects): Add tests for
typedefs and access specifiers.
GDB Administrator [Tue, 17 Oct 2017 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Fri, 13 Oct 2017 00:20:09 +0000 (18:20 -0600)]
Return unique_xmalloc_ptr from target_fileio_read_stralloc
Change target_fileio_read_stralloc to return unique_xmalloc_ptr and
fix up the callers. This removes a number of cleanups.
ChangeLog
2017-10-16 Tom Tromey <tom@tromey.com>
* linux-tdep.c (linux_info_proc, linux_find_memory_regions_full)
(linux_fill_prpsinfo, linux_vsyscall_range_raw): Update.
* target.c (target_fileio_read_stralloc): Update.
* sparc64-tdep.c (adi_is_addr_mapped): Update.
* target.h (target_fileio_read_stralloc): Return
unique_xmalloc_ptr.
Tom Tromey [Thu, 12 Oct 2017 22:48:35 +0000 (16:48 -0600)]
Return unique_xmalloc_ptr from target_read_stralloc
This changes target_read_stralloc to return a unique_xmalloc_ptr, and
then fixes all the callers. unique_xmalloc_ptr is used, rather than
std::string, because target_read_stralloc gives a special meaning to a
NULL return.
ChangeLog
2017-10-16 Tom Tromey <tom@tromey.com>
* xml-syscall.c (xml_init_syscalls_info): Update.
* xml-support.c (xinclude_start_include): Update.
(xml_fetch_content_from_file): Return unique_xmalloc_ptr.
* xml-support.h (xml_fetch_another): Return unique_xmalloc_ptr.
(xml_fetch_content_from_file): Likewise.
* osdata.c (get_osdata): Update.
* target.h (target_read_stralloc, target_get_osdata): Return
unique_xmalloc_ptr.
* solib-aix.c (solib_aix_get_library_list): Update.
* solib-target.c (solib_target_current_sos): Update.
* solib-svr4.c (svr4_current_sos_via_xfer_libraries): Update.
* xml-tdesc.c (fetch_available_features_from_target): Update.
(target_fetch_description_xml): Update.
(file_read_description_xml): Update.
* remote.c (remote_get_threads_with_qxfer, remote_memory_map)
(remote_traceframe_info, btrace_read_config, remote_read_btrace)
(remote_pid_to_exec_file): Update.
* target.c (target_read_stralloc): Return unique_xmalloc_ptr.
(target_get_osdata): Likewise.
Tom Tromey [Thu, 12 Oct 2017 22:40:01 +0000 (16:40 -0600)]
Simple cleanup removals in remote.c
This removes a few cleanups in remote.c using the usual techniques:
std::vector, unique_xmalloc_ptr, and gdb::def_vector.
ChangeLog
2017-10-16 Tom Tromey <tom@tromey.com>
* remote.c (remote_register_number_and_offset): Use std::vector.
(remote_set_syscall_catchpoint): Use gdb::unique_xmalloc_ptr.
(putpkt_binary): Use gdb::def_vector.
(compare_sections_command): Use gdb::byte_vector.
Tom Tromey [Thu, 12 Oct 2017 22:24:13 +0000 (16:24 -0600)]
Remove cleanup from ppc-linux-nat.c
This removes a cleanup from ppc-linux-nat.c, by using
unique_xmalloc_ptr. It also slightly simplifies the code by using
XDUP rather than XNEW and memcpy.
ChangeLog
2017-10-16 Tom Tromey <tom@tromey.com>
* ppc-linux-nat.c (hwdebug_insert_point): Use
gdb::unique_xmalloc_ptr, XDUP.
Tom Tromey [Thu, 12 Oct 2017 22:19:55 +0000 (16:19 -0600)]
Remove some cleanups from probe.c
This removes some cleanups from parse_probes by using std::string; and
removes some unnecessary cleanups from elsewhere in probe.c.
ChangeLog
2017-10-16 Tom Tromey <tom@tromey.com>
* probe.c (parse_probes): Use std::string.
(info_probes_for_ops, enable_probes_command)
(disable_probes_command): Remove cleanups.
Tom Tromey [Thu, 12 Oct 2017 21:46:42 +0000 (15:46 -0600)]
Use std::vector in end_symtab_get_static_block
Change end_symtab_get_static_block to use std::vector. This removes a
cleanup.
ChangeLog
2017-10-16 Tom Tromey <tom@tromey.com>
* buildsym.c (block_compar): Remove.
(end_symtab_get_static_block): Use std::vector.
Pedro Alves [Mon, 16 Oct 2017 19:24:21 +0000 (20:24 +0100)]
Make native gdbserver boards no longer be "remote" (in DejaGnu terms)
This commit finally clears the "isremote" flag in the native-gdbserver
and native-stdio-gdbserver boards. The goal is to make all "native"
boards be considered not remote in DejaGnu terms, like the
native-extended-gdbserver board is too.
DejaGnu automatically considers boards remote if their names don't
match the local hostname. That means that native-gdbserver and
native-extended-gdbserver are considered remote by default by DejaGnu,
even though they run locally. native-extended-gdbserver, however,
overrides its isremote flag to force it to be not remote. So we are
in that weird state where native-gdbserver is considered remote, and
native-extended-gdbserver is considered not remote.
A recent set of commits fixed all the problems (and some more) exposed
by testing with --target_board=native-gdbserver and
--target_board=native-stdio-gdbserver with isremote forced off on
x86-64 GNU/Linux. I believe we're good to go now.
The native-stdio-gdbserver.exp/remote-stdio-gdbserver.exp boards
required deep non-obvious modifications unfortunately... The problem
is that if a board is not remote, then DejaGnu doesn't call
${board}_spawn / ${board}_exec at all, and the
native-stdio-gdbserver.exp board relies on those procedures being
called. To fix that, this commit redesigns how the stdio boards hook
into the testing framework to spawn gdbserver. IMO, this is a good
change anyway, because the way its done currently is a bit of a hack,
and the result turns out to be simpler, even. With this commit, they
now no longer load the "gdbserver" generic config, and hook at the
mi_gdb_target_load/gdb_reload level instead, making them more like
traditional board files.
To share code between native-stdio-gdbserver.exp and
remote-stdio-gdbserver.exp, a new shared stdio-gdbserver-base.exp file
is created.
Instead of having each native board clear isremote manually, boards
source the new "local-board.exp" file.
This also adds a new section to testsuite/README file discussing
local/remote/native, so that we can easily refer to it.
gdb/testsuite/ChangeLog:
2017-10-16 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@polymtl.ca>
* README (Local vs Remote vs Native): New section.
* boards/local-board.exp: New file, with bits factored out from
...
* boards/native-extended-gdbserver.exp: ... here. Load
"local-board".
* boards/native-gdbserver.exp: Load "local-board".
(${board}_spawn, ${board}_exec): Delete.
* boards/native-stdio-gdbserver.exp: Most contents factored out to
...
* boards/stdio-gdbserver-base.exp: ... this new file.
* boards/native-stdio-gdbserver.exp: Reimplement, by loading
"stdio-gdbserver-base" and defining a get_target_remote_pipe_cmd
procedure.
* boards/remote-stdio-gdbserver.exp: Load stdio-gdbserver-base
instead of native-stdio-gdbserver. Don't set gdb_server_prog nor
stdio_gdbserver_command.
(${board}_get_remote_address, ${board}_get_comm_port)
(${board}_download, ${board}_upload): Delete.
(get_target_remote_pipe_cmd): New.
Simon Marchi [Mon, 16 Oct 2017 19:06:14 +0000 (15:06 -0400)]
Use proc_with_prefix in py-breakpoint.exp
Use proc_with_prefix to avoid having to call with_test_prefix with a
duplicate of the proc name. The diff is mostly lines being re-indented.
gdb/testsuite/ChangeLog:
* gdb.python/py-breakpoint.exp (test_bkpt_basic,
test_bkpt_deletion, test_bkpt_cond_and_cmds,
test_bkpt_invisible, test_watchpoints, test_bkpt_internal,
test_bkpt_eval_funcs, test_bkpt_temporary, test_bkpt_address,
test_bkpt_pending, test_bkpt_events): Use proc_with_prefix,
remove with_test_prefix.
Simon Marchi [Mon, 16 Oct 2017 14:14:53 +0000 (10:14 -0400)]
Get rid of VEC(mem_range_s)
This patch replaces the last usages of VEC(mem_range_s) with
std::vector<mem_range>. This allows getting rid of a few cleanups and
of the DEF_VEC_O(mem_range_s).
I added a test for normalize_mem_ranges to make sure I didn't break
anything there.
Regtested on the buildbot.
gdb/ChangeLog:
* memrange.h (struct mem_range): Define operator< and operator==.
(mem_range_s): Remove.
(DEF_VEC_O (mem_range_s)): Remove.
(normalize_mem_ranges): Change parameter type to std::vector.
* memrange.c (compare_mem_ranges): Remove.
(normalize_mem_ranges): Change parameter type to std::vector,
adjust to vector change.
* exec.c (section_table_available_memory): Return vector, remove
parameter.
(section_table_read_available_memory): Adjust to std::vector
change.
* remote.c (remote_read_bytes): Adjust to std::vector
change.
* tracepoint.h (traceframe_available_memory): Change parameter
type to std::vector.
* tracepoint.c (traceframe_available_memory): Change parameter
type to std::vector, adjust.
* gdb/mi/mi-main.c (mi_cmd_trace_frame_collected): Adjust to
std::vector change.
* gdb/Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/memrange-selftests.c.
(SUBDIR_UNITTESTS_OBS): Add memrange-selftests.o.
* gdb/unittests/memrange-selftests.c: New file.
Pedro Alves [Mon, 16 Oct 2017 12:39:12 +0000 (13:39 +0100)]
Work around GCC 6.3.1 bug
This commit works around a GCC 6.3.1 bug several people are hitting:
https://sourceware.org/ml/gdb-patches/2017-09/msg00270.html
https://sourceware.org/ml/gdb-patches/2017-10/msg00418.html
It manifests like this:
../../../binutils-gdb/gdb/probe.c:68:12: error: types may not be defined in a for-range-declaration [-Werror]
for (struct probe *probe : probes)
^~~~~~
Fix it by renaming the range-for named variables to something different
from their type's name.
gdb/ChangeLog:
2017-10-16 Pedro Alves <palves@redhat.com>
* elfread.c (probe_key_free): Rename range-for variable.
* probe.c (parse_probes_in_pspace, find_probes_in_objfile)
(find_probe_by_pc, collect_probes): Rename range-for variable.
H.J. Lu [Mon, 16 Oct 2017 10:49:54 +0000 (03:49 -0700)]
ELF: Call check_relocs after opening all inputs
For all ELF targers, call check_relocs after opening all inputs and
garbage collection. Since the symbol resolution is known, check_relocs
can be simplified. Also garbage collection doesn't need to undo what
check_relocs has done for symbols which have been garbage collected.
Since ELF targets never see the removed sections, gc_sweep_hook can be
removed from elf_backend_data and we can avoid GOT/PLT with garbage
collection now.
Set link_info.check_relocs_after_open_input to TRUE for all linker
targets which use ELF linker and update garbage collection tests to
remove unused GOT section.
ldemul_after_check_relocs is added for powerpc to support --secure-plt,
--bss-plt and --sdata-got.
Tested natively without regressions on i686, x86-64 and x32. Tested
cross binutils on x86-64 without regressions for aarch64-linux,
alpha-linux, arm-linux, bfin-elf, cr16-elf, cris-elf, crx-elf, frv-linux,
hppa64-linux, hppa-linux, ia64-linux, lm32-elf, m32r-elf, m68k-linux,
mcore-elf, metag-elf, microblaze-linux, mips-linux, mmix, mn10300-elf,
nds32le-linux, nios2-linux, or1k-elf, powerpc64-linux, powerpc-linux,
riscv32-linux, riscv64-linux, s390-linux, s390x-linux, score-elf,
sh3-linux, sparc64-linux, sparc-linux, tic6x-elf, tilegx-linux,
tilepro-linux, vax-linux, x86_64-mingw32 and xtensa-linux.
bfd/
* elf-bfd.h (elf_backend_data): Remove gc_sweep_hook.
* elf32-arm.c (elf32_arm_gc_sweep_hook): Removed.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-bfin.c (bfin_gc_sweep_hook): Likewise.
(bfinfdpic_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-cr16.c (elf32_cr16_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-cris.c (cris_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-hppa.c (elf32_hppa_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-lm32.c (lm32_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-m32r.c (m32r_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-m68k.c (elf_m68k_got_entry): Remove elf_m68k_gc_sweep_hook
from comments.
(elf_m68k_remove_got_entry_type): Removed.
(elf_m68k_find_got_entry_ptr): Likewise.
(elf_m68k_remove_got_entry): Likewise.
(elf_m68k_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-mcore.c (mcore_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-metag.c (elf_metag_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-microblaze.c (elf_backend_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-mips.c (elf_backend_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-nds32.c (nds32_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-nios2.c (nios2_elf32_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-or1k.c (or1k_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-ppc.c (ppc_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-s390.c (elf_s390_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-sparc.c (elf_backend_gc_sweep_hook): Likewise.
* elf32-tic6x.c (elf32_tic6x_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-tilegx.c (elf_backend_gc_sweep_hook): Likewise.
* elf32-tilepro.c (tilepro_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-vax.c (elf_vax_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf64-alpha.c (elf64_alpha_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf64-mips.c (elf_backend_gc_sweep_hook): Likewise.
* elf64-mmix.c (mmix_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf64-ppc.c (elf_backend_gc_sweep_hook): Likewise.
(ppc64_elf_gc_sweep_hook): Likewise.
* elf64-s390.c (elf_s390_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf64-sparc.c (elf_backend_gc_sweep_hook): Likewise.
* elf64-tilegx.c (elf_backend_gc_sweep_hook): Likewise.
* elflink.c (elf_link_add_object_symbols): Don't call
_bfd_elf_link_check_relocs here.
(gc_sweep_hook_fn): Removed.
(elf_gc_sweep): Remove gc_sweep_hook.
* elfnn-aarch64.c (elfNN_aarch64_gc_sweep_hook): Removed.
(elf_backend_gc_sweep_hook): Likewise.
* elfnn-riscv.c (riscv_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elfxx-mips.c (_bfd_mips_elf_gc_sweep_hook): Likewise.
* elfxx-mips.h (_bfd_mips_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_gc_sweep_hook): Likewise.
* elfxx-sparc.h (_bfd_sparc_elf_gc_sweep_hook): Likewise.
* elfxx-target.h (elf_backend_gc_sweep_hook): Likewise.
(elfNN_bed): Remove elf_backend_gc_sweep_hook.
* elfxx-tilegx.c (tilegx_elf_gc_sweep_hook): Removed.
* elfxx-tilegx.h (tilegx_elf_gc_sweep_hook): Likewise.
ld/
* emulparams/elf32_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Removed.
* emulparams/elf_i386_be.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_i386_chaos.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_i386_ldso.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_i386_vxworks.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_iamcu.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_k1om.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_l1om.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/i386lynx.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/i386moss.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/i386nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/i386nw.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/shelf.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/shelf32.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/shelf_nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/shelf_vxworks.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/shlelf32_linux.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/shlelf_linux.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/shlelf_nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emultempl/aarch64elf.em (gld${EMULATION_NAME}_before_parse):
Set link_info.check_relocs_after_open_input to TRUE.
* emultempl/armelf.em (gld${EMULATION_NAME}_before_parse):
Likewise.
* emultempl/scoreelf.em (gld${EMULATION_NAME}_before_parse):
Likewise.
* emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Add
after_parse_default.
* emultempl/armcoff.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/beos.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/generic.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/gld960.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/gld960c.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/lnk960.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/m68kcoff.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/msp430.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/pe.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/pep.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/sunos.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/ticoff.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/vanilla.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Always
set link_info.check_relocs_after_open_input to TRUE.
(ld_${EMULATION_NAME}_emulation): Add $LDEMUL_AFTER_CHECK_RELOCS.
* emultempl/linux.em (gld${EMULATION_NAME}_before_parse):
Set link_info.check_relocs_after_open_input to TRUE.
(ld_${EMULATION_NAME}_emulation): Add after_check_relocs_default.
* emultempl/mmix-elfnmmo.em (mmix_before_parse): New function.
(LDEMUL_BEFORE_PARSE): New.
* emultempl/mmixelf.em (elfmmix_before_parse): Replace
gld${EMULATION_NAME}_before_parse with mmix_before_parse.
* emultempl/ppc32elf.em (ppc_after_open): Renamed to ...
(ppc_after_check_relocs): This. Call after_check_relocs_default
instead of gld${EMULATION_NAME}_after_open.
(LDEMUL_AFTER_OPEN): Removed.
(LDEMUL_AFTER_CHECK_RELOCS): New.
* ldemul.c (ldemul_after_check_relocs): New.
(after_check_relocs_default): Likewise.
* ldemul.h (ldemul_after_check_relocs): Likewise.
(after_check_relocs_default): Likewise.
(ld_emulation_xfer_struct): Add after_check_relocs.
* ldlang.c (lang_process): Call ldemul_after_check_relocs after
lang_check_relocs.
* testsuite/ld-aarch64/gc-got-relocs.d: Don't expect GOT section.
* testsuite/ld-aarch64/gc-tls-relocs.d: Likewise.
* testsuite/ld-cris/tls-gc-68.d: Likewise.
* testsuite/ld-cris/tls-gc-69.d: Likewise.
* testsuite/ld-cris/tls-gc-70.d: Likewise.
* testsuite/ld-cris/tls-gc-75.d: Likewise.
* testsuite/ld-cris/tls-gc-79.d: Likewise.
* testsuite/ld-mmix/bpo-10.d: Don't expect .MMIX.reg_contents
section.
Yao Qi [Mon, 16 Oct 2017 10:26:38 +0000 (11:26 +0100)]
Regenerate gdbserver/configure
4fa7574 (Fix gdb 8.1 Solaris compilation) changes warning.m4 and updates
configure, but gdbserver/configure is not updated.
gdb/gdbserver:
2017-10-16 Yao Qi <yao.qi@linaro.org>
* configure: Regenerated.
Yao Qi [Mon, 16 Oct 2017 08:27:43 +0000 (09:27 +0100)]
Remove features/tic6x-*.c files
features/*.c are generated from *.xml files, in order to get pre-defined
target descriptions, (for native debugging, for example). However, these
pre-generated tdesc_tic6x_* are not used in GDB at all. This patch removes
features/tic6x-*.c files.
gdb:
2017-10-16 Yao Qi <yao.qi@linaro.org>
* features/Makefile (XMLTOC): Remove tic6x-*.xml.
* features/tic6x-c62x.c: Remove.
* features/tic6x-c64x-linux.c: Remove.
* features/tic6x-c64x.c: Remove.
* features/tic6x-c64xp-linux.c: Remove.
* features/tic6x-c64xp.c: Remove.
* tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Don't call
initialize_tdesc_tic6x_*_linux functions.
* tic6x-tdep.c (_initialize_tic6x_tdep): Don't call
initialize_tdesc_tic6x_* functions.
Yao Qi [Mon, 16 Oct 2017 08:15:07 +0000 (09:15 +0100)]
Remove regformats/tic6x-{c62x,c64x,c64xp}.dat
tic6x-uclinux GDBserver uses linux target descriptions, instead of these
non-linux target descriptions. So we can remove these *.dat files.
gdb:
2017-10-16 Yao Qi <yao.qi@linaro.org>
* features/Makefile (WHICH): Remove tic6x-c64xp, tic6x-c64x
tic6x-c62x.
* regformats/tic6x-c62x.dat: Remove.
* regformats/tic6x-c64x.dat: Remove.
* regformats/tic6x-c64xp.dat: Remove.
Simon Marchi [Mon, 16 Oct 2017 02:13:22 +0000 (22:13 -0400)]
Fix GDB build without expat
An earlier patch of mine changed parse_traceframe_info to make it return
a unique_ptr. I forgot to update the version of the function used in an
expat-less build, this patch fixes it.
gdb/ChangeLog:
* tracepoint.c (parse_traceframe_info): Return a unique_ptr
(the !HAVE_LIBEXPAT version).
GDB Administrator [Mon, 16 Oct 2017 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 15 Oct 2017 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sat, 14 Oct 2017 18:32:29 +0000 (11:32 -0700)]
x86: Add elf_x86_backend_data
Add plt0_pad_byte and target_os fields to elf_x86_link_hash_table.
Replace elf_i386_backend_data and elf_x86_64_backend_data with
elf_x86_backend_data.
* elf32-i386.c (elf_i386_backend_data): Removed.
(get_elf_i386_backend_data): Likewise.
(elf_i386_arch_bed): Replace elf_i386_backend_data with
elf_x86_backend_data.
(elf_i386_get_synthetic_symtab): Likewise.
(elf_i386_nacl_arch_bed): Likewise.
(elf_i386_vxworks_arch_bed): Likewise.
(elf_i386_relocate_section): Check target_os instead of
is_vxworks.
(elf_i386_finish_dynamic_symbol): Likewise.
(elf_i386_finish_dynamic_sections): Use htab->plt0_pad_byte.
Check target_os instead of is_vxworks.
(elf_i386_link_setup_gnu_properties): Remove normal_target and
is_vxworks. Initialize plt0_pad_byte.
* elf64-x86-64.c (elf_x86_64_backend_data); Removed.
(get_elf_x86_64_arch_data): Likewise.
(get_elf_x86_64_backend_data): Likewise.
(elf_x86_64_arch_bed): Replace elf_x86_64_backend_data with
elf_x86_backend_data.
(elf_x86_64_get_synthetic_symtab): Likewise.
(elf_x86_64_nacl_arch_bed): Likewise.
(elf_x86_64_link_setup_gnu_properties): Remove is_vxworks and
normal_target. Initialize plt0_pad_byte.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Check target_os
instead of is_vxworks.
(_bfd_x86_elf_size_dynamic_sections): Likewise.
(_bfd_x86_elf_finish_dynamic_sections): Likewise.
(_bfd_x86_elf_adjust_dynamic_symbol): Likewise.
(_bfd_x86_elf_link_hash_table_create): Initialize target_os.
(_bfd_x86_elf_link_setup_gnu_properties): Remove is_vxworks.
Update normal_target. Set up plt0_pad_byte. Check target_os
instead of is_vxworks.
* elfxx-x86.h (elf_x86_target_os): New.
(elf_x86_backend_data): Likewise.
(get_elf_x86_backend_data): Likewise.
(elf_x86_link_hash_table): Remove is_vxworks. Add plt0_pad_byte
and target_os.
(elf_x86_init_table): Remove normal_target and is_vxworks. Add
plt0_pad_byte.
H.J. Lu [Sat, 14 Oct 2017 18:29:58 +0000 (11:29 -0700)]
x86: Add _bfd_x86_elf_finish_dynamic_sections
Extract the common parts of elf_i386_finish_dynamic_sections and
elf_x86_64_finish_dynamic_sections into a separate function in
elfxx-x86.c.
* elf32-i386.c (elf_i386_finish_dynamic_sections): Call
_bfd_x86_elf_finish_dynamic_sections.
* elf64-x86-64.c (elf_x86_64_finish_dynamic_sections): Likewise.
* elfxx-x86.c (_bfd_x86_elf_finish_dynamic_sections): New
function.
* elfxx-x86.h (_bfd_x86_elf_finish_dynamic_sections): New
prototype.
H.J. Lu [Sat, 14 Oct 2017 18:23:45 +0000 (11:23 -0700)]
cris: Don't hide symbol which was forced to be dynamic
h->root.dynamic is set on symbols which were forced to be dynamic due
to a version script file. Don't remove such symbols from dynamic symbol
table. This fixes:
FAIL: ld-elf/pr21384
PR ld/21384
* elf32-cris.c (elf_cris_discard_excess_program_dynamics): Don't
hide symbol which was forced to be dynamic.
H.J. Lu [Sat, 14 Oct 2017 18:09:29 +0000 (11:09 -0700)]
cris: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.
bfd/
PR ld/22269
* elf32-cris.c (cris_elf_relocate_section): Don't generate
dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(cris_elf_check_relocs): Don't allocate dynamic relocation
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
ld/
PR ld/22269
* testsuite/ld-cris/weakhiddso.d: Update and remove R_CRIS_NONE.
H.J. Lu [Sat, 14 Oct 2017 18:07:18 +0000 (11:07 -0700)]
sh: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.
PR ld/22269
* elf32-sh.c (allocate_dynrelocs): Discard dynamic relocations
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(sh_elf_relocate_section): Don't generate dynamic relocation if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
H.J. Lu [Sat, 14 Oct 2017 18:06:00 +0000 (11:06 -0700)]
s390: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.
PR ld/22269
* elf32-s390.c (allocate_dynrelocs): Discard dynamic
relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(elf_s390_relocate_section): Don't generate dynamic relocation
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
* elf64-s390.c (allocate_dynrelocs): Discard dynamic
relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(elf_s390_relocate_section): Don't generate dynamic relocation
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
H.J. Lu [Sat, 14 Oct 2017 18:04:32 +0000 (11:04 -0700)]
nios2: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.
PR ld/22269
* elf32-nios2.c (nios2_elf32_relocate_section): Don't generate
dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(allocate_dynrelocs): Discard dynamic relocations if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
H.J. Lu [Sat, 14 Oct 2017 18:03:26 +0000 (11:03 -0700)]
microblaze: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.
PR ld/22269
* elf32-microblaze.c (microblaze_elf_relocate_section): Don't
generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is
true.
(allocate_dynrelocs): Discard dynamic relocations if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
H.J. Lu [Sat, 14 Oct 2017 18:02:20 +0000 (11:02 -0700)]
m68k: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.
PR ld/22269
* elf32-m68k.c (elf_m68k_check_relocs): Don't allocate dynamic
relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(elf_m68k_adjust_dynamic_symbol): Don't make symbol dynamic if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(elf_m68k_relocate_section): Don't generate dynamic relocation
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
H.J. Lu [Sat, 14 Oct 2017 17:54:50 +0000 (10:54 -0700)]
hppa: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.
PR ld/22269
* elf32-hppa.c (ensure_undef_dynamic): Don't make undefined
symbol dynamic if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(allocate_dynrelocs): Discard dynamic relocations if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(elf32_hppa_relocate_section): Don't generate dynamic
relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
H.J. Lu [Sat, 14 Oct 2017 17:53:43 +0000 (10:53 -0700)]
ia64: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.
PR ld/22269
* elfnn-ia64.c (elfNN_ia64_check_relocs): Don't allocate
dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(allocate_fptr): Don't allocate function pointer if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(allocate_dynrel_entries): Don't allocate dynamic relocation
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(set_got_entry): Don't set GOT entry if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(set_pltoff_entry): Don't set PLTOFF entry if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(elfNN_ia64_relocate_section): Don't install dynamic relocation
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
H.J. Lu [Sat, 14 Oct 2017 17:52:12 +0000 (10:52 -0700)]
mips: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.
PR ld/22269
* elfxx-mips.c (mips_elf_calculate_relocation): Don't generate
dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(allocate_dynrelocs): Don't allocate dynamic relocations if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
H.J. Lu [Sat, 14 Oct 2017 17:27:33 +0000 (10:27 -0700)]
arm: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.
PR ld/22269
* elf32-arm.c (elf32_arm_final_link_relocate): Don't generate
dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(allocate_dynrelocs_for_symbol): Discard dynamic relocations
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
H.J. Lu [Sat, 14 Oct 2017 17:25:33 +0000 (10:25 -0700)]
tile: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.
PR ld/22269
* elf32-tilepro.c (allocate_dynrelocs): Discard dynamic
relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(tilepro_elf_relocate_section): Don't generate dynamic
relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
* elfxx-tilegx.c (allocate_dynrelocs): Discard dynamic
relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(tilegx_elf_relocate_section): Don't generate dynamic
relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
H.J. Lu [Sat, 14 Oct 2017 17:23:48 +0000 (10:23 -0700)]
aarch64: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.
PR ld/22269
* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Don't
generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is
true.
(elfNN_aarch64_allocate_dynrelocs): Discard dynamic relocations
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
H.J. Lu [Sat, 14 Oct 2017 17:19:30 +0000 (10:19 -0700)]
Move UNDEFWEAK_NO_DYNAMIC_RELOC to elf-bfd.h
Move UNDEFWEAK_NO_DYNAMIC_RELOC to elf-bfd.h so that it can be used by
other ELF linker backends.
* elf32-ppc.c (UNDEFWEAK_NO_DYNAMIC_RELOC): Moved to ...
* elf-bfd.h (UNDEFWEAK_NO_DYNAMIC_RELOC): Here.
* elf64-ppc.c (UNDEFWEAK_NO_DYNAMIC_RELOC): Removed.
Simon Marchi [Sat, 14 Oct 2017 13:28:07 +0000 (09:28 -0400)]
Fix build failure in linux-osdata.c
Commit
Use std::vector in linux_xfer_osdata_processgroups
b129dcac882da87767cb863ad8b2572f90e9e5bc
broke the build with older gcc (at least 4.7 and 4.8):
In file included from /usr/include/c++/4.7/algorithm:63:0,
from /home/emaisin/src/binutils-gdb/gdb/nat/linux-osdata.c:40:
/usr/include/c++/4.7/bits/stl_algo.h: In instantiation of ‘_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pid_pgid_entry*, std::vector<pid_pgid_entry> >; _Tp = pid_pgid_entry]’:
/usr/include/c++/4.7/bits/stl_algo.h:2315:70: required from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pid_pgid_entry*, std::vector<pid_pgid_entry> >]’
/usr/include/c++/4.7/bits/stl_algo.h:2347:54: required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pid_pgid_entry*, std::vector<pid_pgid_entry> >; _Size = long int]’
/usr/include/c++/4.7/bits/stl_algo.h:5483:4: required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<pid_pgid_entry*, std::vector<pid_pgid_entry> >]’
/home/emaisin/src/binutils-gdb/gdb/nat/linux-osdata.c:480:57: required from here
/usr/include/c++/4.7/bits/stl_algo.h:2277:4: error: passing ‘const pid_pgid_entry’ as ‘this’ argument of ‘bool pid_pgid_entry::operator<(const pid_pgid_entry&)’ discards qualifiers [-fpermissive]
Making the operator< method const fixes it.
gdb/ChangeLog:
* nat/linux-osdata.c (struct pid_pgid_entry) <operator<>: Make
const.
Simon Marchi [Sat, 14 Oct 2017 13:11:12 +0000 (09:11 -0400)]
gdbserver: use std::list for all_threads
Remove the usage of inferior_list for the all_threads list in
gdbserver. The entry field in thread_info is removed, and replaced by a
simple ptid field.
I added some functions to iterate (for_each_thread) and find threads
(find_thread). However, changing all the users of find_inferior & co to
use these new functions would have made the patch way too big. So I
opted instead to make find_inferior & co some shims, so that the
existing code only needs to be updated minimally. We can then update
the existing code to use the new functions incrementally (I've started
to do the work, but I'll post it afterwards, see [1] if you want a peek).
This patch has been built-tested on all relevant platforms, except
lynx. I also regtested using the native-gdbserver and
native-extended-gdbserver boards on x86.
[1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry
gdb/gdbserver/ChangeLog:
* inferiors.h: (struct inferior_list): Remove.
(struct inferior_list_entry); Remove.
(add_inferior_to_list, clear_inferior_list, one_inferior_p,
A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior,
get_first_inferior): Remove.
(for_each_inferior, for_each_inferior_with_data, find_inferior,
find_inferior_id, find_inferior_in_random): Change signature.
* inferiors.c (all_threads): Change type to
std::list<thread_info *>.
(get_thread): Remove macro.
(find_inferior, find_inferior_id): Change signature, implement
using find_thread.
(find_inferior_in_random): Change signature, implement using
find_thread_in_random.
(for_each_inferior, for_each_inferior_with_data): Change
signature, implement using for_each_thread.
(add_inferior_to_list, remove_inferior): Remove.
(add_thread, get_first_thread, thread_of_pid,
find_any_thread_of_pid, free_one_thread, remove_thread): Update.
(get_first_inferior, one_inferior_p, clear_inferior_list):
Remove.
(clear_inferiors, get_thread_process): Update.
* gdbthread.h: Include <list>.
(struct thread_info) <entry>: Remove field.
<id>: New field.
(all_threads): Change type to std::list<thread_info *>.
(get_first_inferior): Add doc.
(find_thread, for_each_thread, find_thread_in_random): New
functions.
(current_ptid, pid_of, ptid_of, lwpid_of): Update.
* linux-arm-low.c (update_registers_callback): Update.
* linux-low.c (second_thread_of_pid_p): Update.
(kill_one_lwp_callback, linux_detach_lwp_callback,
delete_lwp_callback, status_pending_p_callback, same_lwp,
find_lwp_pid, num_lwps, iterate_over_lwps_filter,
iterate_over_lwps, not_stopped_callback,
resume_stopped_resumed_lwps, count_events_callback,
select_singlestep_lwp_callback, select_event_lwp_callback,
unsuspend_one_lwp, linux_wait_1, send_sigstop_callback,
suspend_and_send_sigstop_callback, wait_for_sigstop,
stuck_in_jump_pad_callback, move_out_of_jump_pad_callback,
lwp_running, linux_set_resume_request, resume_status_pending_p,
need_step_over_p, start_step_over, linux_resume_one_thread,
proceed_one_lwp, unsuspend_and_proceed_one_lwp,
reset_lwp_ptrace_options_callback): Update.
* linux-mips-low.c (update_watch_registers_callback): Update.
* regcache.c (regcache_invalidate_one, regcache_invalidate):
Update.
(free_register_cache_thread_one): Remove.
(regcache_release): Update.
* server.c (handle_btrace_enable_bts, handle_btrace_enable_pt,
handle_qxfer_threads_worker): Update.
(handle_query): Update, use list iterator.
(visit_actioned_threads, handle_pending_status,
queue_stop_reply_callback, gdb_wants_all_threads_stopped,
clear_pending_status_callback, set_pending_status_callback,
find_status_pending_thread_callback, handle_status,
process_serial_event): Update.
* target.c (thread_search_callback): Update.
* thread-db.c (thread_db_get_tls_address): Update.
* tracepoint.c (tracepoint_finished_step, tracepoint_was_hit):
Update.
* win32-i386-low.c (update_debug_registers_callback): Update.
* win32-low.c (delete_thread_info, child_delete_thread,
continue_one_thread, suspend_one_thread,
get_child_debug_event): Adjust.
Simon Marchi [Sat, 14 Oct 2017 13:10:42 +0000 (09:10 -0400)]
gdbserver: Use std::list for all_processes
Remove the usage of inferior_list for the all_processes list in
gdbserver, replace it with an std::list. The entry field in process_info
is removed, and replaced by a simple pid field.
The pid_of macro, used for both processes and threads, is replaced with
separate functions. For completeness, I changed ptid_of and lwpid_of to
functions as well.
gdb/gdbserver/ChangeLog:
* gdbthread.h (ptid_of, pid_of, lwpid_of): New functions.
* inferiors.h: Include <list>.
(struct process_info) <entry>: Remove field.
<pid>: New field.
(pid_of): Change macro to function.
(ptid_of, lwpid_of): Remove macro.
(all_processes): Change type to std::list<process_info *>.
(ALL_PROCESSES): Remove macro.
(for_each_process, find_process): New function.
* inferiors.c (all_processes): Change type to
std::list<process_info *>.
(find_thread_process): Adjust.
(add_process): Likewise.
(remove_process): Likewise.
(find_process_pid): Likewise.
(get_first_process): Likewise.
(started_inferior_callback): Remove.
(have_started_inferiors_p): Adjust.
(attached_inferior_callback): Remove.
(have_attached_inferiors_p): Adjust.
* linux-low.c (check_zombie_leaders): Likewise.
* linux-x86-low.c (x86_arch_setup_process_callback): Remove.
(x86_linux_update_xmltarget): Adjust.
* server.c (handle_query): Likewise.
(gdb_reattached_process): Remove.
(handle_status): Adjust.
(kill_inferior_callback): Likewise.
(detach_or_kill_inferior): Remove.
(print_started_pid): Likewise.
(print_attached_pid): Likewise.
(detach_or_kill_for_exit): Update.
(process_serial_event): Likewise.
* linux-arm-low.c (arm_new_fork): Likewise.
Simon Marchi [Sat, 14 Oct 2017 13:09:21 +0000 (09:09 -0400)]
gdbserver: Use std::list for all_dlls
As a small step towards removing inferior_list/inferior_list_entry, this
patch replaces the usage of inferior_list for the list of dlls by an
std::list. The dll_info type now uses an std::string for name and has a
simple constructor.
I am able to build gdbserver with mingw on Linux, but I am not able to
test this on a Windows machine (the only platform that uses this code).
gdb/gdbserver/ChangeLog:
* dll.h: Include <list>.
(struct dll_info): Add constructor.
<entry>: Remove field.
(all_dlls): Change type to std::list<dll_info>.
* dll.c: Include <algorithm>.
(get_dll): Remove macro.
(all_dlls): Change type to std::list<dll_info *>.
(free_one_dll): Remove.
(match_dll): Likewise.
(loaded_dll): Adjust.
(unloaded_dll): Adjust to all_dlls type change, use
std::find_if. Inline code from match_dll.
(clear_dlls): Adjust to all_dlls type change.
* server.c (emit_dll_description): Remove.
(handle_qxfer_libraries): Adjust to all_dlls type change,
integrate emit_dll_description's functionality.
Simon Marchi [Sat, 14 Oct 2017 12:47:44 +0000 (08:47 -0400)]
Make to_traceframe_info return a unique_ptr
Since this target method returns an allocated object, return a
unique_ptr. It allows getting rid a some cleanups here and there.
I had to shuffle the includes around. First, target.h now needs to
include tracepoint.h, to get the definition of traceframe_info_up.
However, the definition of enum trace_find_type was later in target, so
I had to move it to tracepoint.h, so that the declaration of tfind_1
could know about it. I then had to remove the include of target.h from
tracepoint.h, which caused a circular dependency (it was probably
included to get enum trace_find_type in the first place anyway).
Regression tested on the buildbot.
gdb/ChangeLog:
* target.h: Include tracepoint.h.
(enum trace_find_type): Move to tracepoint.h.
(struct target_ops) <to_traceframe_info>: Return a unique ptr.
* tracepoint.h: Don't include target.h
(enum trace_find_type): Move from target.h.
(parse_traceframe_info): Return a unique ptr.
* tracepoint.c (current_traceframe_info): Change type to unique
ptr.
(free_traceframe_info): Remove.
(clear_traceframe_info): Don't manually free
current_traceframe_info.
(free_result): Remove.
(parse_traceframe_info): Return a unique ptr.
(get_traceframe_info): Adjust to unique ptr.
* ctf.c (ctf_traceframe_info): Return a unique ptr.
* remote.c (remote_traceframe_info): Return a unique ptr.
* tracefile-tfile.c (tfile_traceframe_info): Return a unique
ptr.
* target-debug.h (target_debug_print_traceframe_info_up): New
macro.
* target-delegates.c: Regenerate.
Simon Marchi [Sat, 14 Oct 2017 12:43:54 +0000 (08:43 -0400)]
Use std::vector for traceframe_info::memory
Straightforward change from a VEC to std::vector. This allows making
the destruction of a traceframe_info trivial.
I added a constructor with parameters to mem_range to be able to
emplace_back directly with the values. It is necessary to leave a
default constructor there because mem_range is still used in a VEC.
gdb/ChangeLog:
* memrange.h (struct mem_range): Add constructors.
* tracepoint.h (struct traceframe_info) <memory>: Change type to
std::vector<mem_range>.
* tracepoint.c (free_traceframe_info): Don't manually free
vector.
(traceframe_info_start_memory): Adjust to vector change.
(traceframe_available_memory): Likewise.
* tracefile-tfile.c (build_traceframe_info): Likewise.
* ctf.c (ctf_traceframe_info): Likewise.