Cary Coutant [Sat, 2 Dec 2017 17:56:40 +0000 (09:56 -0800)]
Handle case where posix_fallocate is not supported for a filesystem.
2017-12-02 Vladimir Kondratyev <vladimir@kondratyev.su>
Cary Coutant <ccoutant@gmail.com>
gold/
PR gold/22540
* output.cc (gold_fallocate): Trivial return for len == 0.
Add fallback options when posix_fallocate and fallocate return
not-supported errors.
Cary Coutant [Wed, 15 Feb 2017 08:25:29 +0000 (00:25 -0800)]
Disallow --incremental with -pie and force -no-pie for incremental tests.
This is a partial fix for the gold testsuite failures documented in
PR 21090. The use of -fpie triggers some mov-to-lea optimizations that
are not compatible with incremental linking, so those optimizations need
to be disabled. We also diagnose the attempt to use -pie with incremental
linking, and force -no-pie for the incremental tests in case the build has
been configured to have GCC pass -pie all the time.
We still have a problem where compiling with -fpie results in some GOT
entries even when linking with -no-pie. This combination still causes test
failures because we are not updating the GOT entries in an incremental update
link.
gold/
PR gold/21090
* incremental.cc (Sized_relobj_incr::do_relocate): Fix comment.
* options.cc (General_options::finalize): Disallow -pie with
incremental linking.
* x86_64.cc (Target_x86_64::Scan::local): Don't do mov-to-lea
or callq-to-direct optimizations for incremental links.
(Target_x86_64::Scan::global): Likewise.
(Target_x86_64::Relocate::relocate): Likewise.
* testsuite/Makefile.am (incremental_test): Force -no-pie.
(incremental_test_2): Likewise.
(incremental_test_3): Likewise.
(incremental_test_4): Likewise.
(incremental_test_5): Likewise.
(incremental_test_6): Likewise.
(incremental_copy_test): Likewise.
(incremental_common_test_1): Likewise.
(incremental_comdat_test_1): Likewise.
* testsuite/Makefile.in: Regenerate.
Cary Coutant [Sat, 2 Dec 2017 06:53:08 +0000 (22:53 -0800)]
Workaround GCC 7 bug with debug line numbers causing debug_msg.sh failure.
gold/
PR gold/21841
* testsuite/debug_msg.sh: Adjust expected line numbers.
* testsuite/odr_violation2.cc (DummyFunction): New function.
Cary Coutant [Sat, 2 Dec 2017 06:03:09 +0000 (22:03 -0800)]
Fix incremental linking failure with GCC 7+.
With the new compiler, we're running out of patch space for the .eh_frame
section. To workaround that issue, we compile the before and after versions
both with no unwind tables.
gold/
PR gold/22309
* testsuite/Makefile.am (two_file_test_1_v1_ndebug.o): Compile with
no EH information.
(two_file_test_1_ndebug.o): Likewise.
* testsuite/Makefile.in: Regenerate.
* testsuite/two_file_test_1.cc: Touch to force recompilation with new
flags.
* testsuite/two_file_test_1_v1.cc: Likewise.
Sergio Durigan Junior [Fri, 24 Nov 2017 21:56:08 +0000 (16:56 -0500)]
Add support for the readnever concept
The purpose of this concept is to turn the load of debugging
information off, either globally (via the '--readnever' option), or
objfile-specific. The implementation proposed here is an extension of
the patch distributed with Fedora GDB; looking at the Fedora patch
itself and the history, one can see some reasons why it was never
resubmitted:
- The patch appears to have been introduced as a workaround, at
least initially;
- The patch is far from perfect, as it simply shunts the load of
DWARF debugging information, without really worrying about the
other debug format.
- Who really does non-symbolic debugging anyways?
One use of this feature is when a user simply wants to do the
following sequence: attach, dump core, detach. Loading the debugging
information in this case is an unnecessary cause of delay.
This patch expands the version shipped with Fedora GDB in order to
make the feature available for all the debuginfo backends, not only
for DWARF. It also implements a per-objfile flag which can be
activated by using the "-readnever" command when using the
'add-symbol-file' or 'symbol-file' commands.
It's also worth mentioning that this patch tests whether GDB correctly
fails to initialize if both '--readnow' and '--readnever' options are
passed.
Tested on the BuildBot.
gdb/ChangeLog:
2017-12-01 Andrew Cagney <cagney@redhat.com>
Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* NEWS (Changes since GDB 8.0: Mention new '--readnever'
feature.
* coffread.c (coff_symfile_read): Do not map over sections with
'coff_locate_sections' if readnever is on.
* dwarf2read.c (dwarf2_has_info): Return 0 if
readnever is on.
* elfread.c (elf_symfile_read): Do not map over sections with
'elf_locate_sections' if readnever is on.
* main.c (validate_readnow_readnever): New function.
(captured_main_1): Add support for --readnever.
(print_gdb_help): Document --readnever.
* objfile-flags.h (enum objfile_flag) <OBJF_READNEVER>: New
flag.
* symfile.c (readnever_symbol_files): New global.
(symbol_file_add_with_addrs): Set 'OBJF_READNEVER' when
'READNEVER_SYMBOL_FILES' is set.
(validate_readnow_readnever): New function.
(symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(add_symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(_initialize_symfile): Document new '-readnever' option for
both 'symbol-file' and 'add-symbol-file' commands.
* top.h (readnever_symbol_files): New extern global.
* xcoffread.c (xcoff_initial_scan): Do not read debug
information if readnever is on.
gdb/doc/ChangeLog:
2017-12-01 Andrew Cagney <cagney@redhat.com>
Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.texinfo (File Options): Document --readnever.
(Commands to Specify Files): Likewise, for 'symbol-file' and
'add-symbol-file'.
gdb/testsuite/ChangeLog:
2017-12-01 Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* gdb.base/readnever.c, gdb.base/readnever.exp: New files.
GDB Administrator [Sat, 2 Dec 2017 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in
Jim Wilson [Fri, 1 Dec 2017 23:34:42 +0000 (15:34 -0800)]
Update and clean up RISC-V gas documentation.
gas/
* doc/as.texinfo (RISC-V): Alphabetize RISC-V entries. Change
RISC-V-Opts to RISC-V-Options. Delete redundant space. Add -fpic
and related options to option list.
* doc/c-riscv.texi: (RISC-V-Options): Renamed from RISC-V-Opts.
(RISC-V Options): Renamed from Options. Add missing period.
(-fpic): Also mention -fPIC.
(RISC-V Directives): New node.
Sergio Durigan Junior [Wed, 29 Nov 2017 21:36:13 +0000 (16:36 -0500)]
Make '{add-,}symbol-file' not care about the position of command line arguments
This is a bug that's been detected while doing the readnever work.
If you use 'symbol-file' or 'add-symbol-file', the position of each
argument passed to the command matters. This means that if you do:
(gdb) symbol-file -readnow /foo/bar
The symbol file specified will (correctly) have all of its symbols
read by GDB (because of the -readnow flag). However, if you do:
(gdb) symbol-file /foo/bar -readnow
GDB will silently ignore the -readnow flag, because it was specified
after the filename. This is not a good thing to do and may confuse
the user.
To address that, I've modified the argument parsing mechanisms of
symbol_file_command and add_symbol_file_command to be
"position-independent". I have also added one error call at the end
of add_symbol_file_command's argument parsing logic, which now clearly
complains if no filename has been specified. Both commands now
support the "--" option to stop argument processing.
This patch provides a testcase for both commands, in order to make
sure that the argument order does not matter. It has been
regression-tested on BuildBot.
gdb/ChangeLog:
2017-12-01 Sergio Durigan Junior <sergiodj@redhat.com>
* symfile.c (symbol_file_command): Call
'symbol_file_add_main_1' only after processing all command
line options.
(add_symbol_file_command): Modify logic to make arguments
position-independent.
gdb/testsuite/ChangeLog:
2017-12-01 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.base/relocate.exp: Add tests to guarantee that arguments
to 'symbol-file' and 'add-symbol-file' can be
position-independent.
Sergio Durigan Junior [Fri, 1 Dec 2017 21:58:47 +0000 (16:58 -0500)]
Revert "Add support for the readnever concept"
This reverts commit
e2e321740ce2e36a97be2a410cd56eebaa2304aa.
It was mistakenly pushed.
Cary Coutant [Fri, 1 Dec 2017 21:44:54 +0000 (13:44 -0800)]
Fix localized help string output for -fuse-ld.
gold/
PR gold/22042
* options.h (-fuse-ld): Use NULL instead of empty string.
Joel Brobecker [Fri, 1 Dec 2017 20:45:30 +0000 (15:45 -0500)]
(Ada) GDB crash printing expression with type casting
One of our users reported that trying to print the following expression,
caused GDB to SEGV:
(gdb) print some_package.some_type (val)
In this particular instance, the crash occurred inside ada_args_match
because it is given a NULL "func", leading to the SEGV because of:
struct type *func_type = SYMBOL_TYPE (func);
This NULL symbol comes from a list of symbols which was given to
ada_resolve_function (parameter called "syms") which then iterates
over each of them to discard the ones that don't match the actuals:
for (k = 0; k < nsyms; k += 1)
{
struct type *type = ada_check_typedef (SYMBOL_TYPE (syms[k].symbol));
if (ada_args_match (syms[k].symbol, args, nargs)
&& (fallback || return_match (type, context_type)))
[...]
}
What's really interesting is that, when entering the block above for
the first time, all entries in SYMS have a valid (non-NULL) symbol.
However, once we return from the call to ada_check_typedef, the first
entry of our SYMS table gets set to all zeros:
(gdb) p syms[0]
$2 = {symbol = 0x0, block = 0x0}
Hence the call to ada_args_match with a NULL symbol, and the ensuing
SEGV.
To find out why this happen, we need to step back a little and look
at how syms was allocated. This list of symbols comes from a symbol
lookup, which means ada_lookup_symbol_list_worker. We have our first
hint when we look at the function's documentation and see:
This vector is transient---good only to the next call of
ada_lookup_symbol_list.
Implementation-wise, this is done by using a static global obstack,
which we just re-initialize each time ada_lookup_symbol_list_worker
gets called:
obstack_free (&symbol_list_obstack, NULL);
obstack_init (&symbol_list_obstack);
This property was probably established in order to facilitate the use
of the returned vector, since the users of that function would not have
to worry about releasing that memory when no longer needed. However,
I found during this investigation that it is all to easy to indirectly
trigger another symbol lookup while still using the results of a previous
lookup.
In our particular case, there is the call to ada_check_typedef, which
leads to check_typedef. As it happens, my first symbol had a type which
was a typedef to a stub type, so check_typedef calls lookup_symbol to
find the non-stub version. This in turn eventually leads us back to
ada_lookup_symbol_list_worker, where the first thing it does is free
the memory area when our list of symbols have been residing and then
recreates a new one. in other words, SYMS then becomes a dangling
pointer!
This patch fixes the issue by having ada_lookup_symbol_list_worker
return a copy of the list of symbols, with the responsibility of
deallocating that list now transfered to the users of that list.
More generally speaking, it is absolutely amazing that we haven't seen
consequences of this issue before. This can happen fairly frequently.
For instance, I found that ada-exp.y::write_var_or_type calls
ada_lookup_symbol_list, and then, while processing that list, calls
select_possible_type_sym, which leads to ada_prefer_type, eventually
leading to ada_check_typedef again (via eg. ada_is_array_descriptor_type).
Even more amazing is the fact that, while I was able to produce multiple
scenarios where the corruption occurs, none of them leads to incorrect
behavior at the user level. In other words, it requires a very precise
set of conditions for the corruption to become user-visible, and
despite having a megalarge program where the crash occured, using that
as a template for creating a reproducer did not work (pb goes away).
This is why this patch does not come with a reproducer. On the other hand,
this should not be a problem in terms of testing coverage, as the changes
are made in common areas which, at least for the most part, are routinely
exercised during testing.
gdb/ChangeLog:
* ada-lang.c (symbol_list_obstack): Delete.
(resolve_subexp): Make sure "candidates" gets xfree'ed.
(ada_lookup_symbol_list_worker): Remove the limitation that
the result is only good until the next call, now making it
the responsibility of the caller to free the result when no
longer needed. Adjust the function's intro comment accordingly.
(ada_lookup_symbol_list): Adjust the function's intro comment.
(ada_iterate_over_symbols): Make sure "results" gets xfree'ed.
(ada_lookup_encoded_symbol, get_var_value): Likewise.
(_initialize_ada_language): Remove symbol_list_obstack
initialization.
* ada-exp.y (block_lookup): Make sure "syms" gets xfree'ed.
(write_var_or_type, write_name_assoc): Likewise.
Tested on x86_64-linux.
Benjamin Peterson [Fri, 1 Dec 2017 20:59:36 +0000 (12:59 -0800)]
Fix internal error from command line with unbalanced --start-lib/--end-lib.
The problem is that while the command line isn't trivially empty,
it contains no input files. As gold tries to configure the number
of threads to use based on the number of input files, this causes
the assertion failure above. Fix this problem by making the logic
in gold.cc more robust and also adding a better error message
about --start-lib to options.cc.
gold/
PR gold/22406
* gold.cc (queue_initial_tasks) Check for number of real input files.
* options.cc (Command_line::process) Check for unterminated --start-lib
options.
* testsuite/Makefile.am: Add new test script.
* testsuite/Makefile.in: Regenerate.
* testsuite/check_empty_command_lines.sh: New test script.
Stephen Crane [Fri, 1 Dec 2017 20:10:02 +0000 (12:10 -0800)]
Fix problem where undef can fail to trigger archive rescan.
If a shared library contains an undefined symbol and LTO adds
a new reference to that same undefined symbol, the reference in the new
object added by the plugin would not trigger a rescan of the archive
containing the symbol.
2017-11-17 Stephen Crane <sjc@immunant.com>
gold/
PR gold/22448
* symtab.cc (Symbol_table::add_from_object): Only rescan for
undefined symbols in regular, not dynamic, objects.
Sergio Durigan Junior [Fri, 24 Nov 2017 21:56:08 +0000 (16:56 -0500)]
Add support for the readnever concept
The purpose of this concept is to turn the load of debugging
information off, either globally (via the '--readnever' option), or
objfile-specific. The implementation proposed here is an extension of
the patch distributed with Fedora GDB; looking at the Fedora patch
itself and the history, one can see some reasons why it was never
resubmitted:
- The patch appears to have been introduced as a workaround, at
least initially;
- The patch is far from perfect, as it simply shunts the load of
DWARF debugging information, without really worrying about the
other debug format.
- Who really does non-symbolic debugging anyways?
One use of this feature is when a user simply wants to do the
following sequence: attach, dump core, detach. Loading the debugging
information in this case is an unnecessary cause of delay.
This patch expands the version shipped with Fedora GDB in order to
make the feature available for all the debuginfo backends, not only
for DWARF. It also implements a per-objfile flag which can be
activated by using the "-readnever" command when using the
'add-symbol-file' or 'symbol-file' commands.
It's also worth mentioning that this patch tests whether GDB correctly
fails to initialize if both '--readnow' and '--readnever' options are
passed.
Tested on the BuildBot.
gdb/ChangeLog:
2017-12-01 Andrew Cagney <cagney@redhat.com>
Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* NEWS (Changes since GDB 8.0: Mention new '--readnever'
feature.
* coffread.c (coff_symfile_read): Do not map over sections with
'coff_locate_sections' if readnever is on.
* dwarf2read.c (dwarf2_has_info): Return 0 if
readnever is on.
* elfread.c (elf_symfile_read): Do not map over sections with
'elf_locate_sections' if readnever is on.
* main.c (validate_readnow_readnever): New function.
(captured_main_1): Add support for --readnever.
(print_gdb_help): Document --readnever.
* objfile-flags.h (enum objfile_flag) <OBJF_READNEVER>: New
flag.
* symfile.c (readnever_symbol_files): New global.
(symbol_file_add_with_addrs): Set 'OBJF_READNEVER' when
'READNEVER_SYMBOL_FILES' is set.
(validate_readnow_readnever): New function.
(symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(add_symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(_initialize_symfile): Document new '-readnever' option for
both 'symbol-file' and 'add-symbol-file' commands.
* top.h (readnever_symbol_files): New extern global.
* xcoffread.c (xcoff_initial_scan): Do not read debug
information if readnever is on.
gdb/doc/ChangeLog:
2017-12-01 Andrew Cagney <cagney@redhat.com>
Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.texinfo (File Options): Document --readnever.
(Commands to Specify Files): Likewise, for 'symbol-file' and
'add-symbol-file'.
gdb/testsuite/ChangeLog:
2017-12-01 Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* gdb.base/readnever.c, gdb.base/readnever.exp: New files.
Peter Bergner [Fri, 1 Dec 2017 17:20:15 +0000 (11:20 -0600)]
Use consistent types for holding instructions, instruction masks, etc.
include/
* opcode/ppc.h (PPC_INT_FMT): Define.
(struct powerpc_opcode) <opcode>: Update type.
(struct powerpc_opcode) <mask>: Likewise.
(struct powerpc_opcode) <bitm>: Likewise.
(struct powerpc_opcode) <insert>: Likewise.
(struct powerpc_opcode) <extract>: Likewise.
(ppc_optional_operand_value): Likewise.
gas/
* config/tc-ppc.c (last_insn): Update type.
(insn_validate) <omask, mask>: Likewise.
(ppc_setup_opcodes) <mask, right_bit>: Likewise.
<PRINT_OPCODE_TABLE>: Update types and printf format specifiers.
(ppc_insert_operand): Update return and argument types and remove
unneeded type casts.
<min, max, right, tmp>: Update type.
(md_assemble): Remove unneeded type casts.
<insn, val, tmp_insn>: Update type.
opcodes/
* opcodes/ppc-dis.c (disassemble_init_powerpc): Fix white space.
(operand_value_powerpc): Update return and argument type.
<value, top>: Update type.
(skip_optional_operands): Update argument type.
(lookup_powerpc): Likewise.
(lookup_vle): Likewise.
<table_opcd, table_mask, insn2>: Update type.
(lookup_spe2): Update argument type.
<table_opcd, table_mask, insn2>: Update type.
(print_insn_powerpc) <insn, value>: Update type.
Use PPC_INT_FMT for printing instructions and operands.
* opcodes/ppc-opc.c (insert_arx, extract_arx, insert_ary, extract_ary,
insert_rx, extract_rx, insert_ry, extract_ry, insert_bat, extract_bat,
insert_bba, extract_bba, insert_bdm, extract_bdm, insert_bdp,
extract_bdp, valid_bo_pre_v2, valid_bo_post_v2, valid_bo, insert_bo,
extract_bo, insert_boe, extract_boe, insert_dcmxs, extract_dcmxs,
insert_dxd, extract_dxd, insert_dxdn, extract_dxdn, insert_fxm,
extract_fxm, insert_li20, extract_li20, insert_ls, extract_ls,
insert_esync, extract_esync, insert_mbe, extract_mbe, insert_mb6,
extract_mb6, extract_nb, insert_nbi, insert_nsi, extract_nsi,
insert_ral, extract_ral, insert_ram, extract_ram, insert_raq,
extract_raq, insert_ras, extract_ras, insert_rbs, extract_rbs,
insert_rbx, extract_rbx, insert_sci8, extract_sci8, insert_sci8n,
extract_sci8n, insert_sd4h, extract_sd4h, insert_sd4w, extract_sd4w,
insert_oimm, extract_oimm, insert_sh6, extract_sh6, insert_spr,
extract_spr, insert_sprg, extract_sprg, insert_tbr, extract_tbr,
insert_xt6, extract_xt6, insert_xtq6, extract_xtq6, insert_xa6,
extract_xa6, insert_xb6, extract_xb6, insert_xb6s, extract_xb6s,
insert_xc6, extract_xc6, insert_dm, extract_dm, insert_vlesi,
extract_vlesi, insert_vlensi, extract_vlensi, insert_vleui,
extract_vleui, insert_vleil, extract_vleil, insert_evuimm1_ex0,
extract_evuimm1_ex0, insert_evuimm2_ex0, extract_evuimm2_ex0,
insert_evuimm4_ex0, extract_evuimm4_ex0, insert_evuimm8_ex0,
extract_evuimm8_ex0, insert_evuimm_lt8, extract_evuimm_lt8,
insert_evuimm_lt16, extract_evuimm_lt16, insert_rD_rS_even,
extract_rD_rS_even, insert_off_lsp, extract_off_lsp, insert_off_spe2,
extract_off_spe2, insert_Ddd, extract_Ddd): Update types.
(OP, OPTO, OPL, OPVUP, OPVUPRT, A, AFRALFRC_MASK, B, BD8, BD8IO, BD15,
BD24, BBO, Y_MASK , AT1_MASK, AT2_MASK, BBOCB, C_LK, C, CTX, UCTX,
DX, EVSEL, IA16, I16A, I16L, IM7, LI20, MME, MD, MDS, SC, SC_MASK,
SCI8, SCI8BF, SD4, SE_IM5, SE_R, SE_RR, VX, VX_LSP, VX_RA_CONST,
VX_RB_CONST, VX_SPE_CRFD, VX_SPE2_CLR, VX_SPE2_SPLATB, VX_SPE2_OCTET,
VX_SPE2_DDHH, VX_SPE2_HH, VX_SPE2_EVMAR, VX_SPE2_EVMAR_MASK, VXA,
VXR, VXASH, X, EX, XX2, XX3, XX3RC, XX4, Z, XWRA_MASK, XLRT_MASK,
XRLARB_MASK, XLRAND_MASK, XRTLRA_MASK, XRTLRARB_MASK, XRTARARB_MASK,
XRTBFRARB_MASK, XOPL, XOPL2, XRCL, XRT, XRTRA, XCMP_MASK, XCMPL_MASK,
XTO, XTLB, XSYNC, XEH_MASK, XDSS, XFL, XISEL, XL, XLO, XLYLK, XLOCB,
XMBAR, XO, XOPS, XS, XFXM, XSPR, XUC, XW, APU): Update types in casts.
Tom Tromey [Thu, 30 Nov 2017 18:49:27 +0000 (11:49 -0700)]
Fix dependency tracking for objects in subdirectories
On irc, Pedro pointed out that dependencies for objects in
subdirectories didn't seem to be working.
The bug was that the "-include" for .deps files was using the wrong file
name for subdirectory objects; e.g., for cli/cli-decode.o it was trying
to open .deps/cli/cli-decode.o, whereas the correct file is
cli/.deps/cli-decode.o.
This patch changes how the dep files are found. Tested by touching a
source file and rebuilding cli/cli-decode.o.
2017-12-01 Tom Tromey <tom@tromey.com>
* Makefile.in (all_deps_files): New variable.
Include .Po files using all_deps_files.
Joel Brobecker [Fri, 1 Dec 2017 13:35:56 +0000 (08:35 -0500)]
Update GDB's list of maintainers to reflect today's reality
gdb/ChangeLog:
* MAINTAINERS: Update list of maintainers, moving those who
stepped down or became inactive to the "Past Maintainers"
section.
H.J. Lu [Fri, 1 Dec 2017 12:01:11 +0000 (04:01 -0800)]
x86: Print dynreloc in readonly section for map file output
This fixed:
FAIL: DT_TEXTREL map file warning
on Linux/x86.
* elfxx-x86.c (_bfd_x86_elf_readonly_dynrelocs): Print dynamic
relocation in readonly section for map file output.
Yao Qi [Fri, 1 Dec 2017 11:34:14 +0000 (11:34 +0000)]
Replace mail address with the URL in copyright header
The copyright header in most of GDB files were changed from mail address
to the URL in the conversion to GPLv3 in Aug 2007. However, some files
still use mail address instead of the URL. This patch fixes them.
gdb/testsuite:
2017-12-01 Yao Qi <yao.qi@linaro.org>
* gdb.arch/aarch64-atomic-inst.exp: Replace mail address with
the URL in copyright header.
* gdb.arch/aarch64-fp.exp: Likewise.
* gdb.arch/ppc64-atomic-inst.exp: Likewise.
* gdb.arch/ppc64-isa207-atomic-inst.exp: Likewise.
* gdb.base/expand-psymtabs.exp: Likewise.
* gdb.cp/expand-psymtabs-cxx.exp: Likewise.
* gdb.fortran/common-block.exp: Likewise.
* gdb.fortran/common-block.f90: Likewise.
* gdb.fortran/logical.exp: Likewise.
* gdb.fortran/vla-datatypes.f90: Likewise.
* gdb.fortran/vla-sub.f90: Likewise.
Tobias Ulmer [Fri, 1 Dec 2017 08:55:19 +0000 (19:25 +1030)]
Check return value of bfd_new_link_order
* ldwrite.c (build_link_order): Check return value of all
bfd_new_link_order calls.
Oleksandr Pikozh [Fri, 1 Dec 2017 07:10:55 +0000 (17:40 +1030)]
Add --strip-unneeded to objcopy synopsis
* doc/binutils.texi: Add --strip-unneeded to objcopy synopsis.
Alan Modra [Fri, 1 Dec 2017 03:08:01 +0000 (13:38 +1030)]
weak alias test
This adds the test I was using when testing
60d67dc8.
* testsuite/ld-elfweak/alias.c,
* testsuite/ld-elfweak/alias.dat,
* testsuite/ld-elfweak/aliasmain.c,
* testsuite/ld-elfweak/weakref1.c,
* testsuite/ld-elfweak/weakref2.c: New test.
* testsuite/ld-elfweak/elfweak.exp: Run it. Don't return on fails,
attempt other tests.
Alan Modra [Thu, 30 Nov 2017 09:16:17 +0000 (19:46 +1030)]
readonly_dynrelocs
In early October, HJ Lu added support for a number of targets to "Dump
dynamic relocation in read-only section with minfo". This extends
that support to more targets, displays the symbol involved, and splits
the existing function that sets TEXTREL into a "readonly_dynrelocs"
and "maybe_set_textrel" function. I'll need "readonly_dynrelocs" if I
ever get around to fixing "pr22374 function pointer initialization"
fails.
am33_2.0, arc, bfin, hppa64, mn10300, and nios2 fail to mark a binary
needing text relocations with DT_TEXTREL. That's not good. xtensa also
fails to do so but complains about "dangerous relocation: dynamic
relocation in read-only section" so I reckon that is fine and have
marked the test as an xfail. The other targets need maintainer
attention.
Curiously, the map file dump wasn't added for x86, so the map test
currently fail on x86. It also fails on alpha, am33_2.0, arc, bfin,
hppa64, ia64, m68k, mips, mn10300, nios2, score and vax. cris
complains with "tmpdir/textrel.o, section .rodata: relocation
R_CRIS_32 should not be used in a shared object; recompile with -fPIC"
so I've marked it as an xfail.
bfd/
* elf32-hppa.c (maybe_set_textrel): Print symbol for map file output.
* elf32-ppc.c (maybe_set_textrel): Likewise.
* elf64-ppc.c (maybe_set_textrel): Likewise.
* elf32-arm.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing..
(elf32_arm_readonly_dynrelocs): ..this.
* elf32-lm32.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-m32r.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-metag.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-nds32.c: Delete unnecessary forward declarations.
(readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-or1k.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-s390.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-sh.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf32-tic6x.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing..
(elf32_tic6x_readonly_dynrelocs): ..this.
* elf32-tilepro.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elf64-s390.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elfnn-aarch64.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing..
(aarch64_readonly_readonly_dynrelocs): ..this.
* elfnn-riscv.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elfxx-sparc.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
* elfxx-tilegx.c (readonly_dynrelocs): New function.
(maybe_set_textrel): New function, replacing old version of..
(readonly_dynrelocs): ..this.
ld/
* testsuite/ld-elf/shared.exp: Run new textrel tests.
* testsuite/ld-elf/textrel.map: New file.
* testsuite/ld-elf/textrel.rd: New file.
* testsuite/ld-elf/textrel.s: New file.
* testsuite/ld-elf/textrel.warn: New file.
GDB Administrator [Fri, 1 Dec 2017 00:00:33 +0000 (00:00 +0000)]
Automatic date update in version.in
Joel Brobecker [Thu, 30 Nov 2017 23:41:55 +0000 (18:41 -0500)]
New gdb.ada/repeat_dyn testcase.
This patch introduces a testcase that exercises a scenario
which used to trigger an internal-error, but no longer does:
Consider the following array:
type Small is new Integer range Ident (1) .. Ident (10);
type Table is array (1 .. 3) of Small;
A1 : Table := (3, 5, 8);
The particularity of this array is that the type of each element
is a range type whose bounds are dynamic, since they depend on
the value returned by Ident (1) and Ident (10). Trying to apply
the repeat operator ('@') on one of its elements used to yield
an internal error:
(gdb) p a1(1)@3
$1 =
/[...]/gdbtypes.c:4512: internal-error:
copy_type: Assertion `TYPE_OBJFILE_OWNED (type)' failed.
Although the issue no longer appears, the testcase is still
interesting to have.
gdb/testsuite/ChangeLog:
* gdb.ada/repeat_dyn: New testcase.
Tested on x86_64-linux with clean results.
Peter Smith [Thu, 30 Nov 2017 23:07:26 +0000 (15:07 -0800)]
Fix internal error in fix_errata on aarch64.
The addresses of erratum stubs can be changed by relaxation passes, and
need to be updated.
gold/
PR gold/20765
* aarch64.cc (Aarch64_relobj::update_erratum_address): New method.
(AArch64_relobj::scan_errata): Update addresses in stub table after
relaxation pass.
Cary Coutant [Thu, 30 Nov 2017 21:44:28 +0000 (13:44 -0800)]
Fix problem where erratum stubs are not always applied.
I checked over the results of applying --fix-cortex-a53-843419 to
a very large program (gitit) with two stub tables and thousands
of erratum fixes. I noticed that all the erratum_stubs were being
created but about 1/3 of them were being skipped over by
fix_errata_and_relocate_erratum_stubs(). By skipped over I mean
no branch relocation or adrp -> adr transformation was applied to
the erratum address, leaving the erratum_stub unreachable, and
with a branch with a 0 immediate.
The root cause of the skipped over erratum_stubs is
Erratum_stub::invalidate_erratum_stub() that is used to set
relobj_ to NULL when an erratum_stub has been processed.
Unfortunately relobj_ is used in operator<() so altering relobj
makes the results from erratum_stubs_.lower_bound() as used in
find_erratum_stubs_for_input_section() unreliable.
2017-11-30 Peter Smith <peter.smith@linaro.org>
Cary Coutant <ccoutant@gmail.com>
gold/
PR gold/20765
* aarch64.cc (Erratum_stub::invalidate_erratum_stub): Use erratum_insn_
instead of relobj_ to invalidate the stub.
(Erratum_stub::is_invalidated_erratum_stub): Likewise.
Peter Smith [Thu, 30 Nov 2017 21:30:58 +0000 (13:30 -0800)]
Fix segfault in relocate_erratum_stub on aarch64.
The fix for PR21868 (an internal error when --fix-cortex-a53-843419
is applied) has a small mistake in it. When the stub_owner section
needs an erratum fix an incorrect address for the stubs for the section
is given to relocate_erratum_stub. If we are lucky we will get a segfault;
if we aren't, an incorrect patch or data corruption is possible.
The error is visible in PR21868, but the side-effects aren't fatal.
gold/
PR gold/22233
* aarch64.cc (AArch64_relobj::fix_errata_and_relocate_erratum_stubs):
Fix calculation of stub address.
Alan Modra [Thu, 30 Nov 2017 21:23:16 +0000 (07:53 +1030)]
PR22533, dynamic relocs generated for weak aliases
This cleans up yet more craziness with non_got_ref.
PR 22533
* elf32-hppa.c (elf32_hppa_copy_indirect_symbol): Don't do anything
special with non_got_ref for weak aliases.
(elf32_hppa_check_relocs): Tweak setting of non_got_ref.
(elf32_hppa_adjust_dynamic_symbol): When initialising weak aliases,
don't uselessly copy non_got_ref. Clear dyn_relocs instead if
strong symbol is allocated in dynbss. Tidy comments.
(elf32_hppa_relocate_section): Comment fix.
* elf32-ppc.c (ppc_elf_copy_indirect_symbol): Don't do anything
special with non_got_ref for weak aliases.
(ppc_elf_adjust_dynamic_symbol): When initialising weak aliases,
don't uselessly copy non_got_ref. Clear dyn_relocs instead if
strong symbol is allocated in dynbss. Tidy comments.
* elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Don't do anything
special with non_got_ref for weak aliases.
(ppc64_elf_adjust_dynamic_symbol): When initialising weak aliases,
don't uselessly copy non_got_ref. Clear dyn_relocs instead if
strong symbol is allocated in dynbss. Tidy comments.
Ulrich Weigand [Thu, 30 Nov 2017 17:35:54 +0000 (18:35 +0100)]
[spu] Some additional test fixes
Now that the ppc64 breakpoint regression is fixed, running the
gdb.cell test suite showed a few more test case problems, caused
by tests that haven't been updated to adapt to GDB changes.
gdb/testsuite/ChangeLog:
2017-11-30 Ulrich Weigand <uweigand@de.ibm.com>
* gdb.cell/gcore.exp: Fix typo when setting spu_bin.
Update for changed thread numbering.
* gdb.cell/bt.exp: Update for changed GDB output.
Simon Marchi [Thu, 30 Nov 2017 16:39:31 +0000 (11:39 -0500)]
Use boards/local-board.exp more
local-board.exp was introduced recently, containing the code required to
force the gdbserver boards to be non-remote (from the DejaGNU point of
view). Other board files use the same trick of forcing isremote to 0.
Instead of doing it by hand in each file, include local-board.exp.
gdb/testsuite/ChangeLog:
* boards/cc-with-tweaks.exp: Include local-board.exp instead of
setting isremote by hand.
* boards/dwarf4-gdb-index.exp: Likewise.
* boards/fission.exp: Likewise.
* boards/stabs.exp: Likewise.
Pedro Alves [Thu, 30 Nov 2017 16:32:10 +0000 (16:32 +0000)]
Fix gdb.linespec/cpls-ops.exp on 32-bit
gdb.linespec/cpls-ops.exp is currently failing on x86-64 -m32 and other
32-bit ports:
b test_op_new::operator new(unsigned int) FAIL: gdb.linespec/cpls-ops.exp: operator-new: tab complete "b test_op_new::operator" (timeout)
^CQuit
(gdb) complete b test_op_new::operator
b test_op_new::operator new(unsigned int)
(gdb) FAIL: gdb.linespec/cpls-ops.exp: operator-new: cmd complete "b test_op_new::operator"
The problem is simply that the testcase incorrectly assumes that
size_t is "unsigned long".
Fix this by extracting the right type with the "ptype" command.
gdb/testsuite/ChangeLog:
2017-11-30 Pedro Alves <palves@redhat.com>
* gdb.linespec/cpls-ops.exp
(check_explicit_skips_function_argument): Extract the underlying
type of size_t instead of hardcoding it.
Rainer Orth [Thu, 30 Nov 2017 15:05:30 +0000 (16:05 +0100)]
Remove ioctl-based procfs support on Solaris
This is the previously mentioned patch to get rid of
unstructured/ioctl-based procfs support in procfs.c. Given that support
for structured procfs was introduced in Solaris 2.6 back in 1997 and
we're just removing support for Solaris < 10, there's no point in
carrying that baggage (and tons of support for IRIX and OSF/1 as well)
around any longer.
Most of the patch should be straightforward (removing support for
!NEW_PROC_API, non-Solaris OSes and pre-Solaris 10 quirks).
Only a few points need explanations:
* <sys/syscall.h> was already included unconditionally in most places,
so there's no need to have guards in a few remaining ones.
* configure.host already obsoletes i?86-*-sysv4.2, i?86-*-sysv5, so
NEW_PROC_API detection for those in configure.ac can go.
* I'm still including <sys/procfs.h> with #define _STRUCTURED_PROC 1.
Theoretically, it would be better to include <procfs.h> on Solaris
(which includes that define), but that breaks the build over
<procfs.h> vs. gdb's "procfs.h", and doesn't exist on Linux.
* I've regenerated syscall_table[] in proc-events.c with a small script
from Solaris 10, 11.3, 11.4 <sys/syscall.h>, so there should be no
traces of older Solaris versions and other OSes left.
* prsysent_t and DYNAMIC_SYSCALLS was only used for AIX 5, but AIX
doesn't use procfs.c any longer, so all related code can go.
The patch was generated with diff -w so one can easier see changes
without being distracted by simple reindentations.
So far, it has only been compiled and smoke-tested on
amd64-pc-solaris2.1[01], sparcv9-sun-solaris2.1[01], and
x86_64-pc-linux-gnu. Certainly needs more testing (Solaris 11.3
vs. 11.4, 32-bit gdb, testsuite once I've figured out what's wrong on
Solaris 10 etc.), but it's enough to get a first impression how much
cleanup is possible here.
* configure.ac Don't check for sys/fault.h, sys/syscall.h,
sys/proc.h.
(NEW_PROC_API): Remove.
(prsysent_t, pr_sigset_t, pr_sigaction64_t, pr_siginfo64_t):
Likewise.
* common/common.m4 (GDB_AC_COMMON): Don't check for sys/syscall.h.
* configure: Regenerate.
* config.in: Regenerate.
* gdbserver/configure: Regenerate.
* gdbserver/config.in: Regenerate.
* i386-sol2-nat.c (_initialize_amd64_sol2_nat): Remove
NEW_PROC_API test.
* sparc-sol2-nat.c (_initialize_sparc_sol2_nat): Likewise.
* linux-btrace.c: Remove HAVE_SYS_SYSCALL_H test.
* proc-api.c: Remove !NEW_PROC_API support.
Remove HAVE_SYS_PROC_H and HAVE_SYS_USER_H tests.
Remove tests for macros always defined on Solaris.
* proc-events.c: Remove !NEW_PROC_API support.
Remove Remove HAVE_SYS_SYSCALL_H, HAVE_SYS_PROC_H and
HAVE_SYS_USER_H tests.
(init_syscall_table): Remove non-Solaris syscalls.
Remove tests for syscalls present on all Solaris versions.
Add missing Solaris 10+ syscalls.
(signal_table): Remove non-Solaris signals.
Remove tests for signals present on all Solaris versions.
(fault_table): Remove non-Solaris faults.
Remove tests for faults present on all Solaris versions.
* proc-flags.c: Remove !NEW_PROC_API support.
(pr_flag_table): Remove non-Solaris and pre-Solaris 7 comments.
Remove non-Solaris flags.
* proc-why.c: Remove !NEW_PROC_API support.
(pr_why_table): Remove meaningless comments.
Remove tests for reasons present on all Solaris versions.
Remove OSF/1 cases.
(proc_prettyfprint_why): Likewise.
* procfs.c: Remove !NEW_PROC_API and DYNAMIC_SYSCALLS support.
Remove HAVE_SYS_FAULT_H and HAVE_SYS_SYSCALL_H tests.
Remove WA_READ test, IRIX watchpoint support.
(gdb_sigset_t, gdb_sigaction_t, gdb_siginfo_t): Replace by base
types. Change users.
(gdb_praddset, gdb_prdelset, gdb_premptysysset, gdb_praddsysset)
(gdb_prdelset, gdb_pr_issyssetmember): Replace by base macros.
Change callers.
Remove CTL_PROC_NAME_FMT tests.
(gdb_prstatus_t, gdb_lwpstatus_t): Replace by base types. Change
users.
(sysset_t_size): Remove. Use sizeof (sysset_t) in callers.
Remove PROCFS_DONT_PIOCSSIG_CURSIG support.
(proc_modify_flag): Replace GDBRESET by PCUNSET.
Remove PR_ASYNC, PR_KLC tests.
(proc_unset_inherit_on_fork): Remove PR_ASYNC test.
(proc_parent_pid): Remove PCWATCH etc. tests.
(proc_set_watchpoint): Remove !PCWATCH && !PIOCSWATCH support.
Remove PCAGENT test.
(proc_get_nthreads) [PIOCNTHR && PIOCTLIST]: Remove.
Remove SYS_lwpcreate || SYS_lwp_create test.
(proc_get_current_thread): Likewise.
[PIOCNTHR && PIOCTLIST]: Remove.
[PIOCLSTATUS]: Remove.
(procfs_debug_inferior): Remove non-Solaris cases, conditionals.
[PRFS_STOPEXEC]: Remove.
(syscall_is_lwp_exit): Remove non-Solaris cases, conditionals.
(syscall_is_exit): Likewise.
(syscall_is_exec): Likewise.
(syscall_is_lwp_create): Likewise.
Remove SYS_syssgi support.
(procfs_wait): Remove PR_ASYNC, !PIOCSSPCACT tests.
[SYS_syssgi]: Remove.
Remove non-Solaris cases, conditionals.
(unconditionally_kill_inferior) [PROCFS_NEED_PIOCSSIG_FOR_KILL]:
Remove.
(procfs_init_inferior) [SYS_syssgi]: Remove.
(procfs_set_exec_trap) [PRFS_STOPEXEC]: Remove.
(procfs_inferior_created) [SYS_syssgi]: Remove.
(procfs_set_watchpoint): Remove !AIX5 test.
(procfs_stopped_by_watchpoint): Remove FLTWATCH test, FLTKWATCH
case.
(mappingflags) [MA_PHYS]: Remove.
(info_mappings_callback): Remove PCAGENT test.
Remove PIOCOPENLWP || PCAGENT test.
Jan Beulich [Thu, 30 Nov 2017 10:48:13 +0000 (11:48 +0100)]
x86: derive DispN from BaseIndex
BaseIndex implies - with the exception of string instructions the
optional presence of a displacement. This is almost completely uniform
for all instructions (the sole exception being MPX ones, which don't
allow 16-bit addressing and hence Disp16), so there's no point in
explicitly stating this in the main opcode table. Drop those explict
specifications in favor of adding logic to i386-gen, shrinking the
table size quite a bit and hence making it more readable.
The opcodes/i386-tbl.h changes are due to a few cases where pointless
Disp* still hadn't been removed from their insns.
Jan Beulich [Thu, 30 Nov 2017 10:47:38 +0000 (11:47 +0100)]
x86: drop Vec_Disp8
This is fully redundant with Disp8MemShift being non-zero, and hence can
be folded with normal Disp8 handling.
Jan Beulich [Thu, 30 Nov 2017 10:46:26 +0000 (11:46 +0100)]
x86/Intel: issue diagnostics for redundant segment override prefixes
While we shouldn't outright reject such (as was wrongly done by commit
4d36230d59 ("x86: Update segment register check in Intel syntax"), as
MASM accepts them even silently, issue (by default) a warning for such
questionable constructs.
Jan Beulich [Thu, 30 Nov 2017 10:44:27 +0000 (11:44 +0100)]
Revert "x86: Update segment register check in Intel syntax"
This reverts commit
4d36230d59903b92fbe2b53b31ed64a884860f0e.
I was committed without maintainer ack and regresses intended
functionality. A replacement will be committed shortly.
Nick Clifton [Thu, 30 Nov 2017 10:25:01 +0000 (10:25 +0000)]
Prevent an illegal memory access in readelf when attempting to parse a corrupt ELF file.
PR 22510
* readelf.c (load_debug_section): Fail if there are no section
headers available.
Rainer Orth [Thu, 30 Nov 2017 09:57:04 +0000 (10:57 +0100)]
Fix sol-thread.c compilation on Solaris
Building current gdb mainline with gcc 7.1 on Solaris 11.4 fails:
/vol/src/gnu/gdb/gdb/dist/gdb/sol-thread.c: In function `void _initialize_sol_thread()':
/vol/src/gnu/gdb/gdb/dist/gdb/sol-thread.c:1229:66: error: invalid conversion from `void (*)(char*, int)' to `void (*)(const char*, int)' [-fpermissive]
_("Show info on Solaris user threads."), &maintenanceinfolist);
^
In file included from /vol/src/gnu/gdb/gdb/dist/gdb/completer.h:21:0,
from /vol/src/gnu/gdb/gdb/dist/gdb/symtab.h:31,
from /vol/src/gnu/gdb/gdb/dist/gdb/language.h:26,
from /vol/src/gnu/gdb/gdb/dist/gdb/frame.h:72,
from /vol/src/gnu/gdb/gdb/dist/gdb/gdbarch.h:39,
from /vol/src/gnu/gdb/gdb/dist/gdb/defs.h:557,
from /vol/src/gnu/gdb/gdb/dist/gdb/sol-thread.c:51:
/vol/src/gnu/gdb/gdb/dist/gdb/command.h:140:33: note: initializing argument 3 of `cmd_list_element* add_cmd(const char*, command_class, void (*)(const char*, int), const char*, cmd_list_element**)'
extern struct cmd_list_element *add_cmd (const char *, enum command_class,
^~~~~~~
The following patch allows compilation to succeed on i386-pc-solaris2.11
and sparc-sun-solaris2.11.
* sol-thread.c (info_solthreads): Constify args.
Cast args to void *.
Alan Modra [Thu, 30 Nov 2017 02:40:35 +0000 (13:10 +1030)]
Fix testcase for PR ld/22471
ASFLAGS should be restored after any modification. Fixes
metag-linux +FAIL: Long branch stub
metag-linux +FAIL: Long branch stub (PIC, app)
mn10300-elf +FAIL: difference of two same-section symbols where the difference is held in another section
mn10300-elf +FAIL: relaxation and alignment directives
PR 22471
* testsuite/ld-elf/shared.exp: Save and restore ASFLAGS.
John Baldwin [Thu, 30 Nov 2017 00:28:01 +0000 (16:28 -0800)]
Define MPFR_USE_INTMAX_T so that mpfr.h assumes intmax_t is available.
mpfr.h uses a non-portable test to guess if intmax_t is available and
if API functions using intmax_t should be exposed. Define
MPFR_USE_INTMAX_T to override the non-portable test and always expose
these functions. This fixes the build on platforms where the test
guesses incorrectly.
gdb/ChangeLog:
* target-float.c [HAVE_LIBMPFR]: Define MPFR_USE_INTMAX_T.
GDB Administrator [Thu, 30 Nov 2017 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in
Joel Brobecker [Wed, 29 Nov 2017 23:31:18 +0000 (18:31 -0500)]
preserve type length in ada-lang.c::to_fixed_range_type
This patch fixes a potential issue which was noticed by code inspection:
ada-lang.c::to_fixed_range_type uses gdbtypes.c::create_static_range_type
to create most of the range type, which relies on create_range_type to
do most of the work. The latter has the following piece of code which
sets the length of the range type to match the length of the index_type:
if (TYPE_STUB (index_type))
TYPE_TARGET_STUB (result_type) = 1;
else
TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type));
In Ada, it is actually possible to have a range type whose size
is smaller than its base type. For instance, with:
type Unsigned2_T is range 0 .. 2 ** 16 - 1;
for Unsigned2_T'SIZE use 16;
The compiler generates the following DWARF:
.uleb128 0x3 # (DIE (0x4e) DW_TAG_subrange_type)
.byte 0x2 # DW_AT_byte_size
.byte 0 # DW_AT_lower_bound
.value 0xffff # DW_AT_upper_bound
.long .LASF64 # DW_AT_name: "try__unsigned2_t___XDLU_0__65535"
.long 0x616 # DW_AT_type
... which points to the following base type...
.uleb128 0x1d # (DIE (0x616) DW_TAG_base_type)
.byte 0x4 # DW_AT_byte_size
.byte 0x5 # DW_AT_encoding
.long .LASF57 # DW_AT_name: "try__Tunsigned2_tB"
# DW_AT_artificial
... which has a size of 4 bytes.
With a type like this one, create_range_type returns a type whose
size is 4 bytes, instead of 2, which is not what we we would normally
expect.
Currently, this function is only used to handle array index types,
so the length of the type actually does not matter and there should
not be any user-visible consequences of the current behavior. But
it seems best to plug this latent bug now, rather than wait for it
to surface....
gdb/ChangeLog:
* ada-lang.c (to_fixed_range_type): Make sure that the size
of the range type being returned is the same as the size
of the range type being fixed.
Tested on x86_64-linux, no regression.
Pedro Alves [Wed, 29 Nov 2017 19:33:24 +0000 (19:33 +0000)]
Breakpoints in symbols with ABI tags (PR c++/19436)
Trying to set a breakpoint in a function with an ABI tag does not work
currently. E.g., debugging gdb itself, we see this with the
"string_printf" function:
(top-gdb) b string_print [TAB]
(top-gdb) b string_printf[abi:cxx11](char const*, ...) [RET]
No source file named string_printf[abi.
Make breakpoint pending on future shared library load? (y or [n])
Quoting doesn't help:
(top-gdb) b 'string_printf[abi:cxx11]'(char const*, ...)
malformed linespec error: unexpected string, "(char const*, ...)"
(top-gdb) b 'string_printf[abi:cxx11](char const*, ...)'
No source file named string_printf[abi.
Make breakpoint pending on future shared library load? (y or [n]) n
This patch fixes this, and takes it a bit further.
The actual symbol name as demangled by libiberty's demangler is really
string_printf[abi:cxx11](char const*, ...)
however, this patch makes it possible to set the breakpoint with
string_printf(char const*, ...)
too. I.e., ignoring the ABI tag.
And to match, it teaches the completer to complete the symbol name
without the ABI tag, i.e.,
"string_pri<TAB>" -> "string_printf(char const*, ...)"
If however, you really want to break on a symbol with the tag, then
you simply start writing the tag, and GDB will preserve it, like:
"string_printf[a<TAB>" -> "string_printf[abi:cxx11](char const*, ...)"
Grows the gdb.linespec/ tests like this:
-# of expected passes 8977
+# of expected passes 9176
gdb/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
PR c++/19436
* NEWS: Mention setting breakpoints on functions with C++ ABI
tags.
* completer.h (completion_match_for_lcd) <match,
mark_ignored_range>: New methods.
<finish>: Consider ignored ranges.
<clear>: Clear ignored ranges.
<m_ignored_ranges, m_finished_storage>: New fields.
* cp-support.c (cp_search_name_hash): Ignore ABI tags.
(cp_symbol_name_matches_1, cp_fq_symbol_name_matches): Pass the
completion_match_for_lcd pointer to strncmp_iw_with_mode.
(test_cp_symbol_name_cmp): Add [abi:...] tags unit tests.
* language.c (default_symbol_name_matcher): Pass the
completion_match_for_lcd pointer to strncmp_iw_with_mode.
* linespec.c (linespec_lexer_lex_string): Don't tokenize ABI tags.
* utils.c (skip_abi_tag): New function.
(strncmp_iw_with_mode): Add completion_match_for_lcd parameter.
Handle ABI tags.
* utils.h (strncmp_iw_with_mode): Add completion_match_for_lcd
parameter.
gdb/testsuite/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
PR c++/19436
* gdb.linespec/cpls-abi-tag.cc: New file.
* gdb.linespec/cpls-abi-tag.exp: New file.
gdb/doc/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
PR c++/19436
* gdb.texinfo (Debugging C Plus Plus): Document setting
breakpoints in functions with ABI tags.
Pedro Alves [Wed, 29 Nov 2017 19:33:23 +0000 (19:33 +0000)]
Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching]
This patch teaches GDB about setting breakpoints in all scopes
(namespaces and classes) by default.
Here's a contrived example:
(gdb) b func<tab>
(anonymous namespace)::A::function() Bn::(anonymous namespace)::B::function() function(int, int)
(anonymous namespace)::B::function() Bn::(anonymous namespace)::function() gdb::(anonymous namespace)::A::function()
(anonymous namespace)::B::function() const Bn::(anonymous namespace)::function(int, int) gdb::(anonymous namespace)::function()
(anonymous namespace)::function() Bn::B::func() gdb::(anonymous namespace)::function(int, int)
(anonymous namespace)::function(int, int) Bn::B::function() gdb::A::func()
A::func() Bn::func() gdb::A::function()
A::function() Bn::function() gdb::func()
B::func() Bn::function(int, int) gdb::function()
B::function() Bn::function(long) gdb::function(int, int)
B::function() const func() gdb::function(long)
B::function_const() const function()
(gdb) b function
Breakpoint 1 at 0x4005ce: function. (26 locations)
(gdb) b B::function<tab>
(anonymous namespace)::B::function() B::function() const Bn::B::function()
(anonymous namespace)::B::function() const B::function_const() const
B::function() Bn::(anonymous namespace)::B::function()
(gdb) b B::function
Breakpoint 1 at 0x40072c: B::function. (6 locations)
To get back the original behavior of interpreting the function name as
a fully-qualified name, you can use the new "-qualified" (or "-q")
option/flag (added by this commit). For example:
(gdb) b B::function
(anonymous namespace)::B::function() B::function() const Bn::B::function()
(anonymous namespace)::B::function() const B::function_const() const
B::function() Bn::(anonymous namespace)::B::function()
vs:
(gdb) b -qualified B::function
B::function() B::function() const B::function_const() const
I've chosen "-qualified" / "-q" because "-f" (for "full" or
"fully-qualified") is already taken for "-function".
Note: the "-qualified" option works with both linespecs and explicit
locations. I.e., these are equivalent:
(gdb) b -q func
(gdb) b -q -f func
and so are these:
(gdb) b -q filename.cc:func
(gdb) b -q -s filename.cc -f func
(gdb) b -s filename.cc -q -f func
(gdb) b -s filename.cc -f func -q
To better understand why I consider wild matching the better default,
consider what happens when we get to the point when _all_ of GDB is
wrapped under "namespace gdb {}". I have a patch series that does
that, and when I started debugging that GDB, I immediately became
frustrated. You'd have to write "b gdb::internal_error", "b
gdb::foo", "b gdb::bar", etc. etc., which gets annoying pretty
quickly. OTOH, consider how this makes it very easy to set
breakpoints in classes wrapped in anonymous namespaces. You just
don't think of them, GDB finds the symbols for you automatically.
(At the Cauldron a couple months ago, several people told me that they
run into a similar issue when debugging other C++ projects. One
example was when debugging LLVM, which puts all its code under the
"llvm" namespace.)
Implementation-wise, what the patch does is:
- makes C++ symbol name hashing only consider the last component of
a symbol name. (so that we can look up symbol names by
last-component name only).
- adds a C++ symbol name matcher for symbol_name_match_type::WILD,
which ignores missing leading specifiers / components.
- adjusts a few preexisting testsuite tests to use "-qualified" when
they mean it.
- adds new testsuite tests.
- adds unit tests.
Grows the gdb.linespec/ tests like this:
-# of expected passes 7823
+# of expected passes 8977
gdb/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* NEWS: Mention that breakpoints on C++ functions are now set on
on all namespaces/classes by default, and mention "break
-qualified".
* ax-gdb.c (agent_command_1): Adjust to pass a
symbol_name_match_type to new_linespec_location.
* breakpoint.c (parse_breakpoint_sals): Adjust to
get_linespec_location's return type change.
(strace_marker_create_sals_from_location): Adjust to pass a
symbol_name_match_type to new_linespec_location.
(strace_marker_decode_location): Adjust to get_linespec_location's
return type change.
(strace_command): Adjust to pass a symbol_name_match_type to
new_linespec_location.
(LOCATION_HELP_STRING): Add paragraph about wildmatching, and
mention "-qualified".
* c-lang.c (cplus_language_defn): Install cp_search_name_hash.
* completer.c (explicit_location_match_type::MATCH_QUALIFIED): New
enumerator.
(complete_address_and_linespec_locations): New parameter
'match_type'. Pass it down.
(explicit_options): Add "-qualified".
(collect_explicit_location_matches): Pass the requested match type
to the linespec completers. Handle MATCH_QUALIFIED.
(location_completer): Handle "-qualified" combined with linespecs.
* cp-support.c (cp_search_name_hash): New.
(cp_symbol_name_matches_1): Implement wild matching for C++.
(cp_fq_symbol_name_matches): Reimplement.
(cp_get_symbol_name_matcher): Return different matchers depending
on the lookup name's match type.
(selftests::test_cp_symbol_name_matches): Add wild matching tests.
* cp-support.h (cp_search_name_hash): New declaration.
* dwarf2read.c
(selftests::dw2_expand_symtabs_matching::test_symbols): Add
symbols.
(test_dw2_expand_symtabs_matching_symbol): Add wild matching
tests.
* guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Adjust to
pass a symbol_name_match_type to new_linespec_location.
* linespec.c (linespec_parse_basic): Lookup function symbols using
the parser's symbol name match type.
(convert_explicit_location_to_linespec): New
symbol_name_match_type parameter. Pass it down to
find_linespec_symbols.
(convert_explicit_location_to_sals): Pass the location's name
match type to convert_explicit_location_to_linespec.
(parse_linespec): New match_type parameter. Save it in the
parser.
(linespec_parser_new): Default to symbol_name_match_type::WILD.
(linespec_complete_function): New symbol_name_match_type
parameter. Use it.
(complete_linespec_component): Pass down the parser's recorded
name match type.
(linespec_complete_label): New symbol_name_match_type parameter.
Use it.
(linespec_complete): New symbol_name_match_type parameter. Save
it in the parser and pass it down. Adjust to
get_linespec_location's prototype change.
(find_function_symbols, find_linespec_symbols): New
symbol_name_match_type parameter. Pass it down instead of
assuming symbol_name_match_type::WILD.
* linespec.h (linespec_complete, linespec_complete_function)
(linespec_complete_label): New symbol_name_match_type parameter.
* location.c (event_location::linespec_location): Now a struct
linespec_location.
(EL_LINESPEC): Adjust.
(initialize_explicit_location): Default to
symbol_name_match_type::WILD.
(new_linespec_location): New symbol_name_match_type parameter.
Record it in the location.
(get_linespec_location): Now returns a struct linespec_location.
(new_explicit_location): Also copy func_name_match_type.
(explicit_to_string_internal)
(string_to_explicit_location): Handle "-qualified".
(copy_event_location): Adjust to LINESPEC_LOCATION type change.
Copy symbol_name_match_type fields.
(event_location_deleter::operator()): Adjust to LINESPEC_LOCATION
type change.
(event_location_to_string): Adjust to LINESPEC_LOCATION type
change. Handle "-qualfied".
(string_to_explicit_location): Handle "-qualified".
(string_to_event_location_basic): New symbol_name_match_type
parameter. Pass it down.
(string_to_event_location): Handle "-qualified".
* location.h (struct linespec_location): New.
(explicit_location::func_name_match_type): New field.
(new_linespec_location): Now returns a const linespec_location *.
(string_to_event_location_basic): New symbol_name_match_type
parameter.
(explicit_completion_info::saw_explicit_location_option): New
field.
* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Adjust to pass a
symbol_name_match_type to new_linespec_location.
* python/py-breakpoint.c (bppy_init): Likewise.
* python/python.c (gdbpy_decode_line): Likewise.
gdb/testsuite/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* gdb.base/langs.exp: Use -qualified.
* gdb.cp/meth-typedefs.exp: Use -qualified, and add tests without
it.
* gdb.cp/namespace.exp: Use -qualified.
* gdb.linespec/cpcompletion.exp (overload-2, fqn, fqn-2)
(overload-3, template-overload, template-ret-type, const-overload)
(const-overload-quoted, anon-ns, ambiguous-prefix): New
procedures.
(test_driver): Call them.
* gdb.cp/save-bp-qualified.cc: New.
* gdb.cp/save-bp-qualified.exp: New.
* gdb.linespec/explicit.exp: Test -qualified.
* lib/completion-support.exp (completion::explicit_opts_list): Add
"-qualified".
* lib/gdb.exp (gdb_breakpoint): Handle "qualified".
gdb/doc/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Linespec Locations): Document how "function" is
interpreted in C++ and Ada. Document "-qualified".
(Explicit Locations): Document how "-function" is interpreted in
C++ and Ada. Document "-qualified".
Pedro Alves [Wed, 29 Nov 2017 19:33:23 +0000 (19:33 +0000)]
Handle custom completion match prefix / LCD
A following patch will add support for wild matching for C++ symbols,
making completing on "b push_ba" on a C++ program complete to
std::vector<...>::push_back, std::string::push_back etc., like:
(gdb) b push_ba[TAB]
std::vector<...>::push_back(....)
std::string<...>::push_back(....)
Currently, we compute the "lowest common denominator" between all
completion candidates (what the input line is adjusted to) as the
common prefix of all matches. That's problematic with wild matching
as above, as then we'd end up with TAB changing the input line to
"b std::", losing the original input, like:
(gdb) b push_ba[TAB]
std::vector<...>::push_back(....)
std::string<...>::push_back(....)
(gdb) b std::
while obviously we'd want it to adjust itself to "b push_back(" instead:
(gdb) b push_ba[TAB]
std::vector<...>::push_back(....)
std::string<...>::push_back(....)
(gdb) b push_back(
This patch adds the core code necessary to support this, though
nothing really makes use of it yet in this patch.
gdb/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_lookup_name_info::matches): Change type of
parameter from completion_match to completion_match_result.
Adjust.
(do_wild_match, do_full_match, ada_symbol_name_matches): Likewise.
* completer.c (completion_tracker::maybe_add_completion): Add
match_for_lcd parameter and use it.
(completion_tracker::add_completion): Likewise.
* completer.h (class completion_match_for_lcd): New class.
(completion_match_result::match_for_lcd): New field.
(completion_match_result::set_match): New method.
(completion_tracker): Add comments.
(completion_tracker::add_completion): Add match_for_lcd parameter.
(completion_tracker::reset_completion_match_result): Reset
match_for_lcd too.
(completion_tracker::maybe_add_completion): Add match_for_lcd
parameter.
(completion_tracker::m_lowest_common_denominator_unique): Extend
comments.
* cp-support.c (cp_symbol_name_matches_1)
(cp_fq_symbol_name_matches): Change type of parameter from
completion_match to completion_match_result. Adjust.
* language.c (default_symbol_name_matcher): Change type of
parameter from completion_match to completion_match_result.
Adjust.
* language.h (completion_match_for_lcd): Forward declare.
(default_symbol_name_matcher): Change type of parameter from
completion_match to completion_match_result.
* symtab.c (compare_symbol_name): Adjust.
(completion_list_add_name): Pass the match_for_lcd to the tracker.
* symtab.h (ada_lookup_name_info::matches): Change type of
parameter from completion_match to completion_match_result.
(symbol_name_matcher_ftype): Likewise, and update comments.
Pedro Alves [Wed, 29 Nov 2017 19:25:58 +0000 (19:25 +0000)]
Fix setting-breakpoints regression on PPC64 (function descriptors)
The recent-ish commit
e5f25bc5d6db ('Fix "list ambiguous_variable"')
caused a serious regression on PPC64. See
<https://sourceware.org/ml/gdb-patches/2017-11/msg00666.html>.
Basically, after that patch, GDB sets breakpoints in function
descriptors instead of where the descriptors point to, which is
incorrect.
The problem is that GDB now only runs a minsym's address through
gdbarch_convert_from_func_ptr_addr if msymbol_is_text returns true.
However, if the symbol points to a function descriptor,
msymbol_is_text is false since function descriptors are in fact
outside the text section.
The fix is to also run a non-text address through
gdbarch_convert_from_func_ptr_addr, and if that detects that it was
indeed a function descriptor, treat the resulting address as a
function.
While implementing that directly in linespec.c:minsym_found (where the
bad msymbol_is_text check is) fixes the issue, I noticed that
linespec.c:add_minsym has some code that also basically needs to do
the same checks, however it's implemented differently. Also,
add_minsym is calling find_pc_sect_line on non-function symbols, which
also doesn't look right.
So I introduced msymbol_is_function, so that we have a simple place to
consider minsyms and function descriptors.
And then, the only other use of msymbol_is_text is in
find_function_alias_target, which turns out to also be incorrect.
Changing that one to use msymbol_is_function, i.e., to consider
function descriptors too fixes (on PPC64):
-FAIL: gdb.base/symbol-alias.exp: p func_alias
-FAIL: gdb.base/symbol-alias.exp: p *func_alias()
+PASS: gdb.base/symbol-alias.exp: p func_alias
+PASS: gdb.base/symbol-alias.exp: p *func_alias()
And then after that, msymbol_is_text is no longer used anywhere, so it
can be removed.
Tested on x86_64 GNU/Linux, no regressions. Tested on PPC64 GNU/Linux
and results compared to a testrun of
e5f25bc5d6db^ (before the
offending commit), also no regressions. (there's a couple new FAILs
and some new symbol name matching unit tests are crashing, but that
looks unrelated).
gdb/ChangeLog:
2017-11-29 Pedro Alves <palves@redhat.com>
* linespec.c (minsym_found, add_minsym): Use msymbol_is_function.
* minsyms.c (msymbol_is_text): Delete.
(msymbol_is_function): New function.
* minsyms.h (msymbol_is_text): Delete.
(msymbol_is_function): New declaration.
* symtab.c (find_function_alias_target): Use msymbol_is_function.
Tom Tromey [Wed, 29 Nov 2017 16:27:40 +0000 (09:27 -0700)]
Fix gdb snapshots
Joel pointed out that gdb snapshots were broken by my Makefile patch
series. The bug is that rmdir in distclean was failing, because the
directory did not exist. This fixes the bug by only invoking rmdir when
the directory exists.
Tested using "src-release.sh gdb".
2017-11-29 Tom Tromey <tom@tromey.com>
* Makefile.in (distclean): Handle the case where rmdir fails.
Jim Wilson [Wed, 29 Nov 2017 18:51:36 +0000 (10:51 -0800)]
Give Palmer co-credit for last patch.
Jim Wilson [Wed, 29 Nov 2017 18:36:46 +0000 (10:36 -0800)]
Fix riscv malloc error on small alignment after norvc.
gas/
* config/tc-riscv.c (riscv_frag_align_code): New local insn_alignment.
Early return if bytes less than or equal to insn_alignment.
* testsuite/gas/riscv/align-1.l: New.
* testsuite/gas/riscv/align-1.s: New.
* testsuite/gas/riscv/riscv.exp: Use run_dump_tests. Use run_list_test
for align-1.
Jim Wilson [Wed, 29 Nov 2017 18:22:26 +0000 (10:22 -0800)]
In x86 -n docs, mention that you need an explicit nop fill byte.
gas/
PR gas/22464
* doc/c-i386.texi (-n): Clarify docs.
Renlin Li [Wed, 29 Nov 2017 16:00:47 +0000 (16:00 +0000)]
[GAS][AARCH64]Fix a typo for IP1 register alias.
This should be an obvious fix.
It corrects the register number for IP1 to 17.
gas/
2017-11-29 Renlin Li <renlin.li@arm.com>
* config/tc-aarch64.c (reg_names): Fix IP1 register alias error.
* testsuite/gas/aarch64/register_aliases.s: Add IP0 and IP1 tests.
* testsuite/gas/aarch64/register_aliases.d: Update.
Nick Clifton [Wed, 29 Nov 2017 17:12:12 +0000 (17:12 +0000)]
Check for a NULL symbol pointer when reading relocs from a COFF based file.
PR 22509
* coffcode.h (coff_slurp_reloc_table): Check for a NULL symbol
pointer when processing relocs.
Phil Muldoon [Wed, 29 Nov 2017 16:48:32 +0000 (16:48 +0000)]
Fix Python rbreak tests setting too many breakpoints when glibc debug info is installed.
2017-11-29 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/py-rbreak.exp: Set nosharedlibrary before tests.
Tom Tromey [Tue, 22 Aug 2017 02:01:40 +0000 (20:01 -0600)]
Update usage text for add-symbol-file, symbol-file, and load
This updates the usage text for the add-symbol-file, symbol-file, and
load commands.
gdb/ChangeLog
2017-11-29 Tom Tromey <tom@tromey.com>
* symfile.c (_initialize_symfile): Update usage text for
add-symbol-file, symbol-file, load.
Tom Tromey [Sun, 6 Aug 2017 17:07:28 +0000 (11:07 -0600)]
Fix add-symbol-file usage and errors
This patch updates add-symbol-file help and error text.
It changes add-symbol-file to throw an exception if "-s" is seen but
not all of the arguments are given. Previously this was silently
ignored.
It changes the unrecognized argument message to more clearly state
what went wrong.
Finally, it updates the usage line in the help text to follow GNU
style regarding "metasyntactic variables"; a change I believe should
be made to all gdb help messages.
gdb/ChangeLog
2017-11-29 Tom Tromey <tom@tromey.com>
* symfile.c (add_symbol_file_command): Error if some arguments to
-s are missing. Change unrecognized-argument error message.
(_initialize_symfile): Fix usage text for add-symbol-file.
gdb/testsuite/ChangeLog
2017-11-29 Tom Tromey <tom@tromey.com>
* gdb.base/relocate.exp: Update invalid argument test.
Add new tests for invalid arguments.
Thomas Preud'homme [Wed, 29 Nov 2017 13:40:59 +0000 (13:40 +0000)]
[gdb/testsuite] Fix return type of psymtab-parameter
As pointed out by Pedro Alves, psymtab-parameter testcase rely on the
return type being long. This patch revert the changes made in
f106e10e5e80265e1c43532bba4cb997a7dfa022 and change psymtab-parameter.cc
to return 0 long instead.
2017-11-29 Thomas Preud'homme <thomas.preudhomme@arm.com>
gdb/testsuite/
* gdb.cp/psymtab-parameter.cc (func): Change return type back to long.
Return 0 as a long.
* gdb.cp/psymtab-parameter.exp: Change func's return type back to long.
Nick Clifton [Wed, 29 Nov 2017 12:40:43 +0000 (12:40 +0000)]
Stop objdump from attempting to allocate a huge chunk of memory when parsing relocs in a corrupt file.
PR 22508
* objdump.c (dump_relocs_in_section): Also check the section's
relocation count to make sure that it is reasonable before
attempting to allocate space for the relocs.
H.J. Lu [Wed, 29 Nov 2017 12:20:48 +0000 (04:20 -0800)]
ld: Add a testcase for PR ld/22471
PR ld/22471
* testsuite/ld-elf/pr22471.t: New file.
* testsuite/ld-elf/pr22471a.s: Likewise.
* testsuite/ld-elf/pr22471b.s: Likewise.
* testsuite/ld-elf/shared.exp (ASFLAGS): Define UNDERSCORE for
underscore targets.
Run PR ld/22471 tests.
Thomas Preud'homme [Wed, 29 Nov 2017 10:45:31 +0000 (10:45 +0000)]
[gdb/testsuite] Fix wrong return type in tests
The following tests are marked untested with latest GCC due to a warning
being emitted for a mismatch between their return type and what the lack
of return statement:
* gdb.cp/breakpoint.exp
* gdb.cp/psymtab-parameter.exp
* gdb.cp/shadow.exp
This patch fix the return type to match the function definitions.
2017-11-29 Thomas Preud'homme <thomas.preudhomme@arm.com>
gdb/testsuite/
* gdb.cp/breakpoint.cc (bar): Set return type to void.
* gdb.cp/psymtab-parameter.cc (func): Likewise.
* gdb.cp/psymtab-parameter.exp: Update comment regarding prototype of
func ().
* gdb.cp/shadow.cc (B.func): Return 0.
Stefan Stroe [Wed, 29 Nov 2017 07:42:14 +0000 (18:12 +1030)]
Support --localedir, --datarootdir and --datadir
bfd/
* po/Make-in (datadir): Define as @datadir@.
(localedir): Define as @localedir@.
(gnulocaledir, gettextsrcdir): Use @datarootdir@.
binutils/
* po/Make-in (datadir): Define as @datadir@.
(localedir): Define as @localedir@.
(gnulocaledir, gettextsrcdir): Use @datarootdir@.
gas/
* po/Make-in (datadir): Define as @datadir@.
(localedir): Define as @localedir@.
(gnulocaledir, gettextsrcdir): Use @datarootdir@.
gold/
* po/Make-in (datadir): Define as @datadir@.
(localedir): Define as @localedir@.
(gnulocaledir, gettextsrcdir): Use @datarootdir@.
gprof/
* po/Make-in (datadir): Define as @datadir@.
(localedir): Define as @localedir@.
(gnulocaledir, gettextsrcdir): Use @datarootdir@.
ld/
* po/Make-in (datadir): Define as @datadir@.
(localedir): Define as @localedir@.
(gnulocaledir, gettextsrcdir): Use @datarootdir@.
opcodes/
* po/Make-in (datadir): Define as @datadir@.
(localedir): Define as @localedir@.
(gnulocaledir, gettextsrcdir): Use @datarootdir@.
Nick Clifton [Wed, 29 Nov 2017 09:32:49 +0000 (09:32 +0000)]
Use the record_alignment function when creating a .note section, in case the user has already created the section.
PR 22492
* config/obj-elf.c (obj_elf_version): Use record_alignment rather
than bfd_set_section_alignment.
Cary Coutant [Wed, 29 Nov 2017 02:48:12 +0000 (18:48 -0800)]
Allow multiply-defined absolute symbols when they have the same value.
gold/
* resolve.cc (Symbol_table::resolve): Allow multiply-defined absolute
symbols when they have the same value.
Cary Coutant [Wed, 29 Nov 2017 02:09:41 +0000 (18:09 -0800)]
Allow multiple .eh_frame sections per object file.
LLVM is experimenting with placing .eh_frame sections in the COMDAT group
with the function's text. This triggers an internal error in gold because
we don't expect to see but one .eh_frame section in an object, and we use
a single data member in class Sized_relobj_file to keep track of that section.
This patch removes that data member, and instead checks the output section
and the input section offset to identify an optimized .eh_frame section.
gold/
* object.h (class Sized_relobj_file): Remove discarded_eh_frame_shndx_.
* object.cc (Sized_relobj_file::Sized_relobj_file): Likewise.
(Sized_relobj_file::layout_eh_frame_section): Likewise.
(Sized_relobj_file::do_count_local_symbols): Check for optimized
.eh_frame section by other means.
(Sized_relobj_file::compute_final_local_value_internal): Likewise.
GDB Administrator [Wed, 29 Nov 2017 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in
Nick Clifton [Tue, 28 Nov 2017 18:00:29 +0000 (18:00 +0000)]
Prevent a memory exhaustion problem when trying to read in strings from a COFF binary with a corrupt string table size.
PR 22507
* coffgen.c (_bfd_coff_read_string_table): Check for an excessive
size of the external string table.
H.J. Lu [Tue, 28 Nov 2017 17:00:44 +0000 (09:00 -0800)]
gold: Add a newline at end of pr22266_a.c
This patch fixes the build with GCC 4.2:
gold/testsuite/pr22266_a.c:13:2: error: no newline at end of file
* testsuite/pr22266_a.c: Add a newline at end of file.
H.J. Lu [Tue, 28 Nov 2017 16:18:33 +0000 (08:18 -0800)]
Properly handle note sections and segments
When dumping notes, get note alignment from either note section or note
segment. To support notes generated by assemblers with
https://sourceware.org/bugzilla/show_bug.cgi?id=22492
we treate alignment as 4 bytes if it is less than 4. Otherwise, we skip
notes if alignment isn't 4 nor 8 bytes.
We should call load_separate_debug_file only if e_shstrndx != SHN_UNDEF.
PR binutils/22490
* readelf.c (process_notes_at): Add an argument for note
alignment. If note alignment is less than 4, use 4 byte
alignment. Otherwise, skip notes if alignment isn't 4 nor
8 bytes.
(process_corefile_note_segments): Pass segment alignment to
process_notes_at.
(process_note_sections): Pass section alignment to
process_notes_at.
(process_object): Call load_separate_debug_file only if
e_shstrndx != SHN_UNDEF.
Nick Clifton [Tue, 28 Nov 2017 13:20:31 +0000 (13:20 +0000)]
Fix a memory access violation when attempting to parse a corrupt COFF binary with a relocation that points beyond the end of the section to be relocated.
PR 22506
* reloc.c (reloc_offset_in_range): Rename to
bfd_reloc_offset_in_range and export.
(bfd_perform_relocation): Rename function invocation.
(bfd_install_relocation): Likewise.
(bfd_final_link_relocate): Likewise.
* bfd-in2.h: Regenerate.
* coff-arm.c (coff_arm_reloc): Use bfd_reloc_offset_in_range.
* coff-i386.c (coff_i386_reloc): Likewise.
* coff-i860.c (coff_i860_reloc): Likewise.
* coff-m68k.c (mk68kcoff_common_addend_special_fn): Likewise.
* coff-m88k.c (m88k_special_reloc): Likewise.
* coff-mips.c (mips_reflo_reloc): Likewise.
* coff-x86_64.c (coff_amd64_reloc): Likewise.
H.J. Lu [Tue, 28 Nov 2017 12:54:35 +0000 (04:54 -0800)]
ELF: Don't set non_ir_ref_regular in check_relocs
Since elf_link_add_object_symbols sets non_ir_ref_regular now, there is
no need to set non_ir_ref_regular in check_relocs.
Tested on i686 and x86-64.
* elf-m10300.c (mn10300_elf_check_relocs): Don't set
non_ir_ref_regular.
* elf32-arm.c (elf32_arm_check_relocs): Likewise.
* elf32-bfin.c (bfin_check_relocs): Likewise.
* elf32-cr16.c (cr16_elf_check_relocs): Likewise.
* elf32-cris.c (cris_elf_check_relocs): Likewise.
* elf32-d10v.c (elf32_d10v_check_relocs): Likewise.
* elf32-dlx.c (elf32_dlx_check_relocs): Likewise.
* elf32-fr30.c (fr30_elf_check_relocs): Likewise.
* elf32-frv.c (elf32_frv_check_relocs): Likewise.
* elf32-hppa.c (elf32_hppa_check_relocs): Likewise.
* elf32-i370.c (i370_elf_check_relocs): Likewise.
* elf32-i386.c (elf_i386_check_relocs): Likewise.
* elf32-iq2000.c (iq2000_elf_check_relocs): Likewise.
* elf32-lm32.c (lm32_elf_check_relocs): Likewise.
* elf32-m32c.c (m32c_elf_check_relocs): Likewise.
* elf32-m32r.c (m32r_elf_check_relocs): Likewise.
* elf32-m68hc1x.c (elf32_m68hc11_check_relocs): Likewise.
* elf32-m68k.c (elf_m68k_check_relocs): Likewise.
* elf32-mcore.c (mcore_elf_check_relocs): Likewise.
* elf32-metag.c (elf_metag_check_relocs): Likewise.
* elf32-microblaze.c (microblaze_elf_check_relocs): Likewise.
* elf32-moxie.c (moxie_elf_check_relocs): Likewise.
* elf32-msp430.c (elf32_msp430_check_relocs): Likewise.
* elf32-mt.c (mt_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-rl78.c (rl78_elf_check_relocs): Likewise.
* elf32-s390.c (elf_s390_check_relocs): Likewise.
* elf32-score.c (s3_bfd_score_elf_check_relocs): Likewise.
* elf32-score7.c (s7_bfd_score_elf_check_relocs): Likewise.
* elf32-sh.c (sh_elf_check_relocs): Likewise.
* elf32-tic6x.c (elf32_tic6x_check_relocs): Likewise.
* elf32-tilepro.c (tilepro_elf_check_relocs): Likewise.
* elf32-v850.c (v850_elf_check_relocs): Likewise.
* elf32-vax.c (elf_vax_check_relocs): Likewise.
* elf32-xstormy16.c (xstormy16_elf_check_relocs): Likewise.
* elf32-xtensa.c (elf_xtensa_check_relocs): Likewise.
* elf64-aarch64.c (elf64_aarch64_check_relocs): Likewise.
* elf64-alpha.c (elf64_alpha_check_relocs): Likewise.
* elf64-hppa.c (elf64_hppa_check_relocs): Likewise.
* elf64-ia64-vms.c (elf64_ia64_check_relocs): Likewise.
* elf64-mmix.c (mmix_elf_check_relocs): Likewise.
* elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
* elf64-s390.c (elf_s390_check_relocs): Likewise.
* elf64-sh64.c (sh_elf64_check_relocs): Likewise.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Likewise.
* elfnn-ia64.c (elfNN_ia64_check_relocs): Likewise.
* elfnn-riscv.c (riscv_elf_check_relocs): Likewise.
* elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Likewise.
* elfxx-tilegx.c (tilegx_elf_check_relocs): Likewise.
Alan Modra [Mon, 27 Nov 2017 03:10:43 +0000 (13:40 +1030)]
PR22471, undefined reference to linker-defined symbols
This patch processes linker script assignment statements before ld
opens DT_NEEDED libraries, in order to define symbols like __bss_start
that might also be defined by a library, falsely triggering an error
about "DSO missing from command line".
The initial value won't be correct when assigning a symbol from dot,
and I make no attempt to handle all expressions. For example, an
assignment like "_start_foo = ADDR (.foo)" isn't valid until sections
are laid out, so won't define _start_foo early. What's here should be
enough for most common scripts, and hopefully won't perturb fragile
scripts.
bfd/
PR 22471
* elflink.c (_bfd_elf_merge_symbol): Allow weak symbols to override
early passes over linker script symbols.
* linker.c (_bfd_generic_link_add_one_symbol): Allow symbols to
override early passes over linker script symbols. Clear ldscript_def
on symbol definitions.
ld/
PR 22471
* ldexp.c (struct definedness_hash_entry): Delete "by_script". Make
"iteration" an 8-bit field, and update mask in all uses.
(definedness_newfunc): Don't init "by_script".
(update_definedness): Test ldscript_def rather than by_script.
(is_sym_value): Likewise.
(fold_name <DEFINED>): Return a result for first phase. Test
ldscript_def.
(fold_name <NAME>): Return a result for first phase.
* ldlang.c (open_input_bfds): Process all assignments, not just
defsym.
(lang_process): Increment lang_statement_iteration before
open_input_bfds.
* testsuite/ld-mips-elf/tlsdyn-o32-1.d: Adjust for larger .dynsym.
* testsuite/ld-mips-elf/tlsdyn-o32-1.got: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-2.d: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-2.got: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-3.d: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-3.got: Likewise.
Alan Modra [Mon, 27 Nov 2017 08:13:03 +0000 (18:43 +1030)]
Copying symbol type in ld script assignments
There is a call to update_definedness between code that evaluates an
assignment expression value and code that transfers symbol
attributes. When script assignment expressions contain DEFINED, that
can mean the wrong symbol type is copied. This patch tracks symbols
read during expression evaluation, rather than examining the
expression and re-evaluating conditionals. Not only does this
simplify the code, it also means ld can now copy symbol types in more
complex expressions.
An unfortunate side effect of copying symbol type for more complex
expressions affects mmix, which uses
PROVIDE (Main = DEFINED (Main) ? Main : (DEFINED (_start) ? _start : _start.));
in a default script. So now _start or _start. symbol type may be
copied, losing the function type specially set up for Main. This can
be avoided by making bfd_copy_link_hash_symbol_type do nothing for
mmix.
bfd/
* elf64-mmix.c (bfd_elf64_bfd_copy_link_hash_symbol_type): Define.
ld/
* ldexp.h (struct ldexp_control): Add "assign_src".
* ldexp.c (fold_trinary): Save and restore assign_src around
condition evaluation.
(fold_name <NAME>): Set expld.assign_src.
(try_copy_symbol_type): Delete.
(exp_fold_tree_1): Set symbol type using expld.assign_src.
H.J. Lu [Tue, 28 Nov 2017 11:48:25 +0000 (03:48 -0800)]
ld: Set non_ir_ref_regular on symbols referenced in regular objects
If linker plugin is enabled, set non_ir_ref_regular on symbols referenced
in regular objects so that linker plugin will get the correct symbol
resolution.
bfd/
PR ld/22502
* elflink.c (_bfd_elf_merge_symbol): Also skip definition from
an IR object.
(elf_link_add_object_symbols): If linker plugin is enabled, set
non_ir_ref_regular on symbols referenced in regular objects so
that linker plugin will get the correct symbol resolution.
ld/
PR ld/22502
* testsuite/ld-plugin/lto.exp: Run PR ld/22502 test.
* testsuite/ld-plugin/pr22502a.c: New file.
* testsuite/ld-plugin/pr22502b.c: Likewise.
Jim Wilson [Tue, 28 Nov 2017 03:20:53 +0000 (19:20 -0800)]
Compress loads/stores with implicit 0 offset.
gas/
* config/tc-riscv.c (riscv_handle_implicit_zero_offset): New.
(riscv_ip): Cases 'k', 'l', 'm', 'n', 'M', 'N', add call to
riscv_handle_implicit_zero_offset. At label load_store, replace
existing code with call to riscv_handle_implicit_zero_offset.
* testsuite/gas/riscv/c-ld.d, testsuite/gas/riscv/c-ld.s: New.
* testsuite/gas/riscv/c-lw.d, testsuite/gas/riscv/c-lw.s: New.
* testsuite/gas/riscv/riscv.exp: Run new tests.
Cary Coutant [Tue, 28 Nov 2017 01:32:55 +0000 (17:32 -0800)]
Fix symbol values and relocation addends for relocatable links.
The fix for PR 19291 broke some other cases where -r is used with scripts,
as reported in PR 22266. The original fix for PR 22266 ended up breaking
many cases for REL targets, where the addends are stored in the section data,
and are not being adjusted properly.
The problem was basically that in a relocatable output file (ET_REL),
symbol values are supposed to be relative to the start address of their
section. Usually in a relocatable file, all sections start at 0, so the
failure to get this right is often irrelevant, but with a linker script,
we occasionally see an output section whose starting address is not 0,
and gold would occasionally write a symbol with its relocated value instead
of its section-relative value.
This patch reverts the recent fix for PR 22266 as well as my original fix
for PR 19291. The original fix moved the symbol value adjustment to
write_local_symbols, but neglected to undo a few places where the adjustment
was also being applied, resulting in an occasional double adjustment. The
more recent fix removed those other adjustments, but then failed to
re-account for the adjustment when rewriting the relocations on REL targets.
With the old attempts reverted, we now apply the symbol value adjustment to
the one case that had been missed (non-section symbols in merge sections).
But now we also need to account for the adjustment when rewriting the addends
for RELA relocations.
gold/
PR gold/19291
PR gold/22266
* object.cc (Sized_relobj_file::compute_final_local_value_internal):
Revert changes from 2017-11-08 patch. Adjust symbol value in
relocatable links for non-section symbols.
(Sized_relobj_file::compute_final_local_value): Revert changes from
2017-11-08 patch.
(Sized_relobj_file::do_finalize_local_symbols): Likewise.
(Sized_relobj_file::write_local_symbols): Revert changes from
2015-11-25 patch.
* object.h (Sized_relobj_file::compute_final_local_value_internal):
Revert changes from 2017-11-08 patch.
* powerpc.cc (Target_powerpc::relocate_relocs): Adjust addend for
relocatable links.
* target-reloc.h (relocate_relocs): Adjust addend for relocatable links.
* testsuite/pr22266_a.c (hello): New function.
* testsuite/pr22266_main.c (main): Add test for merge sections.
* testsuite/pr22266_script.t: Add rule for .rodata.
GDB Administrator [Tue, 28 Nov 2017 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Thu, 23 Nov 2017 03:57:04 +0000 (20:57 -0700)]
Remove REMOTE_OBS
This removes REMOTE_OBS from the Makefile. It is no longer needed, as
remote support is always built into gdb. The relevant sources are now
added to COMMON_SFILES, where they are treated like other ordinary
sources.
ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>
* Makefile.in (REMOTE_OBS): Remove.
(SFILES): Remove remote sources.
(COMMON_SFILES): Add remote sources.
(ALLDEPFILES): Remove dcache.c.
Tom Tromey [Tue, 21 Nov 2017 21:29:59 +0000 (14:29 -0700)]
Move target object files to target subdirectory
Move the object files corresponding to target/*.c to the target
subdirectory in the build tree.
ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>
* Makefile.in (SUBDIR_TARGET_SRCS, SUBDIR_TARGET_OBS): New
variables.
(SFILES): Use SUBDIR_TARGET_SRCS.
(COMMON_OBS): Use SUBDIR_TARGET_OBS. Remove waitstatus.o.
(CONFIG_SRC_SUBDIR): Add target.
(%.o): Remove target rule.
Tom Tromey [Tue, 21 Nov 2017 21:24:29 +0000 (14:24 -0700)]
Add missing files to COMMON_SFILES
While working on the previous patch, I found a few .o files whose
corresponding .c file was not mentioned in Makefile.in. This patch
fixes the problem. I pulled this out separately to make it simpler to
review.
ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>
* Makefile.in (COMMON_OBS): Remove filename-seen-cache.o,
registry.o, thread-fsm.o, debug.o.
(COMMON_SFILES): Add filename-seen-cache.c, registry.c,
thread-fsm.c, debug.c.
Tom Tromey [Tue, 21 Nov 2017 21:19:27 +0000 (14:19 -0700)]
Simplify COMMON_OBS by using list of sources
This introduces a new COMMON_SFILES variable, and then defines some of
COMMON_OBS in terms of this new variable. This simpifies adding a new
ordinary source file.
ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>
* Makefile.in (COMMON_SFILES): New.
(SFILES): Move some entries to COMMON_SFILES.
(COMMON_OBS): Use COMMON_SFILES.
Tom Tromey [Tue, 21 Nov 2017 20:44:11 +0000 (13:44 -0700)]
Define YYOBJ in terms of YYFILES
Change YYOBJ to be defined in terms of YYFILES.
ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>
* Makefile.in (YYFILES): Update comment.
(YYOBJ): Redefine.
Tom Tromey [Tue, 21 Nov 2017 20:17:31 +0000 (13:17 -0700)]
Move python object files to python subdirectory
Move the object files corresponding to python/*.c to the python
subdirectory in the build tree.
Because special CFLAGS are passed just to Python compilations, this
patch also required the addition of a pattern rule to update
INTERNAL_CFLAGS for here.
ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>
* Makefile.in (SUBDIR_PYTHON_OBS): Redefine.
(CONFIG_SRC_SUBDIR): Add python.
(%.o): Remove python rule.
(python/%.o): New rule.
* configure: Rebuild.
* configure.ac (CONFIG_OBS): Refer to python/python.o
Tom Tromey [Tue, 21 Nov 2017 20:05:26 +0000 (13:05 -0700)]
Move guile object files to guile subdirectory
Move the object files corresponding to guile/*.c to the guile
subdirectory in the build tree.
ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
* configure.ac (CONFIG_OBS): Refer to guile/guile.o.
* Makefile.in (SUBDIR_GUILE_OBS): Redefine.
(CONFIG_SRC_SUBDIR): Add guile.
(%.o): Remove guile rule.
Tom Tromey [Tue, 21 Nov 2017 19:56:55 +0000 (12:56 -0700)]
Move unittests object files to unittests subdirectory
Move the object files corresponding to unittests/*.c to the unittests
subdirectory in the build tree.
ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>
* Makefile.in (SUBDIR_UNITTESTS_OBS): Redefine.
(%.o): Remove unittests rule.
(CONFIG_SRC_SUBDIR): Add unittests.
Tom Tromey [Tue, 21 Nov 2017 19:42:33 +0000 (12:42 -0700)]
Move tui object files to tui subdirectory
Move the object files corresponding to tui/*.c to the tui subdirectory
in the build tree.
ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>
* Makefile.in (SUBDIR_TUI_OBS): Redefine.
(CONFIG_SRC_SUBDIR): Add tui.
(%.o): Remove tui rule.
Tom Tromey [Tue, 21 Nov 2017 19:35:05 +0000 (12:35 -0700)]
Move compile object files to compile subdirectory
Move the object files corresponding to compile/*.c to the compile
subdirectory in the build tree.
ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>
* Makefile.in (SUBDIR_GCC_COMPILE_OBS): Redefine.
(%.o): Remove compile rule.
(CONFIG_SRC_SUBDIR): Add compile.
Tom Tromey [Tue, 21 Nov 2017 19:26:11 +0000 (12:26 -0700)]
Move mi objects to mi subdirectory
Move object files corresponding to mi/*.c to a subdirectory in the
build tree.
ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>
* Makefile.in (SUBDIR_MI_OBS): Redefine.
(%.o): Remove mi rule.
(CONFIG_SRC_SUBDIR): Add mi.
(COMMON_OBS): Use mi/mi-common.o
Tom Tromey [Tue, 21 Nov 2017 19:22:11 +0000 (12:22 -0700)]
Move cli object files to cli subdirectory
Following the "arch" move, this moves the object files corresponding
to the cli/*.c source files to the "cli" build directory.
ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>
* Makefile.in (SUBDIR_CLI_OBS): Redefine.
(%.o): Remove cli rule.
(CONFIG_SRC_SUBDIR): Add cli.
Tom Tromey [Tue, 21 Nov 2017 19:15:33 +0000 (12:15 -0700)]
A simpler way to make the "arch" build directory
This implements a simpler way to make the "arch" build directory --
namely, now it is done as an order-only dependency in the Makefile,
rather than being created when config.status is run. This simpler
because it means that the build directories can be changed without
re-running autoconf.
ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>
* configure.ac (CONFIG_SRC_SUBDIR): Don't subst.
* configure: Rebuild.
* Makefile.in (CONFIG_SRC_SUBDIR): Redefine.
(CONFIG_DEP_SUBDIR): New variable.
(%.o): Add order-only dependency.
($(CONFIG_DEP_SUBDIR)): New target.
Max Filippov [Mon, 20 Nov 2017 14:35:06 +0000 (06:35 -0800)]
gas: xtensa: speed up find_trampoline_seg
find_trampoline_seg takes noticeable time when assembling source with
many sections. Cache the result of the most recent search and check it
first. No functional changes.
gas/
2017-11-27 Max Filippov <jcmvbkbc@gmail.com>
* config/tc-xtensa.c (find_trampoline_seg): Add static variable
that caches the result of the most recent search.
Max Filippov [Tue, 14 Nov 2017 23:16:08 +0000 (15:16 -0800)]
gas: xtensa: implement trampoline coalescing
There is a recurring pattern in assembly files generated by a compiler
where a lot of jumps in a function are going to the same place. When
these jumps are relaxed with trampolines the assembler generates a
separate jump thread from each source.
Create an index of trampoline jump targets for each segment and see if a
jump being relaxed goes to a location from that index, in which case
replace its target with a location of existing trampoline jump that
results in the shortest path to the original target.
gas/
2017-11-27 Max Filippov <jcmvbkbc@gmail.com>
* config/tc-xtensa.c (trampoline_chain_entry, trampoline_chain)
(trampoline_chain_index): New structures.
(trampoline_index): Add chain_index field.
(xg_order_trampoline_chain_entry, xg_sort_trampoline_chain)
(xg_find_chain_entry, xg_get_best_chain_entry)
(xg_order_trampoline_chain, xg_get_trampoline_chain)
(xg_find_best_eq_target, xg_add_location_to_chain)
(xg_create_trampoline_chain, xg_get_single_symbol_slot): New
functions.
(xg_relax_fixups): Call xg_find_best_eq_target to adjust jump
target to point to an existing jump. Call
xg_create_trampoline_chain to create new jump target. Call
xg_add_location_to_chain to add newly created trampoline jump
to the corresponding chain.
(add_jump_to_trampoline): Extract loop searching for a single
slot with a symbol into a separate function, replace that code
with a call to that function.
(relax_frag_immed): Call xg_find_best_eq_target to adjust jump
target to point to an existing jump.
* testsuite/gas/xtensa/all.exp: Add trampoline-2 test.
* testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses
as many duplicate trampoline chains are now coalesced.
* testsuite/gas/xtensa/trampoline.s: Add _nop so that objdump
stays in sync with instruction stream.
* testsuite/gas/xtensa/trampoline-2.l: New test result file.
* testsuite/gas/xtensa/trampoline-2.s: New test source file.
Max Filippov [Mon, 13 Nov 2017 08:42:43 +0000 (00:42 -0800)]
gas: xtensa: reuse trampoline placement code
There's almost exact copy of the trampoline placement code in the
search_trampolines function that is used for jumps generated for relaxed
branch instructions. Get rid of the duplication and reuse
xg_find_best_trampoline function for that.
gas/
2017-11-27 Max Filippov <jcmvbkbc@gmail.com>
* config/tc-xtensa.c (search_trampolines, get_best_trampoline):
Remove definitions.
(xg_find_best_trampoline_for_tinsn): New function.
(relax_frag_immed): Replace call to get_best_trampoline with a
call to xg_find_best_trampoline_for_tinsn.
* testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses
as the placement of trampolines for relaxed branches has been
changed.
Max Filippov [Sat, 11 Nov 2017 12:15:55 +0000 (04:15 -0800)]
gas: xtensa: rewrite xg_relax_trampoline
Replace linked list of trampoline frags with an ordered array, so that
instead of indexing fixups trampolines could be indexed. Keep each array
in the trampoline_seg structure, so there's no need to rebuild it for
every new processed segment. Don't run relaxation for each trampoline
frag, instead run it for each fixup in the current segment that needs
relaxation at the beginning of each relaxation pass. This way the
complexity of this process drops from about O(n^2 * m) to about
O(log n * m), where n is the number of trampoline frags and m is the
number of fixups that need relaxation in the segment.
gas/
2017-11-27 Max Filippov <jcmvbkbc@gmail.com>
* config/tc-xtensa.c (trampoline_index): New structure.
(trampoline_seg): Replace trampoline list with trampoline index.
(xg_find_trampoline, xg_add_trampoline_to_index)
(xg_remove_trampoline_from_index, xg_add_trampoline_to_seg)
(xg_is_trampoline_frag_full, xg_get_fulcrum)
(xg_find_best_trampoline, xg_relax_fixup, xg_relax_fixups)
(xg_is_relaxable_fixup): New functions.
(J_MARGIN): New macro.
(xtensa_create_trampoline_frag): Use xg_add_trampoline_to_seg
instead of open-coded addition to the linked list.
(dump_trampolines): Iterate through the trampoline_seg::index.
(cached_fixupS, cached_fixup, fixup_cacheS, fixup_cache)
(fixup_order, xtensa_make_cached_fixup)
(xtensa_realloc_fixup_cache, xtensa_cache_relaxable_fixups)
(xtensa_find_first_cached_fixup, xtensa_delete_cached_fixup)
(xtensa_add_cached_fixup, check_and_update_trampolines): Remove
definitions.
(xg_relax_trampoline): Extract logic into separate functions,
replace body with a call to xg_relax_fixups.
(search_trampolines): Replace search in linked list with search
in index. Change data type of address-tracking variables from
int to offsetT. Replace abs with labs.
(xg_append_jump): Finish the trampoline frag if it's full.
(add_jump_to_trampoline): Remove trampoline frag from the index
if the frag is full.
* config/tc-xtensa.h (xtensa_frag_type): Remove next_trampoline.
* testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses
as the placement of trampolines has slightly changed.
* testsuite/gas/xtensa/trampoline.s: Add _nop so that objdump
stays in sync with instruction stream.
Max Filippov [Fri, 10 Nov 2017 22:27:42 +0000 (14:27 -0800)]
gas: xtensa: merge trampoline_frag into xtensa_frag_type
The split between fragS and trampoline_frag doesn't save much space, but
makes trampolines management much more awkward. Merge trampoline_frag
data into the xtensa_frag_type, which is a part of fragS. No functional
changes.
gas/
2017-11-27 Max Filippov <jcmvbkbc@gmail.com>
* config/tc-xtensa.c (init_trampoline_frag): Replace pointer to
struct trampoline_frag parameter with pointer to fragS.
(xg_append_jump): Remove jump_around parameter.
(struct trampoline_frag): Remove.
(struct trampoline_seg): Change type of trampoline_list from
struct trampoline_frag to fragS.
(xtensa_create_trampoline_frag): Don't allocate struct
trampoline_frag. Initialize new fragS::tc_frag_data fields.
(dump_trampolines, xg_relax_trampoline, search_trampolines)
(get_best_trampoline, init_trampoline_frag)
(add_jump_to_trampoline, relax_frag_immed): Replace pointer to
struct trampoline_frag with a pointer to fragS.
(xg_append_jump): Remove jump_around parameter, use
fragS::tc_frag_data.jump_around_fix instead.
(xg_relax_trampoline, init_trampoline_frag)
(add_jump_to_trampoline): Don't pass jump_around parameter to
xg_append_jump.
* config/tc-xtensa.h (struct xtensa_frag_type): Add new fields:
needs_jump_around, next_trampoline and jump_around_fix.
Max Filippov [Fri, 10 Nov 2017 21:38:23 +0000 (13:38 -0800)]
gas: xtensa: reuse find_trampoline_seg
xtensa_create_trampoline_frag has opencoded fragment equivalent to
find_trampoline_seg. Drop the fragment and use find_trampoline_seg
instead. No functional changes.
gas/
2017-11-27 Max Filippov <jcmvbkbc@gmail.com>
* config/tc-xtensa.c (find_trampoline_seg): Move above the first
use.
(xtensa_create_trampoline_frag): Replace trampoline seg search
code with a call to find_trampoline_seg.
Max Filippov [Thu, 9 Nov 2017 22:51:18 +0000 (14:51 -0800)]
gas: xtensa: extract jump assembling for trampolines
init_trampoline_frag, add_jump_to_trampoline and xg_relax_trampoline add
a jump to the end of a trampoline frag. Extract it into a separate
funciton and use it in all these places. No functional changes.
gas/
2017-11-27 Max Filippov <jcmvbkbc@gmail.com>
* config/tc-xtensa.c (xg_append_jump): New function.
(xg_relax_trampoline, init_trampoline_frag)
(add_jump_to_trampoline): Replace trampoline jump assembling
code with a call to xg_append_jump.
Max Filippov [Fri, 20 Oct 2017 23:23:28 +0000 (16:23 -0700)]
gas: extract xg_relax_trampoline from xtensa_relax_frag
To make measurement and changes easier extract trampoline relaxation
function. No functional changes.
gas/
2017-11-27 Max Filippov <jcmvbkbc@gmail.com>
* config/tc-xtensa.c (xg_relax_trampoline): New function.
(xtensa_relax_frag): Replace trampoline relaxation code with a
call to xg_relax_trampoline.
Joel Brobecker [Mon, 27 Nov 2017 19:38:54 +0000 (11:38 -0800)]
fix two issues in gdb.ada/mi_catch_ex.exp (re: "exception-message")
The following patch introduced a new feature related to Ada exception
catchpoints:
commit
e547c119d043f2ecffb70452020ab9150d083a91
Author: Joel Brobecker <brobecker@adacore.com>
Date: Fri Nov 24 17:09:42 2017 -0500
Subject: (Ada) provide the exception message when hitting an exception catchpoint
Unfortunately, the patch left 2 errors in gdb.ada/mi_catch_ex.exp,
both inside the "continue_to_exception" function:
1. The exception message on the console can include the exception
message, and thus this patch adjust the expected output in
the corresponding gdb_expect call to allow it;
to allow it.
2. There was a TCL syntax confusion in "$exception_name(..."
that caused TCL to evaluate "exception_name as an array,
rather than as a variable. This patch fixes this by escaping
the '(' (and the corresponding closing parenthesis, for
consistency).
gdb/testsuite/ChangeLog:
* gdb.ada/mi_catch_ex.exp (continue_to_exception): Adjust
expected output in gdb_expect call to allow the exception
message to be present as well. Fix syntax confusion to avoid
TCL thinking that exception_name is an array.
Tested on x86_64-linux, with:
DejaGnu version 1.6
Expect version 5.45
Tcl version 8.6
Szabolcs Nagy [Wed, 15 Nov 2017 17:40:04 +0000 (17:40 +0000)]
[PR ld/22263] aarch64: Avoid dynamic TLS relocs in PIE
No dynamic relocs are needed for TLS defined in an executable, the
TP relative offset is known at link time.
Fixes
FAIL: Build pr22263-1
bfd/
PR ld/22263
* elfnn-aarch64.c (elfNN_aarch64_relocate_section): Use
bfd_link_executable instead of bfd_link_pic for TLS.
(elfNN_aarch64_allocate_dynrelocs): Likewise.
(aarch64_can_relax_tls): Likewise.
Szabolcs Nagy [Wed, 15 Nov 2017 15:56:30 +0000 (15:56 +0000)]
[PR ld/22269] aarch64: Handle local undefined weak symbols
With static pie linking undefined weak symbols are forced to resolve locally
to 0, so no GOT setup is needed in elfNN_aarch64_finish_dynamic_symbol,
which previously failed for these symbols.
The failure caused the unhelpful error message:
"ld: final link failed: Nonrepresentable section on output"
bfd/
PR ld/22269
* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol): Use
UNDEFWEAK_NO_DYNAMIC_RELOC to avoid dynamic GOT relocs.
(elfNN_aarch64_allocate_dynrelocs): Likewise.