[binutils-gdb] [bfd/mach-o] Add DWARF5 sections in dwarf_section_names_xlat
Tom de Vries
vries@sourceware.org
Thu Nov 5 10:58:27 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1c63d994da57cb26ef85f3996aaf821a8bc4e666
commit 1c63d994da57cb26ef85f3996aaf821a8bc4e666
Author: Tom de Vries <tdevries@suse.de>
Date: Thu Nov 5 11:58:24 2026 +0100
[bfd/mach-o] Add DWARF5 sections in dwarf_section_names_xlat
I built gdb on macos aarch64, using the gdb.rb formula of homebrew [1]:
--target=x86_64-apple-darwin20 --enable-targets=all.
Then I tried compiling a hello world, and did:
...
$ gdb -q -batch a.out -ex "list main"
...
DW_FORM_GNU_str_index or DW_FORM_strx used without .debug_str section in CU \
at offset 0x0 \
[in module /Users/vries/gdb/a.out.dSYM/Contents/Resources/DWARF/a.out]
...
The error message is actually wrong, it's the .debug_str_offsets section that
gdb can't find.
This is because that and other DWARF5 sections are not supported in the
dwarf_section_names_xlat table in bfd/mach-o.c.
Fix this by adding the missing sections.
Tested by rebuilding gdb, and getting instead:
...
$ gdb -q -batch a.out -ex "list main"
warning: .debug_names not created by gdb; ignoring
1 #include <stdio.h>
2
3 int
4 main (void)
5 {
6 printf ("hello\n");
7 return 0;
8 }
...
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32235
[1] https://formulae.brew.sh/formula/gdb
Diff:
---
bfd/mach-o.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 6aec6f24676..f9a90eacbb8 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -163,6 +163,9 @@ static const mach_o_section_name_xlat data_section_names_xlat[] =
/* __DWARF Segment. */
static const mach_o_section_name_xlat dwarf_section_names_xlat[] =
{
+ { ".debug_addr", "__debug_addr",
+ SEC_DEBUGGING, BFD_MACH_O_S_REGULAR,
+ BFD_MACH_O_S_ATTR_DEBUG, 0},
{ ".debug_frame", "__debug_frame",
SEC_DEBUGGING, BFD_MACH_O_S_REGULAR,
BFD_MACH_O_S_ATTR_DEBUG, 0},
@@ -181,21 +184,36 @@ static const mach_o_section_name_xlat dwarf_section_names_xlat[] =
{ ".debug_line", "__debug_line",
SEC_DEBUGGING, BFD_MACH_O_S_REGULAR,
BFD_MACH_O_S_ATTR_DEBUG, 0},
+ { ".debug_line_str", "__debug_line_str",
+ SEC_DEBUGGING, BFD_MACH_O_S_REGULAR,
+ BFD_MACH_O_S_ATTR_DEBUG, 0},
{ ".debug_loc", "__debug_loc",
SEC_DEBUGGING, BFD_MACH_O_S_REGULAR,
BFD_MACH_O_S_ATTR_DEBUG, 0},
+ { ".debug_loclists", "__debug_loclists",
+ SEC_DEBUGGING, BFD_MACH_O_S_REGULAR,
+ BFD_MACH_O_S_ATTR_DEBUG, 0},
{ ".debug_pubnames", "__debug_pubnames",
SEC_DEBUGGING, BFD_MACH_O_S_REGULAR,
BFD_MACH_O_S_ATTR_DEBUG, 0},
{ ".debug_pubtypes", "__debug_pubtypes",
SEC_DEBUGGING, BFD_MACH_O_S_REGULAR,
BFD_MACH_O_S_ATTR_DEBUG, 0},
+ { ".debug_names", "__debug_names",
+ SEC_DEBUGGING, BFD_MACH_O_S_REGULAR,
+ BFD_MACH_O_S_ATTR_DEBUG, 0},
{ ".debug_str", "__debug_str",
SEC_DEBUGGING, BFD_MACH_O_S_REGULAR,
BFD_MACH_O_S_ATTR_DEBUG, 0},
+ { ".debug_str_offsets", "__debug_str_offs",
+ SEC_DEBUGGING, BFD_MACH_O_S_REGULAR,
+ BFD_MACH_O_S_ATTR_DEBUG, 0},
{ ".debug_ranges", "__debug_ranges",
SEC_DEBUGGING, BFD_MACH_O_S_REGULAR,
BFD_MACH_O_S_ATTR_DEBUG, 0},
+ { ".debug_rnglists", "__debug_rnglists",
+ SEC_DEBUGGING, BFD_MACH_O_S_REGULAR,
+ BFD_MACH_O_S_ATTR_DEBUG, 0},
{ ".debug_macro", "__debug_macro",
SEC_DEBUGGING, BFD_MACH_O_S_REGULAR,
BFD_MACH_O_S_ATTR_DEBUG, 0},
More information about the Binutils-cvs
mailing list