[PATCH] D22683: [ELF] Symbol assignment within input section list

Rafael Ávila de Espíndola via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 29 09:56:09 PDT 2016


rafael added inline comments.

================
Comment at: ELF/LinkerScript.cpp:67
@@ +66,3 @@
+
+  // This section should never be written.
+  Hdr.sh_type = SHT_NOBITS;
----------------
evgeny777 wrote:
> ruiu wrote:
> > It's a bit misleading. This section is written, but because it is empty, there's nothing to be written in reality.
> Not exactly. If you don't set SHT_NOBITS, lld will *attempt* to write the section and fail because file pointer is set to null.
Include something like that in the comment.

================
Comment at: ELF/LinkerScript.cpp:71
@@ +70,3 @@
+  SymbolBody *B = Symtab<ELFT>::X->find(Cmd->Name);
+  if ((!B && !Cmd->Provide) || (B && B->isUndefined())) {
+    typename ELFT::Sym Sym = {};
----------------
This logic is duplicated with addAbsoluteSymbols. We probably need a predicate.

================
Comment at: ELF/LinkerScript.cpp:85
@@ +84,3 @@
+    // OutSecOff is added to value in getSymVA().
+    Regular->Value = Cmd->Expression(this->OutSecOff) - this->OutSecOff;
+}
----------------
This is a bit odd.

The way normal DefinedRegular symbols are handled is to have a Value that is the offset in the input section. In this case, since the input section is a dummy empty section that should always be 0.

It is the offset of the input section in the output section that we should be computing.



Repository:
  rL LLVM

https://reviews.llvm.org/D22683





More information about the llvm-commits mailing list