[PATCH] D69160: [obj2yaml] - Stop triggering UB when dumping corrupted strings.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 20 08:50:58 PDT 2019


grimar marked an inline comment as done.
grimar added inline comments.


================
Comment at: test/tools/obj2yaml/invalid-section-name.yaml:31
+    Type: SHT_STRTAB
+    Content: "00FEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFE00"
----------------
MaskRay wrote:
> Does a shorter sequence work?
For this particular test "00FE00" works fine.

But in this case another sections produced (.strtab, .shstrtab) get a sh_name larger than the section name string table size though.
e.g. sh_name=5. 

Then if we use "llvm-readobj -a" for the object produced, we'll have an error like
"error: '1.o': a section [index 3] has an invalid sh_name (0xf) offset which goes past the end of the section name string table"

A minimal sequence that allowes llvm-readobj -a to pass is

```
Content: "00FEFEFEFEFEFEFEFEFEFEFEFEFEFE00"
```

I wasn't sure what to use here. I had a feeling that it is a bit tricky place and is not the best candidate for optimization,
so even added s few more "FE" just in case.


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

https://reviews.llvm.org/D69160





More information about the llvm-commits mailing list