Bit 7 of BXNS is a fixed bit which distinguish it from BLXNS. Yet it is
not set in the disassembler entry mask. This commit fixes that.
2018-02-19 Thomas Preud'homme <thomas.preudhomme@arm.com>
opcodes/
* arm-dis.c (thumb_opcodes): Fix BXNS mask.
Commit 325ba6fb34 excluded degenerate zero length PT_LOAD segments,
but that only fixed part of the problem, which was that the load
segment limits were not calculated properly.
PR 22845
* elf.c (IS_TBSS): Define.
(_bfd_elf_map_sections_to_segments): Use IS_TBSS.
(assign_file_positions_for_non_load_sections): Revert last change.
Properly calculate load segment limits to compare against relro limits.
ld-elf/ehdr_start fails with -z separate-code. Since there is no data
LOAD segment before code LOAD segment:
There are 2 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x200000 0x0000000000600000 0x0000000000600000 0x000010 0x000010 R E 0x200000
LOAD 0x400000 0x0000000000800000 0x0000000000800000 0x000008 0x000008 R 0x200000
Section to Segment mapping:
Segment Sections...
00 .text
01 .rodata
the program header isn't included in any LOAD segment. As the result,
reference to __ehdr_start is resolved to zero. Pass --build-id to ld
to add a data LOAD segment before code LOAD segment to put the program
header in the data LOAD segment.
PR ld/22845
* testsuite/ld-elf/ehdr_start.d: Pass --build-id to ld.
-z separate-code creates separate code LOAD segment, aligns it to the
maximum page size and places .plt section before .text section. But
ld-elf/eh4 passes -Ttext 0x400 to linker to place .text section at
address 0x400, which is impossible for linker to accomplish:
$ ld -shared -Ttext 0x400 -z separate-code -o x.so eh4.o
ld: section .eh_frame LMA [0000000000200000,000000000020006b] overlaps section .plt LMA [0000000000200000,000000000020001f]
Since ld-elf/eh4 also checks exact addresses, this patch passes
-z max-page-size=0x200000 -z noseparate-code to ld.
PR ld/22845
* ld-elf/eh4.d: Pass -z max-page-size=0x200000 -z noseparate-code
to ld.
Implement the '.nop SIZE[, CONTROL]' assembler directive, which emits
SIZE bytes filled with no-op instructions. SIZE is absolute expression.
The optional CONTROL byte controls how no-op instructions should be
generated. If the comma and @var{control} are omitted, CONTROL is
assumed to be zero.
For Intel 80386 and AMD x86-64 targets, CONTROL byte specifies the size
limit of a single no-op instruction. The valid values of CONTROL byte
are between 0 and 8 for 16-bit mode, between 0 and 10 for 32-bit mode,
between 0 and 11 for 64-bit mode. When 0 is used, the no-op size limit
is set to the maximum supported size.
2 new relax states, rs_space_nop and rs_fill_nop, are added to enum
_relax_state, which are similar to rs_space and rs_fill, respectively,
but they fill with no-op instructions, instead of a single byte. A
target backend must override the default md_generate_nops to generate
proper no-op instructions. Otherwise, an error of unimplemented .nop
directive will be issued whenever .nop directive is used.
* NEWS: Mention .nop directive.
* as.h (_relax_state): Add rs_space_nop and rs_fill_nop.
* read.c (potable): Add .nop.
(s_nop): New function.
* read.h (s_nop): New prototype.
* write.c (cvt_frag_to_fill): Handle rs_space_nop and
rs_fill_nop.
(md_generate_nops): New function.
(relax_segment): Likewise.
(write_contents): Use md_generate_nops for rs_fill_nop.
* config/tc-i386.c (alt64_11): New.
(alt64_patt): Likewise.
(md_convert_frag): Handle rs_space_nop.
(i386_output_nops): New function.
(i386_generate_nops): Likewise.
(i386_align_code): Call i386_output_nops.
* config/tc-i386.h (i386_generate_nops): New.
(md_generate_nops): Likewise.
* doc/as.texinfo: Document .nop directive.
* testsuite/gas/i386/i386.exp: Run .nop directive tests.
* testsuite/gas/i386/nop-1.d: New file.
* testsuite/gas/i386/nop-1.s: Likewise.
* testsuite/gas/i386/nop-2.d: Likewise.
* testsuite/gas/i386/nop-2.s: Likewise.
* testsuite/gas/i386/nop-3.d: Likewise.
* testsuite/gas/i386/nop-3.s: Likewise.
* testsuite/gas/i386/nop-4.d: Likewise.
* testsuite/gas/i386/nop-4.s: Likewise.
* testsuite/gas/i386/nop-5.d: Likewise.
* testsuite/gas/i386/nop-5.s: Likewise.
* testsuite/gas/i386/nop-6.d: Likewise.
* testsuite/gas/i386/nop-6.s: Likewise.
* testsuite/gas/i386/nop-bad-1.l: Likewise.
* testsuite/gas/i386/nop-bad-1.s: Likewise.
* testsuite/gas/i386/x86-64-nop-1.d: Likewise.
* testsuite/gas/i386/x86-64-nop-2.d: Likewise.
* testsuite/gas/i386/x86-64-nop-3.d: Likewise.
* testsuite/gas/i386/x86-64-nop-4.d: Likewise.
* testsuite/gas/i386/x86-64-nop-5.d: Likewise.
* testsuite/gas/i386/x86-64-nop-6.d: Likewise.
Fixes a failure triggered by -z separate-code. p_memsz is tested
rather than p_filesz for objcopy --only-keep-debug where p_filesz is
set to zero.
PR 22845
* elf.c (assign_file_positions_for_non_load_sections): Ignore
degenerate zero size PT_LOAD segments when finding one overlapping
the PT_GNU_RELRO segment.
"-z separate-code" generates different addresses. Update these tests
to accept any addresses.
* testsuite/ld-x86-64/bnd-ifunc-1.d: Updated.
* testsuite/ld-x86-64/ilp32-4.d: Likewise.
Add -z noseparate-code -z max-page-size=0x200000 since these tests
check for exact addresses and don't expect extra PT_LOAD segment. But
don't add them to nacl targets since they generate different addresses.
* testsuite/ld-x86-64/x86-64.exp: Add -z noseparate-code
-z max-page-size=0x200000, excluding NaCl target.
This patch adds a new class allocate_on_obstack, and let dwarf2_per_objfile
inherit it, so that dwarf2_per_objfile is automatically allocated on
obstack, and "delete dwarf2_per_objfile" doesn't de-allocate any space.
gdb:
2018-02-16 Yao Qi <yao.qi@linaro.org>
* block.c (block_namespace_info): Inherit allocate_on_obstack.
(block_initialize_namespace): Use new.
* dwarf2read.c (dwarf2_per_objfile): Inherit allocate_on_obstack.
(dwarf2_free_objfile): Use delete.
* gdbtypes.c (type_pair): Inherit allocate_on_obstack.
(copy_type_recursive): Use new.
* gdb_obstack.h (allocate_on_obstack): New.
These tests fail due to one extra PT_LOAD segment with -z separate-code.
* testsuite/ld-elf/pr19162.d: Add -z noseparate-code.
* testsuite/ld-elf/textaddr1.d: Likewise.
* testsuite/ld-elf/textaddr2.d: Likewise.
* testsuite/ld-elf/textaddr4.d: Likewise.
* testsuite/ld-elf/textaddr6.d: Likewise.
2018-02-07 Sriraman Tallam <tmsriram@google.com>
* expression.cc (Symbol_expression::set_expr_sym_in_real_elf):
New method.
(Unary_expression::set_expr_sym_in_real_elf): New method.
(Binary_expression::set_expr_sym_in_real_elf): New method.
(Trinary_expression::set_expr_sym_in_real_elf): New method.
* plugin.cc (get_symbol_resolution_info): Fix symbol resolution if
defined or used in defsyms.
* plugin.h (Plugin_manager::is_defsym_def): New method.
(Plugin_manager::Plugin_manager): Initialize defsym_defines_set_.
(Plugin_manager::defsym_defines_set_): New member.
(Plugin_manager::Defsym_defines_set): New typedef.
* script.cc (Script_options::set_defsym_uses_in_real_elf): New method.
(Script_options::find_defsym_defs): New method.
* script.h (Expression::set_expr_sym_in_real_elf): New method.
(Symbol_assignment::is_defsym): New method.
(Symbol_assignment::value): New method.
(Script_options::find_defsym_defs): New method.
(Script_options::set_defsym_uses_in_real_elf): New method.
* testsuite/Makefile.am (plugin_test_defsym): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/plugin_test.c: Check for new symbol resolution.
* testsuite/plugin_test_defsym.sh: New script.
* testsuite/plugin_test_defsym.c: New test source.
bfd/
* elfnn-riscv.c (riscv_elf_relocate_section): Use bfd_reloc_dangerous
when pcrel_lo reloc has an addend. Use reloc_dangerous callback for
bfd_reloc_dangerous. Use einfo instead of warning callback for errors.
Add %X%P to error messages.
ld/
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Run pcrel-lo-addend test.
* testsuite/ld-riscv-elf/pcrel-lo-addend.d: New.
* testsuite/ld-riscv-elf/pcrel-lo-addend.s: New.
The build attribute number for Armv8.4-A is currently incorrectly set to that of Armv8-M.
This patch fixes that by setting it as part of the Armv8-A family and adds a test for it.
gas/
2018-02-15 Tamar Christina <tamar.christina@arm.com>
* config/tc-arm.c (cpu_arch_ver): Renumber ARM_ARCH_V8_4A.
* testsuite/gas/arm/attr-march-armv8_4-a.d: New.
The fix for PR ld/22727 on SPARC passed TRUE as the 'create' argument
in the call to bfd_link_hash_lookup. It turns out this was a bad idea
because, if the symbol is created at this point, the link will abort
later in elf_link_output_extsym. This changes the TRUE into a FALSE
and puts an assertion on the result of the call, making it easier to
debug the issue; that's exactly in keeping with what Gold does.
bfd/
* elfxx-sparc.c (_bfd_sparc_elf_check_relocs) <R_SPARC_TLS_GD_CALL>:
Pass FALSE instead of TRUE as 'create' argument to bfd_link_hash_lookup
and assert that the result of the call is not NULL.
When we kill an inferior, the inferior is not deleted. What is more, it
is reused when the new process is created, so we need to reset inferior's
state when it exits.
gdb:
2018-02-15 Yao Qi <yao.qi@linaro.org>
PR gdb/22849
* inferior.c (exit_inferior_1): Reset inf->control.
This advance declaration really isn't necesary, since the implementation
of this function comes before the first reference to it.
gdb/ChangeLog:
* ada-lang.c (ada_to_fixed_value_create): Delete advance
declaration.
Tested by rebuilding GDB.
I ran into a GDB crash in gdb.base/bp-cmds-continue-ctrl-c.exp in my
multi-target branch, which turns out exposed a bug that exists in
master too.
That testcase has a breakpoint with a "continue" command associated.
Then the breakpoint is constantly being hit. At the same time, the
testcase is continualy interrupting the program with Ctrl-C, and
re-resuming it, in a loop.
Running that testcase manually under Valgrind, after a few sequences
of 'Ctrl-C' + 'continue', I got:
Breakpoint 1, Quit
(gdb) ==21270== Invalid read of size 8
==21270== at 0x4D8185: pyuw_this_id(frame_info*, void**, frame_id*) (py-unwind.c:461)
==21270== by 0x6D426A: compute_frame_id(frame_info*) (frame.c:505)
==21270== by 0x6D43B7: get_frame_id(frame_info*) (frame.c:537)
==21270== by 0x84F3B8: scoped_restore_current_thread::scoped_restore_current_thread() (thread.c:1678)
==21270== by 0x718E3D: fetch_inferior_event(void*) (infrun.c:4076)
==21270== by 0x7067C9: inferior_event_handler(inferior_event_type, void*) (inf-loop.c:43)
==21270== by 0x45BEF9: handle_target_event(int, void*) (linux-nat.c:4419)
==21270== by 0x6C4255: handle_file_event(file_handler*, int) (event-loop.c:733)
==21270== by 0x6C47F8: gdb_wait_for_event(int) (event-loop.c:859)
==21270== by 0x6C3666: gdb_do_one_event() (event-loop.c:322)
==21270== by 0x6C3712: start_event_loop() (event-loop.c:371)
==21270== by 0x746801: captured_command_loop() (main.c:329)
==21270== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==21270==
==21270==
==21270== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==21270== Access not within mapped region at address 0x0
==21270== at 0x4D8185: pyuw_this_id(frame_info*, void**, frame_id*) (py-unwind.c:461)
==21270== by 0x6D426A: compute_frame_id(frame_info*) (frame.c:505)
==21270== by 0x6D43B7: get_frame_id(frame_info*) (frame.c:537)
==21270== by 0x84F3B8: scoped_restore_current_thread::scoped_restore_current_thread() (thread.c:1678)
==21270== by 0x718E3D: fetch_inferior_event(void*) (infrun.c:4076)
==21270== by 0x7067C9: inferior_event_handler(inferior_event_type, void*) (inf-loop.c:43)
==21270== by 0x45BEF9: handle_target_event(int, void*) (linux-nat.c:4419)
==21270== by 0x6C4255: handle_file_event(file_handler*, int) (event-loop.c:733)
==21270== by 0x6C47F8: gdb_wait_for_event(int) (event-loop.c:859)
==21270== by 0x6C3666: gdb_do_one_event() (event-loop.c:322)
==21270== by 0x6C3712: start_event_loop() (event-loop.c:371)
==21270== by 0x746801: captured_command_loop() (main.c:329)
==21270== If you believe this happened as a result of a stack
==21270== overflow in your program's main thread (unlikely but
==21270== possible), you can try to increase the size of the
==21270== main thread stack using the --main-stacksize= flag.
==21270== The main thread stack size used in this run was 8388608.
==21270==
Above, when we get to compute_frame_id, fi->unwind is non-NULL,
meaning, we found an unwinder, in this case the Python unwinder, but
somehow, fi->prologue_cache is left NULL. pyuw_this_id then crashes
because it assumes fi->prologue_cache is non-NULL:
static void
pyuw_this_id (struct frame_info *this_frame, void **cache_ptr,
struct frame_id *this_id)
{
*this_id = ((cached_frame_info *) *cache_ptr)->frame_id;
^^^^^^^^^^
'*cache_ptr' here is 'fi->prologue_cache'.
There's a quit() call in pyuw_sniffer that I believe is the one that
sometimes triggers the crash above. The crash can be reproduced
easily with this hack to force a quit out of the python unwinder:
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -497,6 +497,8 @@ pyuw_sniffer (const struct frame_unwind *self, struct frame_info *this_frame,
struct gdbarch *gdbarch = (struct gdbarch *) (self->unwind_data);
cached_frame_info *cached_frame;
+ quit ();
+
gdbpy_enter enter_py (gdbarch, current_language);
TRACE_PY_UNWIND (3, "%s (SP=%s, PC=%s)\n", __FUNCTION__,
After that quit is thrown, any subsequent operation that involves
unwinding results in GDB crashing with SIGSEGV like above.
The problem is that this commit:
commit 30a9c02fef
CommitDate: Sun Oct 8 23:16:42 2017 -0600
Subject: Remove cleanup from frame_prepare_for_sniffer
missed that we need to call frame_cleanup_after_sniffer before
rethrowing the exception too.
Without the fix, the "bt" added to
gdb.base/bp-cmds-continue-ctrl-c.exp in this commit makes GDB crash:
Running src/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp ...
ERROR: Process no longer exists
gdb/ChangeLog:
2018-02-14 Pedro Alves <palves@redhat.com>
* frame-unwind.c (frame_unwind_try_unwinder): Always call
frame_cleanup_after_sniffer on exception.
gdb/testsuite/ChangeLog:
2018-02-14 Pedro Alves <palves@redhat.com>
* gdb.base/bp-cmds-continue-ctrl-c.exp (do_test): Test "bt" after
getting a "Quit".
This constifies the bfd_open method of struct target_so_ops.
gdb/ChangeLog
2018-02-14 Tom Tromey <tom@tromey.com>
* solist.h (struct target_so_ops) <bfd_open>: Make pathname
const.
(solib_bfd_open): Make pathname const.
* solib.c (solib_bfd_open): Make pathname const.
* solib-spu.c (spu_bfd_fopen): Make name const.
(spu_bfd_open): Make pathname const.
* solib-darwin.c (darwin_bfd_open): Make pathname const.
* solib-aix.c (solib_aix_bfd_open): Make pathname const.
This changes openp, source_full_path_of, and find_and_open_source to
take a unique_xmalloc_ptr, rather than a char*, as an outgoing
argument type. This simplifies the API, ownership-wise, and allows
for the removal of some cleanups.
gdb/ChangeLog
2018-02-14 Tom Tromey <tom@tromey.com>
* symfile.c (symfile_bfd_open): Update.
* source.h (openp, source_full_path_of, find_and_open_source):
Change argument type to unique_xmalloc_ptr.
* source.c (openp): Take a unique_xmalloc_ptr.
(source_full_path_of, find_and_open_source): Likewise.
(open_source_file, symtab_to_fullname): Update.
* solist.h (struct target_so_ops) <find_and_open_solib>: Take a
unique_xmalloc_ptr.
* solib.c (solib_find_1): Use unique_xmalloc_ptr.
(exec_file_find): Update.
* psymtab.c (psymtab_to_fullname): Update.
* nto-tdep.h (nto_find_and_open_solib): Update.
* nto-tdep.c (nto_find_and_open_solib): Change temp_path to a
unique_xmalloc_ptr.
* exec.c (exec_file_attach): Update.
* dwarf2read.c (try_open_dwop_file): Use unique_xmalloc_ptr.
* cli/cli-cmds.c (find_and_open_script): Use unique_xmalloc_ptr.
I noticed a few declarations in defs.h that really could be put into
source.h. I think it's generally preferable to something out of
defs.h unless it is needed by most of the files in gdb.
gdb/ChangeLog
2018-02-14 Tom Tromey <tom@tromey.com>
* solib.c: Include source.h.
* nto-tdep.c: Include source.h.
* mi/mi-cmd-env.c: Include source.h.
* infcmd.c: Include source.h.
* exec.c: Include source.h.
* defs.h (enum openp_flag, openp, source_full_path_of, mod_path)
(add_path, directory_switch, source_path, init_source_path): Move
declarations...
* source.h (enum openp_flag, openp, source_full_path_of, mod_path)
(add_path, directory_switch, source_path, init_source_path):
...here.
This changes a couple of solib.c functions -- exec_file_find and
solib_find -- to return a unique_xmalloc_ptr, and then fixes up the
users. This allows the removal of some cleanups.
This also changes solib_bfd_open to not take ownership of its
argument. I think this change is somewhat cleaner.
gdb/ChangeLog
2018-02-14 Tom Tromey <tom@tromey.com>
* solist.h (exec_file_find, solib_find): Return
unique_xmalloc_ptr.
(solib_bfd_fopen): Take a const char *.
* solib.c (solib_find_1): Return unique_xmalloc_ptr.
(exec_file_find, solib_find): Likewise.
(solib_bfd_fopen): Do not take ownership of "pathname".
(solib_bfd_open): Use unique_xmalloc_ptr.
* solib-darwin.c (darwin_bfd_open): Use unique_xmalloc_ptr.
* solib-aix.c (solib_aix_bfd_open): Use unique_xmalloc_ptr.
* infrun.c (follow_exec): Use unique_xmalloc_ptr.
* exec.c (exec_file_locate_attach): Use unique_xmalloc_ptr.
Since PLT in PDE and PC-relative PLT in PIE can be used as function
address, there is no need for dynamic PC-relative relocation against
a dynamic function definition in PIE. Linker should resolve PC-relative
reference to its PLT address.
NB: i386 has non-PIC PLT and PIC PLT. Only non-PIC PLT in PDE can
be used as function address. PIC PLT in PIE can't be used as
function address.
bfd/
PR ld/22842
* elf32-i386.c (elf_i386_check_relocs): Pass FALSE for non
PC-relative PLT to NEED_DYNAMIC_RELOCATION_P.
* elf64-x86-64.c (elf_x86_64_check_relocs): Create PLT for
R_X86_64_PC32 reloc against dynamic function in data section.
Pass TRUE for PC-relative PLT to NEED_DYNAMIC_RELOCATION_P.
(elf_x86_64_relocate_section): Use PLT for R_X86_64_PC32 reloc
against dynamic function in data section.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Use PLT in PIE as
function address only if pcrel_plt is true.
(_bfd_x86_elf_link_hash_table_create): Set pcrel_plt.
* elfxx-x86.h (NEED_DYNAMIC_RELOCATION_P): Add PCREL_PLT for
PC-relative PLT. If PLT is PC-relative, don't generate dynamic
PC-relative relocation against a function definition in data
secton in PIE. Remove the obsolete comments.
(elf_x86_link_hash_table): Add pcrel_plt.
ld/
PR ld/22842
* testsuite/ld-i386/i386.exp: Run PR ld/22842 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr22842a.c: New file.
* testsuite/ld-i386/pr22842b.S: Likewise.
* testsuite/ld-x86-64/pr22842a.c: Likewise.
* testsuite/ld-x86-64/pr22842a.rd: Likewise.
* testsuite/ld-x86-64/pr22842b.S: Likewise.
* testsuite/ld-x86-64/pr22842b.rd: Likewise.
This function was deleted on 2017-11-08, but its declaration and
a reference to it in a comment was left behind. This patch just
removes those.
gdb/ChangeLog:
* ada-lang.c (name_match_type_from_name): Remove reference to
ada_name_for_lookup in function's documentation.
* ada-lang.h (ada_name_for_lookup): Delete declaration.
Tested by rebuilding GDB.
Complement commit d4e5e3c330 ("Use getopt instead of lex and yacc to
parse the command line.") and remove a stale `ldlex_command' prototype
for an inexistent function removed back in 1994.
ld/
* ldlex.h (ldlex_command): Remove prototype.
They should be pr22393-3a.so and pr22393-3a-now.so, not pr22393-2a.so
and pr22393-2a-now.so. Since ld-elf/shared.exp creates pr22393-2a.so
and pr22393-2a-now.so, we won't notice the problem if x86-64.exp runs
after ld-elf/shared.exp.
* testsuite/ld-x86-64/x86-64.exp: Replace pr22393-2a.so and
pr22393-2a-now.so with pr22393-3a.so and pr22393-3a-now.so.