Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ELF] Change .debug_names tombstone value to UINT32_MAX/UINT64_MAX #74686

Merged
merged 2 commits into from
Dec 22, 2023

Commits on Dec 7, 2023

  1. [ELF] Change .debug_names tombstone value to UINT32_MAX/UINT64_MAX

    `clang -g -gpubnames -fdebug-types-section` now emits .debug_names
    section with references to local type unit entries defined in COMDAT
    .debug_info sections.
    
    ```
    .section        .debug_info,"G",@progbits,5657452045627120676,comdat
    .Ltu_begin0:
    ...
    
    .section        .debug_names,"",@progbits
    ...
    // DWARF32
    .long   .Ltu_begin0                     # Type unit 0
    // DWARF64
    // .long   .Ltu_begin0                     # Type unit 0
    ```
    
    When `.Ltu_begin0` is relative to a non-prevailing .debug_info section,
    the relocation resolves to 0, which is a valid offset within the
    .debug_info section.
    
    ```
    cat > a.cc <<e
    struct A { int x; };
    inline A foo() { return {1}; }
    int main() { foo(); }
    e
    cat > b.cc <<e
    struct A { int x; };
    inline A foo() { return {1}; }
    void use() { foo(); }
    e
    clang++ -g -gpubnames -fdebug-types-section -fuse-ld=lld a.cc b.cc -o old
    ```
    ```
    % llvm-dwarfdump old
    ...
      Local Type Unit offsets [
        LocalTU[0]: 0x00000000
      ]
    ...
      Local Type Unit offsets [
        LocalTU[0]: 0x00000000  // indistinguishable from a valid offset within .debug_info
      ]
    ```
    
    https://dwarfstd.org/issues/231013.1.html proposes that we use a
    tombstone value instead to inform consumers. This patch implements the
    idea. The second LocalTU entry will now use 0xffffffff.
    
    https://reviews.llvm.org/D84825 has a TODO that we should switch the
    tombstone value for most `.debug_*` sections to UINT64_MAX. We have
    postponed the change for more than three years for consumers to migrate.
    At some point we shall make the change, so that .debug_names is no long
    different from other debug section that is not .debug_loc/.debug_ranges.
    MaskRay committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    4c0d6be View commit details
    Browse the repository at this point in the history
  2. simplify

    MaskRay committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    ee4a389 View commit details
    Browse the repository at this point in the history