zhihua.xie@droid08-sz:/mnt/nfsroot/zhihua.xie/led_on/led_on_c$ // 包含文件,微云:led_on_c.tar.gz
crt0.S led_on_c.c link.ld.S Makefile
--------------------------------------------------------------------------------------------------------------------------
Makefile:
led_on_c.bin : crt0.S led_on_c.c led_on.lds
arm-linux-gnueabihf-gcc -g -c -o crt0.o crt0.S
arm-linux-gnueabihf-gcc -g -c -o led_on_c.o led_on_c.c
arm-linux-gnueabihf-ld -T link.ld.S -g crt0.o led_on_c.o -o led_on_c_elf -Map startup.map
arm-linux-gnueabihf-objcopy -O binary -S led_on_c_elf led_on_c.bin
arm-linux-gnueabihf-objdump -D -m arm led_on_c_elf > led_on_c.dis
clean:
rm -f led_on_c.dis led_on_c.bin led_on_c_elf *.o startup.map
---------------------------------------------------------------------------------------------------------------------------------------------
link.ld.S
OUTPUT_FORMAT(elf32-littlearm)
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
. = 0x30800000;
. = ALIGN(4);
.text :
{
crt0.o(.text)
*(.text)
}
. = ALIGN(4);
.data :{led_on_c.o(.data)}
. = ALIGN(4);
.bss :{led_on_c.o(.bss)}
}
-----------------------------------------------------------------------------------------------------------------
i.mx6 SDK:
$(APP_ELF): $(SUBDIRS) $(app_objs) $(the_ld_file) $(LIBRARIES) $(APP_LIBS)
@$(call printmessage,link,Linking, $(APP_NAME))
$(at)$(LD) -Bstatic -nostartfiles -nostdlib $(LDFLAGS) \
-T $(the_ld_file) \
$(LDINC) \
--start-group \
$(app_objs) \
$(LIBRARIES) \
$(APP_LIBS) \
$(LDADD) \
--end-group \
-o $@ \
-Map $(app_map) --cref
$(at)$(OBJCOPY) --gap-fill 0x00 -I elf32-little -O binary $@ $(app_bin)
@echo "Output ELF:" ; echo " $(APP_ELF)"
@echo "Output binary:" ; echo " $(app_bin)"
---------------------------------------------------------------------------------------------------------------------
ld –o test –Ttext 0x0 –e main test.o
在通过gcc/g++间接调用链接程序ld时,所有的ld选项前必须加上“-Wl,”,因为-Map是ld的选项。
所以,要让g++生成mapfile,需要增加编译参数“ -Wl,-Map,mapfile”。
例:gcc -o helloworld helloworld.c -Wl,-Map,helloworld.map
.text.flasheader
0x27800000 0x71c board/embest/mx6q_marsboard/flash_header.o
cpu/arm_cortexa8/start.o()
*fill* 0x2780071c 0x4 00
.text 0x27800720 0x440 cpu/arm_cortexa8/start.o
0x27800720 _start
0x27800760 _end_vect
0x27800764 _armboot_start
SECTIONS
{
. = 0x00000000; /* 后记:这个链接起始地址实际上被-Ttest $(TEST_BASE)更新了*/
. = ALIGN(4);
.text
阅读(2402) | 评论(0) | 转发(0) |