[PATCH] D39096: [ELF] - Generalize finding output section by name.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 25 04:35:34 PDT 2017


grimar added inline comments.


================
Comment at: ELF/LinkerScript.cpp:107
+  OutputSection *Sec = NameToOutputSection.lookup(Name);
+  if (!Sec || Sec->Location.empty())
+    return nullptr;
----------------
ruiu wrote:
> What does `Location.empty()` mean?
It is the same as check in `LinkerScript::createOutputSection`.

When we parse scripts, sometimes we have forward references to sections,
like in following script (from addr-zero.s):
```
SECTIONS { foo = ADDR(.text) - ABSOLUTE(ADDR(.text)); };
```

In that case script parser calls `getOrCreateOutputSection` to declare output section early,
then `Factory.addInputSec` calls `createOutputSection` to define it and sets `Location`.

This function returns sections only if it was already defined (processed by factory).



https://reviews.llvm.org/D39096





More information about the llvm-commits mailing list