简体   繁体   English

如何使用自定义链接器脚本编译 ld?

[英]How to compile ld with custom linker scripts?

i am trying to build a custom version of the linux kernel 3.8 and i want my linker to behave a bit different so i changed its ldscripts.我正在尝试构建 linux 内核 3.8 的自定义版本,并且我希望我的链接器的行为有所不同,因此我更改了它的 ldscripts。 Specifically I configure binutils -> make -> change ldscripts -> make install .具体来说,我配置 binutils -> make -> change ldscripts -> make install However when i try to compile libc using my linker the only thing i see is this :但是,当我尝试使用链接器编译 libc 时,我看到的唯一一件事是:

GNU ld (GNU Binutils) 2.23
  Supported emulations:
   elf32_sparc
   sparclinux
   elf64_sparc
   sun4
using internal linker script:
==================================================
/* Script for --shared -z combreloc: shared library, combine & sort relocs */

etc等等

The thing is that i have changed my ldscripts and prepended a tag at the beginning of each script in order to recognize them but my compiler does not seem to care.问题是我已经更改了我的 ldscripts 并在每个脚本的开头添加了一个标签以便识别它们,但我的编译器似乎并不关心。 However i don't have any other elf scripts in my system so the option of searching the wrong library path is not actually an option.但是,我的系统中没有任何其他elf脚本,因此搜索错误库路径的选项实际上不是一个选项。

Is there something i am missing here?有什么我在这里想念的吗?

Notice that i am cross compiling for sparc请注意,我正在为 sparc 进行交叉编译

Default ld scripts get compiled into compiler driver ( gcc ) so you should at least rebuild the toolchain.默认ld脚本被编译到编译器驱动程序 ( gcc ) 中,因此您至少应该重建工具链。

That's also probably the case that gcc will not look at any linker scripts other than built into it, so you'll have to modify them in toolchain (it's probably in spec files somewhere).这也可能是gcc不会查看除内置之外的任何链接器脚本的情况,因此您必须在工具链中修改它们(它可能在某处的规范文件中)。

You can pass a custom linker script to ld :您可以将自定义链接器脚本传递给ld

ld -T <path/to/file> ...

or to gcc :gcc

gcc -Wl,-T,<path/tofile> ...

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

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