Commit Graph

106258 Commits

Author SHA1 Message Date
Mike Frysinger
354c317ea4 binutils: update release docs process
Now that we generate multiple html & pdf forms, update the release
process to show how they get updated.
2021-05-08 12:06:41 -04:00
Mike Frysinger
cf758b3960 support generating multi-html pages in parallel
Use the pattern from other projects where we generate the html pages
in a dir named the same as the project.  So now we have:
gas/doc/gas.html - single html page
gas/doc/gas/ - multiple html pages

This works for projects that have a doc/ subdir already, but gprof &
ld require a little tweaking since they generate their docs in their
respective toplevels.
2021-05-08 12:06:07 -04:00
Mike Frysinger
2faf902da5 generate single html manual page by default
This better matches other GNU projects like autoconf/automake where
the html manual is the single page form.  We'll support the multi-page
form in a follow up change.
2021-05-08 11:58:19 -04:00
Mike Frysinger
0d0878d72e sim: add html & pdf stubs
We stub out the info targets already since we don't provide any.
2021-05-08 11:55:22 -04:00
Tom Tromey
65a9835b29 sim: use htab_eq_string
This changes the sim to use htab_eq_string from libiberty.

sim/common/ChangeLog
2021-05-08  Tom Tromey  <tom@tromey.com>

	* sim-options.c (compare_strings): Remove.
	(dup_arg_p): Use htab_eq_string.
2021-05-08 07:50:47 -06:00
Pedro Alves
4655f8509f Don't run personality syscall at configure time; don't check it at all
Currently, in order to tell whether support for disabling address
space randomization on Linux is available, GDB checks if the
personality syscall works, at configure time.  I.e., it does a run
test, instead of a compile/link test:

  AC_RUN_IFELSE([PERSONALITY_TEST],
		[have_personality=true],
		[have_personality=false],

This is a bit bogus, because the machine the build is done on may not
(and is when you consider distro gdbs) be the machine that eventually
runs gdb.  It would be better if this were a compile/link test
instead, and then at runtime, GDB coped with the personality syscall
failing.  Actually, GDB already copes.

One environment where this is problematic is building GDB in a Docker
container -- by default, Docker runs the container with seccomp, with
a profile that disables the personality syscall.  You can tell Docker
to use a less restricted seccomp profile, but I think we should just
fix it in GDB.

"man 2 personality" says:

       This system call first appeared in Linux 1.1.20 (and thus first
       in a stable kernel release with Linux 1.2.0); library support
       was added in glibc 2.3.

...

       ADDR_NO_RANDOMIZE (since Linux 2.6.12)
              With this flag set, disable address-space-layout randomization.

glibc 2.3 was released in 2002.
Linux 2.6.12 was released in 2005.

The original patch that added the configure checks was submitted in
2008.  The first version of the patch that was submitted to the list
called personality from common code:

 https://sourceware.org/pipermail/gdb-patches/2008-June/058204.html

and then was moved to Linux-specific code:

 https://sourceware.org/pipermail/gdb-patches/2008-June/058209.html

Since HAVE_PERSONALITY is only checked in Linux code, and
ADDR_NO_RANDOMIZE exists for over 15 years, I propose just completely
removing the configure checks.

If for some odd reason, some remotely modern system still needs a
configure check, then we can revert this commit but drop the
AC_RUN_IFELSE in favor of always doing the AC_LINK_IFELSE
cross-compile fallback.

gdb/ChangeLog:

	* linux-nat.c (linux_nat_target::supports_disable_randomization):
	Remove references to HAVE_PERSONALITY.
	* nat/linux-personality.c: Remove references to HAVE_PERSONALITY.
	(maybe_disable_address_space_randomization)
	(~maybe_disable_address_space_randomizatio): Remove references to
	HAVE_PERSONALITY.
	* config.in, configure: Regenerate.

gdbserver/ChangeLog:

	* linux-low.cc:
	(linux_process_target::supports_disable_randomization): Remove
	reference to HAVE_PERSONALITY.
	* config.in, configure: Regenerate.

gdbsupport/ChangeLog:

	* common.m4 (personality test): Remove.
2021-05-08 13:45:36 +01:00
Pedro Alves
e2ea3a381a Don't include sys/personality.h in linux-low.cc anymore
Lancelot pointed out that since the refactor at:

  https://sourceware.org/pipermail/gdb-patches/2015-January/120503.html

the sys/personality.h include is not needed in linux-low.cc anymore,
as it does not call personality directly itself anymore.

gdbserver/ChangeLog:

	* linux-low.cc: Don't include sys/personality.h or define
	ADDR_NO_RANDOMIZE.
2021-05-08 13:09:52 +01:00
Mike Frysinger
8a16cc4b93 sim: m68hc11: fix up cycle buffer printing
Make sure the local static buffer is large enough, and simplify the
sprintf for merging the fields all into one.  This fixes compiler
warnings from buf possibly being overflowed.
2021-05-07 21:55:27 -04:00
GDB Administrator
f6593c3d4b Automatic date update in version.in 2021-05-08 00:00:38 +00:00
Andrew Burgess
1845e25464 gdb/guile: perform tilde expansion when sourcing guile scripts
Before this patch:

  (gdb) source ~/script.scm
  ERROR: In procedure apply-smob/1:
  ERROR: In procedure primitive-load-path: Unable to find file "~/script.scm" in load path
  Error while executing Scheme code.
  (gdb)

This is because the path is not tilde expanded.  In contrast, when
sourcing a .py or .gdb script the path is tilde expanded.

This commit fixes this oversight, and allows the above source command
to work as expected.

The tilde expansion is done in the generic GDB code before we call the
sourcer function for any particular extension language.

gdb/ChangeLog:

	* cli/cli-cmds.c: Add 'gdbsupport/gdb_tilde_expand.h'
	include.
	(source_script_with_search): Perform tilde expansion.

gdb/testsuite/ChangeLog:

	* gdb.guile/guile.exp: Add an extra test.
2021-05-07 22:20:47 +01:00
Andrew Burgess
a3237c7cc7 gdb/testsuite: use gdb_test_no_output instead of send_gdb
I noticed gdb.base/ptype-offsets.exp failing occasionally, this was
due to lines like this in the test script:

  send_gdb "set print type hex on\n"

As this does not match the '(gdb)' prompt that is produced, the prompt
would sometimes be matched against the next test, causing the next
test to think its output was missing and fail.

Fix this by switching to:

  gdb_test_no_output "set print type hex on"

gdb/testsuite/ChangeLog:

	* gdb.base/ptype-offsets.exp: Replace use of send_gdb with
	gdb_test_no_output.
2021-05-07 22:19:41 +01:00
Simon Marchi
91e3c425d6 gdb: make target_desc_info::filename an std::string
To make the management of memory automatic.

As to why I chose to make this an std::string and not an
std::unique_xmalloc_ptr<char>: some parts of the code consider both a
NULL value and an empty string value to mean "no filename".
target_desc_info_from_user_p, however, doesn't check for a non-NULL but
empty string value.  So it seems like having two ways of denoting "no
filename" can lead to these kinds of inconsistencies.  Using
std::string, "no filename" is only represented by an empty value.

As a bonus, using an std::string lets us copy target_desc_info objects
using the default assignment operator.

gdb/ChangeLog:

	* target-descriptions.c (struct target_desc_info) <filename>:
	Make std::string.
	(copy_inferior_target_desc_info): Adjust.
	(target_desc_info_free): Adjust.
	(target_find_description): Adjust.
	(set_tdesc_filename_cmd): Adjust.
	(show_tdesc_filename_cmd): Adjust.
	(unset_tdesc_filename_cmd): Adjust.
	(maint_print_c_tdesc_cmd): Adjust.

Change-Id: I4e3a6ad8ccda2b88c202471d4f54249753cad127
2021-05-07 16:28:56 -04:00
Simon Marchi
0b2f7ade53 gdb: (de-)allocate target_desc_info with new/delete
In preparation for using non-POD types in the struct.

gdb/ChangeLog:

	* target-descriptions.c (struct target_desc_info): Initialize
	fields.
	(get_tdesc_info): Use new.
	(target_desc_info_free): Use delete.

Change-Id: I10fdaeeae7cdbd7930ae7adeeb13f7f363c67c7a
2021-05-07 16:28:56 -04:00
Simon Marchi
820c449092 gdb: change target_desc_info::fetched to bool
gdb/ChangeLog:

	* target-descriptions.c (struct target_desc_info) <fetched>:
	bool.
	(target_find_description): Adjust.
	(target_clear_description): Adjust.

Change-Id: Ib69e097b38cf270e674f1249105d535a312954e1
2021-05-07 16:28:56 -04:00
Simon Marchi
c2962e6ab4 gdb: remove target description macros
In my opinion, the target_desc_fetched, current_target_desc and
target_description_filename macros in target-descriptions.c are not very
useful.  I don't think it's useful to hide that they operate on the
current inferior, as everything currently works under the assumption
that the various tdesc commands operate on the current inferior, and I
don't see that changing in the foreseeable future.

This change also avoids having multiple unnecessary calls to
current_inferior and get_tdesc_info per function.

gdb/ChangeLog:

	* target-descriptions.c (struct target_desc_info) <tdesc>:
	Adjust doc.
	(target_desc_fetched): Remove.
	(current_target_desc): Remove.
	(target_description_filename): Remove.
	(target_find_description): Adjust.
	(target_clear_description): Adjust.
	(target_current_description): Adjust.
	(set_tdesc_filename_cmd): Adjust.
	(show_tdesc_filename_cmd): Adjust.
	(unset_tdesc_filename_cmd): Adjust.
	(maint_print_c_tdesc_cmd): Adjust.
	(maint_print_xml_tdesc_cmd): Adjust.

Change-Id: Ibfb581490e949c16d59924e2cac633ede5c26c5b
2021-05-07 16:28:56 -04:00
Dimitar Dimitrov
0d315c88a7 sim: Add bfd include path for common testsuite tools
On a host without installed libbfd, this patch fixes the following
"make check-sim" errors for both pru cross target, and native x86_64:

In file included from ../../../binutils/sim/common/sim-basics.h:131,
                 from testsuite/common/bits32m0.c:13:../../../binutils/sim/../include/gdb/callback.h:55:10: fatal error: bfd.h: No such file or directory
   55 | #include "bfd.h"
      |          ^~~~~~~

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2021-05-07 21:02:34 +03:00
Nick Clifton
476654beae Add a generic .bss directive for ELF based targets.
PR 3136
	* config/obj-elf.c (elf_pseudo_table): Add entry for .bss.
	(obj_elf_bss): New function.  Change to the .bss section.
	Support an optional subsection number.
	(obj_elf_change_section): Call obj_elf_section_change_hook.
	(obj_elf_section): Likewise.
	(obj_elf_data): Likewise.
	(obj_elf_text): Likewise.
	(obj_elf_struct): Likewise.
	(obj_elf_subsection): Likewise.
	(obj_elf_previous): Likewise.
	* config/obj-elf.h (obj_elf_bss): Prototype.
	* doc/as.texi (Bss): New node.
2021-05-07 17:08:48 +01:00
Andrew Burgess
8a82de5884 gdb: some int to bool conversion
Change int parameter to bool in remote_notice_new_inferior (remote.c)
and notice_new_inferior (infcmd.c), and update the callers.

There should be no user visible changes after this commit.

gdb/ChangeLog:

	* infcmd.c (notice_new_inferior): Change parameter type.
	* inferior.h (notice_new_inferior): Change parameter type.
	* remote.c (remote_notice_new_inferior): Change parameter type to
	bool.  Also update type of local variable to bool.
	(remote_target::update_thread_list): Change type of local variable
	to bool.
	(remote_target::process_stop_reply): Pass bool instead of int to
	remote_notice_new_inferior.
2021-05-07 17:00:25 +01:00
Simon Marchi
bedc473418 gdb: remove reference to current inferior in target_stack::unpush
target_stack::unpush needs to get the target beneath the target being
unpushed to update the m_top field (which keeps the stratum of the
top-most target).  It currently does so using target_ops::beneath, which
uses the target stack of the current inferior.  The target stack of the
current inferior is the same as the `this` in the unpush method.

Avoid this detour and remove this reference to the current inferior by
calling target_ops::find_beneath and passing `this` to find the target
beneath `t` in the target stack that is `this`.

gdb/ChangeLog:

	* target.c (target_stack::unpush): Call target_ops::find_beneath
	to get the target beneath `t`.

Change-Id: If9d9661567c5c16f655d270bd2ec9f1b3aa6dadc
2021-05-07 11:52:51 -04:00
Simon Marchi
27f0a4314a gdb: make target_close check that the target isn't pushed in all inferiors
The target_close function currently checks that the target to be closed
isn't pushed in the current inferior:

    gdb_assert (!current_inferior ()->target_is_pushed (targ));

Normally, a target is closed when its refcount has dropped to 0, due to
not being used in any inferior anymore.  I think it would make sense to
change that assert to not only check in the current inferior, but to
check in all inferiors.  It would be quite bad (and a bug) to close a
target while it's still pushed in one of the non-current inferiors.

gdb/ChangeLog:

	* target.c (target_close): Check in all inferiors that the
	target is not pushed.

Change-Id: I6e37fc3f3476a0593da1e476604642b2de90f1d5
2021-05-07 11:51:39 -04:00
Aaron Merey
1d1669e40f debuginfod-support.c: Use long-lived debuginfod_client
Instead of initializing a new debuginfod_client for each query, store
the first initialized client for the remainder of the GDB session and
use it for every debuginfod query.

In conjunction with upcoming changes to libdebuginfod, using one client
for all queries will avoid latency caused by unneccesarily setting up
TCP connections multiple times.

Tested on Fedora 33 x86_64.

gdb/ChangeLog:

	* debuginfod-support.c (debuginfod_init): Remove.
	(get_debuginfod_client): New function.
2021-05-07 11:37:16 -04:00
Tom Tromey
2698f5ead6 Remove streq_hash in favor of htab_eq_string
Now that libiberty includes htab_eq_string, we can remove the
identical function from gdb.

gdb/ChangeLog
2021-05-07  Tom Tromey  <tom@tromey.com>

	* breakpoint.c (ambiguous_names_p): Use htab_eq_string.
	* utils.c (streq_hash): Remove.
	* utils.h (streq_hash): Don't declare.
	* completer.c (completion_tracker::discard_completions): Update
	comment.
	* ada-lang.c (_initialize_ada_language): Use htab_eq_string.
2021-05-07 09:18:18 -06:00
Simon Marchi
13123da89a gdb: re-format Python files using black 21.4b0
Re-format all Python files using black [1] version 21.4b0.  The goal is
that from now on, we keep all Python files formatted using black.  And
that we never have to discuss formatting during review (for these files
at least) ever again.

One change is needed in gdb.python/py-prettyprint.exp, because it
matches the string representation of an exception, which shows source
code.  So the change in formatting must be replicated in the expected
regexp.

To document our usage of black I plan on adding this to the "GDB Python
Coding Standards" wiki page [2]:

--8<--

All Python source files under the `gdb/` directory must be formatted
using black version 21.4b0.

This specific version can be installed using:

    $ pip3 install 'black == 21.4b0'

All you need to do to re-format files is run `black <file/directory>`,
and black will re-format any Python file it finds in there.  It runs
quite fast, so the simplest is to do:

    $ black gdb/

from the top-level.

If you notice that black produces changes unrelated to your patch, it's
probably because someone forgot to run it before you.  In this case,
don't include unrelated hunks in your patch.  Push an obvious patch
fixing the formatting and rebase your work on top of that.

-->8--

Once this is merged, I plan on setting a up an `ignoreRevsFile`
config so that git-blame ignores this commit, as described here:

  https://github.com/psf/black#migrating-your-code-style-without-ruining-git-blame

I also plan on working on a git commit hook (checked in the repo) to
automatically check the formatting of the Python files on commit.

[1] https://pypi.org/project/black/
[2] https://sourceware.org/gdb/wiki/Internals%20GDB-Python-Coding-Standards

gdb/ChangeLog:

	* Re-format all Python files using black.

gdb/testsuite/ChangeLog:

	* Re-format all Python files using black.
	* gdb.python/py-prettyprint.exp (run_lang_tests): Adjust.

Change-Id: I28588a22c2406afd6bc2703774ddfff47cd61919
2021-05-07 10:56:20 -04:00
Marco Barisione
a9b49cbcd5 gdb: add lookup_cmd_exact to simplify a common pattern
In code dealing with commands, there's a pattern repeated a few times of
calling lookup_cmd with some speficic arguments and then using strcmp
on the returned command to check for an exact match.
As a later patch would add a few more similar lines of code, this patch
adds a new lookup_cmd_exact function which simplify this use case.

gdb/ChangeLog:

	* cli/cli-decode.c (lookup_cmd_exact): Add.
	* cli/cli-script.c (do_define_command): Use lookup_cmd_exact.
	(define_prefix_command): Ditto.
	* command.h: Add lookup_cmd_exact.
2021-05-07 15:43:30 +01:00
Cl?ment Chigot
97834047e1 Fix .dwsect generation for XCOFF. Handle .function generated with DWARF on XCOFF.
gas	* config/tc-ppc.c (ppc_function): Update comment for
	fifth argument.
	(ppc_frob_symbol): Remove ppc_last_function check.
	Make sure coff_last_function is reset.
	Correctly set fsize when not provided in .function.
	* testsuite/gas/ppc/aix.exp: New tests.
	* testsuite/gas/ppc/xcoff-function-1-32.d: New test.
	* testsuite/gas/ppc/xcoff-function-1-64.d: New test.
	* testsuite/gas/ppc/xcoff-function-1.s: New test.

bfd	* coff-rs6000.c (xcoff_dwsect_names): Add new DWARF
	sections.
	* coffgen.c (coff_pointerize_aux): Handle C_DWARF.
	(coff_print_symbol): Likewise.
	* libxcoff.h (XCOFF_DWSECT_NBR_NAMES): Update.

gas	* config/obj-coff.c (coff_frob_symbol): Don't skip C_DWARF.
	(coff_adjust_section_syms): Use corrext auxent for C_DWARF.
	(coff_frob_section): Likewise.
	* config/obj-coff.h (SA_GET_SECT_SCNLEN,
	SA_GET_SECT_NRELOC, SA_SET_SECT_SCNLEN,
	SA_SET_SECT_NRELOC) New defines.
	(SET_SECTION_RELOCS): Adjust for C_DWARF.
	* config/tc-ppc.c (ppc_frob_symbol): Don't skip C_DWARF.
	(ppc_adjust_symtab): Reorder C_DWARF symbols.
	* testsuite/gas/ppc/aix.exp: New tests.
	* testsuite/gas/ppc/xcoff-dwsect-2-32.d: New test.
	* testsuite/gas/ppc/xcoff-dwsect-2-64.d: New test.
	* testsuite/gas/ppc/xcoff-dwsect-2.s: New test.

include	* coff/internal.h (C_DWARF): New define.
	* coff/xcoff.h (SSUBTYP_DWLOC, SSUBTYP_DWFRAME,
	SSUBTYP_DWMAC): New defines.
2021-05-07 15:29:49 +01:00
Nick Clifton
3ecc00ec9c Srop readelf's unwind decoder from complaining about x86 binaries.
* readelf.c (no_processor_specific_unwind): New function.
	(process_unwind): Use no_processor_specific_unwind for X86
	targets.
2021-05-07 15:24:14 +01:00
Tom Tromey
c759c777c9 libiberty: add htab_eq_string
The libiberty hash table includes a helper function for strings, but
no equality function.  Consequently, this equality function has been
reimplemented a number of times in both the gcc and binutils-gdb
source trees.  This patch adds the function to the libiberty hash
table, as a step toward the goal of removing all the copies.

One change to gcc is included here.  Normally I would have put this in
the next patch, but gensupport.c used the most natural name for its
reimplementation of this function, and this can't coexist with the
extern function in libiberty.

include

	* hashtab.h (htab_eq_string): Declare.

libiberty

	* hashtab.c (htab_eq_string): New function.
2021-05-07 11:17:11 +01:00
Tom de Vries
4cf88725da [gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder()
With the test-case attached in PR26327, gdb aborts:
...
$ gdb -q -batch 447.dealII -ex "b main"
Aborted (core dumped)
...
when running out of stack due to infinite recursion:
...
 #8  0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x35e4b40)
     at src/gdb/dwarf2/read.c:700
 #9  0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x22ee2c0)
     at src/gdb/dwarf2/read.c:700
 #10 0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x35e4b40)
     at src/gdb/dwarf2/read.c:700
 #11 0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x22ee2c0)
     at src/gdb/dwarf2/read.c:700
...

We're recursing in this code in dwarf2_cu::get_builder():
...
     /* Otherwise, search ancestors for a valid builder.  */
     if (ancestor != nullptr)
       return ancestor->get_builder ();
...
due to the fact that the ancestor chain is a cycle.

Higher up in the call stack, we find some code that is responsible for
triggering this, in new_symbol:
...
       case DW_TAG_formal_parameter:
         {
           /* If we are inside a function, mark this as an argument.  If
              not, we might be looking at an argument to an inlined function
              when we do not have enough information to show inlined frames;
              pretend it's a local variable in that case so that the user can
              still see it.  */
           struct context_stack *curr
             = cu->get_builder ()->get_current_context_stack ();
           if (curr != nullptr && curr->name != nullptr)
             SYMBOL_IS_ARGUMENT (sym) = 1;
...

This is code that was added to support pre-4.1 gcc, to be able to show
arguments of inlined functions as locals, in the absense of sufficiently
correct debug information.

Removing this code (that is, doing SYMBOL_IS_ARGUMENT (sym) = 1
unconditially), fixes the crash.  The ancestor variable also seems to have
been added specifically to deal with fallout from this code, so remove that as
well.

Tested on x86_64-linux:
- openSUSE Leap 15.2 with gcc 7.5.0, and
- openSUSE Tumbleweed with gcc 10.3.0.

gdb/ChangeLog:

2021-05-07  Tom de Vries  <tdevries@suse.de>

	PR symtab/26327
	* dwarf2/read.c (struct dwarf2_cu): Remove ancestor.
	(dwarf2_cu::get_builder): Remove ancestor-related code.
	(new_symbol): Remove code supporting pre-4.1 gcc that show arguments
	of inlined functions as locals.
	(follow_die_offset, follow_die_sig_1): Remove setting of ancestor.

gdb/doc/ChangeLog:

2021-05-07  Tom de Vries  <tdevries@suse.de>

	PR symtab/26327
	* gdb.texinfo (Inline Functions): Update.
2021-05-07 12:13:05 +02:00
Jan Beulich
17c6c3b991 x86-64/ELF: clear src_mask for all reloc types
x86-64 uses rela relocations. The comment next to the field's declaration
says "Non-zero values for ELF USE_RELA targets should be viewed with
suspicion ..." And indeed the fields being non-zero causes section
contents to be accumulated into the final relocated values in addition to
the relocations' addends, which is contrary to the ELF spec.
2021-05-07 12:05:12 +02:00
Jan Beulich
98da05bf26 x86: don't mix disp and imm processing
Surely disp processing should access the disp operand, not an imm one.
This is not an active issue only because imms and disps are, at the
moment, overlapping fields of the same union.
2021-05-07 12:03:12 +02:00
Jan Beulich
9aac24b1a8 x86: move register check in immediate operand parsing
i386_finalize_immediate() is used for both AT&T and Intel immediate
operand handling. Move an AT&T-only check to i386_immediate(), which at
the same time allows it to cover other cases as well, giving an overall
better / more consistent diagnostic.
2021-05-07 12:02:40 +02:00
Jan Beulich
87ed972dc3 x86: minor improvements to optimize_imm()
- Drop a pointless & where just before it was checked that the
  respective bits are clear already anyway.
- Avoid a not really necessary operand_type_set() and a redundant
  operand_type_or() / operand_type_and() pair.
2021-05-07 12:02:07 +02:00
Nick Clifton
d820a652a6 When computing section link order for a relocateable link, ignore section sizes.
* ldelfgen.c (compare_link_order): Ignore section size when
	performing a relocateable link.
2021-05-07 10:57:47 +01:00
Andrew Burgess
9589edb836 gdb/guile: Have gdbscm_safe_source_script return a unique_ptr
Change gdbscm_safe_source_script to return a
gdb::unique_xmalloc_ptr<char> instead of a raw char*.  Update the
users of this function.

There should be no user visible change after this commit.

gdb/ChangeLog:

	* guile/guile-internal.h (gdbscm_safe_source_script): Change
	function return type.
	* guile/guile.c (gdbscm_source_script): Update to handle change in
	gdbscm_safe_source_script.
	* guile/scm-objfile.c (gdbscm_source_objfile_script): Likewise.
	* guile/scm-safe-call.c (gdbscm_safe_source_script): Change return
	type.
2021-05-07 09:53:50 +01:00
Michael Forney
4896932e62 dwarf: Don't omit second operand of '?' operator
This is a GNU C extension and is not valid in ISO C.

	* dwarf.c: Don't omit second operand of '?' operator.
2021-05-07 16:54:00 +09:30
Alan Modra
70993db314 multiple definition warnings from script symbols
In commit 89753bbf81 I enabled a warning for scripts redefining
symbols.  The idea was to not warn for symbols defined by shared
libraries (the h->u.def.section->output_section != NULL test), but the
test failed to take into account absolute symbols.  Absolute symbols
defined in shared libraries are currently indistinguishable from
absolute symbols defined in relocatable objects, at least when only
looking at struct bfd_link_hash_entry.  So, don't warn for any
absolute symbols.

	* ldexp.c (update_definedness): Don't return false for absolute
	symbols.
	* ldmain.c (multiple_definition): Print "warning: " in message
	when not a hard error.
2021-05-07 16:25:40 +09:30
Mike Frysinger
44056b7ce4 sim: m32c: clean up various warnings
A random grab bag of minor fixes to enable -Werror for this port.

Check the return values of read & write calls and issue warnings when
they fail.
Fixup funky pointer math as the compiler doesn't like ++ on void*.
Handle short reads with fread().
2021-05-07 00:36:26 -04:00
Mike Frysinger
0ae995e2df sim: m32c: fix warnings about mixing code & decls
Add scope braces to a bunch of the generated sections to avoid compiler
warnings about mixing code & variable declarations.
2021-05-07 00:34:25 -04:00
Mike Frysinger
a588403597 sim: m32c: switch from custom fgets to getline
No need to implement this ourselves when POSIX has a nice API.
2021-05-07 00:34:03 -04:00
Mike Frysinger
8e78e9b995 sim: m68hc11: fix up last warnings
Change the printf formats a little to fix the last build warnings in
here, and then turn on -Werror by default for the arch port.
2021-05-06 23:54:23 -04:00
Mike Frysinger
8852d02874 sim: m68hc11: warn when emul_write fails
Not sure what we should do here when this fails, so just emit a warning
for now to satisfy unused result compiler warnings.  We can see if any
users actually notice here.
2021-05-06 23:53:30 -04:00
Alan Modra
a41513efec Regenerate bfd-in2.h and libbfd.h
Commit 0b3e14c902 edited these by hand.

	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
2021-05-07 11:26:44 +09:30
GDB Administrator
5790a27645 Automatic date update in version.in 2021-05-07 00:00:35 +00:00
Alan Modra
973bba9164 Re: elf: Always append ".COUNT" to local symbols
Fixes XPASSes on frv-linux.

	* testsuite/ld-elf/pr27825-1.d: Correct xfail.
	* testsuite/ld-elf/pr27825-2.d: Likewise.
2021-05-07 09:18:18 +09:30
Simon Marchi
ec66d6ea54 gdb: make inferior::args a unique_xmalloc_ptr
Use unique_xmalloc_ptr to avoid manual memory management.

gdb/ChangeLog:

	* inferior.h (class inferior) <args>: Change type to
	unique_xmalloc_ptr.
	* inferior.c (inferior::~inferior): Don't free args.
	* infcmd.c (get_inferior_args): Adjust.
	(set_inferior_args): Adjust.

Change-Id: I96300e59eb2faf2d80660416a8f5694d243a944e
2021-05-06 13:16:26 -04:00
Tankut Baris Aktemur
482155e609 gdbserver/server: make some functions void
The 'handle_v_attach', 'handle_v_run', and 'handle_v_kill' functions'
return values are unused.  They indicate error/success result by
putting packets.  Make the functions void.

Tested by rebuilding.

gdbserver/ChangeLog:
2021-05-06  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* server.cc (handle_v_attach)
	(handle_v_run)
	(handle_v_kill): Make void.
2021-05-06 15:15:38 +02:00
Stafford Horne
284a130902 or1k: Support large plt_relocs when generating plt entries
The current PLT generation code will generate invalid code when the PLT
relocation offset exceeds 64k.  This fixes the issue by detecting large
plt_reloc offsets and generare code sequences to create larger plt
relocations.

The "large" plt code needs 2 extra instructions to create 32-bit offsets.

bfd/ChangeLog:

	PR 27746
	* elf32-or1k.c (PLT_ENTRY_SIZE_LARGE, PLT_MAX_INSN_COUNT,
	OR1K_ADD, OR1K_ORI): New macros to help with plt creation.
	(elf_or1k_link_hash_table): New field plt_count.
	(elf_or1k_link_hash_entry): New field plt_index.
	(elf_or1k_plt_entry_size): New function.
	(or1k_write_plt_entry): Update to support variable size PLTs.
	(or1k_elf_finish_dynamic_sections): Use new or1k_write_plt_entry
	API.
	(or1k_elf_finish_dynamic_symbol): Update to write large PLTs
	when needed.
	(allocate_dynrelocs): Use elf_or1k_plt_entry_size to account for
	PLT size.

ld/ChangeLog:

	PR 27746
	testsuite/ld-or1k/or1k.exp (or1kplttests): Add tests for linking
	along with gotha() relocations.
	testsuite/ld-or1k/gotha1.dd: New file.
	testsuite/ld-or1k/gotha1.s: New file.
	testsuite/ld-or1k/gotha2.dd: New file.
	testsuite/ld-or1k/gotha2.s: New file
	testsuite/ld-or1k/pltlib.s (x): Define size to avoid link
	failure.
2021-05-06 20:51:25 +09:00
Stafford Horne
3c3de29b04 or1k: Avoid R_OR1K_GOT16 overflow failures in presence of R_OR1K_GOT_AHI16
Now that we support R_OR1K_GOT_AHI16 we can relax the R_OR1K_GOT16
overflow validation check if the section has R_OR1K_GOT_AHI16.

We cannot simple disable R_OR1K_GOT16 overflow validation as there will
still be binaries that will have only R_OR1K_GOT16.  The
R_OR1K_GOT_AHI16 relocation will only be added by GCC when building with
the option -mcmodel=large.

This assumes that R_OR1K_GOT_AHI16 will come before R_OR1K_GOT16, which
is the code pattern that will be emitted by GCC.

bfd/ChangeLog:

	PR 21464
	* elf32-or1k.c (or1k_elf_relocate_section): Relax R_OR1K_GOT16
	overflow check if we have R_OR1K_GOT_AHI16 followed by
	R_OR1K_GOT16.
2021-05-06 20:51:25 +09:00
Stafford Horne
0b3e14c902 or1k: Implement relocation R_OR1K_GOT_AHI16 for gotha()
The gotha() relocation mnemonic will be outputted by OpenRISC GCC when
using the -mcmodel=large option.  This relocation is used along with
got() to generate 32-bit GOT offsets.  This increases the previous GOT
offset limit from the previous 16-bit (64K) limit.

This is needed on large binaries where the GOT grows larger than 64k.

bfd/ChangeLog:

	PR 21464
	* bfd-in2.h: Add BFD_RELOC_OR1K_GOT_AHI16 relocation.
	* elf32-or1k.c (or1k_elf_howto_table, or1k_reloc_map): Likewise.
	(or1k_final_link_relocate, or1k_elf_relocate_section,
	or1k_elf_check_relocs): Likewise.
	* libbfd.h (bfd_reloc_code_real_names): Likewise.
	* reloc.c: Likewise.

cpu/ChangeLog:

	PR 21464
	* or1k.opc (or1k_imm16_relocs, parse_reloc): Define parse logic
	for gotha() relocation.

include/ChangeLog:

	PR 21464
	* elf/or1k.h (elf_or1k_reloc_type): Define R_OR1K_GOT_AHI16 number.

opcodes/ChangeLog:

	PR 21464
	* or1k-asm.c: Regenerate.

gas/ChangeLog:

	PR 21464
	* testsuite/gas/or1k/reloc-1.s: Add test for new relocation.
	* testsuite/gas/or1k/reloc-1.d: Add test result for new
	relocation.

Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>

fixup reloc, add tests
2021-05-06 20:51:24 +09:00
Stafford Horne
a76ef689b6 or1k: Fix issue with plt link failure for local calls
When building protobuf we were seeing the assert failure:

    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
    collect2: error: ld returned 1 exit status

This failure happens while writing out PLT entries, there is a check
"BFD_ASSERT (h->dynindx != -1)" to confirm all plt entries have dynamic
symbol attributes.  This was failing for symbols that were
"forced_local" in previous linking code.

The fix adds logic to or1k_elf_adjust_dynamic_symbol to identify
"forced_local" symbols and exclude them from the the PLT.

bfd/ChangeLog:

	PR 27624
	* elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Change
	condition used to cleanup plt entries to cleanup forced local
	entries.

Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
2021-05-06 20:51:24 +09:00