5

On my system when I compile something (with bfin-linux-uclibc-g++ but that is irrelevant), I get hundreds of warnings (not in my own code base) with respect to one of the compiler flags. I want to disable it.

fde encoding in src/SpiMessageUtil.o(.eh_frame) prevents .eh_frame_hdr table being created.

This orginates from a default gcc flag which is handed over to the linker, which is easy to check by adding '-v' to the compilation step:

COLLECT_GCC_OPTIONS=... --eh-frame-hdr ...

I would like to get rid of this option, which is indeed by default defined:

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

How can I override this option? I cannot use -Wl,--no-eh-frame-hdr, because there is nothing like that defined.

Anne van Rossum
  • 3,091
  • 1
  • 35
  • 39
  • I disabled the option by this: `strace /opt/uClinux/bfin-linux-uclibc/bin/bfin-linux-uclibc-gcc 2>&1 | grep -i spec`, go to one of these directories, `bfin-linux-uclibc-g++ -dumpspecs > specs` and manually update the `specs` file there. Looks ugly though. Removing the flag does not get rid of the warnings, but seems to be a bug (see patch 22 Jan. 2013): http://sourceware.org/ml/binutils/2013-01/msg00333.html. Is this indeed how you're supposed to do this, or is there a more beautiful way? – Anne van Rossum Jun 04 '13 at 08:29

2 Answers2

1

You can dynamically dump GCC's specs, remove this switch from there and use it when linking, i.e.:

g++ -dumpspecs | sed -e 's,--eh-frame-hdr,,g' > better_specs
g++ -specs=better_specs -o target file1.o file2.o -llib1...

This would replace the specs inline, while keeping original compiler intact.

If you keep your own Makefiles, this could also be handled with something like:

$(TARGET): $(OBJS) | better_specs
    $(LINK.o) $(OUTPUT_OPTION) -specs=$| $^

better_specs:
    $(CXX) -dumpspecs | sed -e 's,--eh-frame-hdr,,g' > $@

This approach could be also used with configure scripts, provided that you generate better_specs before, you could just use ./configure CXX='g++ -specs=/path/to/better_specs'.

raspy
  • 3,995
  • 1
  • 14
  • 18
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:

Fix the source and rebuild the tool-chain:

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);

Patch the ld binary

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.

DrP3pp3r
  • 803
  • 9
  • 33