]> granicus.if.org Git - llvm/commitdiff
Merging r292167:
authorHans Wennborg <hans@hanshq.net>
Thu, 2 Feb 2017 21:44:30 +0000 (21:44 +0000)
committerHans Wennborg <hans@hanshq.net>
Thu, 2 Feb 2017 21:44:30 +0000 (21:44 +0000)
------------------------------------------------------------------------
r292167 | davide | 2017-01-16 14:01:41 -0800 (Mon, 16 Jan 2017) | 3 lines

[llvm-objdump] Dump PT_OPENBSD_{BOOTDATA,RANDOMIZE,WXNEEDED}.

PR: 31641
------------------------------------------------------------------------
Merging r292169:
------------------------------------------------------------------------
r292169 | davide | 2017-01-16 14:58:26 -0800 (Mon, 16 Jan 2017) | 3 lines

[llvm-objdump] Dump PT_GNU_RELRO as part of -p.

PR: 31641
------------------------------------------------------------------------
Merging r292170:
------------------------------------------------------------------------
r292170 | davide | 2017-01-16 15:13:46 -0800 (Mon, 16 Jan 2017) | 3 lines

[llvm-objdump] Dump PT_NOTE as part of -p.

PR: 31641
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@293942 91177308-0d34-0410-b5e6-96231b3b80d8

test/Object/Inputs/phdr-note.elf-x86-64 [new file with mode: 0755]
test/Object/Inputs/phdrs.elf-x86-64 [new file with mode: 0755]
test/tools/llvm-objdump/X86/openbsd-headers.test [new file with mode: 0644]
test/tools/llvm-objdump/X86/phdrs.test [new file with mode: 0644]
tools/llvm-objdump/ELFDump.cpp

diff --git a/test/Object/Inputs/phdr-note.elf-x86-64 b/test/Object/Inputs/phdr-note.elf-x86-64
new file mode 100755 (executable)
index 0000000..2825c68
Binary files /dev/null and b/test/Object/Inputs/phdr-note.elf-x86-64 differ
diff --git a/test/Object/Inputs/phdrs.elf-x86-64 b/test/Object/Inputs/phdrs.elf-x86-64
new file mode 100755 (executable)
index 0000000..078574a
Binary files /dev/null and b/test/Object/Inputs/phdrs.elf-x86-64 differ
diff --git a/test/tools/llvm-objdump/X86/openbsd-headers.test b/test/tools/llvm-objdump/X86/openbsd-headers.test
new file mode 100644 (file)
index 0000000..48f496c
--- /dev/null
@@ -0,0 +1,20 @@
+## openbsd-phdrs.elf-x86-64 was generated using GNU ld (GNU Binutils for Ubuntu) 2.26.1.
+## llvm-mc -filetype=obj -triple=x86_64-pc-linux test.s -o main.o
+## ld -script linker.script main.o -o openbsd-phdrs.elf-x86-64
+##
+## test.s is an empty file.
+## linker.script:
+## PHDRS { text PT_LOAD FILEHDR PHDRS; foo 0x65a3dbe6; bar 0x65a3dbe7; zed 0x65a41be6; }
+##   Where 0x65a3dbe6 is the value of PT_OPENBSD_RANDOMIZE,
+##         0x65a3dbe7 is the value of PT_OPENBSD_WXNEEDED,
+##         0x65a41be6 is the value of PT_OPENBSD_BOOTDATA
+## SECTIONS { . = SIZEOF_HEADERS; .all : { *(.*) } : text }
+RUN: llvm-objdump -p %p/../../../Object/Inputs/openbsd-phdrs.elf-x86-64 \
+RUN:     | FileCheck %s
+
+CHECK: OPENBSD_RANDOMIZE off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**3
+CHECK-NEXT:      filesz 0x0000000000000000 memsz 0x0000000000000000 flags ---
+CHECK-NEXT: OPENBSD_WXNEEDED off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**3
+CHECK-NEXT:      filesz 0x0000000000000000 memsz 0x0000000000000000 flags ---
+CHECK-NEXT: OPENBSD_BOOTDATA off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**3
+CHECK-NEXT:      filesz 0x0000000000000000 memsz 0x0000000000000000 flags ---
diff --git a/test/tools/llvm-objdump/X86/phdrs.test b/test/tools/llvm-objdump/X86/phdrs.test
new file mode 100644 (file)
index 0000000..646f6af
--- /dev/null
@@ -0,0 +1,32 @@
+## phdrs.elf-x86-64 was generated using lld (3.9).
+## llvm-mc -filetype=obj -triple=x86_64-unknown-linux test.s -o test.o
+## lld test.o -o phdrs.elf-x86-64
+##
+## test.s:
+## .global _start
+## _start:
+##
+## .global d
+## .section .foo,"awT",@progbits
+## d:
+## .long 2
+##
+RUN: llvm-objdump -p %p/../../../Object/Inputs/phdrs.elf-x86-64 \
+RUN:     | FileCheck %s
+
+CHECK: RELRO off    0x0000000000001000 vaddr 0x0000000000201000 paddr 0x0000000000201000 align 2**0
+CHECK-NEXT:      filesz 0x0000000000000004 memsz 0x0000000000001000 flags r--
+
+## phdr-note.elf-x86-64 was generated using lld (3.9).
+## llvm-mc -filetype=obj -triple=x86_64-pc-linux test.s -o test.o
+## lld test.o -o phdr-note.elf-x86-64 -shared
+##
+## test.s:
+##       .section        .note.test,"a",@note
+##       .quad 42
+
+RUN: llvm-objdump -p %p/../../../Object/Inputs/phdr-note.elf-x86-64 \
+RUN:     | FileCheck %s --check-prefix=NOTE
+
+NOTE: NOTE off    0x0000000000000200 vaddr 0x0000000000000200 paddr 0x0000000000000200 align 2**0
+NOTE-NEXT:       filesz 0x0000000000000008 memsz 0x0000000000000008 flags r--
index aa6aa94ccd9e1f72cd1a73748cb686519ef3291c..7f5fe5a9d3b8893f3d2de2718f5858448e887545 100644 (file)
@@ -36,6 +36,9 @@ template <class ELFT> void printProgramHeaders(const ELFFile<ELFT> *o) {
     case ELF::PT_GNU_EH_FRAME:
       outs() << "EH_FRAME ";
       break;
+    case ELF::PT_GNU_RELRO:
+      outs() << "   RELRO ";
+      break;
     case ELF::PT_GNU_STACK:
       outs() << "   STACK ";
       break;
@@ -45,6 +48,18 @@ template <class ELFT> void printProgramHeaders(const ELFFile<ELFT> *o) {
     case ELF::PT_LOAD:
       outs() << "    LOAD ";
       break;
+    case ELF::PT_NOTE:
+      outs() << "    NOTE ";
+      break;
+    case ELF::PT_OPENBSD_BOOTDATA:
+      outs() << "    OPENBSD_BOOTDATA ";
+      break;
+    case ELF::PT_OPENBSD_RANDOMIZE:
+      outs() << "    OPENBSD_RANDOMIZE ";
+      break;
+    case ELF::PT_OPENBSD_WXNEEDED:
+      outs() << "    OPENBSD_WXNEEDED ";
+      break;
     case ELF::PT_PHDR:
       outs() << "    PHDR ";
       break;