[PATCH] MachObjectWriter: optimize the string table for common suffices

David Majnemer david.majnemer at gmail.com
Sun Oct 5 18:38:05 PDT 2014


LGTM

================
Comment at: lib/MC/StringTableBuilder.cpp:72
@@ -68,2 +71,3 @@
+      StringTable += '\x00';
   }
 }
----------------
Would it make sense to have an else clause that asserted the kind was ELF? Maybe use a fully covered switch? My thinking is that it would make it easier to catch potential bugs if we ever added a new object file format.

================
Comment at: test/MC/MachO/variable-exprs.s:208
@@ -207,3 +207,3 @@
 // CHECK-I386:     ('n_desc', 0)
-// CHECK-I386:     ('n_value', 4)
+// CHECK-I386:     ('n_value', 7)
 // CHECK-I386:     ('_string', 'd2')
----------------
hans wrote:
> This is the only part where I'm not sure what's going on :/
Obligatory arcane Mach-O infodump:
> If the type is N_INDR then the symbol is defined to be the same as another symbol. 
> In this case the n_value field is an index into the string table of the other symbol's name.

`d2` is defined to be the same as `d`.  `d` has a `n_strx` of 7.  This means that `d2` should have an `n_value` of 7 as well.

http://reviews.llvm.org/D5622






More information about the llvm-commits mailing list