[PING][PATCH] [bfd/mach-o] Add DWARF5 sections in dwarf_section_names_xlat

Tom de Vries tdevries@suse.de
Thu Nov 5 08:53:20 GMT 2026


> 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	}
> ...
> 

Ping.

Thanks,
- Tom

> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32235
> 
> [1] https://formulae.brew.sh/formula/gdb
> ---
>  bfd/mach-o.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/bfd/mach-o.c b/bfd/mach-o.c
> index 83180527b04..e0f1d23e572 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},
> 
> base-commit: 214080ae5328425c3395a116e45d3e4c26f29515
> -- 
> 2.51.0




More information about the Binutils mailing list