先用 "gcc -v -o hello hello.c" 觀察是怎麼link *.o 成一個Non-relocatable executable image (hello)
as -V -Qy -o /tmp/ccYSeOH3.o /tmp/ccn8m1zA.s
/usr/lib/gcc/i486-linux-gnu/4.3.2/collect2 --eh-frame-hdr -m elf_i386 --hash-style=both -dynamic-linker /lib/ld-linux.so.2 -o hello /usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/crt1.o /usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/crti.o /usr/lib/gcc/i486-linux-gnu/4.3.2/crtbegin.o -L/usr/lib/gcc/i486-linux-gnu/4.3.2 -L/usr/lib/gcc/i486-linux-gnu/4.3.2 -L/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/i486-linux-gnu/4.3.2/../../.. /tmp/ccYSeOH3.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i486-linux-gnu/4.3.2/crtend.o /usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/crtn.o
>gcc -S -o hello_x86.s hello.c
>as -o hello.o hello_x86.s
>ld -o hello -dynamic-linker /lib/ld-linux.so.2 hello.o /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o -lc
>./hello
沒有留言:
張貼留言