arm-linux-ld 链接时如何包含头文件?
我写了两个简单的不能再简单的程序,用来测试arm-linux-gcc和arm-linux-ld。
工程总共有Makefile,myld.lds,main.c,app.c,和app.h 这5个文件,下面分别给出代码
makefile文件如下
CC = arm-linux-gcc LD = arm-linux-ldOBJDUMP = arm-linux-objdumpOBJCOPY = arm-linux-objcopy LDFAGS := -T myld.ldsLDFAGS += -lc -lm -lgcc_s -Bstatic CFLAGS := -g -c -O2 -nostdlibCFLAGS += -oobjs=main.o app.oucos_ii.bin:$(objs) $(LD) -o core.elf $(objs) $(LDFAGS) -Map core.map $(OBJCOPY) -O binary -S core.elf core.bin $(OBJDUMP) -D -m arm core.elf > core.dismain.o:main.c $(CC) $(CFLAGS) $@ $<app.o:app.c $(CC) $(CFLAGS) $@ $<clean: -rm -f *.o -rm -f *.elf -rm -f *.bin -rm -f *.map
ENTRY(_start)SECTIONS{. = 0x20000040; .text : { *(.text ) } . = ALIGN(4); .rodata : { *(.rodata) } . = ALIGN(4); .data : { *(.data) } . = ALIGN(4); .bss : { *(.bss) }}
#include "app.h"int main(void){ app(); return 0;}
static void *memcpy(void *dest, void *src, int count){ char *tmp = dest; char *s = src; while (count--) *tmp++ = *s++; return dest;}int app(void){ char a[4]; char str="1234"; memcpy(a,str,4); return 0; }
int app(void);
#include <string.h>int app(void){ char a[4]; char str="1234"; memcpy(a,str,4); return 0; }