不要将 --build-id 从 gcc 传递给链接器 [英] Do not pass --build-id to linker from gcc

查看:100
本文介绍了不要将 --build-id 从 gcc 传递给链接器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 gcc-arm-linux-gnueabi-nostdlib 为嵌入式 arm 处理器进行编译,以删除对 c 库和启动的依赖文件.该芯片没有任何解释 elf 文件的方法,因此使用 objcopy -O binary,我可以从中删除 elf 头文件.但是,如果我保留构建 ID,则二进制文件在输出的开头具有构建 ID,因此它无法运行.我可以使用 /DISCARD/: { *(.note.gnu.build-id) *(.ARM.attributes) } 删除链接器脚本中的构建 ID,但是链接器会警告 .note.gnu.build-id 部分被丢弃,--build-id 被忽略..虽然这工作正常,并且代码在芯片上运行良好,但我希望不必通过然后删除构建 ID.有什么方法可以指示 gcc 将命令传递给链接器而不同时传递 --build-id?

解决方案

我认为这些选项可以满足您的需求:

-Wl,--build-id=none

<块引用>

为 style 设置 none 会禁用命令行中前面任何 --build-id 选项的设置.

ld 手册

I'm trying to compile for an embedded arm processor using gcc-arm-linux-gnueabi, and -nostdlib to remove the dependencies on the c libraries and startup files. The chip doesn't have any way of interpreting elf files, so using objcopy -O binary, I can remove the elf headers from it. However, if I leave the build ID in, then the binary has the build ID at the start of the output, and so it fails to run. I can remove the build id in the linker script using /DISCARD/ : { *(.note.gnu.build-id) *(.ARM.attributes) }, however then the linker warns about .note.gnu.build-id section discarded, --build-id ignored.. While this works fine, and the code runs on the chip fine, I'd like to not have to pass and then drop the build ID. Is there any way to instruct gcc to pass commands to the linker without also passing --build-id?

解决方案

I think these options will do what you want:

-Wl,--build-id=none

Passing none for style disables the setting from any --build-id options earlier on the command line.

ld manual

这篇关于不要将 --build-id 从 gcc 传递给链接器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆