This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch to allow strlen expander to fail


> The programmer can not and should not need to know the details of how that
> assignment is performed.  If they think they need control over that kind of
> implementation detail, then they're barking up the wrong tree.

With the current gcc, the programmer *must* know such details. If she
ignores it, the program won't link in the end unless she provides a
memcpy implementation.

> The fix is for the linux kernel to link in libgcc or to use -nostdlib and
> provide its own memcpy routine.

I can't see how linking libgcc helps; it does not provide a version of
memcpy, either. GCC currently assumes that the programs it generates
will be linked with the system's standard C library; that assumption
is incorrect for a freestanding environment. According to C99, section
4, paragraph 6, in a freestanding environment, only the following
headers are available:

<float.h> 
<iso646.h> 
<limits.h> 
<stdarg.h>
<stdbool.h>
<stddef.h>
<stdint.h>

As you can see, <string.h> is not required for a free-standing
environment, so the kernel is absolutely right not to provide one.

If it is a GCC requirement that <string.h> must be provided even in a
freestanding environment, then this requirement should be documented
(e.g. as an implementation restriction).

Regards,
Martin

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]