Chinaunix首页 | 论坛 | 博客
  • 博客访问: 81464
  • 博文数量: 19
  • 博客积分: 546
  • 博客等级: 中士
  • 技术积分: 232
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-10 00:07
文章分类

全部博文(19)

文章存档

2014年(1)

2013年(3)

2012年(2)

2011年(4)

2010年(9)

我的朋友

分类: 嵌入式

2014-04-18 23:07:02

Question:
Input sequence是如何决定的?因为要用到的object modules可以从command-line, compiler driver, linker script中specify, 比如说startup file? 这三者之间的优先级是如何确定的?More specifically, compiler driver可以在specs string中使用startfile command来指定startup file, 比如说:

*startfile: crti%0%s crtbegin%0%s crt0_freertos%0

 还可以在linker script中使用STARTUP()来指定。

Answer:
--- This depends on where the linker script is referenced in the command.
--- Some hint can also be retrieved from the Makefile:

TPRG_LDFLAGS = -specs=$(TPRG_SPECS) -T$(TPRG_LDSCRIPT)
TPRG_SPECS = $(RTOS_ROOT)/config/ea_lpc2468-ram.specs
TPRG_LDSCRIPT = $(RTOS_ROOT)/config/ea_lpc2468-ram.ld

$(TPRG_ROOT)/%.elf: ...
                  $(CC) $(TPRG_CFLAGS) -o $@ $(TPRG_LDFLAGS) $< $(TPRG_LDLIBS)

因此command line先于spec string,然后spec string优先级高于linker script!

---- 这样的优先级排序确实是有道理的。因为specs string指定的是OS或language相关的object modules. 在此时,并不知道linker script中指定的module中有哪些module会用到它们。 再加上linking process can't look backward, it just scan the input in sequence, 所以spec string指定的object module会放在linkerscript指定的module的前面。


阅读(1291) | 评论(0) | 转发(0) |
0

上一篇:const 常量与define宏定义的区别

下一篇:没有了

给主人留下些什么吧!~~