Linking a C program directly with ld fails with undefined reference to `__libc_csu_fini`

后端 未结 8 1495
被撕碎了的回忆
被撕碎了的回忆 2020-11-30 08:54

I\'m trying to compile a C program under Linux. However, out of curiosity, I\'m trying to execute some steps by hand: I use:

  • the gcc frontend to produce assemb
8条回答
  •  醉酒成梦
    2020-11-30 09:20

    I found another post which contained a clue: -dynamic-linker /lib/ld-linux.so.2.

    Try this:

    $ gcc hello.c -S -masm=intel
    $ as -o hello.o hello.s
    $ ld -o hello -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o hello.o -lc /usr/lib/crtn.o
    $ ./hello
    hello, world
    $ 
    

提交回复
热议问题