[PATCH] D16991: Split the creation of program headers in a few steps

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 11:12:24 PST 2016


ruiu accepted this revision.
ruiu added a comment.

LGTM


================
Comment at: ELF/Writer.cpp:1261
@@ -1274,4 +1260,3 @@
   if (isOutputDynamic()) {
-    Elf_Phdr *PH = &Phdrs[++PhdrIdx];
-    PH->p_type = PT_DYNAMIC;
-    copyPhdr(PH, Out<ELFT>::Dynamic);
+    Phdr &Hdr =
+        *AddHdr(PT_DYNAMIC, toPhdrFlags(Out<ELFT>::Dynamic->getFlags()));
----------------
nit: Can it fit in 80 cols if you rename H?

================
Comment at: ELF/Writer.cpp:1325
@@ +1324,3 @@
+
+    if (needsPhdr<ELFT>(Sec)) {
+      // Don't allocate VA space for TLS NOBITS sections. The PT_TLS PHDR is
----------------
Please leave a comment that sections that are not in any PHDRs don't have VA (because they are not mapped to anywhere at runtime).

================
Comment at: ELF/Writer.cpp:1448-1451
@@ -1416,1 +1447,6 @@
+  auto *HBuf = reinterpret_cast<Elf_Phdr *>(Buf + EHdr->e_phoff);
+  for (Phdr &P : Phdrs) {
+    memcpy(HBuf, &P.H, sizeof(Phdrs[0].H));
+    ++HBuf;
+  }
 
----------------
I think you can do

  for (Phdr & P : Phdrs)
    *HBuf++ = P.H;


Repository:
  rL LLVM

http://reviews.llvm.org/D16991





More information about the llvm-commits mailing list