Commit Graph

124161 Commits

Author SHA1 Message Date
Dennis Dyallo
90a0b08bd0 readelf: Fix typo in --version-info documentation
Change "it they exist" to "if they exist" in the description
of the --version-info option in the readelf man page.
2025-11-10 11:37:43 +01:00
Jan Dubiec
952f99a6bd Minor cleanup in ld documentation
ld/
	* ld.texi : Remove a remnant of previous edits.

Signed-off-by: Jan Dubiec <jdx@o2.pl>
2025-11-10 11:37:24 +01:00
Jan Beulich
6afb0b1127 bfd/ELF: mark internal MIPS functions hidden
This reduces the dynamic symbol table some and allows the compiler to be
more aggressive about inlining (as it sees fit, of course).
2025-11-10 11:36:43 +01:00
Jan Beulich
0ded1882ec bfd/ELF: _bfd_elf_ppc_at_tls_transform() is exposed to gas
As a non-private function, it shouldn't have a "_bfd_" prefix, but merely
a "bfd_" one. Hence commit 50efe229dd ("bfd/ELF: mark internal functions
hidden") also wrongly added ATTRIBUTE_HIDDEN to it.
2025-11-10 11:36:25 +01:00
Jan Dubiec
15a7adca5d ld: Fix a H8/300 specific test case
It seems that glob patterns no longer work in the test suite, at least
on some host/dejagnu/shell combinations.  In any case it is better
here not to create a single relax-7?.o file from the two source files,
but to create two separate objects for linking.

ld/
	* testsuite/ld-h8300/relax-7.d: Replace the glob pattern with
	multiple "source" options.

Signed-off-by: Jan Dubiec <jdx@o2.pl>
2025-11-10 10:48:30 +10:30
GDB Administrator
c52cb06841 Automatic date update in version.in 2025-11-10 00:00:23 +00:00
Indu Bhagat
b91966e2df libsframe: rename encoder to ectx for readability
Addressing (an old) review comment suggesting this housekeeping item.
Use consistent naming style in libsframe.  sframe_decoder_ctx objects
are named 'dctx', so use 'ectx' for sframe_encoder_ctx objects.

Make necessary changes in all the applicable declarations and definitions.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
2025-11-09 00:34:27 -08:00
Tom de Vries
28fc75a7c5 [gdb/testsuite] Fix main in gdb.trace/mi-trace-frame-collected.exp
With test-case gdb.trace/mi-trace-frame-collected.exp I run into:
...
gdb compile failed, gdb.trace/actions.c: In function 'main':
gdb.trace/actions.c:139:1: warning: old-style function definition \
  [-Wold-style-definition]
  139 | main (argc, argv, envp)
      | ^~~~
...

Fix this by rewriting main into a prototyped function.

Tested on x86_64-linux.

PR testsuite/32756
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32756
2025-11-09 09:18:43 +01:00
Indu Bhagat
b263aca0a5 libsframe: fix checks in flip_fde
Adjust the sanity checks for flip_fde workflow and optional trailing
section padding to account for the case of ihp->sfh_fdeoff != 0 or
ihp->sfh_freoff != total FDEs size.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>

libsframe/
        * sframe.c (flip_sframe): Fix checks in flip_fde to accommodate
	cases when sfh_fdeoff != 0 or when SFrame FREs are placed after
	a gap from SFrame FDEs.
2025-11-08 23:33:22 -08:00
Tom de Vries
f081af0715 [gdb/testsuite] Use -std=c99 in gdb.base/callfuncs.exp
In test-case gdb.base/callfuncs.exp I run into:
...
gdb compile failed, gdb.base/callfuncs.c: In function 't_func_values':
gdb.base/callfuncs.c:611:12: error: too many arguments to function \
  'func_arg1'; expected 0, have 2
  611 |   return ((*func_arg1) (5,5)  == (*func_val1) (5,5)
      |           ~^~~~~~~~~~~  ~
...

Fix this by using -std=c99.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>

PR testsuite/32756
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32756
2025-11-09 08:07:57 +01:00
GDB Administrator
c2f9db99b9 Automatic date update in version.in 2025-11-09 00:00:19 +00:00
GDB Administrator
509af7a8c0 Automatic date update in version.in 2025-11-08 00:00:17 +00:00
H.J. Lu
2be0f2da21 readelf: Display the base symbol version as empty string
Update readelf to display the base symbol version as

Symbol table for image contains 5 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000003008     0 OBJECT  GLOBAL DEFAULT   10 bar@@
     2: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS VERS_1
     3: 0000000000003008     0 OBJECT  GLOBAL DEFAULT   10 bar@@VERS_1
     4: 0000000000003000     0 OBJECT  GLOBAL DEFAULT   10 foo@

instead of

Symbol table for image contains 5 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000003008     0 OBJECT  GLOBAL DEFAULT   10 bar
     2: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS VERS_1
     3: 0000000000003008     0 OBJECT  GLOBAL DEFAULT   10 bar@@VERS_1
     4: 0000000000003000     0 OBJECT  GLOBAL DEFAULT   10 foo

That is bar@@ and foo@ vs bar and foo.

binutils/

	PR binutils/33599
	* readelf.c (process_version_sections): Replace 0x8001 with
	(VERSYM_HIDDEN | VERSYM_BASE).
	(get_symbol_version_string): Likewise.  Return "" for the base
	version.

include/

	PR binutils/33599
	* elf/common.h (VERSYM_BASE): New.

ld/

	PR binutils/33599
	* testsuite/ld-elf/pr33599.d: New file.
	* testsuite/ld-elf/pr33599.map: Likewise.
	* testsuite/ld-elf/pr33599.s: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-11-08 06:39:42 +08:00
Simon Marchi
767c92a13e gdb/testsuite: adjust yet another add-inferior test for native-extended-gdbserver board
I'm seeing this FAIL with the native-extended-gdbserver board:

    (gdb) add-inferior^M
    [New inferior 2]^M
    Added inferior 2 on connection 1 (extended-remote localhost:2365)^M
    (gdb) FAIL: gdb.python/py-parameter.exp: test_per_inferior_parameters: add-inferior

This is another case of add-inferior producing more output when
connected to a remote target.  Adjust the regexp to accomodate it.

Change-Id: Ic5760ff66712c54b90b9debf379dcbf6e07f6eeb
2025-11-07 15:59:03 -05:00
Simon Marchi
4554e4aceb gdb/testsuite: adjust another add-inferior test for native-extended-gdbserver board
I see this FAIL when running with the native-extended-gdbserver board:

    Expecting: ^(-add-inferior[^M
    ]+)?(.*\^done,inferior="i2"[^M
    ]+[(]gdb[)] ^M
    [ ]*)
    -add-inferior^M
    =thread-group-added,id="i2"^M
    ~"[New inferior 2]\n"^M
    ~"Added inferior 2 on connection 1 (extended-remote localhost:2345)\n"^M
    ^done,inferior="i2",connection={number="1",name="extended-remote"}^M
    (gdb) ^M
    FAIL: gdb.mi/set-show.exp: test_per_inferior_parameters: add inferior (unexpected output)

This is another case of the add-inferior command producing more output
when connected to a remote target.  Adjust the regexp to accomodate it.

Change-Id: Ifa0590211fd75d4a01dff942c6bb810d5caf1257
2025-11-07 15:56:55 -05:00
Jan Vrany
c2be931046 pre-commit: check for whitespace errors in on all files under gdb
I got a review comment [1] because I forgot to run

    git diff --staged --check

to check commits before submitting. This commit adds a pre-commit hook
to do this automatically.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

[1]: https://inbox.sourceware.org/gdb-patches/c231d267-f541-4774-8005-6d433a9d6e96@simark.ca/
2025-11-07 19:59:32 +00:00
Tom Tromey
cdb5949407 Write entire buffer in gdbserver write_prim
We had a customer bug report which was eventually tracked down to
gdbserver not fully sending a target description to gdb.  (This
presented as a timeout on the gdb side.)

The customer was using the WINAPI code, which does this:

  # define write(fd, buf, len) send (fd, (char *) buf, len, 0)

In this setup, I think it's possible to have a partial write.
However, gdbserver does not account for this possibility, despite the
fact that write_prim documents this.

This patch attempts to fix the problem by always writing the full
buffer in write_prim.  In this case the customer fixed their bug in a
different way, so we haven't actually tested this in the wild.

v2: Return bool from write_prim.

Reviewed-by: Kévin Le Gouguec <legouguec@adacore.com>
2025-11-07 11:53:28 -07:00
Simon Marchi
9452b2fb46 gdb/dwarf: pass is_debug_types to dwarf2_per_cu constructor, make field private
Make the field private to make it clear it is never meant to change.
Pass its value through the constructor, and add a getter.  The only
place that passes true is the signature_type constructor.

Change-Id: Ifb76bc015bca16696fd66cdf45c048b4ba713479
Approved-By: Tom Tromey <tom@tromey.com>
2025-11-07 11:48:55 -05:00
Simon Marchi
f0944db5ef gdb/dwarf: make some fields in dwarf2_per_cu private
Except for the m_length field, that is already private and has a setter,
make the fields whose values are passed through the constructor private.
The idea is that their values should be constant throughout the life of
the object.  Add some getters and update the callers.

I wasn't sure if making some bitfields public and some private would
change how they are packed, so I checked with "ptype/o", it does not.

Change-Id: I7087bebf69e44d16a36c1dd4d7edf9b8bf085343
Approved-By: Tom Tromey <tom@tromey.com>
2025-11-07 11:47:58 -05:00
Simon Marchi
f8d3f9bb8a gdb/dwarf: clarify comment on dwarf_per_bfd::all_units
I thought that this comment could be updated to clarify what this vector
holds and what it is used for.

Change-Id: I0e1968c8c6455b49aa156669c43ea8c436c59e45
Approved-By: Tom Tromey <tom@tromey.com>
2025-11-07 11:47:58 -05:00
Simon Marchi
6d30159f9a Revert "bfd/ELF: make is_debuginfo_file() static"
This reverts commit 5e648fc6a0, since it
breaks the GDB build:

      CXX    elfread.o
    /home/smarchi/src/binutils-gdb/gdb/elfread.c: In function ‘symfile_segment_data_up elf_symfile_segments(bfd*)’:
    /home/smarchi/src/binutils-gdb/gdb/elfread.c:145:12: error: ‘is_debuginfo_file’ was not declared in this scope
      145 |       if (!is_debuginfo_file (abfd)
          |            ^~~~~~~~~~~~~~~~~

Change-Id: I180a9f6936365c365a853c7dae2af01f5207a84e
2025-11-07 16:43:28 +00:00
Simon Marchi
b94d8189ae gdb/testsuite: issue "no repeat" command before "no previous command to relaunch" test
I see this failure:

    $ make check TESTS="gdb.base/with.exp" RUNTESTFLAGS="--target_board=native-extended-gdbserver"
    FAIL: gdb.base/with.exp: repeat: reinvoke with no previous command to relaunch

It seems like that failure has always been there and I didn't notice?

I'm not sure what is the intent of the test exactly.  It sounds like it
is meant to test what happens when you use command "with language ada"
as the very first command of a GDB session?  However, clean_restart and
gdb_load issue some commands before that test.  The different between
the native-extended-gdbserver board and the other boards is: for other
boards, the previous command is a "file" command, which is a "no repeat"
command, which gives the expected error message.  With the
native-extended-gdbserver board, the previous command is "set remote
exec-file", which is a repeatable command.

"Fix" it by making a "no repeat" command just before the test, so that
it works the same regardless of the target board.

Change-Id: I254faf196f49e9efd492fc9dd5f6ce7b96f72af7
Approved-By: Tom Tromey <tom@tromey.com>
2025-11-07 11:13:02 -05:00
Lukas Durfina
3d649e28eb gdb/testsuite: rename thread_local variables
C standard gnu23 introduces a new keyword 'thread_local'.
So, this variables must be renamed to avoid build errors.

Approved-By: Tom Tromey <tom@tromey.com>
2025-11-07 09:11:49 -07:00
Jens Remus
c1011a70b0 s390: Bind defined symbol locally in PIE
Symbols defined in PIE should be bound locally, the same as -shared
-Bsymbolic.

Port x86 commit 4e0c91e454 ("Bind defined symbol locally in PIE")
change of relocate_section as well as linker tests to s390.  Similar as
done for other architectures with the following commits:
- AArch64: ac33b731d2 ("[AArch64] Bind defined symbol locally in PIE")
- ARM: 1dcb9720d6 ("[ARM] Bind defined symbol locally in PIE")
- RISC-V: 39c7793ba8 ("RISC-V: Bind defined symbol locally in PIE")
- x86: 4e0c91e454 ("Bind defined symbol locally in PIE")
With this change symbols defined in an executable (i.e. PDE or PIE) are
bound locally, as they cannot be interposed.  In the same way as symbols
defined in a shared library linked with -Bsymbolic are bound locally.

This also ensures that all defined symbols are bound locally in
static PIE.

Do not port the x86 change of check_relocs (now scan_relocs).  None of
the linker tests where the change in condition triggers (e.g. bootstrap,
cdtest) produce different readelf -Wa output.  The change appears to
affect accounting of space required for dynamic relocations.  Instead of
accounting them in check_relocs and later filtering them away in
allocate_dynrelocs, they would not get accounted in the first place:
The change in the expression would only have an effect if the following
conditions are all met in addition to PIE:  ALLOC, PC-relative
relocation, global symbol, not defined weak, and defined regular.  In
this specific case the accounting of the PC relative relocation in
h->dyn_relocs would be skipped for PIE.  But allocate_dynrelocs later
eliminates any PC-relative dynamic relocations if PIC (= PIE or shared
library) and SYMBOL_CALLS_LOCAL.

bfd/
	PR ld/33141
	* elf64-s390.c (elf_s390_relocate_section): Bind defined symbol
	locally in PIE.

ld/testsuite/
	PR ld/33141
	* ld-s390/s390.exp: Add pr33141 tests.
	* ld-s390/pr33141.rd: New file.
	* ld-s390/pr33141a.s: Likewise.
	* ld-s390/pr33141b.s: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-11-07 17:09:55 +01:00
Jan Beulich
8bf8f4380d bfd/ELF: _bfd_elf_linker_x86_set_options() is exposed to ld
As a non-private function, it shouldn't have a "_bfd_" prefix, but merely
a "bfd_" one.
2025-11-07 15:01:08 +01:00
Jan Beulich
97df0abb93 bfd/ELF: _bfd_elf_link_create_dynamic_sections() is exposed to ld
As a non-private function, it shouldn't have "_bfd_" prefixes, but merely
a "bfd_" one. Even if, sadly, it needs exposing just for the sake for
VxWorks.
2025-11-07 15:00:51 +01:00
Jan Beulich
e3dd2eb6f5 bfd/ELF: mark functions exposed to ld as non-private
As non-private functions, these shouldn't have "_bfd_" prefixes,
but merely "bfd_" ones:
- _bfd_elf_size_group_sections(),
- _bfd_elf_match_sections_by_type(),
- _bfd_elf_strtab_{str,len}(),
- _bfd_elf_map_sections_to_segments(),
- _bfd_elf_tls_setup().
2025-11-07 15:00:25 +01:00
Jan Beulich
70aa9fbb41 bfd/ELF: _bfd_elf{,32,64}_hppa_gen_reloc_type are exposed to gas
As non-private functions / macros, they shouldn't have "_bfd_" prefixes,
but merely "bfd_" ones.
2025-11-07 15:00:08 +01:00
Jan Beulich
8b322fc15a bfd/ELF: _bfd_elf_large_com_section is exposed to gas and x86-only
As a non-private data item, it shouldn't have a "_bfd_" prefix, but merely
a "bfd_" one. Furthermore, as being x86-only (forever since its
introduction), it doesn't need to be present in libbfd.{a,so} at all for
other targets.
2025-11-07 14:59:45 +01:00
Jan Beulich
4a890d55ad bfd/ELF: _bfd_elf_obj_attrs_arg_type() is exposed to gas
As a non-private function, it shouldn't have a "_bfd_" prefix, but merely
a "bfd_" one.
2025-11-07 14:59:16 +01:00
Jan Beulich
82cb152b06 bfd/ELF: properly mark elf_appent_rel{a,}() as private
Add _bfd_ prefixes and make them hidden.
2025-11-07 14:57:36 +01:00
Jan Beulich
85c8b58e2d bfd/ELF: properly mark elf_read_notes() as private
Add a _bfd_ prefix and make it hidden.
2025-11-07 14:57:16 +01:00
Jan Beulich
479613f261 bfd/ELF: properly mark bfd_elf_print_symbol() as private
Add a leading underscore and make it hidden.
2025-11-07 14:57:01 +01:00
Jan Beulich
0141f46278 bfd/ELF: adjust *_size_info properties
Target-specific symbols can be static. The common ones can at least be
hidden.
2025-11-07 14:56:45 +01:00
Jan Beulich
5e648fc6a0 bfd/ELF: make is_debuginfo_file() static
No need to expose it, even less so in the dynamic symbol table.
2025-11-07 14:56:19 +01:00
Jan Beulich
aab90506f5 bfd/ELF: mark VxWorks functions hidden
They're all internal to libbfd.
2025-11-07 14:55:57 +01:00
Jan Beulich
603bc39791 bfd/x86: mark _bfd_x86_elf_link_report_tls_{transition,invalid_section}_error() hidden
For some reason the attributes were missing there.
2025-11-07 14:53:32 +01:00
Jan Beulich
781bf4774d bfd/ELF: mark internal TileGX functions hidden
This reduces the dynamic symbol table a little and allows the compiler to
be more aggressive about inlining (as it sees fit, of course).
2025-11-07 14:53:21 +01:00
Jan Beulich
8f27c85060 bfd/ELF: mark internal Sparc functions hidden
This reduces the dynamic symbol table a little and allows the compiler to
be more aggressive about inlining (as it sees fit, of course).
2025-11-07 14:53:01 +01:00
Jan Beulich
337353d590 bfd/ELF: mark internal SCore functions hidden
This reduces the dynamic symbol table a little and allows the compiler to
be more aggressive about inlining (as it sees fit, of course).
2025-11-07 14:52:41 +01:00
Jan Beulich
fa109576a9 bfd/ELF: mark internal RISC-V functions hidden
This reduces the dynamic symbol table a little and allows the compiler to
be more aggressive about inlining (as it sees fit, of course).
2025-11-07 14:52:19 +01:00
Jan Beulich
57930ff75f bfd/ELF: mark an internal PowerPC function hidden
This reduces the dynamic symbol table a little.

Also drop the ppc_elf_section_processing() declaration, as its definition
was dropped almost 10 years ago.
2025-11-07 14:51:58 +01:00
Jan Beulich
bf4128d0cc bfd/ELF: mark internal NDS32 functions hidden
This reduces the dynamic symbol table a little and allows the compiler to
be more aggressive about inlining (as it sees fit, of course).
2025-11-07 14:51:38 +01:00
Jan Beulich
66c313276d bfd/ELF: mark internal M68HC1x functions hidden
This reduces the dynamic symbol table a little and allows the compiler to
be more aggressive about inlining (as it sees fit, of course).
2025-11-07 14:51:16 +01:00
Jan Beulich
2903d813fc bfd/ELF: mark internal LoongArch functions hidden
This reduces the dynamic symbol table a little and allows the compiler to
be more aggressive about inlining (as it sees fit, of course).
2025-11-07 14:50:50 +01:00
Jan Beulich
c4e99bc14e bfd/ELF: mark internal KVX functions hidden
This reduces the dynamic symbol table a little and allows the compiler to
be more aggressive about inlining (as it sees fit, of course).
2025-11-07 14:50:28 +01:00
Jan Beulich
11fe65581d bfd/ELF: mark internal IA-64 functions hidden
This reduces the dynamic symbol table a little and allows the compiler to
be more aggressive about inlining (as it sees fit, of course).
2025-11-07 14:50:13 +01:00
Jan Beulich
8281d8d247 bfd/ELF: mark internal aarch64 functions hidden
This reduces the dynamic symbol table some and allows the compiler to be
more aggressive about inlining (as it sees fit, of course).
2025-11-07 14:49:59 +01:00
Jan Beulich
50efe229dd bfd/ELF: mark internal functions hidden
This reduces the dynamic symbol table quite a bit (almost 200 symbols) and
allows the compiler to be more aggressive about inlining (as it sees fit,
of course).
2025-11-07 14:43:47 +01:00
Jan Beulich
3e2e413a54 bfd: move ATTRIBUTE_HIDDEN to separate header
... for it to become usable in places where libbfd.h cannot (easily) be
included.
2025-11-07 08:10:49 +01:00