Commit Graph

105466 Commits

Author SHA1 Message Date
Tom Tromey
c04da66c26 Implement Ada operator overloading
In the expression rewrite, I neglected to carry over support for Ada
operator overloading.  It turns out that there were no tests for this
in-tree.

This patch adds support for operator overloading, and adds the missing
test.

gdb/ChangeLog
2021-03-15  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (numeric_type_p, integer_type_p): Return true for
	fixed-point.
	* ada-exp.y (maybe_overload): New function.
	(ada_wrap_overload): New function.
	(ada_un_wrap2, ada_wrap2, ada_wrap_op): Use maybe_overload.
	(exp1, simple_exp, relation, and_exp, and_then_exp, or_exp)
	(or_else_exp, xor_exp, primary): Update.

gdb/testsuite/ChangeLog
2021-03-15  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/operator_call/twovecs.ads: New file.
	* gdb.ada/operator_call/twovecs.adb: New file.
	* gdb.ada/operator_call/opcall.adb: New file.
	* gdb.ada/operator_call.exp: New file.
2021-03-15 06:23:13 -06:00
Tom Tromey
9863c3b5fc Fix regression in Ada ptype
This fixes PR ada/27545, which points out that a test in
gdb.ada/tagged.exp started failing due to the expression rewrite.  I
didn't notice this failure because my system gcc-gnat debuginfo was
out of date, and so the test was already failing in the baseline.

Previously, the OP_VAR_VALUE case in ada_evaluate_subexp ended up
doing a recursive call:

    arg1 = evaluate_subexp (nullptr, exp, pos, EVAL_NORMAL);

However, during the rewrite I missed this fact and had the new code
call the superclass implementation.

This patch fixes the bug by changing this code to use a recursive call
instead.

gdb/ChangeLog
2021-03-15  Tom Tromey  <tromey@adacore.com>

	PR ada/27545:
	* ada-lang.c (ada_var_value_operation::evaluate): Use recursive
	call for tagged type.
2021-03-15 06:23:13 -06:00
Tom Tromey
1ac7452264 Fix Ada assignment resolution
The expression rewrite missed an Ada resolution case.  GDB previously
knew how to disambiguate the right hand side of an assignment, but now
it does not.

This patch fixes the problem and adds the missing test case.

gdb/ChangeLog
2021-03-15  Tom Tromey  <tromey@adacore.com>

	* ada-exp.y (exp1): Handle resolution of the right hand side of an
	assignment.

gdb/testsuite/ChangeLog
2021-03-15  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/enums_overload/enums_overload_main.adb: New file.
	* gdb.ada/enums_overload/enums_overload.ads: New file.
	* gdb.ada/enums_overload/enums_overload.adb: New file.
	* gdb.ada/enums_overload.exp: New file.
2021-03-15 06:23:12 -06:00
Tom Tromey
207582c075 Fix bug in Ada aggregate assignment
The expression rewrite caused a regression in the internal AdaCore
test suite.  The bug was that I had dropped a bit of code from
aggregate assignment -- assign_aggregate used to return the container,
which I thought was redundant, but which can actually change during
the call.  There was no test for this case in the tree, so I've added
one.

gdb/ChangeLog
2021-03-15  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (ada_aggregate_operation::assign_aggregate): Return
	container.
	(ada_assign_operation::evaluate): Update.
	* ada-exp.h (class ada_aggregate_operation) <assign_aggregate>:
	Change return type.

gdb/testsuite/ChangeLog
2021-03-15  Tom Tromey  <tromey@adacore.com>

	* gdb.ada/assign_arr/target_wrapper.ads (IArray, Put, Do_Nothing):
	Declare.
	* gdb.ada/assign_arr/target_wrapper.adb: New file.
	* gdb.ada/assign_arr/main_p324_051.adb (IValue): New variable.
	Call Put.
	* gdb.ada/assign_arr.exp: Update.
2021-03-15 06:23:12 -06:00
Nick Clifton
1996d0f12c Add a symbols-only mode to nm.
PR 27487
	* nm.c (FORMAT_JUST_SYMBOLS): Define.
	(struct optput_fns): Add entry for FORMAT_JUST_SYMBOLS.
	(long_options): Add just-symbols.
	(set_output_format): Add support for just-symbols.
	(get_print_format): Likewise.
	(do_not_print_object_filename): New function.
	(do_not_print_archive_filename): New function.
	(do_not_print_archive_member): New function.
	(do_not_print_symbol_filename): New function.
	(just_print_symbol_name): New function.
	(main): Handle --just-symbols.
	* NEWS: Mention the new feature.
	* doc/binutils.texi: Document the new feature.
2021-03-15 10:55:49 +00:00
Felix Willgerodt
8d624a9d80 gdb/fortran: Fix quad floating-point type for Intel compilers.
Intel Fortran compilers emit the following DWARF for gdb.fortran/complex.f90:

0x00000071:   DW_TAG_base_type
                DW_AT_name	("COMPLEX*32")
                DW_AT_encoding	(DW_ATE_complex_float)
                DW_AT_byte_size	(0x20)

0x00000078:   DW_TAG_base_type
                DW_AT_name	("REAL*16")
                DW_AT_encoding	(DW_ATE_float)
                DW_AT_byte_size	(0x10)

This results in GDB not reading the right values, as it wrongly assumes the
default floatformat "floatformat_i387_ext" instead of
"floatformat_ia64_quad_little".

gdb/ChangeLog:
2021-03-15  Felix Willgerodt  <felix.willgerodt@intel.com>

	* i386-tdep.c (i386_floatformat_for_type): Add COMPLEX*32 and REAL*16.
2021-03-15 11:02:31 +01:00
Jan Beulich
c68b1842bd ld: don't chance overrunning PE .reloc section content
The allocation of reloc_d doesn't take reloc_s->size into account. There
is already padding being emitted up to the allocated size. While
reloc_s->size ought to still be zero at this point anyway (and hence the
code being deleted would have been just dead), don't risk writing past
the actual allocation.
2021-03-15 11:00:44 +01:00
Andrew Burgess
ba6a0ef349 gdb: use make_scoped_restore to restore gdbpy_current_objfile
The current mechanism by which the Python gdb.current_objfile is
maintained does not allow for nested auto-load events.  It is assumed
that once an auto-load script has finished loading then the current
objfile should be set back to NULL.  In a nested situation, we should
be restoring the previous value.

We already have an RAII class to handle save/restore type behaviour,
so lets just switch to use that.

The test is a little contrived, but is simple enough, and triggers the
bug.  The real use case might involve the auto-load script calling
functions (either in the just-loaded object file, or in the main
executable), which in turn trigger further auto-loads to occur.

gdb/ChangeLog:

	* python/python.c (gdbpy_source_objfile_script): Use
	make_scoped_restore to restore gdbpy_current_objfile.
	(gdbpy_execute_objfile_script): Likewise.

gdb/testsuite/ChangeLog:

	* gdb.python/py-auto-load-chaining-f1.c: New file.
	* gdb.python/py-auto-load-chaining-f1.o-gdb.py: New file.
	* gdb.python/py-auto-load-chaining-f2.c: New file.
	* gdb.python/py-auto-load-chaining-f2.o-gdb.py: New file.
	* gdb.python/py-auto-load-chaining.c: New file.
	* gdb.python/py-auto-load-chaining.exp: New file.
2021-03-15 09:21:37 +00:00
GDB Administrator
e838b3ca21 Automatic date update in version.in 2021-03-15 00:00:06 +00:00
Tom Tromey
7c290a04a2 Use cu_header consistently in read_attribute_value
read_attribute_value has a local cu_header variable, but then some
spots in the function use cu->header instead.  It seems better to me
to prefer the local everywhere, so this patch makes this change.

gdb/ChangeLog
2021-03-14  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (read_attribute_value): Use cu_header
	consistently.
2021-03-14 11:59:37 -06:00
Tom Tromey
0280fdcc08 Minor tweak to use die_reader_specs::abfd
For an experiment I'm working on, it would be convenient if
die_reader_specs::cu could be NULL.  This is fairly involved to
implement, but I did notice one spot that could conveniently be
updated.  While making this trivial change, I also noticed a small,
related formatting error.

2021-03-14  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (struct die_reader_specs) <abfd>: Fix formatting.
	(peek_die_abbrev): Use reader.abfd.
2021-03-14 11:50:06 -06:00
Tom Tromey
a9f172c6b7 Set dwarf2_per_cu_data::m_header_read_in
I noticed that nothing in dwarf2/read.c sets
dwarf2_per_cu_data::m_header_read_in.  This patch adds the appropriate
assignment.

gdb/ChangeLog
2021-03-14  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (dwarf2_per_cu_data::get_header): Set
	m_header_read_in.
2021-03-14 11:50:01 -06:00
GDB Administrator
933721ed0c Automatic date update in version.in 2021-03-14 00:00:07 +00:00
Tom Tromey
7c32eebb87 Constify abbrev_table::lookup_abbrev
This changes abbrev_table::lookup_abbrev to return a pointer to const,
then fixes up the affected code.

gdb/ChangeLog
2021-03-13  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (struct partial_die_info): Update.
	(peek_die_abbrev, skip_children, skip_one_die, read_full_die_1)
	(load_partial_dies, partial_die_info::partial_die_info): Update.
	* dwarf2/abbrev.h (lookup_abbrev): Constify.
2021-03-13 09:41:05 -07:00
Tom Tromey
27012aba8a Remove Irix 6 workaround from DWARF abbrev reader
abbrev_table::read has a workaround for Irix 6.  The last release of
Irix was in 2006, and (according to Wikipedia) hardware produced after
2007 cannot run Irix.  I think this workaround can safely be retired.

gdb/ChangeLog
2021-03-13  Tom Tromey  <tom@tromey.com>

	* dwarf2/abbrev.c (abbrev_table::read): Remove Irix 6 workaround.
2021-03-13 09:41:05 -07:00
Mike Frysinger
e7d9022ba8 sim: rename BUILD_LDFLAGS to LDFLAGS_FOR_BUILD
The rest of the binutils tree renamed this variable many years ago.
2021-03-13 11:21:13 -05:00
Mike Frysinger
c6c7769d9d sim: introduce {COMPILE,LINK}_FOR_BUILD
These use the same pattern as seen in the opcodes/ dir and in automake
in general (ish).  This helps simplify the boilerplate for building and
linking build-time code, and fixes some inconsistency in flag usage.

For rules that were compiling+linking in a single step, split them into
separate steps so we can apply the correct set of options.  This matches
automake behavior too.
2021-03-13 11:15:46 -05:00
Mike Frysinger
367c5eb750 sim: drop dep on configure-gdb
I'm not entirely sure why this is here since the sim doesn't use
anything from the gdb/ dir directly, and the commit that added it
included a bunch more changes and doesn't seem to call out this
dep specifically.
2021-03-12 19:50:26 -05:00
GDB Administrator
8673b5d2e0 Automatic date update in version.in 2021-03-13 00:00:06 +00:00
Christian Biesinger
fece451c2a Use RAII to set the per-thread SIGSEGV handler
This avoids using a thread-local extern variable, which causes link errors
on some platforms, notably Cygwin.  But I think this is a better pattern
even outside of working around linker bugs because it encapsulates direct
access to the variable inside the class, instead of having a global extern
variable.

The cygwin link error is:
cp-support.o: in function `gdb_demangle(char const*, int)':
/home/Christian/binutils-gdb/obj/gdb/../../gdb/cp-support.c:1619:(.text+0x6472): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `TLS init function for thread_local_segv_handler'
/home/Christian/binutils-gdb/obj/gdb/../../gdb/cp-support.c:1619:(.text+0x648b): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `TLS init function for thread_local_segv_handler'
collect2: error: ld returned 1 exit status

2021-03-12  Christian Biesinger  <cbiesinger@google.com>

	PR threads/27239
	* cp-support.c: Use scoped_segv_handler_restore.
	* event-top.c (thread_local_segv_handler): Made static.
	(scoped_segv_handler_restore::scoped_segv_handler_restore):
	New function.
	(scoped_segv_handler_restore::~scoped_segv_handler_restore): New
	function.
	* event-top.h (class scoped_segv_handler_restore): New class.
	(thread_local_segv_handler): Removed.
2021-03-12 11:21:42 -06:00
Frederic Cambus
be3b926d8d Add values for NetBSD .note.netbsd.ident notes (PaX).
* elf/common.h (NT_NETBSD_PAX, NT_NETBSD_PAX_MPROTECT)
 (NT_NETBSD_PAX_NOMPROTECT, NT_NETBSD_PAX_GUARD, NT_NETBSD_PAX_NOGUARD)
 (NT_NETBSD_PAX_ASLR, NT_NETBSD_PAX_NOASLR): Define.
2021-03-12 14:37:51 +00:00
Przemyslaw Wirkus
7fce7ea986 aarch64: Add few missing system registers
This patch adds few missing system registers to GAS: LORC_EL1,
LOREA_EL1, LORN_EL1, LORSA_EL1, ICC_CTLR_EL3, ICC_SRE_ELX, ICH_VTR_EL2.

gas/ChangeLog:

2021-03-02  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* testsuite/gas/aarch64/illegal-sysreg-7.d: New test.
	* testsuite/gas/aarch64/illegal-sysreg-7.l: New test.
	* testsuite/gas/aarch64/illegal-sysreg-7.s: New test.
	* testsuite/gas/aarch64/sysreg-7.d: New test.
	* testsuite/gas/aarch64/sysreg-7.s: New test.

opcodes/ChangeLog:

2021-03-02  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

	* aarch64-opc.c: Add lorc_el1, lorea_el1, lorn_el1, lorsa_el1,
	icc_ctlr_el3, icc_sre_elx, ich_vtr_el2 system registers.
2021-03-12 14:20:46 +00:00
Alan Modra
203a206d14 riscv --enable-targets=all on 32-bit host
Attempting to build --enable-targets=all on a 32-bit host results in a
number of errors like the following.

eelf32lriscv.o: in function `gldelf32lriscv_after_allocation':
eelf32lriscv.c:98: undefined reference to `bfd_elf32_riscv_restart_relax_sections'

That's due to needing --enable-64-bit-bfd to get the riscv BFD support
built.

	* Makefile.am (ALL_EMULATION_SOURCES): Move riscv files to..
	(ALL_64_EMULATION_SOURCES): ..here.
	* Makefile.in: Regenerate.
2021-03-12 23:01:01 +10:30
Andrew Burgess
7f99d636c2 gdb/testsuite: resolve remaining duplicate test names in gdb.python/*.exp
This commit resolves the remaining duplicate test names in the
gdb.python/ directory, there's 1 duplicate per test script.  In each
case I have just extended some test names to make them more
descriptive.

gdb/testsuite/ChangeLog:

	* gdb.python/py-bad-printers.exp: Extend test names to make them
	unique.
	* gdb.python/py-events.exp: Likewise.
	* gdb.python/py-finish-breakpoint2.exp: Likewise.
	* gdb.python/py-frame-inline.exp: Likewise.
	* gdb.python/py-frame.exp: Likewise.
	* gdb.python/py-infthread.exp: Likewise.
2021-03-12 12:18:34 +00:00
Andrew Burgess
323b848c51 gdb/testsuite: remove duplicate test from gdb.python/py-value-cc.exp
While squashing duplicate test names I spotted an actual duplicate
test, I suspect a copy & paste error in an earlier patch.  I can see
no reason why we should need to duplicate this test, so I'm removing
one copy of it.

gdb/testsuite/ChangeLog:

	* gdb.python/py-value-cc.exp: Remove a duplicate test.
2021-03-12 12:18:34 +00:00
Andrew Burgess
8a4efb366f gdb/testsuite: check the correct Python variable in test
While squashing duplicate test names I spotted what looked like a copy
& paste error.  During this test a Python variable is created, and
then we call the type method on that variable.  In one case we create
a variable and then call the type method on a variable created for a
previous test.  I can see no reason why this should be what we want,
it doesn't line up with the comments in the test script, so I've
updated the test.  Note, the expected result doesn't change, just the
command issued (the test relates to stripping typedefs).

gdb/testsuite/ChangeLog:

	* gdb.python/lib-types.exp: Update the test to check the correct
	python variable.
2021-03-12 12:18:33 +00:00
Andrew Burgess
66bb1dd9cd gdb/testsuite: make test names unique in gdb.python/py-explore-cc.exp
Add additional text to some test names to make them unique.  In one
case, correct the test name (copy & paste error) to make it correctly
reflect what the test is doing.

gdb/testsuite/ChangeLog:

	* gdb.python/py-explore-cc.exp: Extend test names to make them
	unique.
2021-03-12 12:18:33 +00:00
Andrew Burgess
0125fabc7a gdb/testsuite: remove a duplicate test
I spotted a duplicate test name in this test script.  Turns out it's
an actual duplicate test.  Delete one copy of this test.

gdb/testsuite/ChangeLog:

	* gdb.python/py-lookup-type.exp: Remove duplicate test.
2021-03-12 12:18:33 +00:00
Andrew Burgess
79d041578d gdb/testsuite: make test names unique in gdb.python/py-symtab.exp
Extend the names of some tests to make them unique.

gdb/testsuite/ChangeLog:

	* gdb.python/py-symtab.exp: Extend test names to make them
	unique.
2021-03-12 12:18:33 +00:00
Andrew Burgess
e3e48d8fdb gdb/testsuite: make test names unique in gdb.python/py-prompt.exp
Use with_test_prefix to make test names unique.

gdb/testsuite/ChangeLog:

	* gdb.python/py-prompt.exp: Add with_test_prefix to make test
	names unique.
2021-03-12 12:18:33 +00:00
Andrew Burgess
2cb60e747b gdb/testsuite: make test names unique in gdb.python/py-block.exp
Extend some test names to make them unique.

gdb/testsuite/ChangeLog:

	* gdb.python/py-block.exp: Give tests unique names.
2021-03-12 12:18:33 +00:00
Andrew Burgess
8b12ded4e6 gdb/testsuite: make test names unique in gdb.python/py-pp-maint.exp
Extend the test names with additional text to make them unique.

gdb/testsuite/ChangeLog:

	* gdb.python/py-pp-maint.exp: Extend test names to make them
	unique.
2021-03-12 12:18:33 +00:00
Andrew Burgess
93598ea43d gdb/testsuite: make test names unique in gdb.python/py-explore.exp
Add a with_test_prefix to make test names unique.

gdb/testsuite/ChangeLog:

	* gdb.python/py-explore.exp: Add with_test_prefix to make test
	names unique.
2021-03-12 12:18:33 +00:00
Andrew Burgess
f35d6971cd gdb/testsuite: make test names unique in gdb.python/py-finish-breakpoint.exp
Make test names unique by just adding additional text to the test
names.  As this is a Python test that repeatedly imports the Python
script I've just numbered the test names in this case rather than
trying to come up with anything better, hence we have:

  import python scripts, 1
  import python scripts, 2
  ...
  import python scripts, 6

Not great, but hopefully good enough.  Everything else has a slightly
more descriptive test name.

gdb/testsuite/ChangeLog:

	* gdb.python/py-finish-breakpoint.exp: Make test names unique.
2021-03-12 12:18:33 +00:00
Andrew Burgess
22d3e7f629 gdb/testsuite: make test names unique in gdb.python/py-strfns.exp
Wrap some code in `with_test_prefix` to make test names unique.

gdb/testsuite/ChangeLog:

	* gdb.python/py-strfns.exp: Use with_test_prefix to make test
	names unique.
2021-03-12 12:18:33 +00:00
Andrew Burgess
5fc5a1b882 gdb/testsuite: make test names unique in gdb.python/py-format-string.exp
Make use of `proc_with_prefix` for every test_* proc in order to make
the test names unique within this test file.

gdb/testsuite/ChangeLog:

	* gdb.python/py-format-string.exp: Use proc_with_prefix to make
	test names unique.
2021-03-12 12:18:33 +00:00
Andrew Burgess
e3141a4d89 gdb/testsuite: make test names unique in gdb.python/py-mi.exp
Use with_test_prefix to make the test names unique.

gdb/testsuite/ChangeLog:

	* gdb.python/py-mi.exp: Use with_test_prefix to make test names
	unique.
2021-03-12 12:18:33 +00:00
Clément Chigot
1b2cb8e2ee aix: implement TLS relocation for gas and ld
Add support for TLS in XCOFF. Amongst the things done by this commit:
 - Update XCOFF auxialiary header to match new version and allow TLS
   sections.
 - Add TLS sections (.tdata and .tbss) support in gas and ld.
 - Add support for the TLS relocations in gas and ld.
   Two different types BFD_RELOC are created for PPC and PPC64 as
   the size is a pointer, thus distinct in 32 or 64bit.

The addresses given by ld to .tdata and .tbss is a bit special. In
XCOFF, these addresses are actually offsets from the TLS pointer
computed at runtime. AIX assembly and linker does the same. In
top of that, the .tdata must be before .data (this is mandatory for AIX
loader). Thus, the aix ld script is recomputing "." before .data to restore
its original value. There might be a simpler way, but this one is working.

Optimisation linked to TLS relocations aren't yet implemented.

bfd/
	* reloc.c (BFD_RELOC_PPC_TLS_LE, BFD_RELOC_PPC_TLS_IE,
	BFD_RELOC_PPC_TLS_M, BFD_RELOC_PPC_TLS_ML, BFD_RELOC_PPC64_TLS_GD,
	BFD_RELOC_PPC64_TLS_LD, BFD_RELOC_PPC64_TLS_LE,
	BFD_RELOC_PPC64_TLS_IE, BFD_RELOC_PPC64_TLS_M,
	BFD_RELOC_PPC64_TLS_ML): New relocations.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* coff-rs6000.c (xcoff_calculate_relocation): Call
	xcoff_reloc_type_tls for TLS relocations.
	(xcoff_howto_table): Implement TLS relocations.
	(_bfd_xcoff_reloc_type_lookup): Add cases TLS relocations.
	(xcoff_reloc_type_tls): New function.
	* coff64-rs6000.c (xcoff_calculate_relocation): Likewise.
	(xcoff_howto_table): Likewise.
	(_bfd_xcoff_reloc_type_lookup): Likewise.
	* coffcode.h (sec_to_styp_flags): Handle TLS sections.
	(styp_to_sec_flags): Likewise.
	(coff_compute_section_file_positions): Avoid file offset
	optimisation for .data when the previous section is .tdata.
	(coff_write_object_contents): Handle TLS sections.
	* coffswap.h (coff_swap_aouthdr_out): Add support for
	new fields in aouthdr.
	* libxcoff.h (xcoff_reloc_type_tls): Add prototype.
	* xcofflink.c (xcoff_link_add_symbols): Handle XMC_UL.
	(xcoff_need_ldrel_p): Add cases for TLS relocations.
	(xcoff_create_ldrel): Add l_symndx for TLS sections.
gas/
	* config/tc-ppc.c (ppc_xcoff_text_section, ppc_xcoff_data_section,
	(ppc_xcoff_bss_section, ppc_xcoff_tdata_section,
	(ppc_xcoff_tbss_section): New variables.
	(ppc_text_subsegment, ppc_text_csects, ppc_data_subgments,
	(ppc_data_csects): Removed.
	(ppc_xcoff_section_is_initialized, ppc_init_xcoff_section,
	ppc_xcoff_parse_cons): New functions.
	(md_being): Initialize XCOFF sections.
	(ppc_xcoff_suffix): Add support for TLS relocations
	(fixup_size, md_apply_fix): Add support for new BFD_RELOC.
	(ppc_change_csect): Handle XMC_TL, XMC_UL.  Correctly, add XMC_BS
	to .bss section.  Handle new XCOFF section variables.
	(ppc_comm): Likewise.
	(ppc_toc): Likewise.
	(ppc_symbol_new_hook): Likewise.
	(ppc_frob_symbol): Likewise.
	(ppc_fix_adjustable): Add tbss support.
	* config/tc-ppc.h (TC_PARSE_CONS_EXPRESSION): New define.
	(ppc_xcoff_parse_cons): Add prototype.
	(struct ppc_xcoff_section): New structure.
ld/
	* emultempl/aix.em: Ensure .tdata section is removed
	if empty, even with -r flag.
	* scripttempl/aix.sc: Handle TLS sections.
	* testsuite/ld-powerpc/aix52.exp: Add new tests.
	* testsuite/ld-powerpc/aix-tls-reloc-32.d: New test.
	* testsuite/ld-powerpc/aix-tls-reloc-64.d: New test.
	* testsuite/ld-powerpc/aix-tls-reloc.ex: New test.
	* testsuite/ld-powerpc/aix-tls-reloc.s: New test.
	* testsuite/ld-powerpc/aix-tls-section-32.d: New test.
	* testsuite/ld-powerpc/aix-tls-section-64.d: New test.
	* testsuite/ld-powerpc/aix-tls-section.ex: New test.
	* testsuite/ld-powerpc/aix-tls-section.s: New test.
include/
	* coff/internal.h (struct internal_aouthdr): Add new fields.
	* coff/rs6000.h (AOUTHDRÃ): Add new fields.
	* coff/rs6k64.h (struct external_filehdr): Likewise.
	* coff/xcoff.h (_TDATA), _TBSS): New defines
	(RS6K_AOUTHDR_TLS_LE, RS6K_AOUTHDR_RAS, RS6K_AOUTHDR_ALGNTDATA,
	RS6K_AOUTHDR_SHR_SYMTAB, RS6K_AOUTHDR_FORK_POLICY,
	RS6K_AOUTHDR_FORK_COR): New defines.
	(XMC_TU): Removed.
	(XMC_UL): New define.
2021-03-12 22:47:33 +10:30
Clément Chigot
4a403be0c1 aix: implement R_TOCU and R_TOCL relocations
Implement support for largetoc on XCOFF.
R_TOCU and R_TOCL are referenced by the new BFD defines:
BFD_RELOC_PPC_TOC16_HI and BFD_RELOC_PPC_TOC16_LO.
A new toc storage class is added XMC_TE.

In order to correctly handle R_TOCU, the logic behind
xcoff_reloc_type_toc is changed to compute the whole TOC offset
instead of just the difference between the "link" offset and the
"assembly" offset.

In gas, add a function to transform addis format used by AIX
"addis RT, D(RA)" into the ELF format "addis RT, RA, SI".

bfd/
	* reloc.c (BFD_RELOC_PPC_TOC16_HI, BFD_RELOC_PPC_TOC16_LO):
	New relocations.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* coff-rs6000.c (xcoff_calculate_relocation): Call
	xcoff_reloc_type_toc for R_TOCU and R_TOCL.
	(xcoff_howto_table): Remove src_mask for TOC relocations.
	Add R_TOCU and R_TOCL howtos.
	(_bfd_xcoff_reloc_type_lookup): Add cases for
	BFD_RELOC_PPC_TOC16_HI and BFD_RELOC_PPC_TOC16_LO.
	(xcoff_reloc_type_toc): Compute the whole offset.
	Implement R_TOCU and R_TOCL.
	* coff64-rs6000.c (xcoff64_calculate_relocation):
	Likewise.
	(xcoff64_howto_table): Likewise.
	(xcoff64_reloc_type_lookup): Likewise.
gas/
	* config/tc-ppc.c (ppc_xcoff_suffix): New function.
	(MAP, MAP32, MAP64): New macros for XCOFF.
	(ppc_xcoff_fixup_addis): New function.
	(ppc_is_toc_sym): Handle XMC_TE.
	(fixup_size): Add cases for BFD_RELOC_PPC_TOC16_HI and
	BFD_RELOC_PPC_TOC16_LO.
	(md_assemble): Call ppc_xcoff_fixup_addis for XCOFF.
	(ppc_change_csect): Handle XMC_TE.
	(ppc_tc): Enable .tc symbols to have only a XMC_TC or XMC_TE
	storage class.
	(ppc_symbol_new_hook): Handle XMC_TE.
	(ppc_frob_symbol): Likewise.
	(ppc_fix_adjustable): Likewise.
	(md_apply_fix): Handle BFD_RELOC_PPC_TOC16_HI and
	BFD_RELOC_PPC_TOC16_LO.
ld/
	* scripttempl/aix.sc: Add .te to .data section.
	* testsuite/ld-powerpc/aix52.exp: Add test structure for AIX7+.
	Add aix-largetoc-1 test.
	* testsuite/ld-powerpc/aix-largetoc-1-32.d: New test.
	* testsuite/ld-powerpc/aix-largetoc-1-64.d: New test.
	* testsuite/ld-powerpc/aix-largetoc-1.ex: New test.
	* testsuite/ld-powerpc/aix-largetoc-1.s: New test.
2021-03-12 22:47:23 +10:30
Clément Chigot
2c1bef53de aix: correct HOWTO table and add missing relocations
Since the last time AIX HOWTO table was modified, IBM has now
released an official documentation about XCOFF relocations.
This commit corrects the wrong ones and add some missing.
For now, the "custom" relocations made for xcoff_rtype2howto have
been kept.
The new relocations are still set as EMPTY_HOWTO because they will
be implemented in later commits.

In xcoff[64]_ppc_relocate_section, instead of recreating howto
from scratch, it's better to use the existing howto from the
table and fixing it according to r_size field.

bfd/
	* coff-rs6000.c (xcoff_calculate_relocation): Correct and
	add new relocations.
	(xcoff_howto_table): Likewise.
	(xcoff_rtype2howto): Increase r_type maximum value.
	(xcoff_ppc_relocate_section): Reuse predefined HOWTOs instead
	of create a new one from scratch.  Enable only some relocations
	to have a changing r_size.
	* coff64-rs6000.c (xcoff64_calculate_relocation): Likewise.
	(xcoff64_howto_table): Likewise.
	(xcoff64_rtype2howto): Likewise.
	(xcoff64_ppc_relocate_section): Likewise.
	* libxcoff.h (XCOFF_MAX_CALCULATE_RELOCATION): Fix value.
binutils/
	* od-xcoff.c: Replace RTB by TRL entry.
include/
	* coff/xcoff.h (R_RTB): Remove.
	(R_TRL): Fix value.
2021-03-12 22:08:20 +10:30
Clément Chigot
0c929e83c1 bfd: move xcoff64_ppc_relocate_section after the HOWTO table
This will be needed for later commits, as xcoff64_ppc_relocate_section
will use the HOWTO table unlike now.

	* coff64-rs6000.c (xcoff64_ppc_relocate_section): Move.
2021-03-12 13:09:21 +10:30
Clément Chigot
6d4d932867 bfd: use default coff_write_object_contents for XCOFF64
There is no need for XCOFF64 to have is own write_object_contents.

	* coff64-rs6000.c (xcoff64_write_object_contents): Remove.
	* coffcode.h (coff_write_object_contents): Add bfd_mach_ppc_620
	support for o_cputype field.  Avoid creating an empty a.out header
	for XCOFF64.
2021-03-12 13:04:00 +10:30
Clément Chigot
8aa2d0236a bfd: add missing smclass when creating csect for xcoff64
* coff64-rs6000.c (xcoff64_create_csect_from_smclas): Add
	missing smclass.
2021-03-12 13:00:11 +10:30
Alan Modra
78c84bf926 Re: x86: correct decoding of nop/reserved space (0f18 ... 0x1f)
* i386-dis.c (print_insn <PREFIX_IGNORED>): Correct typo.
2021-03-12 10:41:34 +10:30
Alan Modra
68cb21837f PE image base fallout
Fixes x86_64-w64-mingw32 tests that failed with the recent diagnosis
for out of range RVA, and a couple of other gc-sections tests that failed
for other reasons.

	* testsuite/ld-gc/gc.exp: Pass "-image-base 0" to ld for PE, and
	arrange to define __main for some run_dump_test tests.
	* testsuite/ld-gc/pr13683.d: Accept more symbols.
	* testsuite/ld-gc/pr14265.d: Likewise, and ordering.
	* testsuite/ld-scripts/crossref.exp: Pass "-image-base 0" to ld for PE.
	* testsuite/ld-srec/srec.exp: Likewise.
	* testsuite/lib/ld-lib.exp (ld_link_defsyms): Use is_pecoff_format.
2021-03-12 10:41:34 +10:30
GDB Administrator
1e1e17e5e2 Automatic date update in version.in 2021-03-12 00:00:19 +00:00
Jan Beulich
fd1fd06186 x86: re-order logic in OP_XMM()
Instead of excluding an increasing number of modes in the initial if(),
check the special modes first.
2021-03-11 16:21:48 +01:00
Jan Beulich
ac7a231133 x86: drop a few redundant EVEX-related checks
vex.b can only be set when vex.evex is also set. Similarly vex.evex can
only be set when need_vex is also set.
2021-03-11 16:21:19 +01:00
Jan Beulich
da944c8a70 x86: remove stray uses of xmmq_mode
xmmq_mode is documented to not allow for broadcast - don't include it in
respective checks in OP_E_memory().
2021-03-11 16:20:37 +01:00
Nelson Chu
ebdcad3fdd RISC-V: Improve multiple relax passes problem.
According to the commit abd20cb637, an
intersting thing is that - the more relax passes, the more chances of
relaxations are reduced [1].  Originally, we set the boolean `again`
to TRUE once the code is actually deleted, and then we run the relaxations
repeatedly if `again` is still TRUE.  But `again` only works for the
relax pass itself, and won't affect others.  That is - we can not use
`again` to re-run the relax pass when we already enter into the following
passes (can not run the relax passes backwards).  Besides, we must seperate
the PCREL relaxations into two relax passes for some reasons [2], it make
us lose some relax opportunities.

This patch try to fix the problem, and the basic idea was come from Jim
Wilson - we use a new boolean, restart_relax, to determine if we need to
run the whole relax passes again from 0 to 2.  Once we have deleted the
code between relax pass 0 to 2, the restart_relax will be set to TRUE,
we should run the whole relaxations again to give them more chances to
shorten the code.  We will only enter into the relax pass 3 when the
restart_relax is FALSE, since we can't relax anything else once we start
to handle the alignments.

I have passed the gcc/binutils regressions by riscv-gnu-toolchain, and
looks fine for now.

[1] https://sourceware.org/pipermail/binutils/2020-November/114223.html
[2] https://sourceware.org/pipermail/binutils/2020-November/114235.html

bfd/
    * elfnn-riscv.c (riscv_elf_link_hash_table): New boolean restart_relax,
    used to check if we need to run the whole relaxations from relax pass 0
    to 2 again.
    (riscv_elf_link_hash_table_create): Init restart_relax to FALSE.
    (_bfd_riscv_relax_align): Remove obsolete sec_flg0 set.
    (_bfd_riscv_relax_delete): Set again to TRUE if we do delete the code.
    (bfd_elfNN_riscv_restart_relax_sections): New function.  Called by
    after_allocation to check if we need to run the whole relaxations again.
    (_bfd_riscv_relax_section): We will only enter into the relax pass 3 when
    the restart_relax is FALSE; At last set restart_relax to TRUE if again is
    TRUE, too.
    * elfxx-riscv.h (bfd_elf32_riscv_restart_relax_sections): Declaration.
    (bfd_elf64_riscv_restart_relax_sections): Likewise.
ld/
    * emultempl/riscvelf.em (after_allocation): Run ldelf_map_segments many
    times if riscv_restart_relax_sections returns TRUE.
    * testsuite/ld-riscv-elf/restart-relax.d: New testcase.  Before applying
    this patch, the call won't be relaxed to jal; But now we have more chances
    to do relaxations.
    * testsuite/ld-riscv-elf/restart-relax.s: Likewise.
    * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
2021-03-11 17:27:13 +08:00