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的前面。
阅读(1353) | 评论(0) | 转发(0) |