【问题标题】:How to compile ld with custom linker scripts?如何使用自定义链接器脚本编译 ld?
【发布时间】:2013-11-24 18:21:16
【问题描述】:

我正在尝试构建 linux 内核 3.8 的自定义版本,我希望我的链接器表现得有点不同,所以我更改了它的 ldscripts。 具体来说,我配置 binutils -> make -> change ldscripts -> make install。 但是,当我尝试使用链接器编译 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 */

问题是我已经更改了我的 ldscripts 并在每个脚本的开头添加了一个标签以识别它们,但我的编译器似乎并不关心。 但是我的系统中没有任何其他 elf 脚本,因此搜索错误 library path 的选项实际上不是一个选项。

我这里有什么遗漏吗?

请注意,我正在为 sparc 进行交叉编译

【问题讨论】:

    标签: linux linker ld linker-scripts linux-from-scratch


    【解决方案1】:

    默认 ld 脚本被编译到编译器驱动程序 (gcc) 中,因此您至少应该重建工具链。

    这也可能是gcc 不会查看除内置之外的任何链接器脚本的情况,因此您必须在工具链中修改它们(它可能在某处的规范文件中)。

    【讨论】:

      【解决方案2】:

      您可以将自定义链接器脚本传递给ld

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

      gcc:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-07-11
        • 2011-12-11
        • 1970-01-01
        • 2015-03-14
        • 2015-11-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多