[PATCH] D76742: [lld] Add basic symbol table output

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 8 23:12:56 PDT 2020


ruiu added inline comments.


================
Comment at: lld/MachO/Writer.cpp:356
+
+void Writer::assignSymtabAddresses(uint64_t start) {
+  symtabSeg->symOff = start;
----------------
This function should be called `finalize` and should belong to LCSymtab class instead of Writer.  `nSyms` and `strSize` member variables as well as how to compute the size of symtab are internal details of the symtab section, and Write shouldn't take care of them.

In ELF, we call function in this order:

1. For each output section, call finalize()
2. Call Writer::assignAddresses()
3. For each output section, call write()

(1) finalizes the contents of the section. Each section knows how to compute its size, and the size should be computed by finalize and shouldn't change afterwards.


================
Comment at: lld/MachO/Writer.cpp:375
+// https://github.com/aidansteele/osx-abi-macho-file-format-reference#nlist_64
+void Writer::createSymtabContents() {
+  SmallVector<char, 128> stringTable;
----------------
This should move to LCSymtab as LCSymtab::write(uint8_t *buf). That function should directly write symbol table section contents to a given buffer (specifically without using SmallVector or raw_svector_ostream). I think you should take a look at ELF's writer.cpp as an example how we writer a writer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76742





More information about the llvm-commits mailing list