$ nasm -f elf64 hello.asm
$ ld hello.o -o hello
ELF binary type "0" not known.
This can be fixed with brandelf:
$ brandelf -t freebsd hello
However, the brandelf step should not be necessary.
Do you know when this started? nasm hasn't had a new release and update in over a year. I wonder if this is a change in lld, or something else?
Which version of FreeBSD are you using?
I did a quick check, this looks like an issue with ldd, when I use gnu ld to link the object it works as expected. lld has been made the default ld on 12.1 and 13, so that might be the difference from earlier, when it worked.
Created attachment 212749 [details]
Fix nasm's ELF_OSABI field when emitting object files
(In reply to Dimitry Andric from comment #4)
Note that ideally this would be some sort of command line option, but I think it is too much trouble to bother, unless somebody would want to upstream this (if an upstream even exists? :)
This worked fine for me on 11.2-RELEASE. Now on 12.1-RELEASE-p3
(In reply to Dimitry Andric from comment #5)
Can ld infer this from the .o file?
(In reply to unitrunker from comment #7)
Well, it infers that you are attempting to link the wrong type of .o file for the target system. If you want to link a linux .o file, you should use a target of e.g. x86_64-unknown-linux. The default is obviously to link a freebsd executable, and for that you need freebsd-branded object files. It will not attempt to "correct" any badly branded object files.