Just for fun

Discussion in 'C Programming' started by Domingo Fiesta Segura, Oct 8, 2003.

  1. 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.
     
    Domingo Fiesta Segura, Oct 8, 2003
    #1
    1. Advertising

  2. In article <>,
    Domingo Fiesta Segura <> wrote:
    >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

    --
    Dave Vandervies
    Programmers have a problem. It's a secret we try to keep among ourselves.
    We really like this stuff. We do it even when they don't pay us. Don't tell
    anybody. --Joe Wright in comp.lang.c
     
    Dave Vandervies, Oct 8, 2003
    #2
    1. Advertising

  3. (Dave Vandervies) wrote in message news:<bm0ac7$549$>...
    > ...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 ;-)
     
    Domingo Fiesta Segura, Oct 8, 2003
    #3
  4. Domingo Fiesta Segura

    Mike Wahler Guest

    "Domingo Fiesta Segura" <> wrote in message
    news:...
    > (Dave Vandervies) wrote in message

    news:<bm0ac7$549$>...
    > > ...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.


    This link should help with further
    ventures into Usenet:

    www.usenet.org

    HTH,
    -Mike
     
    Mike Wahler, Oct 8, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Fish
    Replies:
    65
    Views:
    1,796
    Mabden
    May 18, 2004
  2. CII
    Replies:
    10
    Views:
    1,919
    Keith Thompson
    May 11, 2005
  3. CII
    Replies:
    12
    Views:
    559
    Christopher Benson-Manica
    May 12, 2005
  4. dolphin
    Replies:
    4
    Views:
    330
    Jorgen Grahn
    Aug 25, 2007
  5. er
    Replies:
    2
    Views:
    520
Loading...

Share This Page