2

I'm a bit confused. I just read this: http://www.es.freebsd.org/doc/handbook/binary-formats.html, which basically says that freeBSD uses the elf binary format. But when I compile my code I using cc, I get a file called a.out.

So what's going on here? Can I somehow specify in which format cc should build my code? Does freeBSD just support both formats? Is the resulting executable actually in elf format, but is it just called a.out for some reason:P?

  • 1
    Filename a.out is the default output from C-compiler in GNU Compiler collection regardless of output format. – Sami Laine Apr 29 '14 at 13:55
2

The a.out file is still leftover from when compilers were using the a.out format. If you check the file with file a.out you will see it is actually in ELF format.

To specify the name of the output file, use cc -o exec_name code.c.

  • 1
    And, you could double-check it using the "file" command; Example inside Linux: file /usr/bin/file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, stripped. You should have a simmilar output of this command on FreeBSD – user34720 Apr 29 '14 at 13:07
  • I'd say it the other way round — the a.out format was named that way because a.out was the default output file name for the assembler. The default file name remained but the format name stuck to the classical file format. – Gilles Apr 29 '14 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.