当我们编译u-boot的时候会生成System.map文件,vim System.map,然后查找printf,可以发现printf在u-boot中的运行地址。我们可以利用这个printf打印字符串。
下面是head.S,text.c和Makefile:
head.S:
- abc:
- mov ip,sp
- stmfd sp!,{fp, ip, lr, pc}
- sub fp, ip, #4
-
- bl test
-
- sub sp, fp, #12
- ldmfd sp, {fp, sp, pc}
text.c:
- void (*show)(char *, ...) = 0x57e10660;
- void test(void)
- {
- show("i love linux.\n");
- }
Makefile:
- all:
- arm-linux-gcc -c head.S test.c
- arm-linux-ld -Ttext=0x64000000 -o head.elf led.o test.o
- arm-linux-objcopy -O binary head.elf head.bin
- cp head.bin /tftpboot
- clean:
- rm -rf *.elf *.bin *.o
操作方法:
kero > tftp 64000000 head.bin
ERROR: resetting DM9000 -> not responding
dm9000 i/o: 0x18000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 88:88:88:88:88:88
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.99
Filename 'led.bin'.
Load address: 0x64000000
Loading: ###
done
Bytes transferred = 32860 (805c hex)
kero > go 64000000
## Starting application at 0x64000000 ...
i love linux.
## Application terminated, rc = 0xE
kero >
阅读(2857) | 评论(0) | 转发(0) |