linux 生成.s文件,【已解决】给定多个C文件和多个.S汇编文件,如何用他们生成单个.o目标文件...

【已解决】给定多个C文件和多个.S汇编文件,如何用他们生成单个.o目标文件

【问题】

当然编译uboot下面的bch库,在加入对应C源码和.S汇编之后,编译是正常的:arm-linux-uclibc-gcc -D__ASSEMBLY__ -g -Os -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DTEXT_BASE=0x00000000 -I/home/crifan/uboot_as3536/u-boot-2009.03/include -fno-builtin -ffreestanding -nostdinc -isystem /home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -c -o lowlevel_init.o lowlevel_init.S

arm-linux-uclibc-gcc -D__ASSEMBLY__ -g -Os -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DTEXT_BASE=0x00000000 -I/home/crifan/uboot_as3536/u-boot-2009.03/include -fno-builtin -ffreestanding -nostdinc -isystem /home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -c -o bch/bch_enc4t.o bch/bch_enc4t.S

arm-linux-uclibc-gcc -D__ASSEMBLY__ -g -Os -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DTEXT_BASE=0x00000000 -I/home/crifan/uboot_as3536/u-boot-2009.03/include -fno-builtin -ffreestanding -nostdinc -isystem /home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -c -o bch/bch_dec4t.o bch/bch_dec4t.S

arm-linux-uclibc-gcc -g -Os -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DTEXT_BASE=0x00000000 -I/home/crifan/uboot_as3536/u-boot-2009.03/include -fno-builtin -ffreestanding -nostdinc -isystem /home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -c -o bch/bch_gf.o bch/bch_gf.c

arm-linux-uclibc-gcc -g -Os -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DTEXT_BASE=0x00000000 -I/home/crifan/uboot_as3536/u-boot-2009.03/include -fno-builtin -ffreestanding -nostdinc -isystem /home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -c -o bch/bch_lut.o bch/bch_lut.c

arm-linux-uclibc-gcc -g -Os -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DTEXT_BASE=0x00000000 -I/home/crifan/uboot_as3536/u-boot-2009.03/include -fno-builtin -ffreestanding -nostdinc -isystem /home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -c -o bch/bch_dec.o bch/bch_dec.c

arm-linux-uclibc-ar crv libas3536.a as3536.o asdebug.o ccu.o ssp.o ssp_nor.o enc28j60.o i2c_driver_polling.o as353x_nand.o shuffle.o mpmc_driver.o lowlevel_init.o bch/bch_enc4t.o bch/bch_dec4t.o bch/bch_gf.o bch/bch_lut.o bch/bch_dec.o

可以看到,编译后,每个C文件和汇编文件都对应一个.o文件,但是我又不想在release的时候,release多个.o文件,想要把这些多个.o文件,生成单个的.o文件,所以,此处的需求就是:

已经有了两个汇编文件bch/bch_enc4t.S bch/bch_dec4t.S和四个C文件bch/bch_gf.c bch/bch_lut.c bch/bch_dec.c,如何将这些文件,共同制作出来单个的.o文件。

【解决过程】

1.首先有人会问了,为何你为要多个.o弄成一个.o,而不是多个.o正常的用ar制作出一个.a的库文件?

回答是,此处已经可以实现了你所说的:

arm-linux-uclibc-ar rcv bch_4_s_romtable.a bch/bch_enc4t.o bch/bch_dec4t.o bch/bch_gf.o bch/bch_lut.o bch/bch_dec.o

但是,由于此处uboot的makefile规则所决定的,没法在当前目录中,将其加入上面显示的:

arm-linux-uclibc-ar crv libas3536.a as3536.o asdebug.o ccu.o ssp.o ssp_nor.o enc28j60.o i2c_driver_polling.o as353x_nand.o shuffle.o mpmc_driver.o lowlevel_init.o bch/bch_enc4t.o bch/bch_dec4t.o bch/bch_gf.o bch/bch_lut.o bch/bch_dec.o

中的libas3536.a中,因此最后编译,会找不到bch的相关函数,即使此处用生成好的.a,加入到ar中去制作as3536.a,是可以,但是最后在ld生成uboot的时候会出错,显示File format not recognized:

。。。cd /home/crifan/uboot_as3536/u-boot-2009.03 && arm-linux-uclibc-ld -Bstatic -T /home/crifan/uboot_as3536/u-boot-2009.03/board/ams/as3536/u-boot.lds -Ttext 0x00000000 $UNDEF_SYM cpu/arm926ejs/start.o

--start-group lib_generic/libgeneric.a lib_generic/lzma/liblzma.a cpu/arm926ejs/libarm926ejs.a cpu/arm926ejs/ams/libams.a lib_arm/libarm.a fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a fs/yaffs2/libyaffs2.a net/libnet.a disk/libdisk.a drivers/bios_emulator/libatibiosemu.a drivers/block/libblock.a drivers/dma/libdma.a drivers/fpga/libfpga.a drivers/gpio/libgpio.a drivers/hwmon/libhwmon.a drivers/i2c/libi2c.a drivers/input/libinput.a drivers/misc/libmisc.a drivers/mmc/libmmc.a drivers/mtd/libmtd.a drivers/mtd/nand/libnand.a drivers/mtd/nand_legacy/libnand_legacy.a drivers/mtd/onenand/libonenand.a drivers/mtd/ubi/libubi.a drivers/mtd/spi/libspi_flash.a drivers/net/libnet.a drivers/net/phy/libphy.a drivers/net/sk98lin/libsk98lin.a drivers/pci/libpci.a drivers/pcmcia/libpcmcia.a drivers/spi/libspi.a drivers/rtc/librtc.a drivers/serial/libserial.a drivers/usb/libusb.a drivers/video/libvideo.a common/libcommon.a libfdt/libfdt.a api/libapi.a post/libpost.a board/ams/as3536/libas3536.a --end-group -L /home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4 -lgcc

-Map u-boot.map -o u-boot

arm-linux-uclibc-objdump: bch_4_s_romtable.a: File format not recognized

board/ams/as3536/libas3536.a(as353x_nand.o): In function `as353x_correct_data':

/home/crifan/uboot_as3536/u-boot-2009.03/board/ams/as3536/as353x_nand.c:1111: undefined reference to `bchDecode'

board/ams/as3536/libas3536.a(as353x_nand.o): In function `as353x_calculate_ecc':

/home/crifan/uboot_as3536/u-boot-2009.03/board/ams/as3536/as353x_nand.c:1081: undefined reference to `bchEncodeT4'

当然,如果只是想把bch库加入进入,使得可以正常编译链接通过,那肯定是可以的,只需要简单的,把

bch_4_s_romtable.a加入到uboot根目录下的Make中,即:

把这个:$(obj)u-boot: depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT)

UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) |

sed -n -e 's/.*($(SYM_PREFIX)__u_boot_cmd_.*)/-u1/p'|sort|uniq`;

cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS)

--start-group $(__LIBS) --end-group $(PLATFORM_LIBS)

-Map u-boot.map -o u-boot

改成:$(obj)u-boot: depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT)

UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) |

sed -n -e 's/.*($(SYM_PREFIX)__u_boot_cmd_.*)/-u1/p'|sort|uniq`;

cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS)

--start-group board/ams/as3536/bch/bch_4_s_romtable.a $(__LIBS) --end-group $(PLATFORM_LIBS)

-Map u-boot.map -o u-boot

即可正常编译链接成功,生成正常的uboot了。

但是,此处我希望实现的是,不去改变顶层的uboot中的makefile,而只是在board/ams/as3536/下面,

改动其makefile,达到将此bch加入进去,以使得正常编译通过的目的。

2.而在board/ams/as3536/下面的makefile中,

我尝试了:LIB = $(obj)lib$(BOARD).a

COBJS := as3536.o asdebug.o ccu.o ssp.o ssp_nor.o enc28j60.o i2c_driver_polling.o as353x_nand.o shuffle.o mpmc_driver.o

#SOBJS := lowlevel_init.o bch/bch_enc4t.o bch/bch_dec4t.o

SOBJS := lowlevel_init.o

#BCH_COBJS := bch/bch_gf.o bch/bch_lut.o bch/bch_dec.o

SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)

OBJS := $(addprefix $(obj),$(COBJS))

SOBJS := $(addprefix $(obj),$(SOBJS))

BCH_OBJS :=$(addprefix $(obj),$(BCH_COBJS))

#$(LIB): $(obj).depend $(OBJS) $(SOBJS) $(BCH_COBJS)

# $(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS) $(BCH_COBJS)

$(LIB): $(obj).depend $(OBJS) $(SOBJS)

$(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)

在LIB = $(obj)lib$(BOARD).a

下面添加一行:

LIB += bch/bch_4_s_romtable.a

结果实际上,make后,也是没有传递到uboot中,还是缺少bch对应的函数。

所以,此处是希望,有了多个c文件和多个汇编文件,如果获得单个object目标文件,以方便后面

类似于:arm-linux-uclibc-ar crv libas3536.a as3536.o asdebug.o ccu.o ssp.o ssp_nor.o enc28j60.o i2c_driver_polling.o as353x_nand.o shuffle.o mpmc_driver.o lowlevel_init.o bch/bch_4_s_romtable.o

一样,将这个单个的bch的目前文件,ar加入到libas3536.a里面,这样,最后uboot编译链接,就可以正常了。

3.曾经尝试了:

[crifan@linux-41lh bch]$arm-linux-uclibc-gcc -D__ASSEMBLY__ -g -Os   -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DTEXT_BASE=0x00000000 -I/home/crifan/uboot_as3536/u-boot-2009.03/include -fno-builtin -ffreestanding -nostdinc -isystem /home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -c -o bch_4_s_romtable.obj bch_gf.c bch_lut.c bch_dec.c bch_enc4t.S bch_dec4t.S -combine

cc1: error: too many filenames given. Type cc1 –help for usage

对于显示的cc1的错误,一直没完全搞懂是什么原因。

因为刚刚试了下,

单个s文件和多个C文件是可以的:arm-linux-uclibc-gcc -D__ASSEMBLY__ -g -Os -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DTEXT_BASE=0x00000000 -I/home/crifan/uboot_as3536/u-boot-2009.03/include -fno-builtin -ffreestanding -nostdinc -isystem /home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -c -o bch_4_s_romtable.obj bch_gf.c bch_lut.c bch_dec.c bch_enc4t.S -combine

而且,对于as来说,多个汇编也是可以的:

[crifan@linux-41lh bch]$arm-linux-uclibc-as bch_enc4t.S bch_dec4t.S

但是,对于上面的,4个c文件,2个汇编文件,就不能正常编译了。所以,很是迷惑。。。

忘了说了,对于多个C文件,上面的arm-linux-uclibc-gcc是可以正常编译,生成单个目标文件的,只是需要加个参数-combine,详见:

4.刚刚去找了,关于:

cc1: error: too many filenames given

(注:google搜索时,最好把分隔符之类的都去掉,如cc1 error too many filenames given,才能搜到有用信息)

找到了一些:

这个人也是遇到了,但是没人解决。

这人说道“IIRC, –combine -fwhole-program can only be done for C language. The assembler files (.S) are not even run through the compiler, they are just passed down straight to the assembler, so it won’t be using –combine at all.”

好像我这里的arm-linux-uclibc-gcc,不加-combine,无法同时编译多个c文件。但是对于汇编文件,即使加了,好像同时编译多个c文件,1个汇编文件,也是可以的。也就是说,应该也是识别的,不过是要记得加-D__ASSEMBLY__ 。

中,遇到同样问题,但是最后说是“Replace CFLAGS with CPPFLAGS”就可以解决了。。。 而我这里,是直接手动加的参数,好像和他的不一样。。。。

这个人,好像说到的问题的重点,其也是用的是SUSE,然后遇到了类似的问题,并且都一个个解决了:

“Due to some "non-standardness" of

。。。。。。。Third issue is again

f77 -O -ffixed-line-length-132 -o decay decay_couplings.o decay.o decay_matrix.o decay_mom.o decay_event.o vegas.o decay_printout.o hdecay.o ran1.o rw_events.o open_file.o alfas_functions.o ../HELAS/lib/libdhelas3.a f77: ../HELAS/lib/libdhelas3.a: No such file or directory make[1]: * [all] Error 1 make[1]: Leaving directory `/home/roberto/MG_ME_V4.1.24/DECAY’ make: * [decay] Error 2

If you still have this problem then change to folder and issue make. You should get

~/MG_ME_V4.1.24/HELAS> make

f77 -O -I. -c httsxx.F

cc1: error: too many filenames given. Type cc1 –help for usage

# 1 "httsxx.F"

make: *** [httsxx.o] Error 1

To fix it you have to edit /usr/lib/gcc-lib/i586-suse-linux/3.3.5/specs Open this file and look for:

*cpp_options:

%(cpp_unique_options) %1 %{m*} %{std*} %{ansi} %{W*&pedantic*} %{w} %{f*} %{g*} %{O*} %{undef}

edit this line replacing "%{O*}" by "-o"

These are all the erros i had to fix to make MG compile on suse linux, 。。。。。。。。”

而我这里,由于用的是交叉编译器,所以,并不能通过直接去改SUSE里面的那些gcc而解决我的问题,估计要重新编译整套arm-linux-交叉编译的工具链才行。

看来问题很可能就是这个版本的SUSE下制作出来的工具链的这个问题。去查看了下,我这里的环境是

openSUSE 11.1,编译器的信息是:[crifan@linux-41lh bch]$arm-linux-gcc -v

Using built-in specs.

Target: arm-linux-uclibc

Configured with: /home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gcc-4.2.4/configure --prefix=/usr --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=arm-linux-uclibc --enable-languages=c --with-sysroot=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir --with-build-time-tools=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/arm-linux-uclibc/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-libssp --disable-tls --enable-shared --with-gmp=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gmp --with-mpfr=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/mpfr --disable-nls --enable-threads --disable-multilib --with-float=soft --with-abi=apcs-gnu --with-arch=armv5te --with-tune=arm9tdmi : (reconfigured) /home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gcc-4.2.4/configure --prefix=/usr --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=arm-linux-uclibc --enable-languages=c,c++ --with-sysroot=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir --with-build-time-tools=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/arm-linux-uclibc/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-libssp --disable-tls --enable-shared --with-gmp=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gmp --with-mpfr=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/mpfr --disable-nls --enable-threads --disable-multilib --with-float=soft --with-abi=apcs-gnu --with-arch=armv5te --with-tune=arm9tdmi : (reconfigured) /home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gcc-4.2.4/configure --prefix=/usr --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=arm-linux-uclibc --enable-languages=c,c++ --with-sysroot=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir --with-build-time-tools=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/arm-linux-uclibc/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-libssp --disable-tls --enable-shared --with-gmp=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gmp --with-mpfr=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/mpfr --disable-nls --enable-threads --disable-multilib --with-float=soft --with-abi=apcs-gnu --with-arch=armv5te --with-tune=arm9tdmi : (reconfigured) /home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gcc-4.2.4/configure --prefix=/usr --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=arm-linux-uclibc --enable-languages=c,c++ --with-sysroot=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir --with-build-time-tools=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/arm-linux-uclibc/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-libssp --disable-tls --enable-shared --with-gmp=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gmp --with-mpfr=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/mpfr --disable-nls --enable-threads --disable-multilib --with-float=soft --with-abi=apcs-gnu --with-arch=armv5te --with-tune=arm9tdmi

Thread model: posix

gcc version 4.2.4

编译出错时的详细编译信息:[crifan@linux-41lh bch]$arm-linux-uclibc-gcc -D__ASSEMBLY__ -g -Os -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DTEXT_BASE=0x00000000 -I/home/crifan/uboot_as3536/u-boot-2009.03/include -fno-builtin -ffreestanding -nostdinc -isystem /home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -combine -o bch_4_s_romtable.obj -c bch_enc4t.S bch_dec4t.S bch_gf.c bch_lut.c bch_dec.c -v

Using built-in specs.

Target: arm-linux-uclibc

Configured with: /home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gcc-4.2.4/configure --prefix=/usr --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=arm-linux-uclibc --enable-languages=c --with-sysroot=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir --with-build-time-tools=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/arm-linux-uclibc/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-libssp --disable-tls --enable-shared --with-gmp=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gmp --with-mpfr=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/mpfr --disable-nls --enable-threads --disable-multilib --with-float=soft --with-abi=apcs-gnu --with-arch=armv5te --with-tune=arm9tdmi : (reconfigured) /home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gcc-4.2.4/configure --prefix=/usr --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=arm-linux-uclibc --enable-languages=c,c++ --with-sysroot=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir --with-build-time-tools=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/arm-linux-uclibc/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-libssp --disable-tls --enable-shared --with-gmp=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gmp --with-mpfr=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/mpfr --disable-nls --enable-threads --disable-multilib --with-float=soft --with-abi=apcs-gnu --with-arch=armv5te --with-tune=arm9tdmi : (reconfigured) /home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gcc-4.2.4/configure --prefix=/usr --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=arm-linux-uclibc --enable-languages=c,c++ --with-sysroot=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir --with-build-time-tools=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/arm-linux-uclibc/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-libssp --disable-tls --enable-shared --with-gmp=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gmp --with-mpfr=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/mpfr --disable-nls --enable-threads --disable-multilib --with-float=soft --with-abi=apcs-gnu --with-arch=armv5te --with-tune=arm9tdmi : (reconfigured) /home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gcc-4.2.4/configure --prefix=/usr --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=arm-linux-uclibc --enable-languages=c,c++ --with-sysroot=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir --with-build-time-tools=/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/arm-linux-uclibc/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-libssp --disable-tls --enable-shared --with-gmp=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/gmp --with-mpfr=/home/eric/buildroot/buildroot-2009.08/toolchain_build_arm/mpfr --disable-nls --enable-threads --disable-multilib --with-float=soft --with-abi=apcs-gnu --with-arch=armv5te --with-tune=arm9tdmi

Thread model: posix

gcc version 4.2.4

/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../libexec/gcc/arm-linux-uclibc/4.2.4/cc1 -E -lang-asm -quiet -nostdinc -v -I/home/crifan/uboot_as3536/u-boot-2009.03/include -iprefix /home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/ -D__ASSEMBLY__ -D__KERNEL__ -DTEXT_BASE=0x00000000 -DCONFIG_ARM -D__ARM__ -isystem /home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/include bch_enc4t.S bch_dec4t.S -msoft-float -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -mtune=arm9tdmi -fno-strict-aliasing -fno-common -ffixed-r8 -fno-builtin -ffreestanding -fworking-directory -Os -o - |

/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/../../../../arm-linux-uclibc/bin/as --gdwarf2 -march=armv5te -mfloat-abi=soft -o bch_4_s_romtable.obj

#include "..." search starts here:

#include <...> search starts here:

/home/crifan/uboot_as3536/u-boot-2009.03/include

/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/include

End of search list.

cc1: error: too many filenames given. Type cc1 --help for usage

/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../libexec/gcc/arm-linux-uclibc/4.2.4/cc1 -quiet -nostdinc -v -I/home/crifan/uboot_as3536/u-boot-2009.03/include -iprefix /home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/ -D__ASSEMBLY__ -D__KERNEL__ -DTEXT_BASE=0x00000000 -DCONFIG_ARM -D__ARM__ -isystem /home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/include bch_gf.c bch_lut.c bch_dec.c -quiet -dumpbase bch_gf.c -msoft-float -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -mtune=arm9tdmi -auxbase-strip bch_4_s_romtable.obj -g -Os -version -fno-strict-aliasing -fno-common -ffixed-r8 -fno-builtin -ffreestanding -o - |

/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/../../../../arm-linux-uclibc/bin/as -march=armv5te -mfloat-abi=soft -o bch_4_s_romtable.obj

#include "..." search starts here:

#include <...> search starts here:

/home/crifan/uboot_as3536/u-boot-2009.03/include

/home/eric/buildroot/buildroot-2009.08/build_arm/staging_dir/usr/bin/../lib/gcc/arm-linux-uclibc/4.2.4/include

End of search list.

GNU C version 4.2.4 (arm-linux-uclibc)

compiled by GNU C version 4.3.2 [gcc-4_3-branch revision 141291].

GGC heuristics: --param ggc-min-expand=97 --param ggc-min-heapsize=126593

Compiler executable checksum: 07af4830ad3752d283d346e261dbcd0d

此问题有待后续验证:自己单独去ubuntu编译一个工具链,然后用其去编译我的代码,看看是否会出现同样的问题。

5.回来,经过验证,在ubuntu 9.10 + buildroot 2009.11编译出来的EABI版本的arm-linux-交叉编译工具链,

去作上面同样的事情,出现同样的问题:crifan@crifan-laptop:bch$ arm-linux-gcc -D__ASSEMBLY__ -g -Os -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DTEXT_BASE=0x00000000 -I/home/crifan/develop/uboot/u-boot-2009.03_toHome/include -fno-builtin -ffreestanding -nostdinc -isystem /home/crifan/develop/buildroot/buildroot-2009.11/output/staging/usr/bin/../lib/gcc/arm-linux-uclibcgnueabi/4.3.4/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -c -o bch_4_s_romtable.obj bch_gf.c bch_lut.c bch_dec.c bch_enc4t.S bch_dec4t.S -combine -v

Using built-in specs.

Target: arm-linux-uclibcgnueabi

Configured with: /home/crifan/develop/buildroot/buildroot-2009.11/output/toolchain/gcc-4.3.4/configure --prefix=/usr --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=arm-linux-uclibcgnueabi --enable-languages=c --with-sysroot=/home/crifan/develop/buildroot/buildroot-2009.11/output/staging --with-build-time-tools=/home/crifan/develop/buildroot/buildroot-2009.11/output/staging/usr/arm-linux-uclibcgnueabi/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-libssp --enable-tls --enable-shared --with-gmp=/home/crifan/develop/buildroot/buildroot-2009.11/output/toolchain/gmp --with-mpfr=/home/crifan/develop/buildroot/buildroot-2009.11/output/toolchain/mpfr --disable-nls --enable-threads --disable-multilib --disable-decimal-float --with-float=soft --with-abi=aapcs-linux --with-arch=armv5te --with-tune=arm9tdmi

Thread model: posix

gcc version 4.3.4 (GCC)

COLLECT_GCC_OPTIONS='-D__ASSEMBLY__' '-g' '-Os' '-fno-strict-aliasing' '-fno-common' '-ffixed-r8' '-msoft-float' '-D__KERNEL__' '-DTEXT_BASE=0x00000000' '-I/home/crifan/develop/uboot/u-boot-2009.03_toHome/include' '-fno-builtin' '-ffreestanding' '-nostdinc' '-isystem' '/home/crifan/develop/buildroot/buildroot-2009.11/output/staging/usr/bin/../lib/gcc/arm-linux-uclibcgnueabi/4.3.4/include' '-pipe' '-DCONFIG_ARM' '-D__ARM__' '-march=armv5te' '-mabi=apcs-gnu' '-mno-thumb-interwork' '-c' '-o' 'bch_4_s_romtable.obj' '-combine' '-v' '-mtune=arm9tdmi'

/home/crifan/develop/buildroot/buildroot-2009.11/output/staging/usr/bin/../libexec/gcc/arm-linux-uclibcgnueabi/4.3.4/cc1 -quiet -nostdinc -v -I/home/crifan/develop/uboot/u-boot-2009.03_toHome/include -iprefix /home/crifan/develop/buildroot/buildroot-2009.11/output/staging/usr/bin/../lib/gcc/arm-linux-uclibcgnueabi/4.3.4/ -D__ASSEMBLY__ -D__KERNEL__ -DTEXT_BASE=0x00000000 -DCONFIG_ARM -D__ARM__ -isystem /home/crifan/develop/buildroot/buildroot-2009.11/output/staging/usr/bin/../lib/gcc/arm-linux-uclibcgnueabi/4.3.4/include bch_gf.c bch_lut.c bch_dec.c -quiet -dumpbase bch_gf.c -msoft-float -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -mtune=arm9tdmi -auxbase-strip bch_4_s_romtable.obj -g -Os -version -fno-strict-aliasing -fno-common -ffixed-r8 -fno-builtin -ffreestanding -o - |

/home/crifan/develop/buildroot/buildroot-2009.11/output/staging/usr/bin/../lib/gcc/arm-linux-uclibcgnueabi/4.3.4/../../../../arm-linux-uclibcgnueabi/bin/as -march=armv5te -mfloat-abi=soft -meabi=gnu -o bch_4_s_romtable.obj

#include "..." search starts here:

#include <...> search starts here:

/home/crifan/develop/uboot/u-boot-2009.03_toHome/include

/home/crifan/develop/buildroot/buildroot-2009.11/output/staging/usr/bin/../lib/gcc/arm-linux-uclibcgnueabi/4.3.4/include

End of search list.

GNU C (GCC) version 4.3.4 (arm-linux-uclibcgnueabi)

compiled by GNU C version 4.4.1, GMP version 4.2.4, MPFR version 2.4.1-p5.

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072

Compiler executable checksum: 35aadf35a10982bb95d09027a81d2626

COLLECT_GCC_OPTIONS='-D__ASSEMBLY__' '-g' '-Os' '-fno-strict-aliasing' '-fno-common' '-ffixed-r8' '-msoft-float' '-D__KERNEL__' '-DTEXT_BASE=0x00000000' '-I/home/crifan/develop/uboot/u-boot-2009.03_toHome/include' '-fno-builtin' '-ffreestanding' '-nostdinc' '-isystem' '/home/crifan/develop/buildroot/buildroot-2009.11/output/staging/usr/bin/../lib/gcc/arm-linux-uclibcgnueabi/4.3.4/include' '-pipe' '-DCONFIG_ARM' '-D__ARM__' '-march=armv5te' '-mabi=apcs-gnu' '-mno-thumb-interwork' '-c' '-o' 'bch_4_s_romtable.obj' '-combine' '-v' '-mtune=arm9tdmi'

/home/crifan/develop/buildroot/buildroot-2009.11/output/staging/usr/bin/../libexec/gcc/arm-linux-uclibcgnueabi/4.3.4/cc1 -E -lang-asm -quiet -nostdinc -v -I/home/crifan/develop/uboot/u-boot-2009.03_toHome/include -iprefix /home/crifan/develop/buildroot/buildroot-2009.11/output/staging/usr/bin/../lib/gcc/arm-linux-uclibcgnueabi/4.3.4/ -D__ASSEMBLY__ -D__KERNEL__ -DTEXT_BASE=0x00000000 -DCONFIG_ARM -D__ARM__ -isystem /home/crifan/develop/buildroot/buildroot-2009.11/output/staging/usr/bin/../lib/gcc/arm-linux-uclibcgnueabi/4.3.4/include bch_enc4t.S bch_dec4t.S -msoft-float -march=armv5te -mabi=apcs-gnu -mno-thumb-interwork -mtune=arm9tdmi -fno-strict-aliasing -fno-common -ffixed-r8 -fno-builtin -ffreestanding -fworking-directory -Os -fno-directives-only -o - |

/home/crifan/develop/buildroot/buildroot-2009.11/output/staging/usr/bin/../lib/gcc/arm-linux-uclibcgnueabi/4.3.4/../../../../arm-linux-uclibcgnueabi/bin/as --gdwarf2 -march=armv5te -mfloat-abi=soft -meabi=gnu -o bch_4_s_romtable.obj

#include "..." search starts here:

#include <...> search starts here:

/home/crifan/develop/uboot/u-boot-2009.03_toHome/include

/home/crifan/develop/buildroot/buildroot-2009.11/output/staging/usr/bin/../lib/gcc/arm-linux-uclibcgnueabi/4.3.4/include

End of search list.

cc1: error: too many filenames given. Type cc1 --help for usage

所以,初步判断,我这里的问题,不是上面那个人说的SUSE的问题,看来还是哪里没搞清楚,有待以后有机会再解决了。

【后记】

后来,无意间,发现,原来是汇编文件的原因,上面的汇编文件是大S结尾,.S文件,这样编译就会出现:

cc1: error: too many filenames given. Type cc1 –help for usage

而改为正常的小s结尾的.s文件后,即将bch_enc4t.S bch_dec4t.S改为bch_enc4t.s bch_dec4t.s就可以正常编译了。

根本原因不详,个人猜测,好像是汇编的.S是预处理之后的文件吧,不能正常识别为最原始的.s汇编文件,所以不能一起编译。

6. 关于多个多个目前文件合并成单个目标文件的事情,google找到这个帖子:

Re: Can ld combine multiple object files into one?"> The Solaris ld command has an option to combine multiple object files (ie .o

> files) into one. Does the gnu ld have a similar option? The reason we want to

> do this is to hide certain information — combining multiple object files using

> ar will not do.

>

See ld documentation for relocatable link — it’s the same ‘-r’ option for

C code, but you need to use ‘-Ur’ for C++ code so that global constructors and destructors are handled properly.“

说的很清楚了,就是说,用ld,可以实现这个目的,不过要注意的是,对于C 代码的,要加参数-r表示生成的是

可重新定位的目标文件(我的理解是,否则就应该是可执行文件了):

“ -r, -i, –relocatable Generate relocatable output”

而C++代码,还要用-Ur,表示要建立全局构造函数表和析构函数表:

“ -Ur Build global constructor/destructor tables”

此处,试了试:

arm-linux-ld -r -o bch_4_s_noRomTable.obj bch_dec.o bch_gf.o bch_lut.o bch_enc4t.o bch_dec4t.o

就可以正常生成我所需要的单个目标文件/库文件了:

归根到底,还是对底层的这些编译链接等工具不熟悉,否则,就不会浪费这么长时间去搞明白这个简单的问题了:

[举例]

其中-o 表示述输出文件

另外,对于上面的,多个c文件和多个.S汇编文件,为何用arm-linux-gcc不能同时一起编译,具体原因,

希望知道的,帮忙解释一下,到现在为止,还是不知道其原因呢。。。

【后记】

将之前的汇编文件的.S后缀变为.s即可用arm-linux-gcc -combine -o outputFile.obj -c file1.c file2.c … file1.s file2.s …

但是,成功编译出来一个outputFile.obj后,用于其他环境,结果却会出错。

现象是,其中有些函数找不到,而这些函数,很明显地,是通过对应的宏去控制的是否编译的

而且的确是可以正常编译的,不知为何-combine这样的方式一次性地将C文件和s汇编文件,一起编译,却没有将对应函数和变量编译进去,很是奇怪

而单独地去编译这些文件,再通过ld将这些obj汇合到一起,却又可以正常使用了。真是怪事。。。后来发现,好像arm-linux-gcc -combine -march=armv5te -o as3536_linux_bch_eabi_noRomTbl.obj -c bch_dec.c bch_gf.c bch_lut.c bch_enc4t.s bch_dec4t.s

实际只相当于arm-linux-gcc -combine -march=armv5te -o as3536_linux_bch_eabi_noRomTbl.obj -c bch_enc4t.s bch_dec4t.s

[crifan@linux-41lh bch]$arm-linux-gcc -combine -march=armv5te -o as3536_linux_bch_eabi_all.obj -c bch_dec.c bch_gf.c bch_lut.c bch_enc4t.s bch_dec4t.s

[crifan@linux-41lh bch]$ls -lh

total 520K

。。。

-rw-r--r-- 1 crifan develop 2.5K 2010-06-08 13:13 as3536_linux_bch_eabi_all.obj

-rw-r--r-- 1 crifan develop 2.5K 2010-06-08 13:12 as3536_linux_bch_eabi_noRomTbl.obj

。。。

[crifan@linux-41lh bch]$arm-linux-objdump -t as3536_linux_bch_eabi_all.obj

as3536_linux_bch_eabi_all.obj: file format elf32-littlearm

SYMBOL TABLE:

00000000 l d .text 00000000 .text

00000000 l d .data 00000000 .data

00000000 l d .bss 00000000 .bss

0000002c l .text 00000000 bchEncodeT4Loop

00000238 l .text 00000000 bchEncodeT4End

0000020c l .text 00000000 bchEncodeT4LastBytes

00000280 l .text 00000000 bchSyndromePolyT4Loop

000004bc l .text 00000000 bchDecodeT4End

00000490 l .text 00000000 bchDecodeT4LastBytes

00000000 l d .ARM.attributes 00000000 .ARM.attributes

00000000 g .text 00000000 bchEncodeT4

00000000 *UND* 00000000 LUT4

00000258 g .text 00000000 bchSyndromePolyT4

[crifan@linux-41lh bch]$arm-linux-gcc -combine -march=armv5te -o as3536_linux_bch_eabi_noRomTbl.obj -c bch_enc4t.s bch_dec4t.s

[crifan@linux-41lh bch]$ls -lh

total 516K

。。。

-rw-r--r-- 1 crifan develop 2.5K 2010-06-08 13:12 as3536_linux_bch_eabi_noRomTbl.obj

。。。

[crifan@linux-41lh bch]$arm-linux-objdump -t as3536_linux_bch_eabi_noRomTbl.obj

as3536_linux_bch_eabi_noRomTbl.obj: file format elf32-littlearm

SYMBOL TABLE:

00000000 l d .text 00000000 .text

00000000 l d .data 00000000 .data

00000000 l d .bss 00000000 .bss

0000002c l .text 00000000 bchEncodeT4Loop

00000238 l .text 00000000 bchEncodeT4End

0000020c l .text 00000000 bchEncodeT4LastBytes

00000280 l .text 00000000 bchSyndromePolyT4Loop

000004bc l .text 00000000 bchDecodeT4End

00000490 l .text 00000000 bchDecodeT4LastBytes

00000000 l d .ARM.attributes 00000000 .ARM.attributes

00000000 g .text 00000000 bchEncodeT4

00000000 *UND* 00000000 LUT4

00000258 g .text 00000000 bchSyndromePolyT4

后来经过尝试,直接这么操作即可:arm-linux-gcc -combine -mabi=aapcs-linux -mfloat-abi=soft -march=armv5te -o bch_eabi_asm.obj -c bch_enc4t.s bch_dec4t.s

arm-linux-gcc -combine -mabi=aapcs-linux -mfloat-abi=soft -march=armv5te -o bch_eabi_cCode.obj -c bch_dec.c bch_gf.c bch_lut.c

arm-linux-ld -r -o bch_as353x_linux.objs bch_eabi_asm.obj bch_eabi_cCode.obj

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值