Bug 27588 - dwz: libxul.so: loclistptr attribute, yet no .debug_loc section
Summary: dwz: libxul.so: loclistptr attribute, yet no .debug_loc section
Status: RESOLVED NOTABUG
Alias: None
Product: dwz
Classification: Unclassified
Component: default (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-16 09:17 UTC by Martin Liska
Modified: 2023-01-16 10:14 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liska 2021-03-16 09:17:48 UTC
Happens for libxul.so (thunderbird package) when using GCC 11 (-gdwarf-5):

$ dwz libxul.so
/home/marxin/Programming/dwz/dwz: libxul.so: loclistptr attribute, yet no .debug_loc section

Please get the shared library here:
https://splichal.eu/tmp/libxul.so.zst
Comment 1 Tom de Vries 2021-03-16 10:08:17 UTC
So, this is related to this CU:
...
  Compilation Unit @ offset 0x37d3:
   Length:        0x8f (32-bit)
   Version:       3
   Abbrev Offset: 0x602
   Pointer Size:  8
 <0><37de>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <37df>   DW_AT_low_pc      : 0x4a89440
    <37e7>   DW_AT_high_pc     : 0x4a8d580
    <37ef>   DW_AT_stmt_list   : 0x12e55
    <37f3>   DW_AT_name        : /home/abuild/rpmbuild/BUILD/thunderbird-78.8.1/third_party/dav1d/src/x86/cdef.asm
    <3845>   DW_AT_producer    : NASM 2.15.05
    <3852>   DW_AT_language    : 32769  (MIPS assembler)
 <1><3854>: Abbrev Number: 2 (DW_TAG_subprogram)
    <3855>   DW_AT_low_pc      : 0x4a89440
    <385d>   DW_AT_frame_base  : 0x0 (location list)
 <1><3861>: Abbrev Number: 0
 <0><3862>: Abbrev Number: 0
 <-1><3863>: Abbrev Number: 0
...

The dwarf version of the CU is 3, so a .debug_loc section is expected to contain the location list for DW_AT_frame_base.

However, the binary does not contain a .debug_loc section:
...
$ readelf -S -W libxul.so | grep .debug_
  [31] .debug_aranges    PROGBITS        0000000000000000 7d238a0 02a5d0 00      0   0 16
  [32] .debug_pubnames   PROGBITS        0000000000000000 7d4de70 c25c3f 00      0   0  1
  [33] .debug_info       PROGBITS        0000000000000000 8973aaf 143b0f2 00      0   0  1
  [34] .debug_abbrev     PROGBITS        0000000000000000 9daeba1 001195 00      0   0  1
  [35] .debug_line       PROGBITS        0000000000000000 9dafd36 730cdf 00      0   0  1
  [36] .debug_str        PROGBITS        0000000000000000 a4e0a15 159d458 01  MS  0   0  1
  [37] .debug_pubtypes   PROGBITS        0000000000000000 ba7de6d 000c60 00      0   0  1
  [38] .debug_ranges     PROGBITS        0000000000000000 ba7eacd 98b200 00      0   0  1
  [39] .debug_line_str   PROGBITS        0000000000000000 c409ccd 0001b8 01  MS  0   0  1
  [40] .debug_loclists   PROGBITS        0000000000000000 c409e85 000060 00      0   0  1
  [41] .debug_rnglists   PROGBITS        0000000000000000 c409ee5 000042 00      0   0  1
...

So, I'd say the error message is correct.
Comment 2 Martin Liska 2021-03-16 10:36:01 UTC
All right, so it's likely nasm issue, there's reduced test-case:

$ cat cdef.asm
%define ARCH_X86_64 1
%ifndef public_prefix
%endif
%define WIN64  0
%if WIN64 ; Windows x64 ;=================================================
    %if vzeroupper_required
    %endif
%endif
%macro BRANCH_INSTR 0-*
%endmacro
%if ARCH_X86_64
%macro DUP4 1-*
%endmacro
    ret
%endif ; ARCH_X86_64

$ cat a.c
int main(int argc, char **argv)
{
  return 0;
}

$ nasm -o cdef.o -f elf64 -F dwarf cdef.asm && gcc a.c -O2 -g -shared cdef.o -o x.so && dwz x.so

Apparently, cdef.o contains the section you're seeking for:

$ readelf -SW cdef.o | grep debug_loc
  [11] .debug_loc        PROGBITS        0000000000000000 0005c0 000000 00      0   0  1

but the final x.so is somehow corrupted it seems:
$ readelf -w  x.so >/dev/null
readelf: Warning: Bogus end-of-siblings marker detected at offset e6 in .debug_info section
readelf: Warning: Bogus end-of-siblings marker detected at offset e7 in .debug_info section
readelf: Warning: Bogus end-of-siblings marker detected at offset e8 in .debug_info section
readelf: Warning: Further warnings about bogus end-of-sibling markers suppressed
Comment 3 Martin Liska 2021-03-16 10:38:25 UTC
$ eu-readelf -w  x.so
...
 Compilation unit at offset 160:
 Version: 3, Abbreviation section offset: 118, Address size: 8, Offset size: 4
 [    ab]  compile_unit         abbrev: 1
           low_pc               (addr) +0x00000000000005d0 <frame_dummy+0x20>
           high_pc              (addr) +0x00000000000005d0 <frame_dummy+0x20>
           stmt_list            (data4) 182
           name                 (string) "cdef.asm"
           producer             (string) "NASM 2.15.05"
           language             (data2) Mips_Assembler (32769)
 [    d8]    subprogram           abbrev: 2
             low_pc               (addr) +0x00000000000005d0 <frame_dummy+0x20>
eu-readelf: DIE [d8] cannot get attribute 'frame_base' (data4) value: .debug_loc section missing
Comment 4 Tom de Vries 2021-03-16 10:49:59 UTC
(In reply to Martin Liska from comment #2)
> All right, so it's likely nasm issue, there's reduced test-case:
> 
> $ cat cdef.asm
> %define ARCH_X86_64 1
> %ifndef public_prefix
> %endif
> %define WIN64  0
> %if WIN64 ; Windows x64 ;=================================================
>     %if vzeroupper_required
>     %endif
> %endif
> %macro BRANCH_INSTR 0-*
> %endmacro
> %if ARCH_X86_64
> %macro DUP4 1-*
> %endmacro
>     ret
> %endif ; ARCH_X86_64
> 
> $ cat a.c
> int main(int argc, char **argv)
> {
>   return 0;
> }
> 
> $ nasm -o cdef.o -f elf64 -F dwarf cdef.asm && gcc a.c -O2 -g -shared cdef.o
> -o x.so && dwz x.so
> 
> Apparently, cdef.o contains the section you're seeking for:
> 
> $ readelf -SW cdef.o | grep debug_loc
>   [11] .debug_loc        PROGBITS        0000000000000000 0005c0 000000 00  
> 0   0  1
> 

Yes, the section is there, but empty, so indeed an asm issue.

This ( https://bugzilla.nasm.us/show_bug.cgi?id=3392631 ) looks related.

Marking this resolved-notabug.
Comment 5 Martin Liska 2021-03-16 11:12:50 UTC
> This ( https://bugzilla.nasm.us/show_bug.cgi?id=3392631 ) looks related.

Yep, thanks for the pointer!

> 
> Marking this resolved-notabug.

Sure.
Comment 6 Tom de Vries 2021-03-16 14:21:48 UTC
(In reply to Martin Liska from comment #5)
> > This ( https://bugzilla.nasm.us/show_bug.cgi?id=3392631 ) looks related.
> 
> Yep, thanks for the pointer!
> 
> > 
> > Marking this resolved-notabug.
> 
> Sure.

FWIW, proposed a --devel-skip-producer option here ( https://sourceware.org/pipermail/dwz/2021q1/001121.html ).  When used on this example with "--devel-skip-producer NASM", dwz manages to finish.
Comment 7 Martin Liska 2021-03-16 14:23:56 UTC
> FWIW, proposed a --devel-skip-producer option here (
> https://sourceware.org/pipermail/dwz/2021q1/001121.html ).  When used on
> this example with "--devel-skip-producer NASM", dwz manages to finish.

Good proposal, I like it!
Comment 8 Tom de Vries 2021-05-17 08:57:11 UTC
(In reply to Martin Liska from comment #7)
> > FWIW, proposed a --devel-skip-producer option here (
> > https://sourceware.org/pipermail/dwz/2021q1/001121.html ).  When used on
> > this example with "--devel-skip-producer NASM", dwz manages to finish.
> 
> Good proposal, I like it!

This has been committed, but to clarify: this is a developer-only option for experimentation purposes.  There will be more work involved getting this functionality into a release.  See f.i. comment at https://sourceware.org/pipermail/dwz/2021q1/001138.html .