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: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm64 Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-07 10:26 UTC by Mikael Urankar
Modified: 2022-08-22 06:31 UTC (History)
5 users (show)

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


Attachments
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 freebsd_triage 2021-01-07 10:26:09 UTC
Created attachment 221349 [details]
v0

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

./hello 
ELF binary type "0" not known.

brandelf -t FreeBSD hello
./hello 
Hello World

see attached patch for a proposed fix.
Comment 1 Steve Wills freebsd_committer freebsd_triage 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 freebsd_triage 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 freebsd_triage 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).
Comment 5 Mikael Urankar freebsd_committer freebsd_triage 2021-09-28 07:39:13 UTC
(In reply to Jessica Clarke from comment #4)
How I'm supposed to do that?
Comment 6 Mikael Urankar freebsd_committer freebsd_triage 2021-09-28 07:41:07 UTC
Reopen, it's still an issue with binutils or the os.
Comment 7 Mikael Urankar freebsd_committer freebsd_triage 2021-09-28 08:37:21 UTC
There is also this bug:
freepascal/packages/fpmake
ELF interpreter /lib/ld.so.1 not found, error 2