Andrew Burgess [Fri, 12 Jun 2020 13:09:33 +0000 (15:09 +0200)]
gdb/testsuite: Prevent globals leaking between test scripts
Many of the test scripts create variables in the global namespace,
these variables will then be present for the following test scripts.
In most cases this is harmless, but in some cases this can cause
problems.
For example, if a variable is created as an array in one script, but
then assigned as a scalar in a different script, this will cause a TCL
error.
The solution proposed in this patch is to have the GDB test harness
record a list of all known global variables at the point just before
we source the test script. Then, after the test script has run, we
again iterate over all global variables. Any variable that was not in
the original list is deleted, unless it was marked as a persistent global
variable using gdb_persistent_global.
The assumption here is that no test script should need to create a
global variable that will outlive the lifetime of the test script
itself. With this patch in place all tests currently seem to pass, so
the assumption seems to hold.
gdb/testsuite/ChangeLog:
2020-06-12 Andrew Burgess <andrew.burgess@embecosm.com>
Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_known_globals, gdb_persistent_globals): New global.
(gdb_persistent_global, gdb_persistent_global_no_decl): New proc.
(gdb_setup_known_globals): New proc.
(gdb_cleanup_globals): New proc.
* lib/gdb.exp (load_lib): New override proc.
(gdb_stdin_log_init): Set var in_file as persistent global.
* lib/pascal.exp (gdb_stdin_log_init): Set vars
pascal_compiler_is_gpc, pascal_compiler_is_fpc, gpc_compiler and
fpc_compiler as persistent global.
Tom de Vries [Fri, 12 Jun 2020 11:29:43 +0000 (13:29 +0200)]
[gdb/testsuite] Don't leak tuiterm.exp spawn override
In lib/tuiterm.exp the builtin spawn is overridden by a tui-specific version.
After running the first test-case that imports tuiterm.exp, the override
remains active, so it can cause trouble in subsequent test-cases, even if they
do not import tuiterm.exp. See f.i. commit
c8d4f6dfd9 "[gdb/testsuite] Fix
spawn in tuiterm.exp".
Fix this by:
- adding a variable gdb_finish_hooks which is a list of procs to run during
gdb_finish
- adding a proc tuiterm_env that is used in test-cases instead of
"load_lib tuiterm.exp".
- letting tuiterm_env:
- install the tui-specific spawn version, and
- use the gdb_finish_hooks to schedule restoring the builtin spawn
version.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-06-12 Tom de Vries <tdevries@suse.de>
* lib/tuiterm.exp (spawn): Rename to ...
(tui_spawn): ... this.
(toplevel): Move rename of spawn ...
(gdb_init_tuiterm): ... here. New proc.
(gdb_finish_tuiterm): New proc.
* lib/gdb.exp (gdb_finish_hooks): New global var.
(gdb_finish): Handle gdb_finish_hooks.
(tuiterm_env): New proc.
* gdb.python/tui-window.exp: Replace load_lib tuiterm.exp with
tuiterm_env.
* gdb.tui/basic.exp: Same.
* gdb.tui/corefile-run.exp: Same.
* gdb.tui/empty.exp: Same.
* gdb.tui/list-before.exp: Same.
* gdb.tui/list.exp: Same.
* gdb.tui/main.exp: Same.
* gdb.tui/new-layout.exp: Same.
* gdb.tui/regs.exp: Same.
* gdb.tui/resize.exp: Same.
* gdb.tui/tui-layout-asm-short-prog.exp: Same.
* gdb.tui/tui-layout-asm.exp: Same.
* gdb.tui/tui-missing-src.exp: Same.
* gdb.tui/winheight.exp: Same.
Tom de Vries [Fri, 12 Jun 2020 07:13:17 +0000 (09:13 +0200)]
[gdb/testsuite] Don't abort testrun for invalid command in test-case
Say we add a call to foobar at the end of a test-case, and run the
test-suite. We'll run into a dejagnu error:
...
ERROR: (DejaGnu) proc "foobar" does not exist.
...
and the test-suite run is aborted.
It's reasonable that the test-case is aborted, but it's not reasonable that
the testsuite run is aborted.
Problems in one test-case should not leak into other test-cases, and they
generally don't. The exception is the "invalid command name" problem due to
an override of ::unknown in dejagnu's framework.exp.
Fix this by reverting dejagnu's ::unknown override for the duration of each
test-case, using the gdb_init/gdb_finish hooks.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-06-12 Tom de Vries <tdevries@suse.de>
PR testsuite/26110
* lib/gdb.exp (gdb_init): Revert dejagnu's override of ::unknown.
(gdb_finish): Reinstall dejagnu's override of ::unknown.
Nelson Chu [Thu, 11 Jun 2020 01:42:40 +0000 (18:42 -0700)]
RISC-V: Update the rebuild-csr-xml.sh.
We add new arguments defined and aborted verisons for DECLARE_CSR to
support privileged versions controling in binutils. Therefore, the
rebuild-csr-xml.sh should be updated, too.
gdb/
* features/riscv/rebuild-csr-xml.sh: Updated.
Nelson Chu [Wed, 10 Jun 2020 06:07:54 +0000 (14:07 +0800)]
RISC-V: Drop the privileged spec v1.9 support.
There is a conflict between v1.9 and v1.9.1 - CSR MISA address. MISA is
0xf10 in v1.9, but change to 0x301 in v1.9.1. The change made MISA writable,
but may also cause risk of compatibility. Binutils already support the
-mpriv-spec options and ELF priv attributes, which can used to choose what
privileged spec you want, and then give a correponding CSR name and address
to use. But Gdb and other tools don't have the simialr mechanism for now.
However, there are two things can be confirmed,
1. If we don't have a way to control the priv specs, then the changes, like
MISA, will cause risk and hard to maintain.
2. We get the guarantee that the CSR address won't be reused in the future
specs, even if it is dropped.
I'm not sure if Gdb needs to care about the priv spec versions, it is still
discussing. But drop the priv spec v1.9, and make sure that we won't reuse
the CSR address is a useful solution for now. Also, we might drop the v1.9.1
in a year or two. After that, specs above v1.10 should be compatible anyway.
gas/
* testsuite/gas/riscv/priv-reg-fail-version-1p9.d: Removed.
* testsuite/gas/riscv/priv-reg-fail-version-1p9.l: Likewise.
* testsuite/gas/riscv/priv-reg-version-1p9.d: Likewise.
include/
* opcode/riscv-opc.h: Update the defined versions of CSR from
PRIV_SPEC_CLASS_1P9 to PRIV_SPEC_CLASS_1P9P1. Also, drop the
MISA DECLARE_CSR_ALIAS since it's aborted version is v1.9.
* opcode/riscv.h (enum riscv_priv_spec_class): Remove
PRIV_SPEC_CLASS_1P9.
opcodes/
* riscv-opc.c (priv_specs): Remove v1.9 and PRIV_SPEC_CLASS_1P9.
GDB Administrator [Fri, 12 Jun 2020 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Thu, 11 Jun 2020 15:45:51 +0000 (09:45 -0600)]
Update documentation for Ada .gdb_index
.gdb_index now supports Ada, so update the documentation to reflect
this.
gdb/doc/ChangeLog
2020-06-11 Tom Tromey <tromey@adacore.com>
* gdb.texinfo (Index Files): Reword. Remove Ada limitation.
Tom Tromey [Thu, 11 Jun 2020 16:34:31 +0000 (10:34 -0600)]
Fix hex floating point lexing
PR gdb/18318 notes that gdb will sometimes incorrectly handle hex
floating point input. This turns out to be a bug in the C lexer; the
'p' was not being correctly recognized, and so the exponent was not
always passed to the floating point "from_string" method.
Tested by the buildbot "Fedora-x86_64-m64" builder.
gdb/ChangeLog
2020-06-11 Tom Tromey <tom@tromey.com>
PR gdb/18318:
* c-exp.y (lex_one_token): Handle 'p' like 'e'.
gdb/testsuite/ChangeLog
2020-06-11 Tom Tromey <tom@tromey.com>
PR gdb/18318:
* gdb.base/printcmds.exp (test_float_accepted): Add more hex
floating point tests.
Jonny Grant [Thu, 11 Jun 2020 14:30:03 +0000 (10:30 -0400)]
gdb: add mailing list and IRC information to --help
A few user-vibisble changes to the --help output:
* Remove unnecessary quotes around bug url.
* Mention the mailing list and IRC channel as places where users can
ask GDB-related questions.
* Add empty lines between items in the footer, to improve readability.
* Remove unnecessary new line at the end of output.
2020-06-09 Jonny Grant <jg@jguk.org>
2020-06-09 Simon Marchi <simon.marchi@polymtl.ca>
* main.c (captured_main_1): Don't print new line after help.
(print_gdb_help): add mailing list and IRC channel information
to --help. Add new lines between items in the footer. Remove
quotes around bug url.
Signed-off-by: Jonathan Grant <jg@jguk.org>
Change-Id: Ibd0746a348d558fb35b5cd7e366f107742806565
Keith Seitz [Thu, 11 Jun 2020 12:34:44 +0000 (14:34 +0200)]
Compute proper length for dynamic types of TYPE_CODE_TYPEDEF
This patch fixes gdb/21356 in which we hit an assertion in
value_contents_bits_eq:
(gdb) p container_object2
(gdb) p container_object2
$1 = {_container_member2 = 15, _vla_struct_object2 = {_some_member = 0,
_vla_field = {
../../src/gdb/value.c:829: internal-error: \
int value_contents_bits_eq(const value*, int, const value*, int, int): \
Assertion `offset1 + length \
<= TYPE_LENGTH (val1->enclosing_type) * TARGET_CHAR_BIT' failed.
This is happening because TYPE_LENGTH (val1->enclosing_type) is erroneously
based on enclosing_type, which is a typedef, instead of the actual underlying
type.
This can be traced back to resolve_dynamic_struct, where the size of the
type is computed:
...
TYPE_FIELD_TYPE (resolved_type, i)
= resolve_dynamic_type_internal (TYPE_FIELD_TYPE (resolved_type, i),
&pinfo, 0);
gdb_assert (TYPE_FIELD_LOC_KIND (resolved_type, i)
== FIELD_LOC_KIND_BITPOS);
new_bit_length = TYPE_FIELD_BITPOS (resolved_type, i);
if (TYPE_FIELD_BITSIZE (resolved_type, i) != 0)
new_bit_length += TYPE_FIELD_BITSIZE (resolved_type, i);
else
new_bit_length += (TYPE_LENGTH (TYPE_FIELD_TYPE (resolved_type, i))
* TARGET_CHAR_BIT);
...
In this function, resolved_type is TYPE_CODE_TYPEDEF which is not what we
want to use to calculate the size of the actual field.
This patch fixes this and the similar problem in resolve_dynamic_union.
gdb/ChangeLog:
2020-06-11 Keith Seitz <keiths@redhat.com>
PR gdb/21356
* gdbtypes.c (resolve_dynamic_union, resolve_dynamic_struct):
Resolve typedefs for type length calculations.
gdb/testsuite/ChangeLog:
2020-06-11 Keith Seitz <keiths@redhat.com>
PR gdb/21356
* gdb.base/vla-datatypes.c (vla_factory): Add typedef for struct
vla_struct.
Add new struct vla_typedef and union vla_typedef_union and
corresponding instantiation objects.
Initialize new objects.
* gdb.base/vla-datatypes.exp: Add tests for vla_typedef_struct_object
and vla_typedef_union_object.
Fixup type for vla_struct_object.
Tom de Vries [Thu, 11 Jun 2020 12:10:05 +0000 (14:10 +0200)]
[gdb/testsuite] Make gdb.base/dbx.exp more robust
Test-case gdb.base/dbx.exp overrides:
- the GDBFLAGS variable
- the gdb_file_cmd proc
There's code at the end of the test-case to restore both, but that's not
guaranteed to be executed.
Fix this by:
- using save_vars to restore GDBFLAGS
- using a new proc with_override to restore gdb_file_cmd
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-06-11 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (with_override): New proc, factored out of ...
* gdb.base/dbx.exp: ... here. Use with_override and save_vars.
Alex Coplan [Thu, 11 Jun 2020 11:34:37 +0000 (12:34 +0100)]
[PATCH]: aarch64: Refactor representation of system registers
Prior to this patch, the information describing the AArch64 system
registers was separate from the information describing which system
registers are available depending on the CPU feature set. Indeed, the
latter was implemented as a separate function from the main table with
the system register information.
This patch remedies this situation and puts the feature information into
the system register table itself.
This has several advantages:
* Having all the information described in one place is easier to
maintain.
* The logic to check whether a system register is supported now becomes
trivial (and much more efficient).
Since this patch ended up touching every line of the system register
table, I took the opportunity to make the formatting more consistent and
remove some redundant comments.
Note that there is still more refactoring that could be done along the
same lines here (e.g. with the TLB instructions) but this seemed like a
reasonable first pass.
Testing:
* Regression tested an x64 -> aarch64-none-elf cross binutils.
* Built aarch64-none-elf cross toolchain, checked newlib startup
code still works.
* Bootstrapped binutils on aarch64-linux-gnu, regression tested.
* Built aarch64 kernel using new binutils with allyesconfig.
OK for master? If so, I'll need a maintainer to commit on my behalf
since I don't have write access.
Thanks,
Alex
---
include/ChangeLog:
2020-06-11 Alex Coplan <alex.coplan@arm.com>
* opcode/aarch64.h (aarch64_sys_reg): Add required features to struct
describing system registers.
opcodes/ChangeLog:
2020-06-11 Alex Coplan <alex.coplan@arm.com>
* aarch64-opc.c (SYSREG): New macro for describing system registers.
(SR_CORE): Likewise.
(SR_FEAT): Likewise.
(SR_RNG): Likewise.
(SR_V8_1): Likewise.
(SR_V8_2): Likewise.
(SR_V8_3): Likewise.
(SR_V8_4): Likewise.
(SR_PAN): Likewise.
(SR_RAS): Likewise.
(SR_SSBS): Likewise.
(SR_SVE): Likewise.
(SR_ID_PFR2): Likewise.
(SR_PROFILE): Likewise.
(SR_MEMTAG): Likewise.
(SR_SCXTNUM): Likewise.
(aarch64_sys_regs): Refactor to store feature information in the table.
(aarch64_sys_reg_supported_p): Collapse logic for system registers
that now describe their own features.
(aarch64_pstatefield_supported_p): Likewise.
Alan Modra [Thu, 11 Jun 2020 08:23:30 +0000 (17:53 +0930)]
Run certain ld-plugun lto tests only for ELF
lto-6.c refers to _etext, pr12760b.c has a .gnu.warning section,
the pr23818 test uses readelf, and pr23958.c has a .symver directive.
* testsuite/ld-plugin/lto.exp (lto_link_tests): Move lto-6,
pr12760, pr23818 and pr23958 tests to..
(lto_link_elf_tests): ..here.
Nick Clifton [Thu, 11 Jun 2020 08:27:41 +0000 (09:27 +0100)]
Fix a compile time warning in the linker testsuite when compiling using clang.
* testsuite/ld-elf/pr26094-1b.c (main): Change return type to
int.
Alan Modra [Thu, 11 Jun 2020 06:18:12 +0000 (15:48 +0930)]
PR26107, Compilation failure in pdp11.c
PR 26107
* pdp11.c (is_stab): Replace legacy "index" function with "strchr".
Alan Modra [Thu, 11 Jun 2020 05:08:26 +0000 (14:38 +0930)]
Re: asan: readelf: process_mips_specific buffer overflow
Let's do without that unnecessary internal option buffer. This also
fixes another bug in that the REGINFO data was being taken from the
calloc'd internal option buffer, so was all zeros.
* readelf.c (process_mips_specific): Don't alloc memory for
Elf_Internal_Options.
Alan Modra [Thu, 11 Jun 2020 03:57:50 +0000 (13:27 +0930)]
asan: readelf: process_mips_specific buffer overflow
DT_MIPS_OPTIONS is not a regular array as assumed by readelf. This
patch corrects that assumption, and to do so easily, makes various
internal (host byte order) structs the same size as external (target
byte order) structs.
include/
* elf/mips.h (Elf32_RegInfo): Use fixed width integer types.
(Elf64_Internal_RegInfo, Elf_Internal_Options): Likewise.
binutils/
* readelf.c (process_mips_specific): Assert size of internal
types match size of external types, and simplify allocation of
internal buffer. Catch possible integer overflow when sanity
checking option size. Don't assume options are a regular array.
Sanity check reginfo option against option size. Use PRI macros
when printing.
Simon Marchi [Thu, 11 Jun 2020 03:00:20 +0000 (23:00 -0400)]
gdb: fix whitespaces in ChangeLog
Replace 8 spaces with tabs.
Change-Id: I60f2df3a2866f75f0307077bf6cb1fa3918f8180
Jonny Grant [Thu, 11 Jun 2020 02:56:31 +0000 (22:56 -0400)]
gdb/doc: remove broken links Previous and Up from contents
gdb/doc/ChangeLog:
* gdb.texinfo: Remove broken links Previous and Up from
contents.
Signed-off-by: Jonny Grant <jg@jguk.org>
Change-Id: Iad7323580a3c0c7f00eab1264d66f39e8d156e38
H.J. Lu [Thu, 11 Jun 2020 01:15:13 +0000 (18:15 -0700)]
ia64: Set DF_TEXTREL instead of reltext
Update ia64 ELF backend to set DF_TEXTREL for dynamic relocs against
readonly sections like other backends.
* elfnn-ia64.c (elfNN_ia64_link_hash_table): Remove reltext.
(allocate_dynrel_entries): Set DF_TEXTREL instead of reltext.
(elfNN_ia64_size_dynamic_sections): Check DF_TEXTREL instead
of reltext.
GDB Administrator [Thu, 11 Jun 2020 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Wed, 10 Jun 2020 03:38:15 +0000 (13:08 +0930)]
Fix x86 ld testsuite fails with glibc < 2.28
* testsuite/ld-elf/linux-x86.exp: Build tests when non-native.
(check_pr25749b): Add optional args. Set expected pass file
from args. Run -1b and -2a tests with passall.out.
* testsuite/ld-elf/passall.out: New file.
* testsuite/ld-elf/pr25749-1.c: Adjust to pass with older glibc.
* testsuite/ld-elf/pr25749-2.c: Likewise.
* testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Use
regexp_diff to compare expected output from running binary.
Tom de Vries [Wed, 10 Jun 2020 12:46:53 +0000 (14:46 +0200)]
[gdb/symtab] Enable ada .gdb_index
Currently the .gdb_index is not enabled for ada executables (PR24713).
Fix this by adding the required support in write_psymbols, similar to how that
is done for .debug_names in debug_names::insert.
Tested on x86_64-linux, with native and target board cc-with-gdb-index.
gdb/ChangeLog:
2020-06-10 Tom de Vries <tdevries@suse.de>
PR ada/24713
* dwarf2/index-write.c (struct mapped_symtab): Add m_string_obstack.
(write_psymbols): Enable .gdb_index for ada.
* dwarf2/read.c: Remove comment stating .gdb_index is unsupported for
ada.
gdb/testsuite/ChangeLog:
2020-06-10 Tom de Vries <tdevries@suse.de>
* gdb.ada/ptype_union.exp: Remove PR24713 workaround.
Tom de Vries [Wed, 10 Jun 2020 12:46:53 +0000 (14:46 +0200)]
[gdb/symtab] Fix name lookup in dw2_map_matching_symbols
In commit
9a0bacfb08 "[gdb/symtab] Handle .gdb_index in ada language mode", a
missing part of dw2_map_matching_symbols was added, containing a call to
dw2_expand_symtabs_matching_symbol.
However, the callback passed to that call has one problem: the callback has an
argument "offset_type namei", which is ignored. Instead, match_name is passed
as argument to dw2_symtab_iter_init, where a name lookup is done, which may or
may not yield the same value as namei.
Fix this by creating a new version of dw2_symtab_iter_init that takes a
"offset_type namei" argument instead of "const char *name", and passing namei.
Tested on x86_64-linux, with native and target board cc-with-gdb-index.
gdb/ChangeLog:
2020-06-10 Tom de Vries <tdevries@suse.de>
* dwarf2/read.c (dw2_symtab_iter_init_common): Factor out of ...
(dw2_symtab_iter_init): ... here. Add variant with "offset_type
namei" instead of "const char *name" argument.
(dw2_map_matching_symbols): Use "offset_type namei" variant of
dw2_symtab_iter_init.
H.J. Lu [Wed, 10 Jun 2020 12:31:19 +0000 (05:31 -0700)]
ELF: Properly handle section symbols
When defining the section symbol, __start_FOO, for the section FOO:
1. Treat the common symbol, __start_FOO, in input object file as
definition.
2. Clear verinfo.verdef.
bfd/
PR ld/26094
* elflink.c (bfd_elf_define_start_stop): Handle common symbols.
Clear verinfo.verdef.
ld/
PR ld/26094
* testsuite/ld-elf/pr26094-1.ver: New fike.
* testsuite/ld-elf/pr26094-1a.c: Likewise.
* testsuite/ld-elf/pr26094-1a.rd: Likewise.
* testsuite/ld-elf/pr26094-1b.c: Likewise.
* testsuite/ld-elf/pr26094-1b.rd: Likewise.
* testsuite/ld-elf/pr26094-1c.c: Likewise.
* testsuite/ld-elf/shared.exp: Run ld/26094 tests.
Ralf Habacker [Wed, 10 Jun 2020 09:07:26 +0000 (10:07 +0100)]
Fix the windmc program to conform to the behaviour of mc.exe by rejecting lines that reach end-of-file without a terminating newline character.
PR 26082
* mclex.c (yylex): Reject lines that reach end-of-file without a
terminating newline character.
Simon Marchi [Wed, 10 Jun 2020 03:14:46 +0000 (23:14 -0400)]
gdb/testsuite: fix duplicate test names in gdb.base/index-cache.exp
Fix:
DUPLICATE: gdb.base/index-cache.exp: test_cache_disabled: no files were created
DUPLICATE: gdb.base/index-cache.exp: test_cache_disabled: check index-cache stats
We use `proc_with_prefix` for test_cache_disabled, but we call it twice. So we
need an additional prefix to identify the specific call. This patch adds that.
gdb/testsuite/ChangeLog:
* gdb.base/index-cache.exp (test_cache_disabled): Add test_prefix
parameter, update callers.
Change-Id: Idf382fd380c77a654e8a7aa236af50b65c96b1d2
GDB Administrator [Wed, 10 Jun 2020 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Tue, 9 Jun 2020 13:56:55 +0000 (06:56 -0700)]
IFUNC: Update IFUNC resolver check with DT_TEXTREL
Add ifunc_resolvers to elf_link_hash_table and use it for both x86 and
ppc64. Before glibc commit
b5c45e837, DT_TEXTREL is incompatible with
IFUNC resolvers. Set ifunc_resolvers if there are IFUNC resolvers and
issue a warning for IFUNC resolvers with DT_TEXTREL.
bfd/
PR ld/18801
* elf-bfd.h (elf_link_hash_table): Add ifunc_resolvers.
(_bfd_elf_allocate_ifunc_dyn_relocs): Remove the
bfd_boolean * argument. Set ifunc_resolvers if there are IFUNC
resolvers.
* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Updated.
Set ifunc_resolvers if there are FUNC resolvers.
* elf64-ppc.c (ppc_link_hash_table): Remove local_ifunc_resolver.
(build_global_entry_stubs_and_plt): Replace local_ifunc_resolver
with elf.ifunc_resolvers.
(write_plt_relocs_for_local_syms): Likewise.
(ppc64_elf_relocate_section): Likewise.
(ppc64_elf_finish_dynamic_sections): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_allocate_ifunc_dynrelocs):
Updated.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Likewise.
(_bfd_x86_elf_size_dynamic_sections): Check elf.ifunc_resolvers
instead of readonly_dynrelocs_against_ifunc.
* elfxx-x86.h (elf_x86_link_hash_table): Remove
readonly_dynrelocs_against_ifunc.
ld/
PR ld/18801
* testsuite/ld-i386/i386.exp: Run ifunc-textrel-1a,
ifunc-textrel-1b, ifunc-textrel-2a and ifunc-textrel-2b.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/ifunc-textrel-1a.d: Likewise.
* testsuite/ld-i386/ifunc-textrel-1b.d: Likewise.
* testsuite/ld-i386/ifunc-textrel-2a.d: Likewise.
* testsuite/ld-i386/ifunc-textrel-2b.d: Likewise.
* testsuite/ld-x86-64/ifunc-textrel-1.s: Likewise.
* testsuite/ld-x86-64/ifunc-textrel-1a.d: Likewise.
* testsuite/ld-x86-64/ifunc-textrel-1b.d: Likewise.
* testsuite/ld-x86-64/ifunc-textrel-2.s: Likewise.
* testsuite/ld-x86-64/ifunc-textrel-2a.d: Likewise.
* testsuite/ld-x86-64/ifunc-textrel-2b.d: Likewise.
* testsuite/ld-i386/pr18801a.d: Expect warning for IFUNC
resolvers.
* testsuite/ld-i386/pr18801b.d: Likewise.
* estsuite/ld-x86-64/pr18801a.d: Likewise.
* estsuite/ld-x86-64/pr18801b.d: Likewise.
H.J. Lu [Tue, 9 Jun 2020 13:29:33 +0000 (06:29 -0700)]
i386-dis.c: Fix a typo in comments
* i386-dis.c (prefix_table): Fix a typo in comments.
Seth Girvan [Tue, 9 Jun 2020 10:13:39 +0000 (11:13 +0100)]
[PATCH] gas/doc: improve AVR modifiers wording.
* doc/c-avr.texi: Improve wording.
Jan Beulich [Tue, 9 Jun 2020 09:28:15 +0000 (11:28 +0200)]
x86: add missing 64-bit tests for "don't ignore mandatory pseudo prefixes"
Commit
da4977e00b73 added the 32-bit test files, but failed to add the
64-bit ones.
Alan Modra [Tue, 9 Jun 2020 07:32:12 +0000 (17:02 +0930)]
PR26065, ld/testsuite/ld-elf symbolic tests dl4e and dl4f fail
PR 26065
* testsuite/ld-elf/shared.exp: Compile dl4main.c -fPIC.
(dl4e, dl4f): Expect dl4a.out.
* testsuite/ld-elf/dl4e.out: Delete.
Jan Beulich [Tue, 9 Jun 2020 06:59:04 +0000 (08:59 +0200)]
x86: consistently print prefixes explicitly which are invalid with VEX etc
All of data size, rep, lock, and rex prefixes are invalid with VEX- and
alike encoded insns. Make sure they get printed explicitly in all cases,
to signal the anomaly. With this, do away with "rex_ignored" - if there
is a rex prefix, we want to print it anyway for VEX etc (and there's
nothing "ignored" about it in the first place - such an instruction will
raise #UD).
Jan Beulich [Tue, 9 Jun 2020 06:57:55 +0000 (08:57 +0200)]
x86: fix {,V}MOV{L,H}PD disassembly
Neither the legacy nor the VEX-encoded forms are permitted with register
operands, just like is already the case for their store forms as well as
{,V}MOV{L,H}PS.
At the same time, besides folding respective vex_len_table[] entries,
adjust adjacent related legacy mod_table[] entries:
- when the prefix was already decoded, PREFIX_OPCODE is pointless,
- limit the amount of string literals by using X consistently on all
{,V}MOV{L,H}P{S,D} forms.
Jan Beulich [Tue, 9 Jun 2020 06:57:22 +0000 (08:57 +0200)]
x86: utilize X macro in EVEX decoding
For major opcodes allowing only packed FP kinds of operands, i.e. the
ones where legacy and AVX decoding uses the X macro, we can do so for
AVX512 as well, by attaching to the checking logic the "EVEX.W must
match presence of embedded 66 prefix" rule. (Encodings not following
this general pattern simply may not gain the PREFIX_OPCODE attribute.)
Note that testing of the thus altered decoding has already been put in
place by "x86: correct decoding of packed-FP-only AVX encodings".
This can also be at least partly applied to scalar-FP-only insns (i.e.
V{,U}COMIS{S,D}) as well as the vector-FP forms of insns also allowing
scalar encodings (e.g. VADDP{S,D}).
Take the opportunity and also fix EVEX-encoded VMOVNTP{S,D} as well as
to-memory forms of VMOV{L,H}PS and both forms of VMOV{L,H}PD to wrongly
disassemble with only register operands.
Jan Beulich [Tue, 9 Jun 2020 06:56:39 +0000 (08:56 +0200)]
x86: correct decoding of packed-FP-only AVX encodings
Various AVX insns utilizing the X macro fail to reject F3/F2 embedded
prefix encodings. As the PREFIX_OPCODE attribute wasn't used by any
non-legacy-encoded insns so far, re-use it to achieve the intended
effect.
Jan Beulich [Tue, 9 Jun 2020 06:55:50 +0000 (08:55 +0200)]
x86: correct mis-named MOD_0F51 enumerator
This is for extension major opcode 50, so name it accordingly.
Jan Beulich [Tue, 9 Jun 2020 06:47:31 +0000 (08:47 +0200)]
x86-64: adjust far indirect branch handling
An unwanted side effect of
5990e377e5a3 ("x86-64: Intel64 adjustments
for insns dealing with far pointers") was that with -mintel64 LCALL and
LJMP would now default to 64-bit operand size. Since 64-bit far branches
aren't portable, the default operand size should still be 32-bit.
However, since the 64-bit variant is permitted, an ambiguous operand
warning should be issued.
As to the actual code change, please note that the conditional
surrounding the switch() that gets adjusted covers several cases which
are of no interest to or benign in 64-bit mode, hence the new
conditional added can be quite a bit less involved.
Jan Beulich [Tue, 9 Jun 2020 06:46:22 +0000 (08:46 +0200)]
x86: don't ignore mandatory pseudo prefixes
{vex}, {vex3}, and {evex} are mandatory prefixes, and hence should not
be randomly ignored. Fix this for insns without operands as well as for
insns referencing the high 16 [XYZ]MM registers. To achieve the former,
re-purpose VEX_check_operands(), renaming it to VEX_check_encoding() and
moving its only operand check to check_VecOperands().
This involves fixing a testcase relying on {vex2} to get ignored.
Alan Modra [Tue, 9 Jun 2020 00:02:10 +0000 (09:32 +0930)]
PowerPC64: Downgrade ifunc with textrel error to a warning
For ppc64 I set flags when recording the dynamic relocation rather
than when allocating space. That allows you to distinguish three
cases:
1) The dynamic ifunc relocation is in an executable and will always be
to an ifunc resolver in the executable.
2) The dynamic ifunc relocation is in a shared library which provides
an ifunc resolver, but that may be overridden at runtime to use a
resolver in another binary.
3) The dynamic ifunc relocation is not to a locally defined ifunc
resolver.
Case (3) won't cause a segfault trying to run resolver code that is
non-exec on older glibc.
I made case (1) an error for ppc64, but since newer glibc ld.so does
allow running ifunc resolvers when segments are writable I suppose I
should downgrade that to a warning like case (2).
* elf64-ppc.c (struct ppc_link_hash_table): Delete
maybe_local_ifunc_resolver field.
(build_global_entry_stubs_and_plt): Set local_ifunc_resolver in
cases where maybe_local_ifunc_resolver was set.
(ppc64_elf_relocate_section): Likewise.
(ppc64_elf_finish_dynamic_sections): Downgrade ifunc with textrel
error to a warning.
GDB Administrator [Tue, 9 Jun 2020 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Mon, 8 Jun 2020 19:26:20 +0000 (15:26 -0400)]
gdb: remove TYPE_FIELD_TYPE macro
Remove the `TYPE_FIELD_TYPE` macro, changing all the call sites to use
`type::field` and `field::type` directly.
gdb/ChangeLog:
* gdbtypes.h (TYPE_FIELD_TYPE): Remove. Change all call sites
to use type::field and field::type instead.
Change-Id: Ifda6226a25c811cfd334a756a9fbc5c0afdddff3
Simon Marchi [Mon, 8 Jun 2020 19:26:06 +0000 (15:26 -0400)]
gdb: remove FIELD_TYPE macro
Remove the `FIELD_TYPE` macro, changing all the call sites to use
`field::type` directly.
gdb/ChangeLog:
* gdbtypes.h (FIELD_TYPE): Remove. Change all call sites
to use field::type instead.
Change-Id: I7673fedaa276e485189c87991a9043495da22ef5
Simon Marchi [Mon, 8 Jun 2020 19:26:04 +0000 (15:26 -0400)]
gdb: add field::type / field::set_type
Add the `type` and `set_type` methods on `struct field`, in order to
remoremove the `FIELD_TYPE` macro. In this patch, the `FIELD_TYPE`
macro is changed to use `field::type`, so all the call sites that are
useused to set the field's type are changed to use `field::set_type`.
The next patch will remove `FIELD_TYPE` completely.
Note that because of the name clash between the existing field named
`type` and the new method, I renamed the field `m_type`. It is not
private per-se, because we can't make `struct field` a non-POD yet, but
it should be considered private anyway (not accessed outside `struct
field`).
gdb/ChangeLog:
* gdbtypes.h (struct field) <type, set_type>: New methods.
Rename `type` field to...
<m_type>: ... this. Change references throughout to use type or
set_type methods.
(FIELD_TYPE): Use field::type. Change call sites that modify
the field's type to use field::set_type instead.
Change-Id: Ie21f866e3b7f8a51ea49b722d07d272a724459a0
Simon Marchi [Mon, 8 Jun 2020 19:25:53 +0000 (15:25 -0400)]
gdb: remove TYPE_INDEX_TYPE macro
Remove `TYPE_INDEX_TYPE` macro, changing all the call sites to use
`type::index_type` directly.
gdb/ChangeLog:
* gdbtypes.h (TYPE_INDEX_TYPE): Remove. Change all call sites
to use type::index_type instead.
Change-Id: I56715df0bdec89463cda6bd341dac0e01b2faf84
Simon Marchi [Mon, 8 Jun 2020 19:25:50 +0000 (15:25 -0400)]
gdb: add type::index_type / type::set_index_type
Add the `index_type` and `set_index_type` methods on `struct type`, in
order to remove the `TYPE_INDEX_TYPE` macro. In this patch, the
`TYPE_INDEX_TYPE` macro is changed to use `type::index_type`, so all the
call sites that are used to set the type's index type are changed to use
`type::set_index_type`. The next patch will remove `TYPE_INDEX_TYPE`
completely.
gdb/ChangeLog:
* gdbtypes.h (struct type) <index_type, set_index_type>: New
methods.
(TYPE_INDEX_TYPE): Use type::index_type.
* gdbtypes.c (create_array_type_with_stride): Likewise.
Change-Id: I93bdca9de9f3e143d2ccea59310c63745315e18d
Alex Coplan [Mon, 8 Jun 2020 14:16:29 +0000 (15:16 +0100)]
[PATCH] arm: Add DFB instruction for ARMv8-R
gas/ChangeLog:
2020-06-08 Alex Coplan <alex.coplan@arm.com>
* config/tc-arm.c (insns): Add dfb.
* testsuite/gas/arm/dfb.d: New test.
* testsuite/gas/arm/dfb.s: Input for test.
opcodes/ChangeLog:
2020-06-08 Alex Coplan <alex.coplan@arm.com>
* arm-dis.c (arm_opcodes): Add dfb.
(thumb32_opcodes): Add dfb.
H.J. Lu [Mon, 8 Jun 2020 11:24:04 +0000 (04:24 -0700)]
ELF: Move tlsdesc_plt/tlsdesc_got to elf_link_hash_table
All ELF backends with TLS descriptor support have
/* The offset into splt of the PLT entry for the TLS descriptor
resolver. Special values are 0, if not necessary (or not found
to be necessary yet), and -1 if needed but not determined
yet. */
bfd_vma tlsdesc_plt;
/* The GOT offset for the lazy trampoline. Communicated to the
loader via DT_TLSDESC_GOT. The magic value (bfd_vma) -1
indicates an offset is not allocated. */
bfd_vma tlsdesc_got;
in symbol hash entry. Move tlsdesc_plt/tlsdesc_got to elf_link_hash_entry
to reduce code duplication.
* elf-bfd.h (elf_link_hash_entry): Add tlsdesc_plt and
tlsdesc_got.
* elf32-arm.c (elf32_arm_link_hash_table): Remove tlsdesc_plt
and dt_tlsdesc_got.
(elf32_arm_size_dynamic_sections): Updated. Clear
root.tlsdesc_plt for DF_BIND_NOW.
(elf32_arm_finish_dynamic_sections): Updated.
(elf32_arm_output_arch_local_syms): Likewise.
* elf32-nds32.c (nds32_elf_size_dynamic_sections): Updated.
Clear root.tlsdesc_plt for DF_BIND_NOW.
(nds32_elf_finish_dynamic_sections): Updated.
* elf32-nds32.h (elf_nds32_link_hash_table): Remove
dt_tlsdesc_plt and dt_tlsdesc_got.
* elf64-x86-64.c (elf_x86_64_finish_dynamic_sections): Updated.
* elfnn-aarch64.c (elf_aarch64_link_hash_table): Remove
tlsdesc_plt and dt_tlsdesc_got.
(elfNN_aarch64_allocate_dynrelocs): Updated.
(elfNN_aarch64_finish_dynamic_sections): Likewise.
(elfNN_aarch64_size_dynamic_sections): Updated. Clear
root.tlsdesc_plt for DF_BIND_NOW. Don't check DF_BIND_NOW
twice.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Updated.
(_bfd_x86_elf_size_dynamic_sections): Likewise.
(_bfd_x86_elf_finish_dynamic_sections): Likewise.
* elfxx-x86.h (elf_x86_link_hash_table): Remove tlsdesc_plt and
tlsdesc_got.
Nick Clifton [Mon, 8 Jun 2020 10:32:15 +0000 (11:32 +0100)]
Fix a typo in the description of the strings program.
PR 26093
* doc/binutils.texi (strings): Fix typo.
Nick Clifton [Mon, 8 Jun 2020 10:24:06 +0000 (11:24 +0100)]
Fix an illegal memory access when parsing corrupt DWARF debug information.
PR 26086
* dwarf.c (process_debug_info): Check that there is space in the
debug_information array before filling in an entry.
Nick Clifton [Mon, 8 Jun 2020 09:25:57 +0000 (10:25 +0100)]
Fix a gas testsuite failure for PE based targets which cannot assemble the cfi-i386-2 test.
* testsuite/gas/cfi/cfi-i386-2.d: Skip for PE based targets.
Jan Beulich [Mon, 8 Jun 2020 06:40:58 +0000 (08:40 +0200)]
x86: also handle %k<N> and %bnd<N> in debugging helpers
Adjustment of this function was missed when support for the respective
registers was added.
Jan Beulich [Mon, 8 Jun 2020 06:40:22 +0000 (08:40 +0200)]
x86: simplify check_byte_reg()
With the introduction of what right now is the very first conditional
in the function's loop (commit
dc821c5f9ae5 ["x86: replace Reg8, Reg16,
Reg32, and Reg64"]), the last if() in the same loop has become
pointless - retain just its body.
Jan Beulich [Mon, 8 Jun 2020 06:39:57 +0000 (08:39 +0200)]
x86: restrict %tr<N> visibility
First of all, these registers have never been available on any 64-bit
CPU, and hence should not be recognized in 64-bit mode. But even before
that they had already disappeared - also don't recognize them when 586
or 686 architectures were explicitly set.
Jan Beulich [Mon, 8 Jun 2020 06:39:23 +0000 (08:39 +0200)]
ix86: enable 2nd CFI test
While putting together the previous patch I noticed that this test,
forever since its introduction, was dead. Update it so it will pass,
and enable it.
Jan Beulich [Mon, 8 Jun 2020 06:38:54 +0000 (08:38 +0200)]
x86: also allow %st(N) in CFI directives
In
0e0eea782025 ("x86: x87-related adjustments") I screwed up CFI
directives with FPU support disabled, by moving the conditional there
across a check of "allow_pseudo_reg". Add the missing check.
Jan Beulich [Mon, 8 Jun 2020 06:37:47 +0000 (08:37 +0200)]
x86: restrict use of register aliases
Register aliases (created e.g. via .set) check their target register at
the time of creation of the alias. While this makes sense, it's not
enough: The underlying register must also be "visible" at the time of
use. Wrong use of such aliases would lead to internal errors in e.g.
add_prefix() or build_modrm_byte().
Split the checking part of parse_real_register() into a new helper
function and use it also from the latter part of parse_register() (at
the same time replacing a minor open coded part of it).
Since parse_register() returning NULL already has a meaning, a fake new
"bad register" indicator gets added, which all callers need to check
for.
GDB Administrator [Mon, 8 Jun 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sun, 7 Jun 2020 21:53:58 +0000 (14:53 -0700)]
elf32-tic6x.c: Define the default elf32_bed to elf32_tic6x_bed
Get
00000000000007c0 d elf32_tic6x_bed
0000000000000000 d elf32_tic6x_elf_bed
00000000000003e0 d elf32_tic6x_linux_bed
instead of
00000000000007c0 d elf32_bed
0000000000000000 d elf32_tic6x_elf_bed
00000000000003e0 d elf32_tic6x_linux_bed
* elf32-tic6x.c (elf32_bed): Defined the default to
elf32_tic6x_bed.
H.J. Lu [Sun, 7 Jun 2020 21:48:13 +0000 (14:48 -0700)]
ld: Pass $LFLAGS to PR ld/21703 shared test
$LFLAGS is needed for -shared test. This fixes
FAIL: PR ld/21703 shared
for tic6x-*-elf.
* testsuite/ld-elf/shared.exp: Pass $LFLAGS to PR ld/21703
shared test.
H.J. Lu [Sun, 7 Jun 2020 18:52:01 +0000 (11:52 -0700)]
ld: Xfail pr20995 and pr20995-2 for tic6x-*-*
Xfail pr20995 and pr20995-2 for tic6x-*-* since GNU_RELRO is not
supported.
* testsuite/ld-elf/shared.exp: Xfail pr20995/pr20995-2 for
tic6x-*-*.
H.J. Lu [Sun, 7 Jun 2020 15:47:02 +0000 (08:47 -0700)]
pr11304.d: Skip tic6x-*-elf
Since address 0x800000 overlaps with .heap section on tic6x-*-elf, skip
pr11304.d on tic6x-*-elf.
* testsuite/ld-elf/pr11304.d: Skip tic6x-*-elf.
H.J. Lu [Sun, 7 Jun 2020 15:06:22 +0000 (08:06 -0700)]
elf64-hppa: Replace plt_sec/plt_rel_sec with root.splt/root.srelplt
elf64-hppa should use root.splt and root.srelplt instead of plt_sec and
plt_rel_sec so that elflink.c can see splt and srelplt. This fixed:
FAIL: ld-elf/pr19539
* elf64-hppa.c (elf64_hppa_link_hash_table): Remove plt_sec and
plt_rel_sec.
(elf64_hppa_check_relocs): Replace plt_sec/plt_rel_sec with
root.splt/root.srelplt.
(elf64_hppa_create_dynamic_sections): Likewise.
(elf64_hppa_size_dynamic_sections): Likewise.
(elf64_hppa_finish_dynamic_symbol): Likewise.
(elf_hppa_final_link): Likewise.
(elf_hppa_final_link_relocate): Likewise.
Tom Tromey [Sun, 7 Jun 2020 14:22:46 +0000 (08:22 -0600)]
Remove unused parameter from generic_val_print_float
generic_val_print_float has an "embedded_offset" parameter, but it can
only ever be 0. I believe it is a leftover from the val_print
removal. This patch removes this parameter.
gdb/ChangeLog
2020-06-07 Tom Tromey <tom@tromey.com>
* valprint.c (generic_val_print_float): Remove "embedded_offset"
parameter.
(generic_value_print): Update.
H.J. Lu [Sun, 7 Jun 2020 00:40:47 +0000 (17:40 -0700)]
Remove is_vxworks from _bfd_sparc_elf_link_hash_table
Replace is_vxworks with elf.target_os == is_vxworks.
* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Updated.
* elfxx-sparc.h (_bfd_sparc_elf_link_hash_table): Remove
is_vxworks.
GDB Administrator [Sun, 7 Jun 2020 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sat, 6 Jun 2020 13:45:23 +0000 (06:45 -0700)]
ELF: Add target_os to elf_link_hash_table/elf_backend_data
Add target_os to elf_backend_data to identify target OS. Add target_os,
to elf_link_hash_table to identify target OS for linker output.
* elf-bfd.h (elf_target_os): New.
(elf_link_hash_table): Add target_os.
(elf_backend_data): Add target_os.
* elf32-arm.c (elf32_arm_link_hash_table): Remove vxworks_p,
symbian_p and nacl_p.
(create_got_section): Updated.
(elf32_arm_create_dynamic_sections): Likewise.
(arm_type_of_stub): Likewise.
(elf32_arm_create_or_find_stub_sec): Likewise.
(elf32_arm_allocate_plt_entry): Likewise.
(elf32_arm_populate_plt_entry): Likewise.
(elf32_arm_final_link_relocate): Likewise.
(elf32_arm_check_relocs): Likewise.
(allocate_dynrelocs_for_symbol): Likewise.
(elf32_arm_finish_dynamic_symbol): Likewise.
(elf32_arm_finish_dynamic_sections): Likewise.
(elf32_arm_output_plt_map_1): Likewise.
(elf32_arm_output_arch_local_syms): Likewise.
(elf32_arm_add_symbol_hook): Likewise.
(elf32_arm_nacl_link_hash_table_create): Likewise.
(elf32_arm_vxworks_link_hash_table_create): Likewise.
(elf32_arm_symbian_link_hash_table_create): Likewise.
(ELF_TARGET_OS): New.
* elf32-i386.c (elf_i386_arch_bed): Removed.
(elf_backend_arch_data): Likewise.
(elf_i386_solaris_arch_bed): Likewise.
(elf_i386_nacl_arch_bed): Likewise.
(elf_i386_vxworks_arch_bed): Likewise.
(elf_i386_relocate_section): Updated.
(elf_i386_finish_dynamic_sections): Likewise.
(elf_i386_get_synthetic_symtab): Likewise.
(elf_i386_link_setup_gnu_properties): Likewise.
(ELF_TARGET_OS): New.
* elf32-mips.c (ELF_TARGET_OS): New.
* elf32-ppc.c (ppc_elf_link_hash_table): Remove is_vxworks.
(ppc_elf_create_got): Updated.
(ppc_elf_create_dynamic_sections): Likewise.
(ppc_elf_check_relocs): Likewise.
(ppc_elf_adjust_dynamic_symbol): Likewise.
(ppc_elf_size_dynamic_sections): Likewise.
(ppc_elf_relocate_section): Likewise.
(ppc_elf_finish_dynamic_sections): Likewise.
(ppc_elf_vxworks_link_hash_table_create): Likewise.
(ELF_TARGET_OS): New.
* elf32-sh.c (elf_sh_link_hash_table): Remove vxworks_p.
(sh_elf_link_hash_table_create): Updated.
(sh_elf_create_dynamic_sections): Likewise.
(allocate_dynrelocs): Likewise.
(sh_elf_size_dynamic_sections): Likewise.
(sh_elf_relocate_section): Likewise.
(sh_elf_finish_dynamic_symbol): Likewise.
(sh_elf_finish_dynamic_sections): Likewise.
(ELF_TARGET_OS): New.
* elf32-sparc.c (elf32_sparc_vxworks_link_hash_table_create):
Removed.
(bfd_elf32_bfd_link_hash_table_create): Likewise.
(ELF_TARGET_OS): New.
* elf64-x86-64.c (elf_x86_64_arch_bed): Removed.
(elf_x86_64_solaris_arch_bed): Likewise.
(elf_x86_64_nacl_arch_bed): Likewise.
(elf_x86_64_finish_dynamic_sections): Updated.
(elf_x86_64_get_synthetic_symtab): Likewise.
(elf_x86_64_link_setup_gnu_properties): Likewise.
(ELF_TARGET_OS): New.
* elflink.c (_bfd_elf_link_hash_table_init): Initialize
target_o.
* elfxx-mips.c (mips_elf_link_hash_table): Remove is_vxworks.
(MIPS_ELF_REL_DYN_NAME): Updated.
(ELF_MIPS_GP_OFFSET): Likewise.
(mips_elf_create_local_got_entry): Likewise.
(mips_elf_allocate_dynamic_relocations): Likewise.
(mips_elf_count_got_symbols): Likewise.
(is_gott_symbol): Likewise.
(mips_elf_calculate_relocation): Likewise.
(mips_elf_create_dynamic_relocation): Likewise.
(_bfd_mips_elf_check_relocs): Likewise.
(allocate_dynrelocs): Likewise.
(_bfd_mips_elf_adjust_dynamic_symbol): Likewise.
(mips_elf_lay_out_got): Likewise.
(mips_elf_set_plt_sym_value): Likewise.
(_bfd_mips_elf_size_dynamic_sections): Likewise.
(_bfd_mips_elf_finish_dynamic_symbol): Likewise.
(_bfd_mips_elf_finish_dynamic_sections): Likewise.
(_bfd_mips_elf_final_link): Likewise.
(_bfd_mips_init_file_header): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_create_dynamic_sections):
Likewise.
(allocate_dynrelocs): Likewise.
(_bfd_sparc_elf_size_dynamic_sections): Likewise.
(_bfd_sparc_elf_relocate_section): Likewise.
(_bfd_sparc_elf_finish_dynamic_symbol): Likewise.
(sparc_finish_dyn): Likewise.
(_bfd_sparc_elf_finish_dynamic_sections): Likewise.
* elfxx-target.h (ELF_TARGET_OS): New.
(elfNN_bed): Add ELF_TARGET_OS.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Updated.
(_bfd_x86_elf_link_hash_table_create): Likewise.
(_bfd_x86_elf_size_dynamic_sections): Likewise.
(_bfd_x86_elf_finish_dynamic_sections): Likewise.
(_bfd_x86_elf_adjust_dynamic_symbol): Likewise.
(_bfd_x86_elf_link_setup_gnu_properties): Likewise.
* elfxx-x86.h (elf_x86_target_os): Removed.
(elf_x86_backend_data): Likewise.
(get_elf_x86_backend_data): Likewise.
(elf_x86_link_hash_table): Remove target_os.
Alan Modra [Sat, 6 Jun 2020 04:52:37 +0000 (14:22 +0930)]
Power10 tidies
binutils/
* doc/binutils.texi (PowerPC -M option): Mention power10 and pwr10.
gas/
* config/tc-ppc.c (md_show_usage): Mention -mpower10 and -mpwr10.
* doc/c-ppc.texi: Likewise.
opcodes/
* ppc-dis.c (ppc_opts): Accept -mpwr10/-Mpwr10.
Alan Modra [Sat, 6 Jun 2020 02:26:20 +0000 (11:56 +0930)]
Rename PowerPC64 pcrel GOT TLS relocations
These relocations should have had REL in their names, to reflect the
fact that they are pc-relative. Fix that now by adding _PCREL.
I've added some back-compatibility code to support anyone using
.reloc with the old relocations.
include/
* elf/ppc64.h (elf_ppc64_reloc_type): Rename
R_PPC64_GOT_TLSGD34 to R_PPC64_GOT_TLSGD_PCREL34,
R_PPC64_GOT_TLSLD34 to R_PPC64_GOT_TLSLD_PCREL34,
R_PPC64_GOT_TPREL34 to R_PPC64_GOT_TPREL_PCREL34, and
R_PPC64_GOT_DTPREL34 to R_PPC64_GOT_DTPREL_PCREL34.
bfd/
* reloc.c: Rename
BFD_RELOC_PPC64_GOT_TLSGD34 to BFD_RELOC_PPC64_GOT_TLSGD_PCREL34,
BFD_RELOC_PPC64_GOT_TLSLD34 to BFD_RELOC_PPC64_GOT_TLSLD_PCREL34,
BFD_RELOC_PPC64_GOT_TPREL34 to BFD_RELOC_PPC64_GOT_TPREL_PCREL34,
BFD_RELOC_PPC64_GOT_DTPREL34 to BFD_RELOC_PPC64_GOT_DTPREL_PCREL34.
* elf64-ppc.c: Update throughout for reloc renaming.
(ppc64_elf_reloc_name_lookup): Handle old reloc names.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
gas/
* config/tc-ppc.c: Update throughout for reloc renaming.
elfcpp/
* powerpc.h: Rename
R_PPC64_GOT_TLSGD34 to R_PPC64_GOT_TLSGD_PCREL34,
R_PPC64_GOT_TLSLD34 to R_PPC64_GOT_TLSLD_PCREL34,
R_PPC64_GOT_TPREL34 to R_PPC64_GOT_TPREL_PCREL34, and
R_PPC64_GOT_DTPREL34 to R_PPC64_GOT_DTPREL_PCREL34.
gold/
* powerpc.cc: Update throughout for reloc renaming.
Alan Modra [Sat, 6 Jun 2020 02:28:09 +0000 (11:58 +0930)]
Re: PR13802, referred common symbol not UNDefined
It looks like this one was previously just swept under the rug. Prior
to git commit
c4b126b87a6c, the arm backend emitted an absolute
dynamic symbol "foo" with value zero for what was originally a common
symbol. That was just wrong.
The patch also removes an xfail for bfin-linux-uclibc.
PR 13802
* testsuite/ld-elf/comm-data.exp: Don't xfail arm or bfin-linux.
Alan Modra [Sat, 6 Jun 2020 01:58:08 +0000 (11:28 +0930)]
ld -plugin options when plugins are disabled
This patch makes ld accept and ignore -plugin options when configured
with --disable-plugins. The idea is to allow using a linker built
without plugin support with a gcc built with plugin support. Quite
obviously such a combination won't work if using LTO, but gcc has a
habit of passing a bunch of -plugin and -plugin-opt arguments to ld
even when not generating or linking LTO objects.
Why do I want to do this? Well, it lets me and other binutils
developers answer the question as to whether plugin support breaks
binutils in some areas. Which it does for some targets.
* lexsup.c (ld_options): Accept -plugin and -plugin-opt when
!ENABLE_PLUGINS.
* testsuite/lib/ld-lib.exp (check_plugin_api_available): Adjust.
GDB Administrator [Sat, 6 Jun 2020 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Fri, 5 Jun 2020 20:07:58 +0000 (21:07 +0100)]
Revert "gdb/python: Avoid use after free in py-tui.c"
This reverts commit
982a38f60b0ece9385556cff45567e06710478cb.
I missed that the title being assigned too was a std::string, and so
there is no leak.
Andrew Burgess [Fri, 5 Jun 2020 17:13:09 +0000 (18:13 +0100)]
gdb/python: Avoid use after free in py-tui.c
When setting the window title of a tui frame we do this:
gdb::unique_xmalloc_ptr<char> value
= python_string_to_host_string (<python-object>);
...
win->window->title = value.get ();
The problem here is that 'get ()' only borrows the pointer from value,
when value goes out of scope the pointer will be freed. As a result,
the tui frame will be left with a pointer to undefined memory
contents.
Instead we should be using 'value.release ()' to take ownership of the
pointer from value.
gdb/ChangeLog:
* python/py-tui.c (gdbpy_tui_set_title): Use release, not get, to
avoid use after free.
Jose E. Marchesi [Fri, 5 Jun 2020 14:23:30 +0000 (16:23 +0200)]
gas: avoid GCC 10 warning stringop-overflow in tc-bpf.c
The GAS struct frag ends with a field `fr_literal' whose purpose is to
mark the begining of the frag's data:
struct frag {
...
/* Data begins here. */
char fr_literal[1];
};
The code in gas/config/tc-bpf.c recently committed:
where = fixP->fx_frag->fr_literal + fixP->fx_where;
where[1] = target_big_endian ? 0x01 : 0x10;
triggers the stringop-overflow warning in GCC 10+, since the compiler
assumes the size of the modified buffer is 1 byte. This patch
slightly modifies the code to make tc-bpf.c buildable with GCC 10+.
2020-06-05 Jose E. Marchesi <jose.marchesi@oracle.com>
* config/tc-bpf.c (md_apply_fix): Avoid GCC 10 warning
stringop-overflow.
H.J. Lu [Fri, 5 Jun 2020 13:22:56 +0000 (06:22 -0700)]
bfin: Initialize picrel to silence GCC warning
H.J. Lu [Fri, 5 Jun 2020 12:30:25 +0000 (05:30 -0700)]
bfin: Skip non SEC_ALLOC section
* elf32-bfin.c (bfinfdpic_relocate_section): Skip non SEC_ALLOC
section.
Tom de Vries [Fri, 5 Jun 2020 10:24:20 +0000 (12:24 +0200)]
[gdb/NEWS] Fix typos
Fix a few typos in gdb/NEWS.
gdb/ChangeLog:
2020-06-05 Tom de Vries <tdevries@suse.de>
* NEWS: Fix typos.
Joel Anderson [Fri, 5 Jun 2020 10:11:03 +0000 (11:11 +0100)]
Fix a potential infinite loop in the Windows resource parser.
PR 26082
* mclex.c (yylex): Add test for an empty input stream.
Nick Clifton [Fri, 5 Jun 2020 09:08:26 +0000 (10:08 +0100)]
Fix a use before initialization bug in the pdp11.c source file.
* pdp11.c (aout_link_add_symbols): Fix use before initialisation
bug.
Alan Modra [Fri, 5 Jun 2020 06:48:47 +0000 (16:18 +0930)]
bpf stack smashing detected
* cgen-dis.c (hash_insn_array): Increase size of buf. Assert
size is large enough.
Stephen Casner [Fri, 5 Jun 2020 06:41:57 +0000 (23:41 -0700)]
Fix unresolved test in binutils for pdp11.
* binutils/testsuite/binutils-all/pr25662-pdp11.s: Alternate source file
for test using section pseudo-ops compatible with pdp11.
* binutils/testsuite/binutils-all/objcopy.exp: Select alternate source.
Nelson Chu [Fri, 29 May 2020 08:56:36 +0000 (16:56 +0800)]
RISC-V: The object without priv spec attributes can be linked with any object.
bfd/
* elfnn-riscv.c (riscv_merge_attributes): Add new boolean
priv_may_conflict, in_priv_zero and out_priv_zero to decide whether
the object can be linked according to it's priv attributes. The object
without any priv spec attributes can be linked with others. If the first
input object doesn't contain any priv attributes, then we need to copy
the setting from the next input one. Also report more detailed error
messages to user.
ld/
* testsuite/ld-riscv-elf/attr-merge-priv-spec.d: Rename to
attr-merge-priv-spec-01.d.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-c.s: Set priv spec
to 1.11.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-d.s: Empty priv spec
setting.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-02.d: New testcase.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-03.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Likewise.
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
Nelson Chu [Fri, 29 May 2020 07:31:46 +0000 (15:31 +0800)]
RISC-V: Don't generate the ELF privilege attributes when no CSR are used.
gas/
* config/tc-riscv.c (explicit_csr): New static boolean.
Used to indicate CSR are explictly used.
(riscv_ip): Set explicit_csr to TRUE if any CSR is used.
(riscv_write_out_attrs): If we already have set elf priv
attributes, then generate them. Otherwise, don't generate
them when no CSR are used.
* testsuite/gas/riscv/attribute-01.d: Remove the priv attributes.
* testsuite/gas/riscv/attribute-02.d: Likewise.
* testsuite/gas/riscv/attribute-03.d: Likewise.
* testsuite/gas/riscv/attribute-04.d: Likewise.
* testsuite/gas/riscv/attribute-05.d: Likewise.
* testsuite/gas/riscv/attribute-06.d: Likewise.
* testsuite/gas/riscv/attribute-07.d: Likewise.
* testsuite/gas/riscv/attribute-08.d: Likewise.
* testsuite/gas/riscv/attribute-09.d: Likewise.
* testsuite/gas/riscv/attribute-10.d: Likewise.
* testsuite/gas/riscv/attribute-unknown.d: Likewise.
* testsuite/gas/riscv/attribute-11.s: New testcase.
* testsuite/gas/riscv/attribute-11.d: New testcase. The CSR is
used, so we should output the ELF priv attributes.
* testsuite/gas/riscv/attribute-12.d: New testcase. The CSR is
used, so output the priv attributes according to the -mpriv-spec.
* testsuite/gas/riscv/attribute-13.d: New testcase. The CSR isn't
used, so ignore the -mpriv-spec setting.
ld/
* testsuite/ld-riscv-elf/attr-merge-arch-01.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-02.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-03.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-stack-align.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-strict-align-01.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-strict-align-02.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-strict-align-03.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-strict-align-04.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-strict-align-05.d: Likewise.
* testsuite/ld-riscv-elf/call-relax.d: Add -mno-arch-attr.
Stephen Casner [Fri, 5 Jun 2020 01:12:32 +0000 (18:12 -0700)]
Extend pdp11-aout symbol table format and code for .stab symbols.
* bfd/pdp11.c (pdp11_external_nlist): Repurposed e_unused to e_desc.
(N_STAB, is_stab): Needed new function is_stab to disambiguate
normal vs. .stab symbol table type values, replacing N_STAB mask.
(translate_from_native_sym_flags): Determine correct section for
different .stab types.
(translate_to_native_sym_flags): Leave .stab types intact.
(translate_symbol_table): Error if symbol indicates overlay;
store desc field from .stab symbols.
(write_syms): Output desc field with symbol.
(aout_link_check_ar_symbols): Skip .stab symbols.
(aout_link_add_symbols): Correctly distinguish .stab symbols.
(aout_link_write_other_symbol): Write 0 for desk and ovly fields.
(aout_link_write_symbols): Write 0 for desk and ovly fields;
correctly distinguish .stab symbols and select calculate their
section and value; and copy desc and ovly fields from input symbol
to output symbol.
GDB Administrator [Fri, 5 Jun 2020 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in
Stephen Casner [Thu, 4 Jun 2020 19:34:17 +0000 (12:34 -0700)]
Correct a comment.
* bfd/aoutx.h (translate_symbol_table): Comment had external and
internal swapped.
* bfd/pdp11.c (translate_symbol_table): Likewise.
H.J. Lu [Thu, 4 Jun 2020 18:15:06 +0000 (11:15 -0700)]
gas: Fix ip2k-elf and xstormy16-elf build
Fix ip2k-elf and xstormy16-elf build due to
commit
e9bffec9afc45cf7c49308f0b4b8cc6bf68f58f2
Author: Jose E. Marchesi <jose.marchesi@oracle.com>
Date: Thu Jun 4 16:15:53 2020 +0200
opcodes: discriminate endianness and insn-endianness in CGEN ports
* config/tc-ip2k. (ip2k_apply_fix): Pass endianness to
cgen_get_insn_value.
* config/tc-xstormy16.c (xstormy16_md_apply_fix): Pass
endianness to cgen_get_insn_value and cgen_put_insn_value.
Simon Marchi [Thu, 4 Jun 2020 17:56:55 +0000 (13:56 -0400)]
gdb: really share partial symtabs when using .gdb_index or .debug_names
Fix/follow-up to commit
17ee85fc2a ("Share DWARF partial symtabs").
In the non-index case, where GDB builds partial symbols from scratch,
two objfiles around the same BFD correctly share partial symtabs. The
first objfile, which has to do all the work, saves a reference to the
created partial symtabs in the shared per_bfd object (at the end of
dwarf2_build_psymtabs). The second objfile, when it reaches
dwarf2_build_psymtabs, sees that there are already partial symtabs built
for this BFD and just uses it.
However, that commit missed implementing the same sharing for cases
where GDB uses .gdb_index or .debug_names to build the partial symtabs.
This patch fixes it by having the first objfile to use the BFD set
per_bfd->partial_symtabs at the end of dwarf2_read_gdb_index /
dwarf2_read_debug_names. For the subsequent objfiles using that BFD,
the partial symtabs are then picked up in dwarf2_initialize_objfile.
This patch adds a test that mimics how the issue was originally
triggered:
1. Load the test file twice, such that the second objfile re-uses the
per_bfd object created for the first objfile.
2. Run to some point where in the backtrace there is a frame for a
function that's in a CU that's not yet read in.
3. Check that this frame's information is complete in the "backtrace"
output.
Step 2 requires an address -> symbol lookup which uses the addrmap at
objfile->partial_symtabs->psymtabs_addrmap. If the
objfile->partial_symtabs link is not properly setup (as is the case
before this patch), the symbol for that frame won't be found and we'll
get a frame with incomplete information.
The test fails without the fix when using boards "cc-with-gdb-index" and
"cc-with-debug-names".
gdb/ChangeLog:
* dwarf2/read.c (dwarf2_read_gdb_index): Save partial_symtabs in
the per_bfd object.
(dwarf2_read_debug_names): Likewise.
(dwarf2_initialize_objfile): Use partial_symtabs from per_bfd
object when re-using a per_bfd object with an index.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/share-psymtabs-bt.exp: New file.
* gdb.dwarf2/share-psymtabs-bt.c: New file.
* gdb.dwarf2/share-psymtabs-bt-2.c: New file.
Change-Id: Ibb26210e2dfc03b80ba9fa56b875ba4cc58c0352
H.J. Lu [Thu, 4 Jun 2020 16:56:25 +0000 (09:56 -0700)]
x86: Remove target_id from elf_x86_link_hash_table
Since target_id in elf_x86_link_hash_table is the same as hash_table_id
in elf_link_hash_table, we can use elf.hash_table_id instead of target_id.
* elfxx-x86.h (elf_x86_link_hash_table): Remove target_id.
(is_x86_elf): Check elf.hash_table_id instead of target_id.
* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Updated.
Tom de Vries [Thu, 4 Jun 2020 15:37:53 +0000 (17:37 +0200)]
[gdb/testsuite] Remove path names from error messages in gdb_file_cmd
In gdb_file_cmd, perror is called with error message strings using $arg and
$GDB, both of which contain path names, which makes comparison of gdb.sum
files more difficult.
Fix this by using:
- [file tail $arg] instead of $arg
- GDB instead of $GDB.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-06-04 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_file_cmd): Avoid path names in error messages.
Jose E. Marchesi [Thu, 4 Jun 2020 14:33:34 +0000 (16:33 +0200)]
gas: simplify code in tc-bpf.c:md_apply_fix
2020-06-04 Jose E. Marchesi <jose.marchesi@oracle.com>
* config/tc-bpf.c (md_apply_fix): Simplify and avoid using
cgen_put_insn_value.
Tom de Vries [Thu, 4 Jun 2020 14:33:55 +0000 (16:33 +0200)]
[gdb/testsuite] Fix error handling in gdb_file_cmd
Consider a gdb_load patch to call the gdb_file_cmd twice:
...
proc gdb_load { arg } {
if { $arg != "" } {
+ set res [gdb_file_cmd $arg]
+ if { $res != 0 } {
+ return $res
+ }
return [gdb_file_cmd $arg]
}
return 0
}
...
When running test-case gdb.base/index-cache.exp, we run into:
...
ERROR: Couldn't load outputs/gdb.base/index-cache/index-cache, other program \
already loaded (timeout).
FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: check index-cache \
stats (GDB internal error)
ERROR: Couldn't load outputs/gdb.base/index-cache/index-cache, other program \
already loaded (timeout).
...
The first timeout in more detail:
...
(gdb) file outputs/gdb.base/index-cache/index-cache^M
Load new symbol table from "index-cache"? (y or n) y^M
Reading symbols from index-cache...^M
src/gdb/dwarf2/read.c:2540: internal-error: \
void create_cus_from_index(dwarf2_per_bfd*, const gdb_byte*, offset_type, \
const gdb_byte*, offset_type): \
Assertion `per_bfd->all_comp_units.empty ()' failed.^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.^M
Quit this debugging session? (y or n) ERROR: Couldn't load index-cache, \
other program already loaded (timeout).
...
Proc gdb_file_cmd has a gdb_expect handling the result of the file command,
and if the result is a "Load new symbol table from index-cache? (y or n) "
prompt, it sends a "y" and enters in a nested gdb_expect to handle the
result.
The first gdb_expect contains code to handle "A problem internal to GDB has
been detected", but the second one doesn't, which causes the timeout.
Fix this by removing the nested gdb_expect, and using exp_continue instead,
such that we have instead:
...
ERROR: Couldn't load outputs/gdb.base/index-cache/index-cache -- with new \
symbol table into gdb (GDB internal error).
ERROR: Couldn't load outputs/gdb.base/index-cache/index-cache -- with new \
symbol table into gdb (GDB internal error).
...
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-06-04 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_file_cmd): Replace incomplete gdb_expect by
exp_continue.
Jose E. Marchesi [Thu, 4 Jun 2020 14:17:07 +0000 (16:17 +0200)]
cpu,gas,opcodes: remove no longer needed workaround from the BPF port
cpu/ChangeLog:
2020-06-02 Jose E. Marchesi <jose.marchesi@oracle.com>
* bpf.cpu (define-bpf-isa): Set base-insn-bitsize to 64.
* bpf.opc (bpf_print_insn): Do not set endian_code here.
gas/ChangeLog:
2020-06-04 Jose E. Marchesi <jose.marchesi@oracle.com>
* config/tc-bpf.c (md_begin): Pass CGEN_CPU_OPEN_INSN_ENDIAN to
bpf_cgen_cpu_open.
(md_assemble): Remove no longer needed hack.
opcodes/ChangeLog:
2020-06-04 Jose E. Marchesi <jose.marchesi@oracle.com>
* disassemble.c (disassemble_init_for_target): Set endian_code for
bpf targets.
* bpf-desc.c: Regenerate.
* bpf-opc.c: Likewise.
* bpf-dis.c: Likewise.
Jose E. Marchesi [Thu, 4 Jun 2020 14:15:53 +0000 (16:15 +0200)]
opcodes: discriminate endianness and insn-endianness in CGEN ports
The CGEN support code in opcodes accesses instruction contents using a
couple of functions defined in cgen-opc.c: cgen_get_insn_value and
cgen_put_insn_value. These functions use the "instruction endianness"
in the CPU description to order the read/written bytes.
The process of writing an instruction to the object file is:
a) cgen_put_insn_value ;; Writes out the opcodes.
b) ARCH_cgen_insert_operand
insert_normal
insert_1
cgen_put_insn_value ;; Writes out the bytes of the
;; operand.
Likewise, the process of reading an instruction from the object file
is:
a) cgen_get_insn_value ;; Reads the opcodes.
b) ARCH_cgen_extract_operand
extract_normal
extract_1
cgen_get_insn_value ;; Reads in the bytes of the
;; operand.
As can be seen above, cgen_{get,put}_insn_value are used to both
process the instruction opcodes (the constant fields conforming the
base instruction) and also the values of the instruction operands,
such as immediates.
This is problematic for architectures in which the endianness of
instructions is different to the endianness of data. An example is
BPF, where instructions are always encoded big-endian but the data may
be either big or little.
This patch changes the cgen_{get,put}_insn_value functions in order to
get an extra argument with the endianness to use, and adapts the
existin callers to these functions in order to provide cd->endian or
cd->insn_endian, whatever appropriate. Callers like extract_1 and
insert_1 pass cd->endian (since they are reading/writing operand
values) while callers reading/writing the base instruction pass
cd->insn_endian instead.
A few little adjustments have been needed in some existing CGEN based
ports:
* The BPF assembler uses cgen_put_insn_value. It has been adapted to
pass the new endian argument.
* The mep port has code in mep.opc that uses cgen_{get,put}_insn_value.
It has been adapted to pass the new endianargument. Ditto for a
call in the assembler.
Tested with --enable-targets=all.
Regested in all supported targets.
No regressions.
include/ChangeLog:
2020-06-04 Jose E. Marchesi <jose.marchesi@oracle.com>
* opcode/cgen.h: Get an `endian' argument in both
cgen_get_insn_value and cgen_put_insn_value.
opcodes/ChangeLog:
2020-06-04 Jose E. Marchesi <jose.marchesi@oracle.com>
* cgen-opc.c (cgen_get_insn_value): Get an `endian' argument.
(cgen_put_insn_value): Likewise.
(cgen_lookup_insn): Pass endianness to cgen_{get,put}_insn_value.
* cgen-dis.in (print_insn): Likewise.
* cgen-ibld.in (insert_1): Likewise.
(insert_1): Likewise.
(insert_insn_normal): Likewise.
(extract_1): Likewise.
* bpf-dis.c: Regenerate.
* bpf-ibld.c: Likewise.
* bpf-ibld.c: Likewise.
* cgen-dis.in: Likewise.
* cgen-ibld.in: Likewise.
* cgen-opc.c: Likewise.
* epiphany-dis.c: Likewise.
* epiphany-ibld.c: Likewise.
* fr30-dis.c: Likewise.
* fr30-ibld.c: Likewise.
* frv-dis.c: Likewise.
* frv-ibld.c: Likewise.
* ip2k-dis.c: Likewise.
* ip2k-ibld.c: Likewise.
* iq2000-dis.c: Likewise.
* iq2000-ibld.c: Likewise.
* lm32-dis.c: Likewise.
* lm32-ibld.c: Likewise.
* m32c-dis.c: Likewise.
* m32c-ibld.c: Likewise.
* m32r-dis.c: Likewise.
* m32r-ibld.c: Likewise.
* mep-dis.c: Likewise.
* mep-ibld.c: Likewise.
* mt-dis.c: Likewise.
* mt-ibld.c: Likewise.
* or1k-dis.c: Likewise.
* or1k-ibld.c: Likewise.
* xc16x-dis.c: Likewise.
* xc16x-ibld.c: Likewise.
* xstormy16-dis.c: Likewise.
* xstormy16-ibld.c: Likewise.
gas/ChangeLog:
2020-06-04 Jose E. Marchesi <jose.marchesi@oracle.com>
* cgen.c (gas_cgen_finish_insn): Pass the endianness to
cgen_put_insn_value.
(gas_cgen_md_apply_fix): Likewise.
(gas_cgen_md_apply_fix): Likewise.
* config/tc-bpf.c (md_apply_fix): Pass data endianness to
cgen_put_insn_value.
* config/tc-mep.c (mep_check_ivc2_scheduling): Pass endianness to
cgen_put_insn_value.
cpu/ChangeLog:
2020-06-02 Jose E. Marchesi <jose.marchesi@oracle.com>
* mep.opc (print_slot_insn): Pass the insn endianness to
cgen_get_insn_value.
Jose E. Marchesi [Thu, 4 Jun 2020 14:14:41 +0000 (16:14 +0200)]
opcodes: support insn endianness in cgen_cpu_open
This patch adds support for a new CGEN_OPEN_INSN_ENDIAN argument
for @arch@_cgen_cpu_open. This is useful for architectures in
which the endianness of the instruction words is not the same
than the endianness used for data.
An accompanying patch has been sent to the CGEN mailing list that
adds support for this argument on the CGEN side [1]. Its been
already pre-approved [2], and will be applied simultaneously with
this binutils series.
[1] https://sourceware.org/pipermail/cgen/2020q2/002733.html
[2] https://sourceware.org/pipermail/cgen/2020q2/002737.html
include/ChangeLog:
2020-06-04 Jose E. Marchesi <jemarch@gnu.org>
* opcode/cgen.h (enum cgen_cpu_open_arg): New value
CGEN_CPU_OPEN_INSN_ENDIAN.
opcodes/ChangeLog:
2020-06-04 Jose E. Marchesi <jemarch@gnu.org>
* cgen-dis.in (cpu_desc_list): New field `insn_endian'.
(print_insn_): Handle instruction endian.
* bpf-dis.c: Regenerate.
* bpf-desc.c: Regenerate.
* epiphany-dis.c: Likewise.
* epiphany-desc.c: Likewise.
* fr30-dis.c: Likewise.
* fr30-desc.c: Likewise.
* frv-dis.c: Likewise.
* frv-desc.c: Likewise.
* ip2k-dis.c: Likewise.
* ip2k-desc.c: Likewise.
* iq2000-dis.c: Likewise.
* iq2000-desc.c: Likewise.
* lm32-dis.c: Likewise.
* lm32-desc.c: Likewise.
* m32c-dis.c: Likewise.
* m32c-desc.c: Likewise.
* m32r-dis.c: Likewise.
* m32r-desc.c: Likewise.
* mep-dis.c: Likewise.
* mep-desc.c: Likewise.
* mt-dis.c: Likewise.
* mt-desc.c: Likewise.
* or1k-dis.c: Likewise.
* or1k-desc.c: Likewise.
* xc16x-dis.c: Likewise.
* xc16x-desc.c: Likewise.
* xstormy16-dis.c: Likewise.
* xstormy16-desc.c: Likewise.
binutils/ChangeLog:
2020-06-04 Jose E. Marchesi <jose.marchesi@oracle.com>
* objdump.c (disassemble_data): Set disasm_info.endian_code to
disasm_info.endian after the latter is initialized to the
endianness reported by BFD.
Tom de Vries [Thu, 4 Jun 2020 14:13:14 +0000 (16:13 +0200)]
[gdb/testsuite] Fix use of fail in gdb_cmd_file
When building gdb using this patch:
...
static void
file_command (const char *arg, int from_tty)
{
+ gdb_assert (0);
...
and running the testsuite, we run into:
...
Running src/gdb/testsuite/gdb.ada/O2_float_param.exp ...
PASS: gdb.ada/O2_float_param.exp: compilation foo.adb
FAIL: gdb.ada/O2_float_param.exp: (outputs/gdb.ada/O2_float_param/foo) \
(GDB internal error)
PATH: gdb.ada/O2_float_param.exp: (outputs/gdb.ada/O2_float_param/foo) \
(GDB internal error)
FAIL: gdb.ada/O2_float_param.exp: frame
...
The FAIL detecting the GDB internal error is generated by this clause in
gdb_file_cmd:
...
-re "A problem internal to GDB has been detected" {
fail "($arg) (GDB internal error)"
gdb_internal_error_resync
return -1
}
...
The fail message has no text outside parenthesis, and could be considered
empty. Also, it's the only clause in the gdb_expect that uses fail, the
rest uses perror.
Fix this by replacing the fail by perror, such that we have:
...
Running src/gdb/testsuite/gdb.ada/O2_float_param.exp ...
PASS: gdb.ada/O2_float_param.exp: compilation foo.adb
ERROR: Couldn't load outputs/gdb.ada/O2_float_param/foo into \
gdb (GDB internal error).
UNRESOLVED: gdb.ada/O2_float_param.exp: frame
...
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-06-04 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_file_cmd): Use perror instead of fail.
H.J. Lu [Thu, 4 Jun 2020 12:58:34 +0000 (05:58 -0700)]
ELF: Don't check relocations in non-loaded, non-alloced sections
Don't do anything special with non-loaded, non-alloced sections.
In particular, any relocs in such sections should not affect GOT
and PLT reference counting (ie. we don't allow them to create GOT
or PLT entries), there's no possibility or desire to optimize TLS
relocs, and there's not much point in propagating relocs to shared
libs that the dynamic linker won't relocate.
Since check_relocs is no longer called on non-loaded, non-alloced
sections, remove SEC_ALLOC check. Resolve relocation in debug section
against symbol defined in shared library to 0.
bfd/
PR ld/26080
* elf-m10300.c (mn10300_elf_relocate_section): Resolve relocation
in debug section against symbol defined in shared library to 0.
* elf32-i386.c (elf_i386_check_relocs): Remove SEC_ALLOC check.
* elf32-lm32.c (lm32_elf_check_relocs): Likewise.
* elf32-m32r.c (m32r_elf_check_relocs): Likewise.
* elf32-nds32.c (nds32_elf_check_relocs): Likewise.
* elf32-nios2.c (nios2_elf32_check_relocs): Likewise.
* elf32-or1k.c (or1k_elf_check_relocs): Likewise.
* elf32-ppc.c (ppc_elf_check_relocs): Likewise.
* elf32-sh.c (sh_elf_check_relocs): Likewise.
* elf32-xtensa.c (elf_xtensa_check_relocs): Likewise.
* elf64-alpha.c (elf64_alpha_check_relocs): Likewise.
* elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
* elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.
* elf32-vax.c (elf_vax_check_relocs): Set non_got_ref for non-GOT
reference.
(elf_vax_adjust_dynamic_symbol): Generate a copy reloc only if
there is non-GOT reference.
* elflink.c (_bfd_elf_link_check_relocs): Skip non-loaded,
non-alloced sections.
ld/
PR ld/26080
* testsuite/ld-elf/comm-data.exp: Remove copy_reloc.
* testsuite/ld-elf/comm-data2r.rd: Removed.
* testsuite/ld-elf/comm-data2r.sd: Likewise.
* testsuite/ld-elf/comm-data2r.xd: Likewise.
Alan Modra [Thu, 4 Jun 2020 06:30:46 +0000 (16:00 +0930)]
tcl global directive outside proc body does nothing (gas)
* testsuite/config/default.exp: Remove global directive outside
proc body.
* testsuite/gas/mep/complex-relocs.exp: Likewise.
* testsuite/gas/microblaze/relax_size.exp: Likewise.
* testsuite/gas/microblaze/reloc_sym.exp: Likewise.
* testsuite/gas/mt/relocs.exp: Likewise.
* testsuite/gas/rx/rx.exp: Likewise.