[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
Tue Mar 19 06:47:12 PDT 2019


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


================
Comment at: tools/llvm-objcopy/ELF/Object.cpp:308-309
 uint32_t StringTableSection::findIndex(StringRef Name) const {
+  if (Name.empty())
+    return 0;
   return StrTabBuilder.getOffset(Name);
----------------
jhenderson wrote:
> I'm thinking that the `StrTabBuilder` class should actually store an empty string explicitly, rather than have an implicit one as it currently does. That would allow you to do `findIndex` with an empty string, with no problem.
I am not sure I understand. `StrTabBuilder` is an instance of `llvm/MC/StringTableBuilder` class. 
It is used for `enum Kind { ELF, WinCOFF, MachO, RAW, DWARF };` string tables.

Now it works fine for adding the empty string or any other strings.
Empty string's offset is not guaranteed to have a zero offset after the optimization and it seems
fine to me. Why would string builder need to know we need to have a zero offset for no-string (empty) ELF only case?




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

https://reviews.llvm.org/D59496





More information about the llvm-commits mailing list