On 12/19/22 16:09, Mark Wielaard wrote: > Hi Martin, > > On Mon, 2022-12-19 at 15:19 +0100, Martin Liška wrote: >> On 12/15/22 14:17, Mark Wielaard wrote: >>> Is there a particular way you are running eu-readelf? Is it with >>> generic -w or -a, or decoding a specific section type? >> >> Hello. >> >> $ LD_LIBRARY_PATH=./libelf ./src/readelf -w >> ~/Programming/testcases/a.out >> >> where I get: >> >> ./src/readelf: cannot get debug context descriptor: No DWARF >> information found >> >> DWARF section [37] '.debug_info' at offset 0x1ab2: >> [Offset] >> ./src/readelf: cannot get next unit: no error >> >> Call frame information section [13] '.eh_frame' at offset 0x4a8: >> ... >> >> >> t��o5��=I�iAp@a����S^R/<�����^�qi�ַp@ > > [...] > >> So basically a garbage. And I don't know how to bail out properly? > > Aha. If you have that a.out somewhere I can take a look. I suspect this > is because we expect all .debug sections to have been decompressed in > libdw/dwarf_begin_elf.c, but that isn't really true, see check_section > in that file which has: > > if ((shdr->sh_flags & SHF_COMPRESSED) != 0) > { > if (elf_compress (scn, 0, 0) < 0) > { > /* It would be nice if we could fail with a specific error. > But we don't know if this was an essential section or not. > So just continue for now. See also valid_p(). */ > return result; > } > }
Sure, there's a file example: https://splichal.eu/tmp/zstd.out $ ./src/readelf -Sz zstd.out ... [35] .debug_abbrev PROGBITS 0000000000000000 000018b4 00000177 0 C 0 0 1 [ELF ZSTD (2) 00000318 1] $ LD_LIBRARY_PATH=libelf/ ./src/readelf -w zstd.out (prints garbage if not configured with zstd) Please use code from my branch: https://sourceware.org/git/?p=elfutils.git;a=shortlog;h=refs/heads/users/marxin/try-zstd-support-v2 Cheers, Martin > > We should probably adjust valid_p so it produces a more appropriate > error message and/or add additional checks in readlelf.c. > > But lets do that after this patch goes in. > > Cheers, > > Mark