In freestanding mode the compiler can not rely on semantical considerations.
Most builtins in GCC work silently -- for instance the compiler sees that you are using strcpy()
and in hosted mode it may guess that, when you are using strcpy()
, you are intending exactly to copy a string. Then it may replace strcpy
with an extensionally equivalent builtin, which is better for the given target to copy a string.
In freestanding mode, using strcpy()
function means ANYTHING. The idea is just not the standard library absence in linkage. The idea of freestanding mode is that there is no standard library even on definition level, except float.h, iso646.h, limits.h, stdarg.h, stdbool.h, stddef.h, stdint.h (C99 standard 4.6). You may in freestanding mode decide to format your hard drive with strcpy
, and this is perfectly legal for the C language. The compiler thus don't know how to use builtins, and it declines to use them at all.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…