[PATCH] D91943: [llvm-readelf/obj] - Fix the possible crash when dumping group sections.

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 23 01:29:09 PST 2020

jhenderson added inline comments.

Comment at: llvm/test/tools/llvm-readobj/ELF/groups.test:389
+## We set the content of the string table to '0061626300' ('\0abc\0') to fixup the size of the string table.
+# RUN: yaml2obj %s -DSTRTABCONTENT="0061626300" -DSYM1STNAME=4 -DSYM2STNAME=5 -o %t.signame.o
grimar wrote:
> jhenderson wrote:
> > I'm confused. Why do we need to do this, rather than just specifying an arbitrarily large `StName` value greater than the string table size?
> I am testing 2 cases here:
> 1) (OK) When the `StName` == [size of string table - 1]
> 2) (FAIL) When `StName` == size of string table
> I think we should know its size for this test and test values on border.
> It can be done easier when the content of the string table is known.
> Also in the test below I am changing the content to remove the zero terminator, keeping `st_name` values the same.
> This proves that we can never read past the end of the string table and that way we can't have a situation of reading
> past the EOF.
Okay, perhaps worth adding to the commetn that setting the string table contents explicitly makes it easier to show the boundary conditions, or something like effect.

  rG LLVM Github Monorepo



More information about the llvm-commits mailing list