Bug 252490 - devel/binutils: object files doesn't have the ELFOSABI_FREEBSD brand
Summary: devel/binutils: object files doesn't have the ELFOSABI_FREEBSD brand
Status: Closed Works As Intended
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm64 Any
: --- Affects Only Me
Assignee: Mikael Urankar
Depends on:
Reported: 2021-01-07 10:26 UTC by Mikael Urankar
Modified: 2021-03-10 19:39 UTC (History)
5 users (show)

See Also:
bugzilla: maintainer-feedback? (jflopezfernandez)

v0 (6.68 KB, patch)
2021-01-07 10:26 UTC, Mikael Urankar
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mikael Urankar freebsd_committer 2021-01-07 10:26:09 UTC
Created attachment 221349 [details]

file hello.o 
hello.o: ELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV), not stripped

ELF binary type "0" not known.

brandelf -t FreeBSD hello
Hello World

see attached patch for a proposed fix.
Comment 1 Steve Wills freebsd_committer 2021-01-08 22:20:16 UTC
Submitter is committer
Comment 2 maskray 2021-02-03 19:07:18 UTC
On Linux, e_ident[EI_OSABI] is ELFOSABI_NONE if no GNU extension is used.
On FreeBSD, x86-64/powerpc/etc have "_fbsd" emulations which set default as/ld output to ELFOSABI_FREEBSD,
e.g. after https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6afcdeb3581e99e2d4ce06d0034c7c47292aeec1
"PR26667, Add powerpc64le-*-freebsd* support", powerpc64le default to ELFOSABI_FREEBSD.

However, ELFOSABI_FREEBSD is unnecessary. Bdragon reported that ELFOSABI_GNU object files can be linked into ELFOSABI_FREEBSD executable and the important thing is the FreeBSD specific SHT_NOTE section to mark the executable as FreeBSD specific.

So "_fbsd" emulations are not going to be useful.
See also https://sourceware.org/pipermail/binutils/2021-February/115185.html
Comment 3 Mikael Urankar freebsd_committer 2021-03-03 12:20:58 UTC
(In reply to maskray from comment #2)
I'm not sure I understand all of this, what needs to be done exactly?
Comment 4 Jessica Clarke freebsd_committer 2021-03-10 19:39:11 UTC
(In reply to Mikael Urankar from comment #3)

Nothing; this is not a bug. For whatever reason you managed to produce a binary without the FreeBSD ELF note present in the C start-up files that should have been linked in; that's the way binaries get branded for the recent arm64 and riscv ports (with ELFOSABI_FREEBSD continuing to be set and recognised for older ports for backwards compatibility).