我有一个正在 vxWorks 中工作的项目,构建一个用于测试的 vxsim 二进制文件。链接过程分为三个阶段;makefile 的相关部分大致如下所示:
partialImage.o: ${SYSTEM_OBJS} ${OBJS} version.o
ldsparc ${appropriate LDFLAGS go here} ${^} -o ${@}
# Don't ask me why they did it this way; it seems redundant to re-use
# all the other objects as well as partialImage.o, but I'm also not extremely
# versed in what's necessary for munch.tcl to do its thing.
ctdt.o: partialImage.o ${SYSTEM_OBJS} ${OBJS} version.o
${VXSIMNM} ${^} | tclsh ${path to munch.tcl} > ${@:%.o=%.c}
ccsparc ${appropriate CFLAGS go here} ${@:%.o=%.c} -o ${@}
${FINAL_IMAGE}: ${a list of dependencies here}
ldsparc -N -e _sysInit -Ttext 60010000 \
${appropriately ordered list of objects} \
-defsym _VX_DATA_ALIGN=16 \
-T link.RAM \
-o ${@}
如果需要更多信息(标志等),请告诉我。我现在不在那台电脑前,但如果到那时还没有答案,我会在大约一个小时后更新这个问题并提供更多详细信息。
以下是链接描述文件的粗略草图。如果您可以访问 vxWorks 6.x,它只是默认的 'link.RAM' 脚本:
START(_sysInit)
SECTIONS {
.text {
wrs_kernel_text_start = .;
/* A few other variable declarations and inclusions from various other segments */
. = ALIGN(16);
}
. = ALIGN(16);
/* The rest of the linker script */
}
wrs_kernel_text_start
请注意在包含任何内容之前和任何 ALIGN 语句之前发生在文本段开头的事实。
在我做过的其他 vxWorks 项目中,wrs_kernel_text_start = 0x60010000
; 然而,在这个特定的项目中,它是一个大致与0x6025XXXX
. 您没有看错,地址比我预期的地址高 1 个数量级——也就是说,它不是0x60025XXX
. 正如我预期_sysInit
的那样开始。0x60010000