Skip to content

Commit

Permalink
[MC] set OpenBSD's ELFOSABI by default (llvm#98158)
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.
  • Loading branch information
Ericson2314 committed Jul 11, 2024
1 parent 3a14ffb commit b64c1de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
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 b64c1de

Please sign in to comment.