[lld] [llvm] [MC] set OpenBSD's ELFOSABI by default (#98158) (PR #98553)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 11 14:14:45 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mc
Author: John Ericson (Ericson2314)
<details>
<summary>Changes</summary>
This matches what is done for FreeBSD.
OpenBSD has a few special program header types, and other such ELF extensions. Setting the ELFOSABI like so will allow LLD to support them without needlessly impacting non-OpenBSD ELFs.
Testing strategy matches 06cecdc60ec9ebfdd4d8cdb2586d201272bdf6bd.
Take two of #<!-- -->98158 / b64c1de714c50bec7493530446ebf5e540d5f96a, preexisting test is fixed now.
---
Full diff: https://github.com/llvm/llvm-project/pull/98553.diff
3 Files Affected:
- (modified) lld/test/ELF/basic-sparcv9.s (+1-1)
- (modified) llvm/include/llvm/MC/MCELFObjectWriter.h (+2)
- (modified) llvm/test/MC/ELF/osabi.s (+4)
``````````diff
diff --git a/lld/test/ELF/basic-sparcv9.s b/lld/test/ELF/basic-sparcv9.s
index af63dc47ae84e..b2f760f21ab05 100644
--- a/lld/test/ELF/basic-sparcv9.s
+++ b/lld/test/ELF/basic-sparcv9.s
@@ -17,7 +17,7 @@ _start:
# CHECK-NEXT: Class: 64-bit (0x2)
# CHECK-NEXT: DataEncoding: BigEndian (0x2)
# CHECK-NEXT: FileVersion: 1
-# CHECK-NEXT: OS/ABI: SystemV (0x0)
+# CHECK-NEXT: OS/ABI: OpenBSD (0x0)
# CHECK-NEXT: ABIVersion: 0
# CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
# CHECK-NEXT: }
diff --git a/llvm/include/llvm/MC/MCELFObjectWriter.h b/llvm/include/llvm/MC/MCELFObjectWriter.h
index d7c223cdcc07f..12237094ad86a 100644
--- a/llvm/include/llvm/MC/MCELFObjectWriter.h
+++ b/llvm/include/llvm/MC/MCELFObjectWriter.h
@@ -78,6 +78,8 @@ class MCELFObjectTargetWriter : public MCObjectTargetWriter {
return ELF::ELFOSABI_FREEBSD;
case Triple::Solaris:
return ELF::ELFOSABI_SOLARIS;
+ case Triple::OpenBSD:
+ return ELF::ELFOSABI_OPENBSD;
default:
return ELF::ELFOSABI_NONE;
}
diff --git a/llvm/test/MC/ELF/osabi.s b/llvm/test/MC/ELF/osabi.s
index dc6ad2a349d75..44912f4987c11 100644
--- a/llvm/test/MC/ELF/osabi.s
+++ b/llvm/test/MC/ELF/osabi.s
@@ -10,3 +10,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s | llvm-readobj -h - | \
# RUN: FileCheck %s --check-prefix=FREEBSD
# FREEBSD: OS/ABI: FreeBSD
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-openbsd %s | llvm-readobj -h - | \
+# RUN: FileCheck %s --check-prefix=OPENBSD
+# OPENBSD: OS/ABI: OpenBSD
``````````
</details>
https://github.com/llvm/llvm-project/pull/98553
More information about the llvm-commits
mailing list