Chinaunix首页 | 论坛 | 博客
  • 博客访问: 721966
  • 博文数量: 124
  • 博客积分: 3156
  • 博客等级: 中校
  • 技术积分: 1584
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-02 10:29
文章分类

全部博文(124)

文章存档

2012年(3)

2011年(2)

2010年(61)

2009年(34)

2008年(24)

我的朋友

分类: LINUX

2008-11-25 16:06:06

CC=arm-linux-gcc      #换成arm-elf-gcc不行,可以生成flat格式的文件,但我不知道怎么转成binary
LD=arm-linux-ld
OBJCOPY=arm-linux-objcopy
OBJDUMP=arm-linux-objdump
all:test.o
    #arm-linux-ld -Bstatic  -Tubl_davinci.lds -Map system.map --cref -nostartfiles -o target.elf test.o util.o uart.o
    #不能直接使用arm-linux-ld进行连接,一定要用下面的才可以成功。
    
    $(CC)  -v -static -Wl,-Tubl_davinci.lds,-Map,system.map -nostartfiles -o target.elf test.o util.o uart.o
   
    $(OBJCOPY)  -O binary  target.elf boot.bin #这个生产的binary文件有300K,看下system.map,它把非常多的库函数都链接进来了,不知有没办法减少?
    @echo -n "The entry point of the binary is 0x"
    @$(OBJDUMP) -t target.elf | grep -E '[0-9a-f]{8}*[0-9a-f]{8} main' | sed  's/^\([0-9a-f]\{8\}\)\([0-9a-f]\{4\}\).*/\2/'
 
test.o:
    $(CC)   -c test.c util.c uart.c
   
clean:
    rm *.o
# -v 显示编译链接的详细过程
#-static 静态链接
#-Wl,-Tubl_davinci.lds,-Map,system.map 这些参数传给链接器
#-nostartfiles 告诉gcc不要加入启动文件。
阅读(5526) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~