This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Re: -nostdlib option!


I am compiling my C programs with -nostdlib option without providing
mem functions like memcpy and GNU tool chain has not complained so
far(gcc 4.4.2, Fedora 12). Is that natural? I have defined char
pointers, nested functions and no error so far. I wonder if anybody
can write a simple C program and compile it with -nostdlib so that the
compiler needs one of mem functions and the compiler stops with an
error.


On 2/15/11, Patrick Horgan <phorgan1@yahoo.com> wrote:
> On 02/07/2011 04:44 AM, ali hagigat wrote:
>> Thank you Manuel.
>> How will be memset, memcpy, etc. Can i copy them from the source code
>> of gcc? But they are dependent to other functions in other libraries
>> probably and some headers.
>> Are those functions available stand alone some where?
>>
>>
>> On Mon, Feb 7, 2011 at 2:51 PM, Manuel Coutinho
>>> Hi
>>>
>>> Other mechanism: supply your own memset, memcpy, etc.
>>> If you do this, the linker will know which memset, memcpy, etc to use and
>>> will not complaint about not using libc.
>>>
>>> Regards
>>> Manuel Coutinho
>>>
> you would just write your own copies of these methods.  These are very
> simple functions any beginning computer science student could write in a
> few minutes.  For example:
>
> void *memset(void *s, int c, size_t n)
> {
>      size_t ctr;
>      char *ptr=s;
>      for(ctr=0;ctr<n;ctr++){
>          *(ptr+ctr)=(char)c;
>      }
>      return s;
> }
>
>
>


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