强制某些编译器生成的变量进入特定的 ELF 部分(使用 gcc)

问题描述 投票:0回答:1

没关系,这个历史问题与现代无关

c
1个回答
3
投票

一种方法可能比您想要的更黑客,是插入一个脚本来更改编译和汇编之间的节名称。例如:

gcc -fdata-sections -S -o test.s test.c
sed 's/^\t.section\t\.rodata\.__func__\.[0-9]*/\t.section .rom_data/' -i test.s
gcc -c test.s

您还可以尝试编写 clang 转换过程以将

__func__
声明放置在您选择的部分中,或者使用 libbfd 编写对象文件操作程序。

© www.soinside.com 2019 - 2024. All rights reserved.