Skip to content

Commit

Permalink
[MC] set OpenBSD's ELFOSABI by default (llvm#98158) (llvm#98553)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ericson2314 authored and aaryanshukla committed Jul 14, 2024
1 parent 862d54b commit 11b3e0d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lld/test/ELF/basic-sparcv9.s
Original file line number Diff line number Diff line change
Expand Up @@ -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: }
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/MC/MCELFObjectWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/MC/ELF/osabi.s
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 11b3e0d

Please sign in to comment.