[PATCH] D41657: Do not look up symbol names when n_strx == 0

Kevin Enderby via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 3 14:34:38 PST 2018

enderby accepted this revision.
enderby added a comment.

Looks good to me with the update of the one comment.

Comment at: lib/Object/MachOObjectFile.cpp:1662
   MachO::nlist_base Entry = getSymbolTableEntryBase(*this, Symb);
+  // contents of the StringTable at n_strx 0 are not defined
+  if (Entry.n_strx == 0)
Mach-O back in 1988 when I created it, was based on 4.2 BSD Unix.  In there there it states "A n_strx value of 0 indicates that no name is associated with a particular symbol table entry".  Also the a.out(5) format at that time had the size of the string table as the first 4 bytes of the string table, so valid string table indexes where 4 or more.  In the early days of Mach-O since the load command had the string table size, tools still reserved these 4 bytes.  And generally put nulls in them so incase some tool did not correctly understand index 0 was special it would "just work".

So I would update or remove this comment.


More information about the llvm-commits mailing list