今天又看CS630[1]的Chapter 15,发现里头的一个例程manydots.s无法正常编译。
$ gcc manydots.s -o manydots
/tmp/ccIvmRVT.o: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-linux-gnu/4.3.1/../../../../lib/crt1.o:(.text+0x0): first defined here
/usr/lib/gcc/x86_64-linux-gnu/4.3.1/../../../../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
$ sed -i -e "s/_start/main/g" manydots.s
$ gcc manydots.s -o manydots
$ ./manydots
Segmentation fault
$ file manydots
manydots:
ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked
(uses shared libs), for GNU/Linux 2.6.8, not stripped
通过上面的实验,首先根据提示发现_start有multiple
definition,所以根据自己的经验,把里头的_start符号替换成main。因为用gcc编译时默认的程序入口是main&#x
$ gcc manydots.s -o manydots
/tmp/ccIvmRVT.o: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-linux-gnu/4.3.1/../../../../lib/crt1.o:(.text+0x0): first defined here
/usr/lib/gcc/x86_64-linux-gnu/4.3.1/../../../../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
$ sed -i -e "s/_start/main/g" manydots.s
$ gcc manydots.s -o manydots
$ ./manydots
Segmentation fault
$ file manydots
manydots:
ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked
(uses shared libs), for GNU/Linux 2.6.8, not stripped
通过上面的实验,首先根据提示发现_start有multiple
definition,所以根据自己的经验,把里头的_start符号替换成main。因为用gcc编译时默认的程序入口是main&#x