[PATCH] D86860: [DWARFYAML] Make the debug_str section optional.

Xing GUO via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 31 05:06:21 PDT 2020


Higuoxing added a comment.

Thanks for reviewing! Shall I add a test case that the debug_str string table has an empty string?



================
Comment at: llvm/test/tools/yaml2obj/ELF/DWARF/debug-str.yaml:221
+# RUN: yaml2obj --docnum=10 %s -o %t10.o
+# RUN: llvm-readelf -S %t10.o | FileCheck -DSIZE=000000 %s --check-prefix=SHDRS-DEFAULT
+
----------------
grimar wrote:
> It is a bit strange to see that the `.debug_str` section emitted has zero size?
> I believe that ELF string tables are expected to have at least one null byte
> (https://refspecs.linuxbase.org/elf/gabi4+/ch4.strtab.html)
> 
> With that we have an empty string at the offset 0 and a valid null-terminated string table.
> 
> It is probably unrelated to this patch though.
Sorry, my comments is deleted by an accident.

I think having a debug_str section who has zero size is fine here.

The debug_str string table doesn't start with an empty string. I think having an empty string might not apply here.

```
> llvm-dwarfdump --debug-str a.test 
a.test:        file format ELF64-x86-64

.debug_str contents:
0x00000000: "clang version 10.0.1 "
0x00000016: "/home/v/x/llvm/playground/a.c"
0x00000034: "/home/v/x/llvm/playground"
0x0000004e: "main"
```

Besides, we are able to create a debug_str string table with an empty string with the following YAML description.

```
debug_str:
  - '' ## Empty string.
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86860/new/

https://reviews.llvm.org/D86860



More information about the llvm-commits mailing list