[PATCH] D59496: [llvm-objcopy] - Fix a st_name of the first symbol table entry.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 02:29:16 PDT 2019


grimar added a comment.

I need a bit more time to investigate this I think.

Spec says that "The first byte, which is index zero, holds a null character. 
Likewise, a string table's last byte holds a null character, ensuring null termination for all strings.
A string whose index is zero specifies either no name or a null name, depending on the context."
(https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-73709.html)

So looks like I was wrong and string table builder just really should not optimize the first zero bytes for ELF tables.
I.e. we should have 2 zero bytes, at the start and at the end: "\0bat\0".

Also, I observe that LLD's string tables produced do not start with a zero byte. It uses
`StringTableBuilder::RAW` type of builders for threaded building intentionally though.
Seems we just do not conform spec a bit there (perhaps we need to add a zero byte manually on a linker side).


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

https://reviews.llvm.org/D59496





More information about the llvm-commits mailing list