简体   繁体   English

生成 elf 文件时 linker 脚本文件如何工作

[英]How linker script files work when generate elf file

I am using linker script file to generate specific elf file.I add this code to lscript.ld我正在使用 linker 脚本文件生成特定的 elf 文件。我将此代码添加到 lscript.ld

.test : {
    *(.text.ssc_entry)
    *main.o(.text)
    *main.o(.text.*)
} > ins_lmb_bram_if_cntlr_0_Mem_data_lmb_bram_if_cntlr_1_Mem

After I successfully generated the elf file, I checked the contents of.text.ssc_entry in main.o and 。test in elf.我成功生成elf文件后,查看了main.o中的.text.ssc_entry和elf中的.test的内容。 内容 They are identical on the right two bytes, but have different left two bytes.它们右两个字节相同,但左两个字节不同。 I wonder if this is a normal result or something went wrong to cause this result我想知道这是正常结果还是出了什么问题导致了这个结果

They are identical on the right two bytes, but have different left two bytes.它们右两个字节相同,但左两个字节不同。

If by "left two bytes" you mean the (two-byte) file offset, and the "right two bytes" you mean the 16-byte file contents, then yes: everything is working as expected here: in the linked file the location of the .test section is different from the location of the .text.scc_entry in the main.o .如果“左两个字节”是指(两个字节)文件偏移量,而“右两个字节”是指 16 字节文件内容,那么是的:这里的一切都按预期工作:在链接文件中的位置.test部分的位置与.text.scc_entrymain.o的位置不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM