[OpenBIOS] [PATCH 6/6] libc: Fix build on recent gcc
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Mon Nov 7 20:23:37 CET 2016
On 06/11/16 23:18, Segher Boessenkool wrote:
> On Sun, Nov 06, 2016 at 11:41:40PM +0100, Aurelien Jarno wrote:
>>> --- a/libc/string.c
>>> +++ b/libc/string.c
>>> @@ -349,10 +349,7 @@ int memcmp(const void * cs,const void * ct,size_t count)
>>> char *
>>> strdup( const char *str )
>>> {
>>> - char *p;
>>> - if( !str )
>>> - return NULL;
>>> - p = malloc( strlen(str) + 1 );
>>> + char *p = malloc( strlen(str) + 1 );
>>> strcpy( p, str );
>>> return p;
>>> }
>>
>> Sorry to react so late, but wouldn't be better to build openbios with
>> -ffreestanding instead? That way GCC doesn't try to infer things from
>> its knowledge of the GNU libc? After all openbios uses its own libc.
>
> This is required not by glibc but by C, for any hosted environment. Using
> -ffreestanding will work, it probably is best to use that (unless openbios
> wants to make sure everything else is also implemented correctly, not a
> small task).
Oh, interesting. If someone wants to cook up a patch then I'll try it.
ATB,
Mark.
More information about the OpenBIOS
mailing list