[lld] r262331 - Produce PT_NOTE program headers.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 1 05:23:30 PST 2016
Author: rafael
Date: Tue Mar 1 07:23:29 2016
New Revision: 262331
URL: http://llvm.org/viewvc/llvm-project?rev=262331&view=rev
Log:
Produce PT_NOTE program headers.
Added:
lld/trunk/test/ELF/note.s
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=262331&r1=262330&r2=262331&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Mar 1 07:23:29 2016
@@ -1247,6 +1247,7 @@ template <class ELFT> void Writer<ELFT>:
Phdr TlsHdr(PT_TLS, PF_R);
Phdr RelRo(PT_GNU_RELRO, PF_R);
+ Phdr Note(PT_NOTE, PF_R);
for (OutputSectionBase<ELFT> *Sec : OutputSections) {
if (!(Sec->getFlags() & SHF_ALLOC))
break;
@@ -1273,6 +1274,8 @@ template <class ELFT> void Writer<ELFT>:
if (isRelroSection(Sec))
AddSec(RelRo, Sec);
+ if (Sec->getType() == SHT_NOTE)
+ AddSec(Note, Sec);
}
// Add the TLS segment unless it's empty.
@@ -1301,6 +1304,9 @@ template <class ELFT> void Writer<ELFT>:
// pages for the stack non-executable.
if (!Config->ZExecStack)
AddHdr(PT_GNU_STACK, PF_R | PF_W);
+
+ if (Note.First)
+ Phdrs.push_back(std::move(Note));
}
// Used for relocatable output (-r). In this case we create only ELF file
Added: lld/trunk/test/ELF/note.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/note.s?rev=262331&view=auto
==============================================================================
--- lld/trunk/test/ELF/note.s (added)
+++ lld/trunk/test/ELF/note.s Tue Mar 1 07:23:29 2016
@@ -0,0 +1,18 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: ld.lld %t.o -o %t -shared
+// RUN: llvm-readobj -program-headers %t | FileCheck %s
+
+// CHECK: Type: PT_NOTE
+// CHECK-NEXT: Offset:
+// CHECK-NEXT: VirtualAddress:
+// CHECK-NEXT: PhysicalAddress:
+// CHECK-NEXT: FileSize: 8
+// CHECK-NEXT: MemSize: 8
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: PF_R
+// CHECK-NEXT: ]
+// CHECK-NEXT: Alignment: 1
+
+ .section .note.test,"a", at note
+ .quad 42
More information about the llvm-commits
mailing list