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

Eugene Leviant via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 28 13:22:13 PDT 2016


evgeny777 added inline comments.

================
Comment at: ELF/LinkerScript.cpp:67
@@ +66,3 @@
+
+  // This section should never be written.
+  Hdr.sh_type = SHT_NOBITS;
----------------
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.

================
Comment at: ELF/LinkerScript.cpp:179-182
@@ +178,6 @@
+      for (const std::unique_ptr<BaseCommand> &Base2 : Cmd->Commands)
+        if (auto *Assignment = dyn_cast<SymbolAssignment>(Base2.get()))
+          PendingSymbols.push_back(Assignment);
+        else
+          AddMultiple(Cmd->Name, cast<InputSectionDescription>(Base2.get()));
+
----------------
ruiu wrote:
> I do not understand why you needed a concept of "pending" here. You can add a SymbolInputSection as soon as you see a new SymbolAssignment, can't you?
Imagine the symbol is declared before any input section rule, like in the sample below:

```
.foo : { begin_foo = .; *(.foo) }
```

Which output section will own it? You can't create output section given symbol assignment command, because you know only section name, not section attributes, which can be obtained only from InputSectionBase<ELFT>.


Repository:
  rL LLVM

https://reviews.llvm.org/D22683





More information about the llvm-commits mailing list