Exporting _start through library archives

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I got this problem, can anybody help me please? [I hope this is the right mailing list for these kind of questions, if not, please forgive me]

I am developing a system level code, where i cannot use libc directly. So, i wanted to write an assembly file, crt0-ia32.S, which passes control to main function. I have converted it into a library archive file using ar & ranlib. But the linker complaints that it cannot find _start symbol (even though nm reports that symbol). If i try linking directly with crt0-ia32.o file, it works, but not when i linked through library. Is there anyway that i can link crt0 through a library archive?

Thanks in advance,
BVK Chaitanya.

   Here are my source files and the compilation procedure i am following:

crt0-ia32.S
===========
      .text
      .global _start
      .global _stext

_stext:
_start:
       leal    __stack, %esp

       pushl   %ebx    /* mbi ptr      */
       pushl   %eax    /* mb magic     */
       pushl   $___return_from_main
       jmp     main /* call main() */

___return_from_main:
       int     $3
       jmp     1f
       .ascii  "System stopped."
1:      jmp      ___return_from_main

       .bss
       .space  4096
__stack:

main.c
======
int main (int magic, void *mbi)
{
   ...
   return 0;
}

PROCEDURE
=========
gcc -c -nostdinc crt0-ia32.S -o crt0-ia32.o
ar rcs libcrt0.a crt0-ia32.o
ranlib libcrt0.a

gcc -c -nostdinc main.c -o main.o
ld -e_start -N -L. -nostdlib -Ttext=300000 main.o -lcrt0
ld: warning: cannot find entry symbol _start; defaulting to 0000000000300000


--
The question is, how far down the rabbit hole do you want to go?


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux