[PATCH] D18499: [ELF] - Implemented prototype of location counter support.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 10:47:05 PDT 2016


grimar added inline comments.

================
Comment at: ELF/LinkerScript.cpp:113
@@ -75,1 +112,3 @@
 
+uint64_t LinkerScript::getSectionVA(StringRef Name, uint64_t VA) {
+  auto It = SecLoc.find(Name);
----------------
ruiu wrote:
> So, it looks like we need to call this function with section names in the same order as the section names appear in the linker script. Is this correct? If so, is that a good API?
> 
> It feel to me that this patch doesn't capture a correct abstraction of the writer and the linker script. Both LinkerScript and Writer have only partial knowledge of the section layout, and the interaction between them is not well defined. I'd like to see a different approach.
> 
> So, if a linker script has a SECTIONS command, the entire file layout is determined by the linker script, right? Can you pass the list of sections or the symbol table to LinkerScript and let it layout all the things?
>> So, it looks like we need to call this function with section names in the same order as the section names appear in the linker script. Is this correct?

No, that not correct.

We are calling this when already have a list of Output sections and just need to assign addresses:
```
for (OutputSectionBase<ELFT> *Sec : OutputSections) {
...
    VA = Script->getSectionVA(Sec->getName(), VA);

```

It does not matter what is the order of sections in script at that time, because we already have a list of outputsections and just iterating over it.
Location counter can not be moved backward, so it can be moved only forward.
We push the VA to script because it uses is to calculate "." variable. It returns back updated location.


http://reviews.llvm.org/D18499





More information about the llvm-commits mailing list