What are the differences between compiling and compiling bare C / C ++ elements for a particular OS (Linux)?

Suppose you have a cross-compilation toolchain that creates binaries for the ARM architecture.

Your toolchain is similar to this (runs on an X86_64 Linux machine):

  • arm-linux-gnueabi-gcc.exe: for cross-compiling for Linux running on ARM.
  • arm-gcc.exe: for cross-compiling without binding to ARM.

... and many other cross-compiling tools on ARM.

Points that interest me:

  • (E) ABI differences between binary files (if any) Limitations
  • in the case of bare metals (for example, the allocation of dynamic memory, the use of static constructors in the case of C ++, flow models, etc.).
  • differences in the binary level between the two cases in terms of information specific to each of them (for example, support for debugging information, etc.);
+6
source share
2 answers
  • The differences in ABI are how you invoke the compiler, for example GCC has -mabi , and it can be one of "apcs-gnu", atpcs, aapcs, aapcs-linux and "iwmmxt.
  • There are limited restrictions for various runtime functions because someone did not provide them. Let them initialize zero selected areas or provide C ++ features. If you can provide them, they will work.
  • The differences in the binary level are also related to how you call the compiler.

You can check the GCC ARM options online .

+3
source

I recently started a small project to use the standard C Linux library in an uncoated environment. I described this on my blog: http://ellcc.org/blog/?page_id=289 Basically, what I did was set up to handle Linux system calls so that, by implementing simplified versions of some system calls, I can use functions from the standard library. For example, the current state for ARM implements simplified versions of read (), readv (), write (), writev (), and brk (). This allows me to use printf (), fgets () and malloc () unchanged.

I in my case, I use the same compiler to target Linux and bare-metal. Since it is based on clang / LLVM, I can also use the same compiler to target other processors. I am currently working on an example for Mips.

So, I think the answer is that there should be no difference.

+1
source

All Articles