[PATCH] D36256: [ELF] Don't output headers into a segment if there's no space for them

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 18 01:21:13 PDT 2017


grimar added inline comments.


================
Comment at: ELF/LinkerScript.cpp:725
       break;
+    } else if (Sec->FirstInPtLoad == Out::ProgramHeaders) {
+      ActualFirst = Sec;
----------------
Why do you need this change ?


================
Comment at: ELF/LinkerScript.cpp:736
+        Sec->FirstInPtLoad = ActualFirst;
+    }
     FirstPTLoad->First = ActualFirst;
----------------
And this one ?

I removed both and had no no any test failtures:

```
  OutputSection *ActualFirst = nullptr;
  for (OutputSection *Sec : OutputSections) {
    if (Sec->FirstInPtLoad == Out::ElfHeader) {
      ActualFirst = Sec;
      break;
    }
  }
  if (ActualFirst) {
    for (OutputSection *Sec : OutputSections)
      if (Sec->FirstInPtLoad == Out::ElfHeader)
        Sec->FirstInPtLoad = ActualFirst;
    FirstPTLoad->First = ActualFirst;
  } else {
    Phdrs.erase(It);
  }
```


================
Comment at: test/ELF/linkerscript/segment-headers.s:3
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "SECTIONS { \
+# RUN:   . = 0x2000; \
----------------
This can be single line probably.
echo "SECTIONS { . = 0x2000; .text : AT(0x100000) { *(.text)  } }" > %t.script


================
Comment at: test/ELF/linkerscript/segment-headers.s:26
+# CHECK-NEXT:   }
+# CHECK-NEXT:   ProgramHeader {
+# CHECK-NEXT:     Type: PT_GNU_STACK (0x6474E551)
----------------
Do you need to check anything except first load ?


Repository:
  rL LLVM

https://reviews.llvm.org/D36256





More information about the llvm-commits mailing list