Getting GCC to compile without inserting call to memcpy

前端 未结 4 2028
我在风中等你
我在风中等你 2020-12-06 10:50

I\'m currently using GCC 4.5.3, compiled for PowerPC 440, and am compiling some code that doesn\'t require libc. I don\'t have any direct calls to memcpy(), but the compiler

4条回答
  •  长情又很酷
    2020-12-06 11:17

    You can also make your binary a "freestanding" one:

    The ISO C standard defines (in clause 4) two classes of conforming implementation. A conforming hosted implementation supports the whole standard [...]; a conforming freestanding implementation is only required to provide certain library facilities: those in , , , and ; since AMD1, also those in ; and in C99, also those in and . [...].

    The standard also defines two environments for programs, a freestanding environment, required of all implementations and which may not have library facilities beyond those required of freestanding implementations, where the handling of program startup and termination are implementation-defined, and a hosted environment, which is not required, in which all the library facilities are provided and startup is through a function int main (void) or int main (int, char *[]).

    An OS kernel would be a freestanding environment; a program using the facilities of an operating system would normally be in a hosted implementation.

    (paragraph added by me)

    More here. And the corresponding gcc option/s (keywords -ffreestanding or -fno-builtin) can be found here.

提交回复
热议问题