Skip to content

Commit 11b3e0d

Browse files
Ericson2314aaryanshukla
authored andcommitted
[MC] set OpenBSD's ELFOSABI by default (llvm#98158) (llvm#98553)
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 06cecdc. Take two of llvm#98158 / b64c1de, which was reverted in llvm#98494 / c026135. Preexisting test is fixed now.
1 parent 862d54b commit 11b3e0d

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

lld/test/ELF/basic-sparcv9.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ _start:
1717
# CHECK-NEXT: Class: 64-bit (0x2)
1818
# CHECK-NEXT: DataEncoding: BigEndian (0x2)
1919
# CHECK-NEXT: FileVersion: 1
20-
# CHECK-NEXT: OS/ABI: SystemV (0x0)
20+
# CHECK-NEXT: OS/ABI: OpenBSD (0x0)
2121
# CHECK-NEXT: ABIVersion: 0
2222
# CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
2323
# CHECK-NEXT: }

llvm/include/llvm/MC/MCELFObjectWriter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ class MCELFObjectTargetWriter : public MCObjectTargetWriter {
7878
return ELF::ELFOSABI_FREEBSD;
7979
case Triple::Solaris:
8080
return ELF::ELFOSABI_SOLARIS;
81+
case Triple::OpenBSD:
82+
return ELF::ELFOSABI_OPENBSD;
8183
default:
8284
return ELF::ELFOSABI_NONE;
8385
}

llvm/test/MC/ELF/osabi.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@
1010
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s | llvm-readobj -h - | \
1111
# RUN: FileCheck %s --check-prefix=FREEBSD
1212
# FREEBSD: OS/ABI: FreeBSD
13+
14+
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-openbsd %s | llvm-readobj -h - | \
15+
# RUN: FileCheck %s --check-prefix=OPENBSD
16+
# OPENBSD: OS/ABI: OpenBSD

0 commit comments

Comments
 (0)