Is there such thing as a native freebsd binary? reddit / freebsd ---------------------------------------------------------------------- GiveMeMoreBlueberrys · 2021-01-18 07:09 Say I write a simple hello world script in C. When I use clang to compile it, for example like this: cc hello-world.c -o hello-world It produces an ELF file, which then ( I assume ) the kernel uses the ELF compatibility layer to run. This file would then also run on a linux system. But what if I want a binary that only works on freebsd? Is there a way to make a binary that does not use the comparability layer? TIA ---------------------------------------------------------------------- holdenmj · 2021-01-18 07:22 FreeBSD also uses the ELF format, you’re not using any comparability layer in that instance. Check out the [elf 5 man page history section] (https://www.freebsd.org/cgi/man.cgi?query=elf&sektion=5&apropos=0&man path=FreeBSD+12.2-RELEASE+and+Ports#end) ---------------------------------------------------------------------- GiveMeMoreBlueberrys · 2021-01-18 07:36 Ahh, i see. Thanks. This would, I assume, mean that any compiled binarys are forced to be cross compatable on compile time? ---------------------------------------------------------------------- vvelox · 2021-01-18 07:42 For more history etc on ELF also check out https://en.wikipedia.org/wiki/Executable_and_Linkable_Format . Basically it is the standard binary format for nearly all unixes. ---------------------------------------------------------------------- wikipedia_text_bot · 2021-01-18 07:42 **[Executable and Linkable Format](https://en.wikipedia.org/wiki/Executable and Linkable Format)** In computing, the Executable and Linkable Format (ELF, formerly named Extensible Linking Format), is a common standard file format for executable files, object code, shared libraries, and core dumps. First published in the specification for the application binary interface (ABI) of the Unix operating system version named System V Release 4 (SVR4), and later in the Tool Interface Standard, it was quickly accepted among different vendors of Unix systems. In 1999, it was chosen as the standard binary file format for Unix and Unix-like systems on x86 processors by the 86open project. By design, the ELF format is flexible, extensible, and cross-platform. [^(About Me)](https://np.reddit.com/user/wikipedia_text_bot/comments/j rn2mj/about_me/) ^- [^(Opt out)](https://np.reddit.com/user/wikipedia_ text_bot/comments/jrti43/opt_out_here/) ^(- OP can reply !delete to delete) ^- [^(Article of the day)](https://np.reddit.com/comments/k9hx22) **This bot will soon be transitioning to an opt-in system. Click [here ](https://np.reddit.com/user/wikipedia_text_bot/comments/ka4icp/opt_in _for_the_new_system/) to learn more and opt in. Moderators: [click her e](https://np.reddit.com/user/wikipedia_text_bot/comments/ka4icp/opt_i n_for_the_new_system/) to opt in a subreddit.** ---------------------------------------------------------------------- holdenmj · 2021-01-18 08:01 The ELF binary you built on FreeBSD will not work on Linux. There is an opt-in Linux binary compatibility layer in FreeBSD meaning some binaries built on Linux can run on FreeBSD if your system is configured correctly, that however is a runtime compatibility layer. ---------------------------------------------------------------------- urglecom · 2021-01-18 09:43 That both systems use ELF as the format for binaries does not mean that they are cross-compatible. ELF is to executables as zip is to data: it's a container that means that both FreeBSD and Linux systems can unpack them and see what's inside. But if you unpack a zip file full of C code, Excel won't really make much sense of it, just as if you unpack an ELF full of FreeBSD binary, Linux won't make much sense of it. ---------------------------------------------------------------------- FUZxxl · 2021-01-18 14:10 ELF is just a binary format. An ELF binary for FreeBSD won't run on Linux. ---------------------------------------------------------------------- daemonpenguin · 2021-01-18 14:29 There is no "ELF compatibility layer", ELF is just the name of the file format of executable files on FreeBSD and Linux. A file you compile on FreeBSD will not work on Linux. The binary you compile on FreeBSD will only work on FreeBSD. It won't use a compatibility layer. ---------------------------------------------------------------------- grahamperrin · 2021-01-22 07:42 Not an answer to your question, but I'm curious, do you have development of a GUI app in mind? ---------------------------------------------------------------------- GiveMeMoreBlueberrys · 2021-01-22 09:27 No, i just want to write really fast programs, and that means syscalls, but i want to make sure that i’m writing native syscalls, not emulated ones. ---------------------------------------------------------------------- spauldo_the_hippie · 2021-01-22 22:17 One way to verify this is to compile to assembly using the -S flag and see what it gives you. It should be native assembly (in AT&T format) for your processor, not bytecode for some VM. If AT&T syntax isn't your thing, throw in -masm=intel.