如何用二进制文本在LD中指定名称
How to specify names in LD with binary text?
我正试图将一个带有ld
的文本文件包装成.o
。考虑到我的项目的Makefiles是如何设置的,文本文件的完整路径将传递给ld
。这会导致生成的名称包含该路径。我不想这样,因为我不能在C++源代码中链接到那个名字。
当我运行ld
时,有没有办法更改名称或前缀?
ld -r -b binary /path/to/source/Value.txt -o Value.o
objdump -x Value.o | grep binary
0000000000000142 g .data 0000000000000000 _binary__path_to_source_Value_txt_end
0000000000000142 g *ABS* 0000000000000000 _binary__path_to_source_Value_txt_size
0000000000000000 g .data 0000000000000000 _binary__path_to_source_Value_txt_start
我希望看到像_binary_Value_txt_end
这样的名字。
基于Captain Oblivious的评论,我能够开发一个Makefile规则:
%.o: %.txt
pushd $(dir $<) ; $(LD) -r -b binary $(notdir $<) -o $@ ; popd
这将更改文本文件的目录位置,以便ld
创建漂亮的已知名称。我需要做一些工作来确保$@
是一个绝对路径,以便在构建目录中创建.o
。
相关文章:
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 当在同一名称空间中有两个具有相同签名的函数时,会发生什么
- 预处理器:插入结构名称中的前一个行号
- 我想将一个对T类型的非常量左值引用绑定到一个T类型的临时值
- 基类中的函数名称解析
- 模板元程序查找相似的连续类型名称
- 没有名称的C++模板参数
- C++中名称篡改的目的是什么
- 在基于范围的for循环中使用结构化绑定声明
- 使用 LuaBridge 将 LuaJIT 绑定到C++会导致"PANIC: unprotected error"
- ld:bind_at_load和-bitcode_bundle(Xcode设置ENABLE_bitcode=YES)不能
- 尝试通过OCI例程从Oracle获取blob数据,但出现错误:ORA-01008:并非所有变量都绑定
- 如何仅使用对象名称打印特定于对象的成员
- 将依赖名称显式标记为类型名和模板的奇怪之处
- Clang 3.8 错误:参数 '-fuse-ld=gold-2.25' 中的链接器名称无效
- Android NDK Linker (GStreamer) - 无效的链接器名称 -fuse-ld=gold.
- C++中名称查找和名称绑定之间的区别
- OSX "ld" : 如何显示未解析符号的损坏名称?如何获取地图文件?
- 如何用二进制文本在LD中指定名称
- 在C++中具有名称绑定的EDSL