[PATCH] D24795: [ELF] Linkerscript: Try to put section to the last PT_LOAD, in case there is no exact segment specification

Eugene Leviant via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 19 07:18:12 PDT 2016


evgeny777 added inline comments.


================
Comment at: ELF/LinkerScript.cpp:700
+
+    if (DefPhdrIds.empty() && Phdr.H.p_type == PT_LOAD)
+      DefPhdrIds.push_back(Ret.size() - 1);
----------------
rafael wrote:
> Add a comment saying what you are doing. If I understand it, this just puts the first PT_LOAD from PHDRS in the vector. Also add a comment saying what the vector is.
Yes you're right. If we don't have phdr spec for section and hasn't added any section yet, then we'll simply put section to the very first PT_LOAD found. Here is an example:

```
PHDRS { segment PT_LOAD; }
SECTIONS {
   .aaa : { *(.aaa) }
   .bbb : { *(.bbb) } : segment
}
```
Of course this script is malformed, but this happens.



================
Comment at: ELF/LinkerScript.cpp:713
+
     if (!PhdrIds.empty()) {
       // Assign headers specified by linker script
----------------
rafael wrote:
> This if is not necessary anymore, no?
Not exactly. You may have no PT_LOAD segments in PHDRS directive. GNU gold (bunutils 2.26) crashes in such case. I think we shouldn't


https://reviews.llvm.org/D24795





More information about the llvm-commits mailing list