在我的系统上编译时(使用bfin-linux-uclibc-g++
,但这是无关紧要的),我得到了数百个关于其中一个编译器标志的警告(不在我自己的代码库中)。我想禁用它。
fde encoding in src/SpiMessageUtil.o(.eh_frame) prevents .eh_frame_hdr table being created.
这是从默认的gcc标志开始的,该标志被移交给链接器,通过将'-v'
添加到编译步骤中很容易检查:
COLLECT_GCC_OPTIONS=... --eh-frame-hdr ...
我想摆脱这个选项,这确实是默认定义的:
bfin-linux-uclibc-g++ -dumpspecs | grep frame-hdr
%{!static:--eh-frame-hdr}\
%{mfdpic: -m elf32bfinfd -z text} %{shared} %{pie} \
%{static:-dn -Bstatic} %{shared:-G -Bdynamic} \
%{!shared: %{!static: %{rdynamic:-export-dynamic} \
%{!dynamic-linker:-dynamic-linker \
%{mglibc:%{muclibc:%e-mglibc and -muclibc used together;:%e-mglibc not supported for this target};:/lib/ld-uClibc.so.0 \
}}}\
%{static}} -init __init -fini __fini
如何覆盖此选项?我不能使用-Wl,--no-eh-frame-hdr
,因为没有任何类似的定义。
答案 0 :(得分:1)
I just got started with back-porting some code to an old system with a bfin controller and ran into the problem with these terribly annoying warnings - 1000s at a time. I didn't find a way to just deactivate the output.
But there are 2 "ways to go" that work:
Remove the code that creates the output in elf-eh-frame.c in the function _bfd_elf_discard_section_eh_frame:
(*info->callbacks->einfo)
(_("%P: fde encoding in %B(%A) prevents .eh_frame_hdr"
" table being created.\n"), abfd, sec);
Take a look at the ld-Binary and patch the binary directly. I dumped the data segment (.rodata) with objdump to find the address of the string. Then (after creating a disassembly with objdump) I searched where that string was used and replaced the call to the function that creates the output with two NoOps (0xFF 0xD3 -> 0x90 0x90). Linker still creates the same output, but no more messages.
答案 1 :(得分:0)
您可以动态转储GCC的规范,从那里删除此开关并在链接时使用它,即:
g++ -dumpspecs | sed -e 's,--eh-frame-hdr,,g' > better_specs
g++ -specs=better_specs -o target file1.o file2.o -llib1...
这将替换内联规范,同时保持原始编译器的完整。
如果您保留自己的Makefile,也可以使用以下内容处理:
$(TARGET): $(OBJS) | better_specs
$(LINK.o) $(OUTPUT_OPTION) -specs=$| $^
better_specs:
$(CXX) -dumpspecs | sed -e 's,--eh-frame-hdr,,g' > $@
这种方法也可以用于配置脚本,只要你以前生成better_specs,就可以使用./configure CXX='g++ -specs=/path/to/better_specs'
。