Bug 32146 - dwz doesn't handle .gdb_index version 9
Summary: dwz doesn't handle .gdb_index version 9
Status: RESOLVED FIXED
Alias: None
Product: dwz
Classification: Unclassified
Component: default (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Mark Wielaard
URL:
Keywords:
: 32028 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-09-06 14:22 UTC by Mark Wielaard
Modified: 2024-10-14 11:25 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Initial patch to improve error/warning messages and support version 9 .gdb_index (3.40 KB, patch)
2024-09-08 01:38 UTC, Mark Wielaard
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2024-09-06 14:22:41 UTC
https://sourceware.org/gdb/current/onlinedocs/gdb.html/Index-Section-Format.html

 Version 9 adds the name and the language of the main function to the index.
Comment 1 Mark Wielaard 2024-09-08 01:38:36 UTC
Created attachment 15694 [details]
Initial patch to improve error/warning messages and support version 9 .gdb_index
Comment 2 Jakub Jelinek 2024-09-10 17:59:41 UTC
headersize = ver < 9 ? 0x18 : 0x1c;

The comment says the difference is 2 * 4 bytes, but the above difference is just 4 bytes.
Comment 3 Mark Wielaard 2024-10-02 21:03:26 UTC
(In reply to Jakub Jelinek from comment #2)
> headersize = ver < 9 ? 0x18 : 0x1c;
> 
> The comment says the difference is 2 * 4 bytes, but the above difference is
> just 4 bytes.

You are right. The comment is confusing, I'll fix it.

The header is increased by 4 bytes, which is the offset to the new table.

The table content itself is 2 * 4 bytes.
Comment 5 Mark Wielaard 2024-10-14 11:24:02 UTC
commit 1ae37f476bc6c9f7a756fee4830766f03600866c
Author: Mark Wielaard <mark@klomp.org>
Date:   Wed Oct 2 23:20:57 2024 +0200

    Add support for version 9 .gdb_index
    
    Version 9 .gdb_index adds a new shortcut table. The table itself is
    just two offset_type values (2 * 4 bytes) describing the language of
    the main function expresses as an DW_LANG_ constant and the offset of
    the main function's name in the constant pool.
    
    The offset to the shortcut table in the header is between the symbol
    table and constant pool offsets.
    
    write_gdb_index explicitly copies the function's name into the new
    constant pool (if lang is not zero) because it might not be an offset
    to an existing name of a symbol.
    
    Some extra checks and warnings have been added to let the user know
    when parsing the .gdb_index fails. Add a const char *file argument to
    write_gdb_index for better error reporting.
    
    Add -D_GNU_SOURCE to Makefile CFLAGS_COMMON to use memrchr.
    
    This fixes the gdb-add-index.sh testcase with gdb 15+.
    
    https://sourceware.org/bugzilla/show_bug.cgi?id=32146
Comment 6 Mark Wielaard 2024-10-14 11:25:28 UTC
*** Bug 32028 has been marked as a duplicate of this bug. ***