Just for fun

  • Thread starter Domingo Fiesta Segura
  • Start date
D

Domingo Fiesta Segura

Hi,

Recently I've been playing on C programming avoiding libc and also
assembly. Well, I guess some of us like to mess up with things like:

#include <linux/types.h>
#include <linux/unistd.h>

int errno;

_syscall1(int, exit, int, status)
_syscall3(ssize_t, write, int, fd, const void *, buf, size_t, count)

void _start()
{
write(1, "Hello there\n", 12);
exit(0);
}

And then compiling with "-nostdlib".

In case argc, argv and/or envp are needed we have to get it from the
stack (AFAIK). Thats the work for /usr/lib/crt1.o in glibc. Of course,
we all knew that.

Searching through the glibc sources I found a curious code in
glibc-2.3.1/sysdeps/unix/start.c, something like this:

static void start1();

void _start ()
{
start1();
}

/* There are some dummy declarations for i386 */
static void start1(int argc, char *argp)
{
char **argv = &argp;
/* Get environment here ... */
/* Call __libc_init */
exit(main(argc, argv, __environ));
}

But doesn't work, why?

P.S: For now I have my own crt1-toy.S version for x86, I'm trying to
work out another crti1-toy.S PPC32 version. Suggestions welcomed.

Thanks for your attention.
 
D

Dave Vandervies

Hi,

Recently I've been playing on C programming avoiding libc and also
assembly.

....which puts you well outside the scope of comp.lang.c .

Perhaps an appropriate newsgroup for your OS (Linux, if I'm guessing
correctly from a quick look at the rest of your post) would be both more
interested in this and more likely to give helpful comments.


dave
 
D

Domingo Fiesta Segura

...which puts you well outside the scope of comp.lang.c .

Sorry, is the first time I post to newsgroups so I wasn't very
confident trying to classify my question.
Perhaps an appropriate newsgroup for your OS (Linux, if I'm guessing
correctly from a quick look at the rest of your post) would be both more
interested in this and more likely to give helpful comments.

Done. Thanks ;-)
 
M

Mike Wahler

Domingo Fiesta Segura said:
(e-mail address removed) (Dave Vandervies) wrote in message

Sorry, is the first time I post to newsgroups so I wasn't very
confident trying to classify my question.

This link should help with further
ventures into Usenet:

www.usenet.org

HTH,
-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top