[PATCH] D27458: [ELF] - Teach LLD to recognize PT_OPENBSD_BOOTDATA

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 6 08:19:17 PST 2016


grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777.

Minor patch to fix PR31288

OpenBSD commit:
https://github.com/openbsd/src/commit/d39116912b9536bd77326260dc5c6e593fd4ee24


https://reviews.llvm.org/D27458

Files:
  ELF/LinkerScript.cpp
  test/ELF/linkerscript/openbsd-bootdata.s


Index: test/ELF/linkerscript/openbsd-bootdata.s
===================================================================
--- test/ELF/linkerscript/openbsd-bootdata.s
+++ test/ELF/linkerscript/openbsd-bootdata.s
@@ -0,0 +1,23 @@
+# RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t.o
+# RUN: echo "PHDRS { text PT_LOAD FILEHDR PHDRS; boot PT_OPENBSD_BOOTDATA; } \
+# RUN:       SECTIONS { . = SIZEOF_HEADERS; \
+# RUN:         .text : { *(.text) } \
+# RUN:         .openbsd.bootdata : { *(.openbsd.bootdata) } : boot }" > %t.script
+# RUN: ld.lld --script %t.script %t.o -o %t
+# RUN: llvm-readobj --program-headers -s %t | FileCheck %s
+
+# CHECK:      ProgramHeader {
+# CHECK:        Type: PT_OPENBSD_BOOTDATA (0x65A41BE6)
+# CHECK-NEXT:   Offset: 0x74
+# CHECK-NEXT:   VirtualAddress: 0x74
+# CHECK-NEXT:   PhysicalAddress: 0x74
+# CHECK-NEXT:   FileSize: 8
+# CHECK-NEXT:   MemSize: 8
+# CHECK-NEXT:   Flags [ (0x4)
+# CHECK-NEXT:     PF_R (0x4)
+# CHECK-NEXT:   ]
+# CHECK-NEXT:   Alignment: 1
+# CHECK-NEXT: }
+
+.section .openbsd.bootdata, "a"
+.quad 0
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -1859,6 +1859,7 @@
                      .Case("PT_GNU_RELRO", PT_GNU_RELRO)
                      .Case("PT_OPENBSD_RANDOMIZE", PT_OPENBSD_RANDOMIZE)
                      .Case("PT_OPENBSD_WXNEEDED", PT_OPENBSD_WXNEEDED)
+                     .Case("PT_OPENBSD_BOOTDATA", PT_OPENBSD_BOOTDATA)
                      .Default(-1);
 
   if (Ret == (unsigned)-1) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27458.80421.patch
Type: text/x-patch
Size: 1581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161206/6db7d894/attachment.bin>


More information about the llvm-commits mailing list