Commit Graph

97173 Commits

Author SHA1 Message Date
Alan Modra 50ff67e6cf ld TDIRS substitution
It is no longer true that autoconf/automake cannot substitute vars
with embedded new-lines.

	* configure.ac (TDIRS): Build up tdirs in this variable and
	AC_SUBST, also using AM_SUBST_NOTMAKE.
	* configure: Regenerate.
	* Makefile.am (DISTCLEANFILES): Remove tdirs.
	* Makefile.in: Regenerate.
2019-04-13 12:12:43 +09:30
Andrew Burgess 35add35e85 gdb: Fix failure in gdb.base/complex-parts.exp for x86-32
The x86-32 ABI specifies 96-bit long double, this was causing a
failure on the test gdb.base/complex-parts.exp.

The problem is that GDB tries to find a builtin floating point type of
the correct size in order to reuse the name of that type as the name
for the components of the complex type being built.

Previously GDB was only aware of floating point types sized 32, 64, or
128 bits.  This patch teaches GDB how to handle 96 bit floating point
type.

gdb/ChangeLog:

	* dwarf2read.c (dwarf2_init_complex_target_type): Handle complex
	target types of size 96-bits, add some additional comments, and
	check that the builtin type we found was the correct size.
2019-04-13 01:02:43 +01:00
GDB Administrator 9c9f1b1f39 Automatic date update in version.in 2019-04-13 00:00:35 +00:00
John Darrington 8114a5c51e GAS: S12Z: Remove definition of macro TC_M68K.
gas/config:
	* tc-s12z.h: Remove inappropriate macro definition.
2019-04-12 18:39:01 +02:00
John Darrington e5a557ac01 S12Z: opcodes: Replace "operator" with "optr".
opcodes/
	* s12z-dis.c, s12z-opc.c, s12z-opc.h: Replace operator with optr.
2019-04-12 18:39:01 +02:00
John Darrington d04ebfb817 GAS: tc-s12z.c: int -> bfd_boolean
Use bfd_boolean where appropriate.
2019-04-12 18:39:01 +02:00
Eli Zaretskii 51196bbc56 Another fix for GDB styling
gdb/ChangeLog:
2019-04-12  Eli Zaretskii  <eliz@gnu.org>

	* utils.c (prompt_for_continue): Don't restore the styling at the
	end, as applied_style has the wrong value.  This fixes styling in
	long lists of file names that are interrupted by the "Continue?"
	prompt.
2019-04-12 15:35:57 +03:00
Nick Clifton 3bbec4bd95 Fix thinko in linker documentation.
PR 24450
	* ld.texi (Output Section Attributes): Add ALIGN_WITH_INPUT to
	example of section attributes.
2019-04-12 13:15:21 +01:00
Alan Hayward e5a1a79a4e Testsuite: Add gdbserver sysroot test
The local board file ensures that the sysroot is always set to load
files from the local filesystem.

Add a gdbserver test to explicitly test the sysroot set to both the
remote target and the local filesystem.

gdb/testsuite/ChangeLog:

	* gdb.server/sysroot.c: New test.
	* gdb.server/sysroot.exp: New file.
	* lib/gdbserver-support.exp (gdb_target_cmd): Add additional text
        matching param.
2019-04-12 11:37:24 +01:00
Andrew Burgess 62253a6147 gdb: Remove LANG_MAGIC
The language_defn structure has an la_magic field, this used to be
used as a basic check that the language_defn structure had the
expected layout - at least the end of the structure was where we
expected it to be.

This feature only really makes sense if we imagine GDB dynamically
loading language support from dynamic libraries, where a version
mismatch might cause problems.

However, in current GDB language support is statically built into GDB,
and since this commit:

    commit 47e77640be
    Date:   Thu Jul 20 18:28:01 2017 +0100

        Make language_def O(1)

the existing (if pointless) check of the la_magic field was removed.

There now appears to be no use of the la_magic field, and I propose
that we delete it.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* ada-lang.c (ada_language_defn): Remove use of LANG_MAGIC.
	* c-lang.c (c_language_defn): Likewise.
	(cplus_language_defn): Likewise.
	(asm_language_defn): Likewise.
	(minimal_language_defn): Likewise.
	* d-lang.c (d_language_defn): Likewise.
	* f-lang.c (f_language_defn): Likewise.
	* go-lang.c (go_language_defn): Likewise.
	* language.c (unknown_language_defn): Likewise.
	(auto_language_defn): Likewise.
	* language.h (struct language_defn): Remove la_magic field.
	(LANG_MAGIC): Delete.
	* m2-lang.c (m2_language_defn): Remove use of LANG_MAGIC.
	* objc-lang.c (objc_language_defn): Likewise.
	* opencl-lang.c (opencl_language_defn): Likewise.
	* p-lang.c (pascal_language_defn): Likewise.
	* rust-lang.c (rust_language_defn): Likewise.
2019-04-12 09:28:16 +01:00
GDB Administrator 3822612df0 Automatic date update in version.in 2019-04-12 00:00:26 +00:00
Andrew Burgess a9158a863c gdb/riscv: Remove riscv_type_alignment function
Make use of the type_align function and remove riscv_type_alignment as
it is no longer needed.  I tested this against a number of RV32 and
RV64 targets, and I also ran the tests with an assertion in place
checking that the old riscv_type_alignment function gives the same
answer as the common type_align function - it does, and all the tests
still pass.

gdb/ChangeLog:

	* riscv-tdep.c (riscv_type_align): New function.
	(riscv_type_alignment): Delete.
	(riscv_arg_location): Use 'type_align'.
	(riscv_gdbarch_init): Register riscv_type_align gdbarch function.
2019-04-11 23:40:25 +01:00
Andrew Burgess 41077b6625 gdb: Fix alignment computation for structs with only static fields
The current code in gdbtypes.c:type_align incorrectly returns 0 as the
alignment for a structure containing only static fields.  After this
patch the correct value of 1 is returned.  The gdb.base/align.exp test
is extended to cover this case.

gdb/ChangeLog:

	* gdbtypes.c (type_align): A struct with no non-static fields also
	has alignment of 1.

gdb/testsuite/ChangeLog:

	* gdb.base/align.exp: Extend test to cover structures containing
	only static fields.
2019-04-11 23:40:25 +01:00
Andrew Burgess 9f0272f854 gdb/riscv: Handle empty C++ structs during argument passing
This commit resolves a large number of failures in the test script
gdb.base/infcall-nested-structs.exp which were caused by GDB (for
RISC-V) incorrectly handling empty C++ structures when preparing
arguments for a dummy call, or collecting a return value.

The issue is further complicated in that there was a bug in GCC, such
that in some cases GCC would generate incorrect code when passing a
small structure that contained empty sub-structures.  This was fixed
in GCC trunk on 5-March-2019, so in order to see the best results with
this patch you'll need a recent version of GCC.

Anything that used to work should continue to work after this patch,
regardless of GCC version being used.

The fix in this commit is that GDB now pays more attention to the
offset of fields within a structure when preparing arguments as in C++
an empty structure has a non-zero size, this is an example:

  struct s1 { struct s2 { } empty; int f; };

We previously assumed that 'f' was at offset 0 inside type 's1',
however this is not the case in C++ as 's2' has size 1, and with
alignment 'f' is likely at some even bigger offset inside 's1'.

gdb/ChangeLog:

	* riscv-tdep.c (riscv_call_arg_complex_float): Fix offset of first
	component to 0.
	(riscv_struct_info::riscv_struct_info): Initialise m_offsets
	member.
	(riscv_struct_info::analyse): New implementation using new
	analyse_inner member function.
	(riscv_struct_info::field_offset): New member function.
	(riscv_struct_info::m_offsets): New member variable.
	(riscv_struct_info::analyse_inner): New private member function,
	takes the old implementation of riscv_struct_info::analyse but
	extended to track field offsets.
	(riscv_call_arg_struct): Update the struct folding special cases
	to handle cases where empty C++ structs, which are non-zero
	length, are found.
	(riscv_arg_location): Initialise the length of each location, a
	non-zero length now indicates the location is in use.
	(riscv_push_dummy_call): Allow for the first location having a
	non-zero offset when setting up arguments.
	(riscv_return_value): Likewise, but for return values.
2019-04-11 23:37:45 +01:00
Tom Tromey 02cf60c7a4 Make "msg" const in internal_vproblem
I noticed that the "msg" variable in internal_vproblem could be
"const".  This seems like an improvement because it can wind up in
rodata.

Tested by rebuilding.

gdb/ChangeLog
2019-04-11  Tom Tromey  <tromey@adacore.com>

	* utils.c (internal_vproblem): Make "msg" const.
2019-04-11 13:00:48 -06:00
Max Filippov c0b4cd4655 xtensa: gas: add relaxations tests
gas/
2019-04-11  Max Filippov  <jcmvbkbc@gmail.com>

	* testsuite/gas/xtensa/loop-relax-2.d: New test definition.
	* testsuite/gas/xtensa/loop-relax.d: New test definition.
	* testsuite/gas/xtensa/loop-relax.s: New test source.
	* testsuite/gas/xtensa/text-section-literals-1a.d: New test
	definition.
	* testsuite/gas/xtensa/text-section-literals-2.d: New test
	definition.
	* testsuite/gas/xtensa/text-section-literals-2.s: New test
	source.
	* testsuite/gas/xtensa/text-section-literals-2a.d: New test
	definition.
	* testsuite/gas/xtensa/text-section-literals-3.d: New test
	definition.
	* testsuite/gas/xtensa/text-section-literals-3.s: New test
	source.
	* testsuite/gas/xtensa/text-section-literals-4.d: New test
	definition.
	* testsuite/gas/xtensa/text-section-literals-4.s: New test
	source.
	* testsuite/gas/xtensa/text-section-literals-4a.d: New test
	definition.
2019-04-11 11:42:12 -07:00
Max Filippov 6f2b771531 xtensa: gas: convert tests to run_dump_tests
gas/
2019-04-11  Max Filippov  <jcmvbkbc@gmail.com>

	* testsuite/gas/xtensa/all.exp: Remove all expect-based
	tests and all explicit run_dump_test / run_list_test
	invocations. Add run_dump_tests for all .d files in the
	test subdirectory.
	* testsuite/gas/xtensa/entry_align.d: New test definition.
	* testsuite/gas/xtensa/entry_align.l: New test output.
	* testsuite/gas/xtensa/entry_misalign.d: New test definition.
	* testsuite/gas/xtensa/entry_misalign2.d: New test definition.
	* testsuite/gas/xtensa/j_too_far.d: New test definition.
	* testsuite/gas/xtensa/j_too_far.l: New test output.
	* testsuite/gas/xtensa/loop_align.d: New test definition.
	* testsuite/gas/xtensa/loop_misalign.d: New test definition.
	* testsuite/gas/xtensa/trampoline-2.d: New test definition.
	* testsuite/gas/xtensa/trampoline-2.l: Remove empty output.
	* testsuite/gas/xtensa/xtensa-err.exp: Use positive logic.
2019-04-11 11:41:36 -07:00
Max Filippov f8aecf3cc9 xtensa: gas: clean up literal management code
gas/
2019-04-11  Max Filippov  <jcmvbkbc@gmail.com>

	* config/tc-xtensa.c (xtensa_literal_pseudo): Drop code that has
	no effect.
	(get_literal_pool_location): Only search for the literal pool
	when auto litpools is used, otherwise take one recorded in the
	tc_segment_info_data.
	(xtensa_assign_litpool_addresses): New function.
	(xtensa_move_literals): Don't duplicate 'literal pool location
	required...' error message. Call xtensa_assign_litpool_addresses.
2019-04-11 11:40:52 -07:00
Max Filippov 548791769d xtensa: gas: put .literal_position at section start
Provide literal position at the beginning of each section for literal
space reserved by relaxations when text-section-literals or
auto-litpools options are used. Remove code that adds fill frag to the
literal section for every .literal_position directive to avoid creation
of empty literal sections.

Fix auto-litpools tests that got literal pool address changes.

gas/
2019-04-11  Max Filippov  <jcmvbkbc@gmail.com>

	* config/tc-xtensa.c (xtensa_is_init_fini): Add declaration.
	(xtensa_mark_literal_pool_location): Don't add fill frag to literal
	section that records literal pool location.
	(md_begin): Call xtensa_mark_literal_pool_location when text
	section literals or auto litpools are used.
	(xtensa_elf_section_change_hook): Call
	xtensa_mark_literal_pool_location when text section literals or
	auto litpools are used, there's no literal pool location defined
	for the current section and it's not .init or .fini.
	* testsuite/gas/xtensa/auto-litpools-first1.d: Fix up addresses.
	* testsuite/gas/xtensa/auto-litpools-first2.d: Likewise.
	* testsuite/gas/xtensa/auto-litpools.d: Likewise.
2019-04-11 11:40:07 -07:00
Faraz Shahbazker 035801cebe ld: Add --no-print-map-discarded option
Add a new option to disable the listing of discarded sections
in map file output.  The use case stems from a large application
built with -ffunction-sections --gc-sections where the list of
discarded sections blows up the map file output.  The default
behaviour remains to print discarded sections,  but the new option
allows us to disable it.

ld/
	* NEWS: Mention new option --no-print-map-discarded.
	* ld.h (ld_config_type) <print_map_discarded>: New field.
	* ldlang.c (lang_map): Conditionally output discarded sections
	in map files based on configuration option.
	* ldlex.h (option_values) <OPTION_PRINT_MAP_DISCARDED,
	OPTION_NO_PRINT_MAP_DISCARDED>: New.
	* ldmain.c (main): Enabled print_map_discarded by default.
	* lexsup.c (ld_options): Add new command-line options.
	(parse_args) <OPTION_NO_PRINT_MAP_DISCARDED,
	OPTION_PRINT_MAP_DISCARDED>: New cases.
	* ld.texi: Document new options.
	* testsuite/ld-gc/gc.exp: Add new test.
	* testsuite/ld-gc/skip-map-discarded.s: New file.
	* testsuite/ld-gc/skip-map-discarded.d: New file.
	* testsuite/ld-gc/skip-map-discarded.map: New file.
2019-04-11 10:16:31 -07:00
Tom de Vries c30391f893 [gdb/testsuite] Add cc-with-dwz.exp and cc-with-dwz-m.exp
We can use CC_WITH_TWEAKS_FLAGS when cd-ing into the gdb build subdir and
invoking make check:
...
$ cd $objdir/gdb
$ make check \
    RUNTESTFLAGS='--target_board=cc-with-tweaks' \
    CC_WITH_TWEAKS_FLAGS='-z'
...

But when cd-ing into the top-level build dir and invoking make check-gdb
instead:
...
$ cd $objdir
$ make check-gdb \
    RUNTESTFLAGS='--target_board=cc-with-tweaks' \
    CC_WITH_TWEAKS_FLAGS='-z'
...
using CC_WITH_TWEAKS_FLAGS has no effect, because CC_WITH_TWEAKS_FLAGS is not
passed down from the top level Makefile.

Add cc-with-dwz.exp and cc-with-dwz-m.exp, that don't require
CC_WITH_TWEAKS_FLAGS to be set in the make invocation, allowing us to run these
test configurations from the toplevel build dir:
...
$ cd $objdir
$ make check-gdb \
    RUNTESTFLAGS='--target_board=cc-with-dwz'
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-04-11  Tom de Vries  <tdevries@suse.de>

	* boards/cc-with-dwz-m.exp: New file.
	* boards/cc-with-dwz.exp: New file.
	* boards/cc-with-tweaks.exp: Note that check-gdb doesn't work.
2019-04-11 19:13:05 +02:00
H.J. Lu 233a00833b x86: Add -z cet-report=[none|warning|error]
Add -z cet-report=[none|warning|error] to report the missing Intel
Indirect Branch Tracking (IBT) and Shadow Stack (SHSTK) properties
in input .note.gnu.property section.  -z cet-report=none, which is
the default, will make the linker not report missing properties in
input files.  -z cet-report=warning will make the linker issue a
warning for missing properties in input files.  -z cet-report=error
will make the linker issue an error for missing properties in input
files.  Note that -z ibt will turn off the missing IBT property report
and -z shstk will turn off the missing SHSTK property report.
Supported for Linux/i386 and Linux/x86_64.

bfd/

	* elf-linker-x86.h (elf_x86_cet_report): New.
	(elf_linker_x86_params): Add cet_report.
	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Report
	missing IBT and SHSTK properties if needed.

ld/

	* ld.texi: Document -z cet-report=[none|warning|error].
	* emulparams/cet.sh: Add -z cet-report=[none|warning|error].
	* testsuite/ld-i386/i386.exp: Run -z cet-report=[warning|error]
	tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/property-x86-cet1.d: New file.
	* testsuite/ld-i386/property-x86-cet2a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet2b.d: Likewise.
	* testsuite/ld-i386/property-x86-cet3a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet3b.d: Likewise.
	* testsuite/ld-i386/property-x86-cet4a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet4b.d: Likewise.
	* testsuite/ld-i386/property-x86-cet5a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet5b.d: Likewise.
	* testsuite/ld-i386/property-x86-cet6.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet.s: Likewise.
	* testsuite/ld-x86-64/property-x86-cet1-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet1.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet4a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet4a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet4b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet4b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet6-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet6.d: Likewise.
2019-04-11 08:21:30 -07:00
H.J. Lu ca4e633102 Add PR ld/24436 to ChangeLog entry 2019-04-11 07:55:58 -07:00
H.J. Lu b3d7a86748 ld: Add -static-pie tests
Add -static-pie tests for DT_INIT_ARRAY, DT_FINI_ARRAY, DT_PREINIT_ARRAY
and IFUNC.

	* testsuite/config/default.exp (STATIC_PIE_LDFLAGS): New.  Set
	to "-static-pie" if target compiler supports it.
	* testsuite/ld-elf/elf.exp: Run -static-pie tests if
	$STATIC_PIE_LDFLAGS isn't empty.
	* testsuite/ld-ifunc/ifunc.exp: Likewise.
2019-04-11 06:52:03 -07:00
H.J. Lu a0ea3a14dc Check corrupt VTENTRY entry in bfd_elf_gc_record_vtentry
Instead of BFD_ASSERT (h != NULL) with

ld: BFD ... assertion fail .../bfd/elf64-x86-64.c:2562
ld: bad.o: invalid string offset 50331648 >= 371 for section `nterp'

check corrupt VTENTRY entry in bfd_elf_gc_record_vtentry with

ld: bad.o: section 'g': corrupt VTENTRY entry

	* elf-m10300.c (mn10300_elf_check_relocs): Remove BFD_ASSERT of
	"h != NULL".  Don't check "h != NULL" before calling.
	bfd_elf_gc_record_vtentry.
	* elf32-arm.c (elf32_arm_check_relocs): Likewise.
	* elf32-bfin.c (bfin_check_relocs): Likewise.
	* elf32-cris.c (cris_elf_check_relocs): Likewise.
	* elf32-csky.c (csky_elf_check_relocs): Likewise.
	* elf32-d10v.c (elf32_d10v_check_relocs): Likewise.
	* elf32-dlx.c (elf32_dlx_check_relocs): Likewise.
	* elf32-fr30.c (fr30_elf_check_relocs): Likewise.
	* elf32-frv.c (elf32_frv_check_relocs): Likewise.
	* elf32-hppa.c (elf32_hppa_check_relocs): Likewise.
	* elf32-i386.c (elf_i386_check_relocs): Likewise.
	* elf32-iq2000.c (iq2000_elf_check_relocs): Likewise.
	* elf32-m32r.c (m32r_elf_check_relocs): Likewise.
	* elf32-m68hc1x.c (elf32_m68hc11_check_relocs): Likewise.
	* elf32-m68k.c (elf_m68k_check_relocs): Likewise.
	* elf32-mcore.c (mcore_elf_check_relocs): Likewise.
	* elf32-metag.c (elf_metag_check_relocs): Likewise.
	* elf32-or1k.c (or1k_elf_check_relocs): Likewise.
	* elf32-ppc.c (ppc_elf_check_relocs): Likewise.
	* elf32-s390.c (elf_s390_check_relocs): Likewise.
	* elf32-sh.c (sh_elf_check_relocs): Likewise.
	* elf32-v850.c (v850_elf_check_relocs): Likewise.
	* elf32-vax.c (elf_vax_check_relocs): Likewise.
	* elf32-xstormy16.c (xstormy16_elf_check_relocs): Likewise.
	* elf32-xtensa.c (elf_xtensa_check_relocs): Likewise.
	* elf64-mmix.c (mmix_elf_check_relocs): Likewise.
	* elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
	* elf64-s390.c (elf_s390_check_relocs): Likewise.
	* elf64-x86-64.c (elf_s390_check_relocs): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Likewise.
	* elflink.c (bfd_elf_gc_record_vtinherit): Check for corrupt
	VTENTRY entry.
2019-04-11 06:45:05 -07:00
Alan Modra 9bff840e8c PR24435, buffer overflow reading dynamic entries
PR 24435
	* elflink.c (elf_link_add_object_symbols): Don't read partial
	dynamic entries from fuzzed objects.
2019-04-11 20:57:09 +09:30
Tamar Christina ce12121b63 AArch64: When DF_BIND_NOW don't use TLSDESC GOT value.
When using DF_BIND_NOW on AArch64 we don't reserve the GOT slot for a TLSDESC,
but we still emitted DT_TLSDESC_GOT and DT_TLSDESC_PLT.  This caused random
memory corruption as the "special" value of (bfd_vma)-1 would be set for
dt_tlsdesc_got.

Since we don't have a value of dt_tlsdesc_got I also don't emit DT_TLSDESC_PLT
now becuase it would point to an incomplete PLT. To be able to write the PLT
entry DT_TLSDESC_GOT is needed and since we don't have one we can't write the
PLT entry either.

It is my understanding that GLIBC doesn't need these two entries when not lazy
loading.  Conversely AArch32 does not reserve neither the GOT not the PLT slot
when doing DF_BIND_NOW.

AArch32 does not need these checks because these values are initialized to 0
and so the if (...) checks don't pass, but on AArch64 these are initialized
to (bfd_vma)-1 and thus we need some extra checks.

bfd/ChangeLog:

	PR ld/24302
	* elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Don't emit
	DT_TLSDESC_GOT and DT_TLSDESC_PLT when DF_BIND_NOW.
	(elfNN_aarch64_finish_dynamic_sections): Don't write PLT if DF_BIND_NOW.

ld/ChangeLog:

	PR ld/24302
	* testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
	* testsuite/ld-aarch64/tls-relax-gdesc-le-now.d: New test.
2019-04-11 11:30:03 +01:00
Sudakshina Das bd7ceb8d26 [BINUTILS, AArch64, 2/2] Update Store Allocation Tag instructions
This patch updates the Store allocation tags instructions in
Armv8.5-A Memory Tagging Extension. This is part of the changes
that have been introduced recently in the 00bet10 release

All of these instructions have an updated register operand (Xt -> <Xt|SP>)

- STG <Xt|SP>, [<Xn|SP>, #<simm>]
- STG <Xt|SP>, [<Xn|SP>, #<simm>]!
- STG <Xt|SP>, [<Xn|SP>], #<simm>
- STZG <Xt|SP>, [<Xn|SP>, #<simm>]
- STZG <Xt|SP>, [<Xn|SP>, #<simm>]!
- STZG <Xt|SP>, [<Xn|SP>], #<simm>
- ST2G <Xt|SP>, [<Xn|SP>, #<simm>]
- ST2G <Xt|SP>, [<Xn|SP>, #<simm>]!
- ST2G <Xt|SP>, [<Xn|SP>], #<simm>
- STZ2G <Xt|SP>, [<Xn|SP>, #<simm>]
- STZ2G <Xt|SP>, [<Xn|SP>, #<simm>]!
- STZ2G <Xt|SP>, [<Xn|SP>], #<simm>

In order to accept <Rt|SP> a new operand type Rt_SP is introduced which has
the same field as FLD_Rt but follows other semantics of Rn_SP.

*** gas/ChangeLog ***

2019-04-11  Sudakshina Das  <sudi.das@arm.com>

	* config/tc-aarch64.c (process_omitted_operand): Add case for
	AARCH64_OPND_Rt_SP.
	(parse_operands): Likewise.
	* testsuite/gas/aarch64/armv8_5-a-memtag.d: Update tests.
	* testsuite/gas/aarch64/armv8_5-a-memtag.s: Likewise.
	* testsuite/gas/aarch64/illegal-memtag.l: Likewise.
	* testsuite/gas/aarch64/illegal-memtag.s: Likewise.

*** include/ChangeLog ***

2019-04-11  Sudakshina Das  <sudi.das@arm.com>

	* opcode/aarch64.h (enum aarch64_opnd): Add AARCH64_OPND_Rt_SP.

*** opcodes/ChangeLog ***

2019-04-11  Sudakshina Das  <sudi.das@arm.com>

	* aarch64-opc.c (aarch64_print_operand): Add case for
	AARCH64_OPND_Rt_SP.
	(verify_constraints): Likewise.
	* aarch64-tbl.h (QL_LDST_AT): Update to add SP qualifier.
	(struct aarch64_opcode): Update stg, stzg, st2g, stz2g instructions
	to accept Rt|SP as first operand.
	(AARCH64_OPERANDS): Add new Rt_SP.
	* aarch64-asm-2.c: Regenerated.
	* aarch64-dis-2.c: Regenerated.
	* aarch64-opc-2.c: Regenerated.
2019-04-11 10:19:37 +01:00
Sudakshina Das e54010f1ae [BINUTILS, AArch64, 1/2] Add new LDGM/STGM instruction
This patch adds the new LDGM/STGM instructions of the
Armv8.5-A Memory Tagging Extension. This is part of the changes
that have been introduced recently in the 00bet10 release

The instructions are as follows:
LDGM Xt, [<Xn|SP>]
STGM Xt, [<Xn|SP>]

*** gas/ChangeLog ***

2019-04-11  Sudakshina Das  <sudi.das@arm.com>

	* testsuite/gas/aarch64/armv8_5-a-memtag.d: New tests for ldgm and stgm.
	* testsuite/gas/aarch64/armv8_5-a-memtag.s: Likewise.
	* testsuite/gas/aarch64/illegal-memtag.l: Likewise.
	* testsuite/gas/aarch64/illegal-memtag.s: Likewise.

*** opcodes/ChangeLog ***

2019-04-11  Sudakshina Das  <sudi.das@arm.com>

	* aarch64-asm-2.c: Regenerated.
	* aarch64-dis-2.c: Likewise.
	* aarch64-opc-2.c: Likewise.
	* aarch64-tbl.h (aarch64_opcode): Add new ldgm and stgm.
2019-04-11 10:13:23 +01:00
Alan Hayward 68811f8ff8 AArch64: Ensure regcache is reset between tests
A recent change made the AArch64 self tests resuse the saved regs
cache, rather than creating a new one.  Ensure it is reset to default
values between tests.

Do this by splitting the reset functionality from trad_frame_alloc_saved_regs
into a new function.

Fixes selftest on AArch64.

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_analyze_prologue_test): Reset saved regs.
	* trad-frame.c (trad_frame_reset_saved_regs): New function.
	(trad_frame_alloc_saved_regs): Call trad_frame_reset_saved_regs.
	* trad-frame.h (trad_frame_reset_saved_regs): New declaration.
2019-04-11 09:51:07 +01:00
H.J. Lu 795e3bb7de ld: Don't define __rel[a]_iplt_start/__rel[a]_iplt_end in PIE
__rel[a]_iplt_start and __rel[a]_iplt_end are defined to handle IFUNC in
static executables.  For PIE, since IFUNC is handled as the part of the
normal dynamic relocation processing, there is no need to define these
symbols in PIE.

	* scripttempl/elf.sc (CREATE_PIC): New.  Set for CREATE_SHLIB or
	CREATE_PIE.
	(__rel_iplt_start): Don't define for CREATE_PIC.
	(__rel_iplt_end): Likewise.
	(__rela_iplt_start): Likewise.
	(__rela_iplt_end): Likewise.
2019-04-10 18:36:22 -07:00
Kevin Buettner 3f52fdbcb5 Fix amd64->i386 linux syscall restart problem
This commit fixes some failures in gdb.base/interrupt.exp
when debugging a 32-bit i386 linux inferior from an amd64 host.

When running the following test...

  make check RUNTESTFLAGS="--target_board unix/-m32 interrupt.exp"

... without this commit, I see the following output:

FAIL: gdb.base/interrupt.exp: continue (the program exited)
FAIL: gdb.base/interrupt.exp: echo data
FAIL: gdb.base/interrupt.exp: Send Control-C, second time
FAIL: gdb.base/interrupt.exp: signal SIGINT (the program is no longer running)
ERROR: Undefined command "".
ERROR: GDB process no longer exists

		=== gdb Summary ===

When the test is run with this commit in place, we see 12 passes
instead.  This is the desired behavior.

Analysis:

On Linux, when a syscall is interrupted by a signal, the syscall
may return -ERESTARTSYS when a signal occurs.  Doing so indicates that
the syscall is restartable.  Then, depending on settings associated
with the signal handler, and after the signal handler is called, the
kernel can then either return -EINTR or can cause the syscall to be
restarted.  In this discussion, we are concerned with the latter
case.

On i386, the kernel returns this status via the EAX register.

When debugging a 32-bit (i386) process from a 64-bit (amd64)
GDB, the debugger fetches 64-bit registers even though the
process being debugged is 32-bit.  Since we're debugging a 32-bit
target, only 32 bits are being saved in the register cache.
Now, ideally, GDB would save all 64-bits in the regcache and
then would be able to restore those same values when it comes
time to continue the target.  I've looked into doing this, but
it's not easy and I don't see many benefits to doing so.  One
benefit, however, would be that EAX would appear as a negative
value for doing syscall restarts.

At the moment, GDB is setting the high 32 bits of RAX (and other
registers too) to 0.  So, when GDB restores EAX just prior to
a syscall restart, the high 32 bits of RAX are zeroed, thus making
it look like a positive value.  For this particular purpose, we
need to sign extend EAX so that RAX will appear as a negative
value when EAX is set to -ERESTARTSYS.  This in turn will cause
the signal handling code in the kernel to recognize -ERESTARTSYS
which will in turn cause the syscall to be restarted.

This commit is based on work by Jan Kratochvil from 2009:

https://sourceware.org/ml/gdb-patches/2009-11/msg00592.html

Jan's patch had the sign extension code in amd64-nat.c.  Several
other native targets make use of this code, so it seemed better
to move the sign extension code to a linux specific file.  I
also added similar code to gdbserver.

Another approach is to fix the problem in the kernel.  Hui Zhu
tried to get a fix into the kernel back in 2014, but it was not
accepted.  Discussion regarding this approach may be found here:

https://lore.kernel.org/patchwork/patch/457841/

Even if a fix were to be put into the kernel, we'd still need
some kind of fix in GDB in order to support older kernels.

Finally, I'll note that Fedora has been carrying a similar patch for
at least nine years.  Other distributions, including RHEL and CentOS
have picked up this change and have been using it too.

gdb/ChangeLog:

	* amd64-linux-nat.c (amd64_linux_collect_native_gregset): New
	function.
	(fill_gregset): Call amd64_linux_collect_native_gregset instead
	of amd64_collect_native_gregset.
	(amd64_linux_nat_target::store_registers): Likewise.

gdb/gdbserver/ChangeLog:

	* linux-x86-low.c (x86_fill_gregset): Sign extend EAX value
	when using a 64-bit gdbserver.
2019-04-10 17:11:24 -07:00
GDB Administrator e7f0831be8 Automatic date update in version.in 2019-04-11 00:00:28 +00:00
Nick Clifton c1202057eb Pull in patch for libiberty that fixes a stack exhaustion bug when demangling a pathalogically constructed mangled name.
PR 89394
	* cp-demangle.c (cplus_demangle_fill_name): Reject negative
	lengths.
	(d_count_templates_scopes): Replace num_templates and num_scopes
	parameters with a struct d_print_info pointer parameter.  Adjust
	body of the function accordingly.  Add recursion counter and check
	that the recursion limit is not reached.
	(d_print_init): Pass dpi parameter to d_count_templates_scopes.
	Reset recursion counter afterwards, unless the recursion limit was
	reached.
2019-04-10 15:49:36 +01:00
Tom Tromey e9ad22ee5f Introduce a separate debug objfile iterator
This introduces a new iterator and range adapter for iteration over
the separate debug files of a given objfile.  As in the current
approach, the requested objfile is returned first, followed by the
separate debug objfiles.

gdb/ChangeLog
2019-04-10  Tom Tromey  <tom@tromey.com>

	* symtab.c (lookup_global_symbol_from_objfile)
	(lookup_symbol_in_objfile_from_linkage_name): Use the iterator.
	* objfiles.h (class separate_debug_iterator): New.
	(class separate_debug_range): New.
	(struct objfile) <separate_debug_objfiles>: New method.
	(objfile_separate_debug_iterate): Don't declare.
	* objfiles.c (separate_debug_iterator::operator++): Rename from
	objfile_separate_debug_iterate.
	(objfile_relocate, objfile_rebase, objfile_has_symbols): Use the
	iterator.
	* minsyms.c (lookup_minimal_symbol_by_pc_section): Use the
	iterator.
2019-04-10 08:05:17 -06:00
Tom Tromey ee3711344b Fix a couple of comments
While working on objfiles I noticed a typo in one comment, and another
comment that, as far as I can tell, has been obsolete for a very long
time.

gdb/ChangeLog
2019-04-10  Tom Tromey  <tom@tromey.com>

	* symfile.c (reread_symbols): Remove old comment.
	* objfiles.c (free_all_objfiles): Fix a typo.
2019-04-10 08:05:17 -06:00
Tom Tromey bf227d6105 Remove some uses of "object_files"
The "object_files" macro is sometimes used when iterating over
objfiles.  This patch removes a few such uses in favor of the new
range adapter.

gdb/ChangeLog
2019-04-10  Tom Tromey  <tom@tromey.com>

	* ia64-tdep.c (ia64_get_dyn_info_list): Use foreach.
	* minsyms.c (lookup_minimal_symbol): Use foreach.
	(lookup_minimal_symbol_text, lookup_minimal_symbol_by_pc_name)
	(lookup_minimal_symbol_solib_trampoline): Likewise.
	* symfile.c (reread_symbols): Use foreach.
2019-04-10 08:05:17 -06:00
Michael Forney b05971a652 PR24427, bfd/doc/chew.c reads uninitialized memory and subtracts from function pointer
PR 24427
	* doc/chew.c (free_words): Correctly free "push_text" strings.
2019-04-10 18:30:29 +09:30
Rainer Orth a5def729be Disable R_X86_64_PLT32 generation as branch marker on Solaris/x86
The fix H.J. implemented for PR gas/22791 in the thread starting at

	[PATCH] x86-64: Treat PC32 relocation with branch as PLT32
	https://sourceware.org/ml/binutils/2018-02/msg00065.html

is causing problems on Solaris/x86.  The native linker is strongly
preferred there, and there's no intention of implementing the linker
optimization he plans there.  Besides, the kernel runtime linker,
otherwise has no need to deal with that reloc at all, and instead of
adding (possibly even more) workarounds with no benefit, it seems
appropriate to disable the R_X86_64_PLT32 generation as branch marker on
Solaris/x86 in the first place.

The patch itself is trivial, the only complication is adapting the
testsuite.  Since I've found no way to have conditional sections in the
.d files, I've instead used the solution already found elsewhere of
having separate .d files for the affected tests in an i386/solaris
subdirectory and skipping the original ones.

Tested on amd64-pc-solaris2.11 and x86_64-pc-linux-gnu without
regressions.

	* config/tc-i386.c (need_plt32_p) [TE_SOLARIS]: Return FALSE.
	* testsuite/gas/i386/solaris/solaris.exp: New driver.
	* testsuite/gas/i386/solaris/reloc64.d,
	testsuite/gas/i386/solaris/x86-64-jump.d,
	testsuite/gas/i386/solaris/x86-64-mpx-branch-1.d,
	testsuite/gas/i386/solaris/x86-64-mpx-branch-2.d,
	testsuite/gas/i386/solaris/x86-64-nop-3.d,
	testsuite/gas/i386/solaris/x86-64-nop-4.d,
	testsuite/gas/i386/solaris/x86-64-nop-5.d,
	testsuite/gas/i386/solaris/x86-64-relax-2.d,
	testsuite/gas/i386/solaris/x86-64-relax-3.d: New tests.
	* testsuite/gas/i386/reloc64.d,
	testsuite/gas/i386/x86-64-jump.d,
	testsuite/gas/i386/x86-64-mpx-branch-1.d,
	testsuite/gas/i386/x86-64-mpx-branch-2.d,
	testsuite/gas/i386/x86-64-nop-3.d,
	testsuite/gas/i386/x86-64-nop-4.d,
	testsuite/gas/i386/x86-64-nop-5.d,
	testsuite/gas/i386/x86-64-relax-2.d,
	testsuite/gas/i386/x86-64-relax-3.d: Skip on *-*-solaris*.
2019-04-10 09:48:43 +02:00
Alan Modra e6aded7c34 Re: XFAIL PR ld/20995 tests for lynxos and nto targets
* testsuite/ld-elf/shared.exp: Don't xfail PR ld/20995 for
	powerpc-nto.
2019-04-10 15:32:56 +09:30
Alan Modra 53b81c6de1 cskyelf.em branch stub handling
This fixes the csky-elf ld-elf/pr21884 and ld-unique/pr21529 failures,
by disabling branch stubs for binary (and other non-csky) output.
The csky-linux target gets branch stubs off by default because
presumably there are reasons why branch stubs were disabled, but
rather than killing the support completely it can be enabled by
--branch-stub.

	* emultempl/cskyelf.em (csk_elf_before_parse): New function,
	setting use_branch_stub false for linux.
	(csky_elf_create_output_section_statements): Do emit this
	function and all others in the file for linux, plus the branch
	option control.  Disable branch stubs when non-ELF.
2019-04-10 13:30:32 +09:30
Alan Modra c55b17b809 Fix some ld dependencies
In looking at the csky-elf vs. csky-linux differences, the first thing
I compared was csky_elf.sh and cskyelf_linux.sh.  Those files are
mostly the same but besides the real differences, annoyingly have some
lines ordered differently.  It's better in such cases to have one file
source the other, making differences plain.  This patch does that for
csky and microblaze, removes an unused variable defined in a few
places, and fixes ld makefile dependencies.

	* Makefile.am (eskyelf.c, eskyelf_linux.c): Depend on cskyelf.em.
	(ecskyelf_linux.c): Depend on cskyelf.sh.
	(eelf32microblazeel.c): Depend on elf32microblaze.sh.
	* Makefile.in: Regenerate.
	* emulparams/cskyelf.sh: Comment regarding cskelf_linux.sh.
	(PAGE_SIZE): Don't define.
	* emulparams/cskyelf_linux.sh: Source sckyelf.sh, leaving just
	the differing variable defs/undefs.
	* emulparams/elf32mcore.sh (PAGE_SIZE): Don't define.
	* emulparams/elf32microblaze.sh: Comment re. elf32microblazeel.sh.
	(OUTPUT_FORMAT): Use BIG_OUTPUT_FORMAT.
	(PAGE_SIZE): Don't define.
	* emulparams/elf32microblazeel.sh: Source elf32microblaze.sh,
	leaving just the differing OUTPUT_FORMAT.
2019-04-10 13:30:32 +09:30
Alan Modra 6feda62721 Regen BLD-POTFILES.in
* po/BLD-POTFILES.in: Regenerate.
2019-04-10 13:30:32 +09:30
Alan Modra 12400dcc0f te-cloudabi.h
This patch is aimed a fixing large numbers of x86_64-cloudabi failures
caused by gas selecting the wrong target name.

	* config/te-cloudabi.h: New file.
	* config/tc-aarch64.c (aarch64_after_parse_args): Use TE_CLOUDABI
	rather than TARGET_OS to select cloudabi.
	* config/tc-i386.h (ELF_TARGET_FORMAT64): Define for TE_CLOUDABI.
	* configure.tgt (*-*-cloudabi*): Set em=cloudabi.
2019-04-10 13:27:29 +09:30
GDB Administrator 789ce185ac Automatic date update in version.in 2019-04-10 00:00:40 +00:00
Tom Tromey 8dc433a0fb Fix Rust lexer buglet
PR rust/24414 points out that the Rust lexer uses strtoul when lexing
an integer, and that this can give the wrong results in some
situations.

This patch changes it to use strtoulst, like most of the rest of gdb.
It also adds a self test.

Tested on x86-64 Fedora 29 using an i686 build.

gdb/ChangeLog
2019-04-09  Ivan Begert  <ivanbegert@gmail.com>
	    Tom Tromey  <tromey@adacore.com>

	PR rust/24414:
	* rust-exp.y (rust_parser::lex_number): Use strtoulst.
	(rust_lex_int_test): Change "value" to be LONGEST.
	(rust_lex_tests): Add test for long integer literal.
2019-04-09 13:21:13 -06:00
Tom Tromey b0319eaaf9 Use find_thread_in_random in select_event_lwp
I noticed that find_thread_in_random duplicates the code in
find_thread_in_random, so this patch changes the latter to use the
former.

There are two other spots in gdb that do this, but to unify all of
them would require switching some code from using the "iterate over"
idiom to using iterators.

Another possible improvement is that find_thread_in_random could be
made single-pass using reservoir sampling.

Tested by the buildbot.

gdb/gdbserver/ChangeLog
2019-04-09  Tom Tromey  <tromey@adacore.com>

	* linux-low.c (select_event_lwp): Use find_thread_in_random.
2019-04-09 12:03:25 -06:00
Tom Tromey 9ab8741a48 Consistently use bool for fake_pid_p
I noticed a few spots where fake_pid_p is handled as an int, whereas
the field in struct inferior has type bool.  This patch changes the
remaining places to use bool as well.

Tested by the buildbot.

gdb/ChangeLog
2019-04-09  Tom Tromey  <tromey@adacore.com>

	* remote.c (remote_target::remote_add_inferior): Change fake_pid_p
	to bool.
	(extended_remote_target::attach): Update.
	(remote_target::remote_notice_new_inferior): Update.
	(remote_target::add_current_inferior_and_thread): Update.
	* inferior.c (exit_inferior_1): Use "false".
	* corelow.c (add_to_thread_list): Make fake_pid_p bool.
2019-04-09 11:59:25 -06:00
Simon Marchi 9ca1957fcb Fix typo in latest ChangeLog entry 2019-04-09 12:35:29 -04:00
Simon Marchi e242fd1249 Use -qualified flag when setting temporary breakpoint in start command
When using the "start" command, GDB puts a temporary breakpoint on the
"main" symbol (we literally invoke the tbreak command).  However, since
it does wild matching by default, it also puts a breakpoint on any C++
method or "main" function in a namespace.  For example, when debugging
GDB, it creates a total of 24 locations:

  (gdb) start
  Temporary breakpoint 1 at 0x198c1e9: main. (24 locations)

as there are a bunch of methods called main in the selftests, such as

  selftests::string_view::capacity_1::main()

If such method was called in the constructor of a global object, or a
function marked with the attribute "constructor", then we would stop at
the wrong place.  Also, this causes a few extra symtabs (those that
contain the "wrong" mains) to be expanded for nothing.

The dummiest, most straightforward solution is to add -qualified when
invoking tbreak.  With this patch, "start" creates a single-location
breakpoint, as expected.

I copied the start.exp test to start-cpp.exp and made it use a C++ test
file, which contains two main functions.  The new test verifies that the
output of "start" is the output we get when we set a single-location
breakpoint.

gdb/ChangeLog:

	* infcmd.c (run_command_1): Pass -qualified to tbreak when usind
	the "start" command.

gdb/testsuite/ChangeLog:

	* gdb.base/start-cpp.exp: New file.
	* gdb.base/start-cpp.cc: New file.
2019-04-09 12:32:26 -04:00