It turns out that a dwarf2_cu can remain allocated after psymtab
expansion is done, and so it makes sense to clear rust_unions when
done processing it.
Tested on x86-64 Fedora 27.
2018-05-14 Tom Tromey <tom@tromey.com>
* dwarf2read.c (rust_union_quirks): Clear rust_unions.
gas * write.c (maybe_generate_build_notes): Generate notes on a
per-code-section basis. Skip linkonce sections.
ld * testsuite/ld-elf/notes.exp: New file: Run new test.
* testsuite/ld-elf/note1_1.s: New file: Source file for test.
* testsuite/ld-elf/note1_2.s: New file: Source file for test.
* testsuite/ld-elf/note1.r: New file: Expected readelf output.
If IFUNC symbol is defined in position-dependent executable, we should
change it to the normal function and set its address to its PLT entry
which should be resolved by R_*_IRELATIVE at run-time. All external
references should be resolved to its PLT in executable.
bfd/
PR ld/23169
* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Don't issue
an error on IFUNC pointer defined in PDE.
* elf32-i386.c (elf_i386_finish_dynamic_symbol): Call
_bfd_x86_elf_link_fixup_ifunc_symbol.
* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise.
* elfxx-x86.c (_bfd_x86_elf_link_fixup_ifunc_symbol): New
function.
* elfxx-x86.h (_bfd_x86_elf_link_fixup_ifunc_symbol): New.
ld/
PR ld/23169
* testsuite/ld-ifunc/ifunc-9-i386.d: New file.
* testsuite/ld-ifunc/ifunc-9-x86-64.d: Likewise.
* testsuite/ld-ifunc/pr23169a.c: Likewise.
* testsuite/ld-ifunc/pr23169a.rd: Likewise.
* testsuite/ld-ifunc/pr23169b.c: Likewise.
* testsuite/ld-ifunc/pr23169b.c: Likewise.
* testsuite/ld-ifunc/pr23169c.rd: Likewise.
* testsuite/ld-ifunc/pr23169c.rd: Likewise.
* testsuite/ld-ifunc/ifunc-9-x86.d: Removed.
* testsuite/ld-ifunc/ifunc.exp: Run PR ld/23169 tests.
__bss_start, _end and _edata are defined by linker to mark regions
within executables and shared libraries. All references within
executables should be locally resolved.
This patch doesn't change how their references within shared libraries
are resolved.
bfd/
PR ld/23162
* elfxx-x86.c (elf_x86_linker_defined): New function.
(_bfd_x86_elf_link_check_relocs): Use it to mark __bss_start,
_end and _edata locally defined within executables.
ld/
PR ld/23162
* testsuite/ld-elf/pr23162.map: New file.
* testsuite/ld-elf/pr23162.rd: Likewise.
* testsuite/ld-elf/pr23162a.c: Likewise.
* testsuite/ld-elf/pr23162b.c: Likewise.
* testsuite/ld-elf/shared.exp: Run PR ld/23162 tests.
Rather than just silencing the gcc-8 warnings, I decided to rewrite
the buffer handling in the two functions where gcc was warning.
The rest of the file could do with the same treatment.
* config/tc-score.c (s3_do_macro_bcmp): Don't use fixed size
buffers.
(s3_do_macro_bcmpz): Likewise.
Sections may well belong in multiple segments. The testcase in the PR
saw an allocated section being assigned to an ABIFLAGS segment, then
not being assigned to a LOAD segment because it had already been
handled. To fix that particular problem this patch sets and tests
segment_mark only for LOAD segments. I kept the segment_mark test for
LOAD segments because I think there may otherwise be a problem with
zero size sections.
A few other problems showed up with the testcase. Some targets align
.dynamic, resulting in the test failing with "section .dynamic lma
0x800000c0 adjusted to 0x800000cc" and similar messages. I've tried
to handle that with some more hacks to the segment lma, which do the
right thing for the testcase, but may well fail in other situations.
I've also removed the tests of segment lma (p_paddr) and code involved
in deciding that an adjusted segment no longer covers the file or
program headers. Those test can't be correct in the face of objcopy
--change-section-lma. It may be necessary to reinstate the tests but
do them modulo page size, but we'll see how this goes.
PR 20659
bfd/
* elf.c (rewrite_elf_program_header): Use segment_mark only for
PT_LOAD headers. Delete first_matching_lma and first_suggested_lma.
Instead make matching_lma and suggested_lma pointers to the
sections. Align section vma and lma calculated from segment.
Don't clear includes_phdrs or includes_filehdr based on p_paddr
test. Try to handle alignment padding before first section by
adjusting new segment lma down. Adjust PT_PHDR map p_paddr.
ld/
* testsuite/ld-elf/changelma.d,
* testsuite/ld-elf/changelma.lnk,
* testsuite/ld-elf/changelma.s: New test.
In commit:
commit 8ee22052f6
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date: Thu May 3 17:46:14 2018 +0100
gdb/x86: Handle kernels using compact xsave format
in two places FXSAVE_ADDR was used instead of FXSAVE_MXCSR_ADDR to get
the address of the mxcsr register within the xsave buffer. This will
mean we are potentially accessing the wrong location within the xsave
buffer.
There are no tests included with this patch. The first mistake would
only trigger an issue if/when the user tries to manually set the mxcsr
register to a value that matches the random (value off stack) value
that is in the xsave buffer, in this case the change by the user will
go unnoticed by GDB, and the default value of mxcsr will be preserved.
The second mistake only happens on the code path where all x87
registers are being written out of the register cache. I'm not sure
how to trigger that code path.
gdb/ChangeLog:
* i387-tdep.c (i387_collect_xsave): Use FXSAVE_MXCSR_ADDR not
FXSAVE_ADDR for the mxcsr register.
gdb_target definitions were removed from configure.tgt in 2007, before
xtensa port was merged. Remove it from the xtensa target as well.
gdb/
2018-05-11 Max Filippov <jcmvbkbc@gmail.com>
* configure.tgt (xtensa*-*-linux*): Drop gdb_target definition.
This gets rid of the core_ops global, and replaces it with
heap-allocated core_target instances. In practice, there will only be
one such instance, though that will change further ahead as more
pieces of multi-target support are merged.
Notice that this replaces one heap-allocated object for another, the
number of allocations is the same. Specifically, currently we
heap-allocate the 'core_data' object, which holds the core's section
table. With this patch, that object is made a field of the
core_target class, and no longer allocated separately.
Note that this bit:
- /* Looks semi-reasonable. Toss the old core file and work on the
- new. */
-
- unpush_target (&core_ops);
does not need a replacement, because by the time we get here, the
target_preopen call at the top of core_target_open has already
unpushed any previous target.
gdb/ChangeLog:
2018-05-11 Pedro Alves <palves@redhat.com>
* corelow.c (core_target) <core_target>: No longer inline.
Initialize m_core_gdbarch, m_core_vec and build the section table
here.
<~core_target>: New.
<core_gdbarch, get_core_register_section>: New methods.
<m_core_section_table, m_core_vec, m_core_gdbarch>: New fields,
factored out from ...
<core_data, core_vec, core_gdbarch>: ... these deleted globals.
(core_ops): Delete.
(sniff_core_bfd): Add gdbarch parameter.
(core_close): Delete, merged into ...
(core_target::close): ... here. Delete self.
(core_close_cleanup): Delete.
(core_target_open): Allocate a core_target on the heap. Use a
unique_ptr instead of a cleanup. Bits moved into the core_target
ctor. Adjust to use core_target methods instead of globals.
(get_core_register_section): Rename to ...
(core_target::get_core_register_section): ... this and adjust.
(struct get_core_registers_cb_data): New.
(get_core_registers_cb): Use it. Use bool.
(core_target::fetch_registers, core_target::files_info)
(core_target::xfer_partial, core_target::read_description)
(core_target::pid_to, core_target::thread_name): Adjust to
reference class fields instead of globals.
* target.h (struct target_ops_deleter, target_ops_up): New.
(previously called 'core_target', but since renamed because
'core_target' is the name of the target_ops class now.)
This eliminates the "the_core_target" global, as preparation for being
able to have more than one core loaded. When we get there, we will
instantiate one core_target object per core instead.
Essentially, this replaces the reference to the_core_target in
core_file_command by a reference to core_bfd, which is per
program_space.
Currently, core_file_command calls 'the_core_target->detach()' even if
the core target is not open and pushed on the target stack. If it is
indeed not open, then the practical effect is that
core_target::detach() prints "No core file now.". That is preserved
by printing that directly from within core_file_command if not
debugging a core.
gdb/ChangeLog:
2018-05-11 Pedro Alves <palves@redhat.com>
* corefile.c (core_file_command): Move to corelow.c.
* corelow.c (the_core_target): Delete.
(core_file_command): Moved from corefile.c. Check exec_bfd
instead of the_core_target. Use target_detach instead of calling
into the_core_target directly.
(maybe_say_no_core_file_now): New.
(core_target::detach): Use it.
(_initialize_corelow): Remove references to the_core_target.
* gdbcore.h (the_core_target): Delete.
This moves the core_bfd global to be a field of the program space. It
then replaces core_bfd with a macro to avoid a massive patch -- the
same approach taken for various other program space fields.
This is a basic transformation for multi-target work.
2018-05-11 Tom Tromey <tromey@redhat.com>
Pedro Alves <tromey@redhat.com>
* corefile.c (core_bfd): Remove.
* gdbcore.h (core_bfd): Now a macro.
* progspace.h (struct program_space) <cbfd>: New field.
This removes the remaining cleanups from mdebugread.c, replacing them
with gdb::def_vector.
Tested by the buildbot, though I doubt this exercises mdebugread.
gdb/ChangeLog
2018-05-11 Tom Tromey <tom@tromey.com>
* mdebugread.c (parse_partial_symbols, psymtab_to_symtab_1): Use
gdb::def_vector.
The floating point context structure on x86 LynxOS-178 is not
the same as on LynxOS 5.x. As a consequence, trying to print
the return value of a function returning a float, for instance,
yields incorrect results.
This patch fixes the issue by providing an updated definition
for LynxOS-178 (the reason why we cannot access the actual definition
provided by the system still remains true).
gdb/gdbserver/ChangeLog:
* lynx-i386-low.c (LYNXOS_178): New macro.
[LYNXOS_178] (usr_fcontext_t): Provide a definition that matches
the layout on LynxOS-178.
(lynx_i386_fill_fpregset, lynx_i386_store_fpregset): Do not
handle floating point registers that are not supported by
LynxOS-178.
Simon pointed out that gdb would not build with clang, due to the
addition of -Wimplicit-fallthrough. This patch fixes the problem by
using -Wimplicit-fallthrough=3 -- this does not work with clang,
bypassing the issue.
Tested by rebuilding with both gcc and clang; and also by verifying
that -Wimplicit-fallthrough=3 is used in the gcc build.
I will file a follow-up bug to convert the fall-through comments to a
form that can be used by both clang and gcc.
gdb/ChangeLog
2018-05-10 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
* warning.m4 (AM_GDB_WARNINGS): Use -Wimplicit-fallthrough=3.
gdb/gdbserver/ChangeLog
2018-05-10 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
This patch makes it possible to use an integer immediate with the fmov instructions
allowing you to simply write fmov d0, #2 instead of needing fmov d0, #2.0.
The parse double function already know to deal with this so we just need to list the
restriction put in place in parser.
The is considered a QoL improvement for hand assembly writers and allows more
code portability between assembler.
gas/
* config/tc-aarch64.c (parse_aarch64_imm_float): Remove restrictions.
* testsuite/gas/aarch64/diagnostic.s: Move fmov int test to..
* testsuite/gas/aarch64/fpmov.s: Here.
* testsuite/gas/aarch64/fpmov.d: Update results with fmov.
* testsuite/gas/aarch64/diagnostic.l: Remove fmov values.
* testsuite/gas/aarch64/sve-invalid.s: Update test files.
* testsuite/gas/aarch64/sve-invalid.l: Likewise
This patch fixes the case where you want to use an integer value the
floating point immediate to a VFP vmov instruction such as
vmovmi.f32 s27, #11.
If the immediate is not a float we convert it and copy it's representation
into the imm field and then carry on validating as if we originally entered
a floating point immediate.
The is considered a QoL improvement for hand assembly writers and allows more
code portability between assembler.
gas/
* gas/config/tc-arm.c (do_neon_mov): Allow integer literal for float
immediate.
* testsuite/gas/arm/vfp-mov-enc.s: New.
* testsuite/gas/arm/vfp-mov-enc.d: New.
On Windows, starting a new process with GDBserver seems to work,
in the sense that the program does get started, and GDBserver
confirms that it is listening for GDB to connect. However, as soon as
GDB establishes the connection with GDBserver, and starts discussing
with it, GDBserver crashes, with a SEGV.
This SEGV occurs in remote-utils.c::prepare_resume_reply...
| regp = current_target_desc ()->expedite_regs;
| [...]
| while (*regp)
... because, in our case, REGP is NULL.
This patches fixes the issues by adding a parameter to init_target_desc,
in order to make sure that we always provide the list of registers when
we initialize a target description.
gdb/ChangeLog:
PR server/23158:
* regformats/regdat.sh: Adjust script, following the addition
of the new expedite_regs parameter to init_target_desc.
gdb/gdbserver/ChangeLog:
PR server/23158:
* tdesc.h (init_target_desc) <expedite_regs>: New parameter.
* tdesc.c (init_target_desc) <expedite_regs>: New parameter.
Use it to set the expedite_regs field in the given tdesc.
* x86-tdesc.h: New file.
* linux-aarch64-tdesc.c (aarch64_linux_read_description):
Adjust following the addition of the new expedite_regs parameter
to init_target_desc.
* linux-tic6x-low.c (tic6x_read_description): Likewise.
* linux-x86-tdesc.c: #include "x86-tdesc.h".
(i386_linux_read_description, amd64_linux_read_description):
Adjust following the addition of the new expedite_regs parameter
to init_target_desc.
* lynx-i386-low.c: #include "x86-tdesc.h".
(lynx_i386_arch_setup): Adjust following the addition of the new
expedite_regs parameter to init_target_desc.
* nto-x86-low.c: #include "x86-tdesc.h".
(nto_x86_arch_setup): Adjust following the addition of the new
expedite_regs parameter to init_target_desc.
* win32-i386-low.c: #include "x86-tdesc.h".
(i386_arch_setup): Adjust following the addition of the new
expedite_regs parameter to init_target_desc.
Trying to start a program with GDBserver on Windows yields
the following error:
$ gdbserver.exe --once :4444 simple_main.exe
Killing process(es): 5008
No program to debug
Exiting
The error itself comes from the following code shortly after
create_inferior gets called (in server.c::main):
/* Wait till we are at first instruction in program. */
create_inferior (program_path.get (), program_args);
[...]
if (last_status.kind == TARGET_WAITKIND_EXITED
|| last_status.kind == TARGET_WAITKIND_SIGNALLED)
was_running = 0;
else
was_running = 1;
if (!was_running && !multi_mode)
error ("No program to debug");
What happens is that the "last_status" global starts initialized
as zeroes, which means last_status.kind == TARGET_WAITKIND_EXITED,
and we expect create_inferior to be waiting for the inferior to
start until reaching the SIGTRAP, and to set the "last_status"
global to match that last event we received.
I suspect this is an unintended side-effect of the following change...
commit 2090129c36
Date: Thu Dec 22 21:11:11 2016 -0500
Subject: Share fork_inferior et al with gdbserver
... which removes some code in server.c that was responsible for
starting the inferior in a functin that was named start_inferior,
and looked like this:
signal_pid = create_inferior (new_argv[0], &new_argv[0]);
[...]
/* Wait till we are at 1st instruction in program, return new pid
(assuming success). */
last_ptid = mywait (pid_to_ptid (signal_pid), &last_status, 0, 0);
The code has been transitioned to using fork_inferior, but sadly,
only for the targets that support it. On Windows, the calls to wait
setting "last_status" simply disappeared.
This patch adds it back in the Windows-specific implementation of
create_inferior.
gdb/gdbserver/ChangeLog:
PR server/23158:
* win32-low.c (win32_create_inferior): Add call to my_wait
setting last_status global.
Trying to start GDBserver on Windows currently yields the following
error...
$ gdbserver.exe --once :4444 simple_main.exe
glob could not process pattern '(null)'.
Exiting
... after which GDB terminates with a nonzero status.
This is because create_process in win32-low.c calls gdb_tilde_expand
with the result of a call to get_inferior_cwd without verifying that
the returned directory is not NULL:
| static BOOL
| create_process (const char *program, char *args,
| DWORD flags, PROCESS_INFORMATION *pi)
| {
| const char *inferior_cwd = get_inferior_cwd ();
| std::string expanded_infcwd = gdb_tilde_expand (inferior_cwd);
This patch avoids this by only calling gdb_tilde_expand when
INFERIOR_CWD is not NULL, which is similar to what is done on
GNU/Linux for instance.
gdb/gdbserver/ChangeLog:
PR server/23158:
* win32-low.c (create_process): Only call gdb_tilde_expand if
inferior_cwd is not NULL.
This patch fixes tagged pointer support for AArch64 GDB. Linux kernel
debugging failure was reported after tagged pointer support was committed.
After a discussion around best path forward to manage tagged pointers
on GDB side we are going to disable tagged pointers support for
aarch64-none-elf-gdb because for non-linux applications we cant be
sure if tagged pointers will be used by MMU or not.
Also for aarch64-linux-gdb we are going to sign extend user-space
address after clearing tag bits. This will help debug both kernel
and user-space addresses based on information from linux kernel
documentation given below:
According to AArch64 memory map:
https://www.kernel.org/doc/Documentation/arm64/memory.txt
"User addresses have bits 63:48 set to 0 while the kernel addresses have
the same bits set to 1."
According to AArch64 tagged pointers document:
https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt
The kernel configures the translation tables so that translations made
via TTBR0 (i.e. userspace mappings) have the top byte (bits 63:56) of
the virtual address ignored by the translation hardware. This frees up
this byte for application use.
Running gdb testsuite after applying this patch introduces no regressions
and tagged pointer test cases still pass.
gdb/ChangeLog:
2018-05-10 Omair Javaid <omair.javaid@linaro.org>
PR gdb/23127
* aarch64-linux-tdep.c (aarch64_linux_init_abi): Add call to
set_gdbarch_significant_addr_bit.
* aarch64-tdep.c (aarch64_gdbarch_init): Remove call to
set_gdbarch_significant_addr_bit.
* utils.c (address_significant): Update to sign extend addr.
Gold resolves GOT-relative relocs relative to the GOT base +
0x8000 when the GOT is larger than 0x8000. However, previously
the _GLOBAL_OFFSET_TABLE_ symbol was set to GOT base + 0x8000
when the .got.plt was larger than 0x8000. This patch makes both
checks use the size of the .got section so that they agree when
to add 0x8000.
Not all literals need to be moved in the presence of
--text-section-literals or --auto-litpools, but only those created by
.literal pseudo op or generated as a result of relaxation. Attempts to
move other literals may result in abnormal termination of the assembler
due to the following assertion failure:
Internal error in xg_find_litpool at gas/config/tc-xtensa.c:11209.
The same assertion may also be triggered by attempting to assign literal
pools to literals in .init and .fini sections; don't try to do that.
gas/
2018-05-09 Max Filippov <jcmvbkbc@gmail.com>
* config/tc-xtensa.c (xtensa_is_init_fini): New function.
(xtensa_move_literals): Only attempt to assign literal pool to
literals with tc_frag_data.is_literal mark and not in .init or
.fini sections.
Join nested 'if' conditions to simplify function structure.
(xtensa_switch_to_non_abs_literal_fragment): Use
xtensa_is_init_fini to test for .init/.fini sections.
* testsuite/gas/xtensa/all.exp (auto-litpools-3)
(auto-litpools-4, text-section-literals-1): New tests.
* testsuite/gas/xtensa/auto-litpools-3.d: New test results.
* testsuite/gas/xtensa/auto-litpools-3.s: New test source.
* testsuite/gas/xtensa/auto-litpools-4.d: New test results.
* testsuite/gas/xtensa/auto-litpools-4.s: New test source.
* testsuite/gas/xtensa/text-section-literals-1.d: New test results.
* testsuite/gas/xtensa/text-section-literals-1.s: New test source.
xtensa GDB may be used with both bare-metal and linux-based
applications. In case of bare-metal application gdbserver is able to
provide information about all CPU registers: both unprivileged and
privileged. In case of linux-based application only a small subset of
privileged state is available. Currently xtensa GDB only expects
unprivileged registers in 'g' packets and it fails to communicate with
server that sends both privileged and unprivileged registers.
Allow bare-metal xtensa GDB to deal with both privileged and
unprivileged registers by initializing tdep->num_regs with the total
number of target CPU registers. Keep linux-based xtensa GDB
functionality as is by copying tdep->num_nopriv_regs to tdep->num_regs.
gdb/
2018-05-09 Max Filippov <jcmvbkbc@gmail.com>
* xtensa-linux-tdep.c (xtensa-tdep.h): New include.
(xtensa_linux_init_abi): Limit tdep->num_regs by
tdep->num_nopriv_regs.
* xtensa-tdep.c (xtensa_derive_tdep): Calculate
tdep->num_nopriv_regs and only copy it to tdep->num_regs if it's
not initialized.
My original implementation for LDI32 pseudo does not conform to
the TI ABI. I wrongly documented my TI PRU ELF object files inspection,
which got propagated into my binutils implementation.
Issue was exposed when running the GCC ABI testsuite against TI toolchain.
According to TI ABI, LDI32 must use first LDI instruction to load
the MSB 16bits, and second LDI instruction for the LSB 16bits.
This patch will break binary compatibility with previously released
binutils versions for PRU. Still, I think it is better to fix
binutils to conform to the chip vendor ABI.
bfd * elf32-pru.c (pru_elf32_do_ldi32_relocate): Make LDI32 relocation
conformant to TI ABI.
(pru_elf32_relax_section): Likewise.
(pru_elf_relax_delete_bytes): Fix offsets for new LDI32 code.
* elf32-pru.c (pru_elf32_do_ldi32_relocate): Ignore addend.
(pru_elf32_pmem_relocate): Trap - should not get here.
(pru_elf32_relocate_section): Add support for REL relocations.
(elf_info_to_howto_rel): Enable REL.
(elf_backend_may_use_rel_p): Likewise.
(elf_backend_may_use_rela_p): Likewise.
(elf_backend_default_use_rela_p): Likewise.
gas * config/tc-pru.c (md_apply_fix): Make LDI32 relocation conformant
to TI ABI.
(pru_assemble_arg_i): Likewise.
(output_insn_ldi32): Likewise.
* testsuite/gas/pru/ldi.d: Update test for the now fixed LDI32.
* gas/config/tc-pru.c (pru_assemble_arg_b): Check imm8 operand range.
* gas/testsuite/gas/pru/illegal2.l: New test.
* gas/testsuite/gas/pru/illegal2.s: New test.
* gas/testsuite/gas/pru/pru.exp: Register new illegal2 test.
ld * scripttempl/pru.sc: Add LD sections to allow linking TI
toolchain object files.
* scripttempl/pru.sc: Switch to init_array.
* testsuite/ld-pru/ldi32.d: Update LDI32 test to conform to TI ABI.
* testsuite/ld-pru/norelax_ldi32-data.d: Likewise.
* testsuite/ld-pru/norelax_ldi32-dis.d: Likewise.
* testsuite/ld-pru/relax_ldi32-data.d: Likewise.
* testsuite/ld-pru/relax_ldi32-dis.d: Likewise.
When building with x86_64-w64-mingw32-g++ (to test cross-compiling for
Windows), I get this error:
unittests/string_view-selftests.o: In function `selftests::string_view::inserters_2::test05(unsigned long long)':
/home/emaisin/src/binutils-gdb/gdb/unittests/basic_string_view/inserters/char/2.cc:60: undefined reference to `std::basic_ofstream<char, std::char_traits<char> >::rpl_close()'
This is caused by gnulib redefining "close" as "rpl_close", and
therefore messing up the declaration of basic_ofstream in the libstdc++
header. The solution would be to use gnulib namespaces [1]. Until we
use them across GDB, we can use them locally in files that are
problematic, like this one.
gdb/ChangeLog:
* unittests/string_view-selftests.c: Define GNULIB_NAMESPACE.
For GNU/Linux on x86-64, if the target is using the xsave format for
passing the floating-point information from the inferior then there
currently exists a bug relating to the x87 control registers, and the
mxcsr register.
The xsave format allows different floating-point features to be lazily
enabled, a bit in the xsave format tells GDB which floating-point
features have been enabled, and which have not.
Currently in GDB, when reading the floating point state, we check the
xsave bit flags, if the feature is enabled then we read the feature
from the xsave buffer, and if the feature is not enabled, then we
supply the default value from within GDB.
Within GDB, when writing the floating point state, we first fetch the
xsave state from the target and then, for any feature that is not yet
enabled, we write the default values into the xsave buffer. Next we
compare the regcache value with the value in the xsave buffer, and, if
the value has changed we update the value in the xsave buffer, and
mark the feature enabled in the xsave bit flags.
The problem then, is that the x87 control registers were not following
this pattern. We assumed that these registers were always written out
by the kernel, and we always wrote them out to the xsave buffer (but
didn't enabled the feature). The result of this is that if the kernel
had not yet enabled the x87 feature then within GDB we would see
random values for the x87 floating point control registers, and if the
user tried to modify one of these register, that modification would be
lost.
Finally, the mxcsr register was also broken in the same way as the x87
control registers. The added complexity with this case is that the
mxcsr register is part of both the avx and sse floating point feature
set. When reading or writing this register we need to check that at
least one of these features is enabled.
This bug was present in native GDB, and within gdbserver. Both are
fixed with this commit.
gdb/ChangeLog:
* common/x86-xstate.h (I387_FCTRL_INIT_VAL): New constant.
(I387_MXCSR_INIT_VAL): New constant.
* amd64-tdep.c (amd64_supply_xsave): Only read state from xsave
buffer if it was supplied by the inferior.
* i387-tdep.c (i387_supply_fsave): Use I387_MXCSR_INIT_VAL.
(i387_xsave_get_clear_bv): New function.
(i387_supply_xsave): Only read x87 control registers from the
xsave buffer if the feature is enabled, and the state will have
been written, otherwise, provide a suitable default.
(i387_collect_xsave): Pre-clear all registers in xsave buffer,
including x87 control registers. Update control registers if they
have changed from the default value, and mark features as enabled
as required.
* i387-tdep.h (i387_xsave_get_clear_bv): Declare.
gdb/gdbserver/ChangeLog:
* i387-fp.c (i387_cache_to_xsave): Only write x87 control
registers to the cache if their values have changed.
(i387_xsave_to_cache): Provide default values for x87 control
registers when these features are available, but disabled.
* regcache.c (supply_register_by_name_zeroed): New function.
* regcache.h (supply_register_by_name_zeroed): Declare new
function.
gdb/testsuite/ChangeLog:
* gdb.arch/amd64-init-x87-values.S: New file.
* gdb.arch/amd64-init-x87-values.exp: New file.
Another fuzzing fix. I think it's reasonable to simply strip out any
group section that is too weird for objcopy to handle.
PR 23141
* objcopy.c (is_strip_section): Strip groups without a valid
signature symbol.
Defining SPE2_OPCD_SEGS as 13 discounts the possibility that we'd
ever look up spe2_opcd_indices[14..16], which I think is possible.
Extend that array to size 16+1, using the macros we use to index the
array. Similarly use the index macros for PPC_OPCD_SEGS and
VLE_OPCD_SEGS.
* ppc-dis.c (PPC_OPCD_SEGS): Define using PPC_OP.
(VLE_OPCD_SEGS, SPE2_OPCD_SEGS): Similarly, using macros used to
partition opcode space for index lookup.
The formatting of the output of the "info spu event" command changed, causing
spurious test suite failures. Use phex instead of phex_nz to get back the
expected format, and fix emission of new line characters.
gdb/ChangeLog:
2018-05-08 Ulrich Weigand <uweigand@de.ibm.com>
* spu-tdep.c (info_spu_event_command): Fix output formatting.
PR 22809
* elf.c (bfd_elf_get_str_section): Check for an excessively large
string section.
* elf-attrs.c (_bfd_elf_parse_attributes): Issue an error if the
attribute section is larger than the size of the file.