[llvm] [llvm-readobj] Add support for the PT_OPENBSD_NOBTCFI segment type. (PR #67239)
Frederic Cambus via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 23 07:17:25 PDT 2023
https://github.com/fcambus created https://github.com/llvm/llvm-project/pull/67239
Reference: https://github.com/openbsd/src/blob/master/sys/sys/exec_elf.h
>From 56a7a057767d5696fd86b638f3864a4d244d26aa Mon Sep 17 00:00:00 2001
From: Frederic Cambus <fred at statdns.com>
Date: Sat, 23 Sep 2023 15:43:14 +0200
Subject: [PATCH] [llvm-readobj] Add support for the PT_OPENBSD_NOBTCFI segment
type.
Reference: https://github.com/openbsd/src/blob/master/sys/sys/exec_elf.h
---
.../llvm-readobj/ELF/program-headers.test | 244 ++++++++++--------
llvm/tools/llvm-readobj/ELFDumper.cpp | 1 +
2 files changed, 133 insertions(+), 112 deletions(-)
diff --git a/llvm/test/tools/llvm-readobj/ELF/program-headers.test b/llvm/test/tools/llvm-readobj/ELF/program-headers.test
index 087876adc29a9ef..702a06b6403f0a1 100644
--- a/llvm/test/tools/llvm-readobj/ELF/program-headers.test
+++ b/llvm/test/tools/llvm-readobj/ELF/program-headers.test
@@ -29,66 +29,68 @@
# RUN: FileCheck %s --check-prefixes=ELF64,MAPPING --strict-whitespace --match-full-lines
# RUN: llvm-readobj -l %t64.elf | FileCheck %s --check-prefixes=ELF-LLVM,ELF64-LLVM
-# ELF32:There are 24 program headers, starting at offset 52
+# ELF32:There are 25 program headers, starting at offset 52
# ELF32-EMPTY:
# ELF32-NEXT:Program Headers:
# ELF32-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
-# ELF32-NEXT: PHDR 0x000334 0x00001000 0x00001000 0x00003 0x00003 W 0x1
-# ELF32-NEXT: PHDR 0x000337 0x00002000 0x00002000 0x00007 0x00007 E 0x1
-# ELF32-NEXT: NULL 0x000337 0x00002000 0x00002000 0x00007 0x00007 E 0x1
-# ELF32-NEXT: DYNAMIC 0x000334 0x00001000 0x00001000 0x00003 0x00003 RWE 0x1
-# ELF32-NEXT: INTERP 0x00033e 0x00003000 0x00003000 0x00004 0x00004 RW 0x1
+# ELF32-NEXT: PHDR 0x000354 0x00001000 0x00001000 0x00003 0x00003 W 0x1
+# ELF32-NEXT: PHDR 0x000357 0x00002000 0x00002000 0x00007 0x00007 E 0x1
+# ELF32-NEXT: NULL 0x000357 0x00002000 0x00002000 0x00007 0x00007 E 0x1
+# ELF32-NEXT: DYNAMIC 0x000354 0x00001000 0x00001000 0x00003 0x00003 RWE 0x1
+# ELF32-NEXT: INTERP 0x00035e 0x00003000 0x00003000 0x00004 0x00004 RW 0x1
# ELF32-NEXT: [Requesting program interpreter: ABC]
-# ELF32-NEXT: NOTE 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: SHLIB 0x000334 0x00001000 0x00001000 0x00001 0x00001 0x1
-# ELF32-NEXT: TLS 0x000342 0x00004000 0x00004000 0x00001 0x00001 0x1
-# ELF32-NEXT: <unknown>: 0x60000000 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: GNU_EH_FRAME 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: SUNW_UNWIND 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: GNU_STACK 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: GNU_RELRO 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: GNU_PROPERTY 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: OPENBSD_MUTABLE 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: OPENBSD_RANDOMIZE 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: OPENBSD_WXNEEDED 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: OPENBSD_BOOTDATA 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: <unknown>: 0x6fffffff 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: <unknown>: 0x70000000 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: <unknown>: 0x70000001 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: <unknown>: 0x70000002 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: <unknown>: 0x70000003 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
-# ELF32-NEXT: <unknown>: 0x7fffffff 0x000334 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: NOTE 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: SHLIB 0x000354 0x00001000 0x00001000 0x00001 0x00001 0x1
+# ELF32-NEXT: TLS 0x000362 0x00004000 0x00004000 0x00001 0x00001 0x1
+# ELF32-NEXT: <unknown>: 0x60000000 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: GNU_EH_FRAME 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: SUNW_UNWIND 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: GNU_STACK 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: GNU_RELRO 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: GNU_PROPERTY 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: OPENBSD_MUTABLE 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: OPENBSD_RANDOMIZE 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: OPENBSD_WXNEEDED 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: OPENBSD_NOBTCFI 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: OPENBSD_BOOTDATA 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: <unknown>: 0x6fffffff 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: <unknown>: 0x70000000 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: <unknown>: 0x70000001 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: <unknown>: 0x70000002 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: <unknown>: 0x70000003 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
+# ELF32-NEXT: <unknown>: 0x7fffffff 0x000354 0x00001000 0x00001000 0x00003 0x00003 0x1
# ELF32-EMPTY:
-# ELF64:There are 24 program headers, starting at offset 64
+# ELF64:There are 25 program headers, starting at offset 64
# ELF64-EMPTY:
# ELF64-NEXT:Program Headers:
# ELF64-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
-# ELF64-NEXT: PHDR 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 W 0x1
-# ELF64-NEXT: PHDR 0x000583 0x0000000000002000 0x0000000000002000 0x000007 0x000007 E 0x1
-# ELF64-NEXT: NULL 0x000583 0x0000000000002000 0x0000000000002000 0x000007 0x000007 E 0x1
-# ELF64-NEXT: DYNAMIC 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 RWE 0x1
-# ELF64-NEXT: INTERP 0x00058a 0x0000000000003000 0x0000000000003000 0x000004 0x000004 RW 0x1
+# ELF64-NEXT: PHDR 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 W 0x1
+# ELF64-NEXT: PHDR 0x0005bb 0x0000000000002000 0x0000000000002000 0x000007 0x000007 E 0x1
+# ELF64-NEXT: NULL 0x0005bb 0x0000000000002000 0x0000000000002000 0x000007 0x000007 E 0x1
+# ELF64-NEXT: DYNAMIC 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 RWE 0x1
+# ELF64-NEXT: INTERP 0x0005c2 0x0000000000003000 0x0000000000003000 0x000004 0x000004 RW 0x1
# ELF64-NEXT: [Requesting program interpreter: ABC]
-# ELF64-NEXT: NOTE 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: SHLIB 0x000580 0x0000000000001000 0x0000000000001000 0x000001 0x000001 0x1
-# ELF64-NEXT: TLS 0x00058e 0x0000000000004000 0x0000000000004000 0x000001 0x000001 0x1
-# ELF64-NEXT: <unknown>: 0x60000000 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: GNU_EH_FRAME 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: SUNW_UNWIND 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: GNU_STACK 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: GNU_RELRO 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: GNU_PROPERTY 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: OPENBSD_MUTABLE 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: OPENBSD_RANDOMIZE 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: OPENBSD_WXNEEDED 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: OPENBSD_BOOTDATA 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: <unknown>: 0x6fffffff 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: <unknown>: 0x70000000 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: <unknown>: 0x70000001 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: <unknown>: 0x70000002 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: <unknown>: 0x70000003 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ELF64-NEXT: <unknown>: 0x7fffffff 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: NOTE 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: SHLIB 0x0005b8 0x0000000000001000 0x0000000000001000 0x000001 0x000001 0x1
+# ELF64-NEXT: TLS 0x0005c6 0x0000000000004000 0x0000000000004000 0x000001 0x000001 0x1
+# ELF64-NEXT: <unknown>: 0x60000000 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: GNU_EH_FRAME 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: SUNW_UNWIND 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: GNU_STACK 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: GNU_RELRO 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: GNU_PROPERTY 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: OPENBSD_MUTABLE 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: OPENBSD_RANDOMIZE 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: OPENBSD_WXNEEDED 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: OPENBSD_NOBTCFI 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: OPENBSD_BOOTDATA 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: <unknown>: 0x6fffffff 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: <unknown>: 0x70000000 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: <unknown>: 0x70000001 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: <unknown>: 0x70000002 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: <unknown>: 0x70000003 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ELF64-NEXT: <unknown>: 0x7fffffff 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# ELF64-EMPTY:
# MAPPING: Section to Segment mapping:
@@ -117,13 +119,14 @@
# MAPPING-NEXT: 21 .foo.begin .foo.end {{$}}
# MAPPING-NEXT: 22 .foo.begin .foo.end {{$}}
# MAPPING-NEXT: 23 .foo.begin .foo.end {{$}}
+# MAPPING-NEXT: 24 .foo.begin .foo.end {{$}}
# MAPPING-NEXT: None .unused .strtab .shstrtab {{$}}
# ELF-LLVM: ProgramHeaders [
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_PHDR (0x6)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -135,8 +138,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_PHDR (0x6)
-# ELF32-LLVM-NEXT: Offset: 0x337
-# ELF64-LLVM-NEXT: Offset: 0x583
+# ELF32-LLVM-NEXT: Offset: 0x357
+# ELF64-LLVM-NEXT: Offset: 0x5BB
# ELF-LLVM-NEXT: VirtualAddress: 0x2000
# ELF-LLVM-NEXT: PhysicalAddress: 0x2000
# ELF-LLVM-NEXT: FileSize: 7
@@ -148,8 +151,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_NULL (0x0)
-# ELF32-LLVM-NEXT: Offset: 0x337
-# ELF64-LLVM-NEXT: Offset: 0x583
+# ELF32-LLVM-NEXT: Offset: 0x357
+# ELF64-LLVM-NEXT: Offset: 0x5BB
# ELF-LLVM-NEXT: VirtualAddress: 0x2000
# ELF-LLVM-NEXT: PhysicalAddress: 0x2000
# ELF-LLVM-NEXT: FileSize: 7
@@ -161,8 +164,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_DYNAMIC (0x2)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -176,8 +179,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_INTERP (0x3)
-# ELF32-LLVM-NEXT: Offset: 0x33E
-# ELF64-LLVM-NEXT: Offset: 0x58A
+# ELF32-LLVM-NEXT: Offset: 0x35E
+# ELF64-LLVM-NEXT: Offset: 0x5C2
# ELF-LLVM-NEXT: VirtualAddress: 0x3000
# ELF-LLVM-NEXT: PhysicalAddress: 0x3000
# ELF-LLVM-NEXT: FileSize: 4
@@ -190,8 +193,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_NOTE (0x4)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -202,8 +205,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_SHLIB (0x5)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 1
@@ -214,8 +217,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_TLS (0x7)
-# ELF32-LLVM-NEXT: Offset: 0x342
-# ELF64-LLVM-NEXT: Offset: 0x58E
+# ELF32-LLVM-NEXT: Offset: 0x362
+# ELF64-LLVM-NEXT: Offset: 0x5C6
# ELF-LLVM-NEXT: VirtualAddress: 0x4000
# ELF-LLVM-NEXT: PhysicalAddress: 0x4000
# ELF-LLVM-NEXT: FileSize: 1
@@ -226,8 +229,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: Unknown (0x60000000)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -238,8 +241,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_GNU_EH_FRAME (0x6474E550)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -250,8 +253,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_SUNW_UNWIND (0x6464E550)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -262,8 +265,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_GNU_STACK (0x6474E551)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -274,8 +277,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_GNU_RELRO (0x6474E552)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -286,8 +289,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_GNU_PROPERTY (0x6474E553)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -298,8 +301,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_OPENBSD_MUTABLE (0x65A3DBE5)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -310,8 +313,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_OPENBSD_RANDOMIZE (0x65A3DBE6)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -322,8 +325,20 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_OPENBSD_WXNEEDED (0x65A3DBE7)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
+# ELF-LLVM-NEXT: VirtualAddress: 0x1000
+# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
+# ELF-LLVM-NEXT: FileSize: 3
+# ELF-LLVM-NEXT: MemSize: 3
+# ELF-LLVM-NEXT: Flags [ (0x0)
+# ELF-LLVM-NEXT: ]
+# ELF-LLVM-NEXT: Alignment: 1
+# ELF-LLVM-NEXT: }
+# ELF-LLVM-NEXT: ProgramHeader {
+# ELF-LLVM-NEXT: Type: PT_OPENBSD_NOBTCFI (0x65A3DBE8)
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -334,8 +349,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: PT_OPENBSD_BOOTDATA (0x65A41BE6)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -346,8 +361,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: Unknown (0x6FFFFFFF)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -358,8 +373,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: Unknown (0x70000000)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -370,8 +385,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: Unknown (0x70000001)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -382,8 +397,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: Unknown (0x70000002)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -394,8 +409,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: Unknown (0x70000003)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -406,8 +421,8 @@
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: Unknown (0x7FFFFFFF)
-# ELF32-LLVM-NEXT: Offset: 0x334
-# ELF64-LLVM-NEXT: Offset: 0x580
+# ELF32-LLVM-NEXT: Offset: 0x354
+# ELF64-LLVM-NEXT: Offset: 0x5B8
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
# ELF-LLVM-NEXT: PhysicalAddress: 0x1000
# ELF-LLVM-NEXT: FileSize: 3
@@ -549,17 +564,22 @@ ProgramHeaders:
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
-## Case 18: the PT_OPENBSD_BOOTDATA segment.
+## Case 18: the PT_OPENBSD_NOBTCFI segment.
+ - Type: 0x65a3dbe8 ## PT_OPENBSD_NOBTCFI
+ VAddr: 0x1000
+ FirstSec: .foo.begin
+ LastSec: .foo.end
+## Case 19: the PT_OPENBSD_BOOTDATA segment.
- Type: 0x65a41be6 ## PT_OPENBSD_BOOTDATA
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
-## Case 19: the PT_HIOS segment.
+## Case 20: the PT_HIOS segment.
- Type: 0x6fffffff ## PT_HIOS
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
-## Case 20: the PT_LOPROC/PT_ARM_ARCHEXT/PT_MIPS_REGINFO segment.
+## Case 21: the PT_LOPROC/PT_ARM_ARCHEXT/PT_MIPS_REGINFO segment.
- Type: 0x70000000 ## PT_LOPROC/PT_ARM_ARCHEXT/PT_MIPS_REGINFO
VAddr: 0x1000
FirstSec: .foo.begin
@@ -569,17 +589,17 @@ ProgramHeaders:
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
-## Case 21: the PT_MIPS_OPTIONS segment.
+## Case 23: the PT_MIPS_OPTIONS segment.
- Type: 0x70000002 ## PT_MIPS_OPTIONS
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
-## Case 22: the PT_MIPS_ABIFLAGS/PT_RISCV_ATTRIBUTES segment.
+## Case 24: the PT_MIPS_ABIFLAGS/PT_RISCV_ATTRIBUTES segment.
- Type: 0x70000003 ## PT_MIPS_ABIFLAGS/PT_RISCV_ATTRIBUTES
VAddr: 0x1000
FirstSec: .foo.begin
LastSec: .foo.end
-## Case 23: the PT_HIPROC segment.
+## Case 25: the PT_HIPROC segment.
- Type: 0x7fffffff ## PT_HIPROC
VAddr: 0x1000
FirstSec: .foo.begin
@@ -590,9 +610,9 @@ ProgramHeaders:
# RUN: llvm-readelf --program-headers %tarm.elf | FileCheck %s --check-prefix=ARM-GNU
# RUN: llvm-readobj --program-headers %tarm.elf | FileCheck %s --check-prefix=ARM-LLVM
-# ARM-GNU: <unknown>: 0x70000000 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ARM-GNU-NEXT: EXIDX 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# ARM-GNU-NEXT: <unknown>: 0x70000002 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ARM-GNU: <unknown>: 0x70000000 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ARM-GNU-NEXT: EXIDX 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# ARM-GNU-NEXT: <unknown>: 0x70000002 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# ARM-LLVM: ProgramHeader {
# ARM-LLVM: Type: Unknown (0x70000000)
@@ -606,10 +626,10 @@ ProgramHeaders:
# RUN: llvm-readelf --program-headers %tmips.elf | FileCheck %s --check-prefix=MIPS-GNU
# RUN: llvm-readobj --program-headers %tmips.elf | FileCheck %s --check-prefix=MIPS-LLVM
-# MIPS-GNU: REGINFO 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# MIPS-GNU-NEXT: RTPROC 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# MIPS-GNU-NEXT: OPTIONS 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
-# MIPS-GNU-NEXT: ABIFLAGS 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# MIPS-GNU: REGINFO 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# MIPS-GNU-NEXT: RTPROC 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# MIPS-GNU-NEXT: OPTIONS 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# MIPS-GNU-NEXT: ABIFLAGS 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# MIPS-LLVM: ProgramHeader {
# MIPS-LLVM: Type: PT_MIPS_REGINFO (0x70000000)
@@ -625,7 +645,7 @@ ProgramHeaders:
# RUN: llvm-readelf --program-headers %triscv.elf | FileCheck %s --check-prefix=RISCV-GNU
# RUN: llvm-readobj --program-headers %triscv.elf | FileCheck %s --check-prefix=RISCV-LLVM
-# RISCV-GNU: ATTRIBUTES 0x000580 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
+# RISCV-GNU: ATTRIBUTES 0x0005b8 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# RISCV-LLVM: ProgramHeader {
# RISCV-LLVM: Type: PT_RISCV_ATTRIBUTES (0x70000003)
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index e3387d02bc8f966..eda3982113f9ba7 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1476,6 +1476,7 @@ static StringRef segmentTypeToString(unsigned Arch, unsigned Type) {
LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_MUTABLE);
LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_RANDOMIZE);
LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_WXNEEDED);
+ LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_NOBTCFI);
LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_BOOTDATA);
default:
return "";
More information about the llvm-commits
mailing list