Menu

#3200 SDCC generates ELF with invalid DWARF info

open
Build
3
2023-06-06
2021-03-23
No

I am really stuck on this issue: I'm trying to get debugging working, which was successful before when I've only compiled one single file (https://github.com/maxgerhardt/stm8-headers-pio). Now I'm compiling STMicro's SPL framework, a simple SPL-Blink example. The resulting ELF file however has broken DWARF information, and stm8-gdb (stm8-binutils-gdb.sourceforge.io/) as well as readelf -wi complain about this, making debugging impossible.

 <2><b0>: Abbrev Number: 3 (DW_TAG_structure_type)
    <b1>   DW_AT_sibling     : <0x105>
    <b5>   DW_AT_name        : GPIO_struct
    <c1>   DW_AT_byte_size   : 5
 <3><c2>: Abbrev Number: 4 (DW_TAG_volatile_type)
    <c3>   DW_AT_type        : <0x11a>readelf: Warning: Unable to find entry for abbreviation 117

 [...]
  <1><411>: Abbrev Number: 15 (DW_TAG_variable)
    <412>   DW_AT_location    : 5 byte block: 3 0 0 80 8c       (DW_OP_addr: 808c)
    <418>   DW_AT_name        : __str_0
    <420>   DW_AT_type        : <0x405>readelf: Warning: Unable to find entry for abbreviation 0

 <1><424>: Abbrev Number: 0
 <0><425>: Abbrev Number: 0
readelf: Warning: Bogus end-of-siblings marker detected at offset 425 in .debug_info section
 <-1><426>: Abbrev Number: 0
readelf: Warning: Bogus end-of-siblings marker detected at offset 426 in .debug_info section
  Compilation Unit @ offset 0x427:

Using latest SDCC 4.1.

sdcc --version
SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/gbz80/tlcs90/ez80_z80/z80n/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15 4.1.0 #12072 (MINGW64)
published under GNU General Public License (GPL)

Exact compiler invocations are listed per https://pastebin.com/5GBbzL89
Full readelf -wi output is listed per https://pastebin.com/tz2Sjver

Reproduction:

  1. Install PlatformIO (https://docs.platformio.org/en/latest/core/installation.html#super-quick-mac-linux)
  2. Clone https://github.com/maxgerhardt/platform-ststm8/tree/patch-1/examples/spl-blink (must be the patch-1 branch
  3. Add build_type = debug to the end of the platformio.ini
  4. Use pio run -e stm8sblue in the project folder to compile it.
  5. Inspect resulting build artifact using readelf -wi .pio/build/stm8sblue/firmware.elf
  6. See multiple errors per above.
  7. Attempt to load firmware.elf into stm8-gdb with `stm8-gdb <firmware.elf></firmware.elf>
  8. Be greeted with
Dwarf Error: Could not find abbrev number 117 in CU at offset 0x0
(no debugging symbols found)...done.

Any help is appreciated.

Related

Bugs: #3303
Wiki: SDCC-STD-UX

Discussion

  • Maximilian Gerhardt

    Woops, one misplaced formatting option makes the above text a bit hard to read, but I can't edit my tickets to fix it. Needs a moderator?

     
  • Benedikt Freisen

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -20,7 +20,7 @@
      &lt;-1&gt;&lt;426&gt;: Abbrev Number: 0
     readelf: Warning: Bogus end-of-siblings marker detected at offset 426 in .debug_info section
       Compilation Unit @ offset 0x427:
    
    -  ```
    +```
    
     Using latest SDCC 4.1. 
    
    @@ -33,6 +33,7 @@
    
    
     Reproduction:
    +
    
     1. Install PlatformIO (https://docs.platformio.org/en/latest/core/installation.html#super-quick-mac-linux)
     2. Clone https://github.com/maxgerhardt/platform-ststm8/tree/patch-1/examples/spl-blink (must be the `patch-1` branch 
     3.  Add `build_type = debug` to the end of the `platformio.ini`
    
     
  • Erik Petrich

    Erik Petrich - 2021-07-09
    • assigned_to: Erik Petrich
     
  • Erik Petrich

    Erik Petrich - 2021-07-09

    The "Bogus end-of-siblings marker detected..." problems should be fixed in [r12536]

    However, I haven't been able to reproduce the "Could not find abbrev number ..." problem. This may be because I could not find the patch-1 branch and used the develop branch instead, or this may be totally unrelated. The pastebin files seem to have evaporated by the time I had free time to look at this ticket, so there is nothing helpful there. If you still have it, please attach the firmware.elf file that you are trying to debug directly to this ticket.

     
    • Maximilian Gerhardt

      Thanks, I'll have another shot at reproducing this with the latest released development version, and reupload the pastebin files if necessary / still occurring.

       
    • Maximilian Gerhardt

      This is still not fixed. Getting the exact same error when using https://sourceforge.net/projects/sdcc/files/snapshot_builds/x86_64-w64-mingw32/sdcc-snapshot-x86_64-w64-mingw32-20211003-12697.zip/download as my toolchain.

      Getting

      Reading symbols from .\.pio\build\debug\firmware.elf...Dwarf Error: Could not find abbrev number 117 in CU at offset 0x0 [in module C:\Users\Max\temp\Blink_PIO_STM8\.pio\build\debug\firmware.elf]
      

      in stm8-gdb when using that toolchain in PlatformIO. (Which I do by adding

      platform_packages =
         toolchain-sdcc@file://C:\Users\Max\Downloads\sdcc-snapshot-x86_64-w64-mingw32-20211003-12697\sdcc
      

      in my platformio.ini , the above folder (sourced from the referenced snapshot) needs to have a package.json file in it as attached.

      The build log and ELF file are attached.

      Still struggling with the same problem :(.

       
  • Maarten Brock

    Maarten Brock - 2021-07-19

    reupload the pastebin files
    Please do not use pastebin, github or any other upload website. Sourceforge can perfectly handle uploads right here.

     

Log in to post a comment.

MongoDB Logo MongoDB