[Bug target/67172] [5/6 regression] i686-w64-mingw32 dwarf2 bootstrap fails with undefined reference to __EH_FRAME_BEGIN__

breedlove.matt at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Aug 11 01:40:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67172

--- Comment #3 from Matt Breedlove <breedlove.matt at gmail dot com> ---
In gcc/defaults.h, it gets defined via:

/* If we have a definition of INCOMING_RETURN_ADDR_RTX, assume that
   the rest of the DWARF 2 frame unwind support is also provided.  */
#if !defined (DWARF2_UNWIND_INFO) && defined (INCOMING_RETURN_ADDR_RTX)
#define DWARF2_UNWIND_INFO 1
#endif

/* If we have named sections, and we're using crtstuff to run ctors,
   use them for registering eh frame information.  */
#if defined (TARGET_ASM_NAMED_SECTION) && DWARF2_UNWIND_INFO \
    && !defined (EH_FRAME_IN_DATA_SECTION)
#ifndef EH_FRAME_SECTION_NAME
#define EH_FRAME_SECTION_NAME ".eh_frame"
#endif
#endif


This then gets pulled in to gcc/c-family/c-cppbuiltin.c at:

#ifdef EH_FRAME_SECTION_NAME
      builtin_define_with_value ("__LIBGCC_EH_FRAME_SECTION_NAME__",
                                 EH_FRAME_SECTION_NAME, 1);
#endif


INCOMING_RETURN_ADDR_RTX gets defined in gcc/config/i386/i386.h and
TARGET_ASM_NAMED_SECTION is defined in gcc/config/i386/cygming.h which is used
by both cygwin and mingw.  Cygwin, however, has their own EH specific blocks
and because many of the headers are shared between it and mingw, I'm unsure
where this actually belongs.  

In addition, libgcc/config/i386/cygming-crtbegin.c defines __EH_FRAME_BEGIN__
via the following:

#if DWARF2_UNWIND_INFO
static EH_FRAME_SECTION_CONST char __EH_FRAME_BEGIN__[]
  __attribute__((used, section(__LIBGCC_EH_FRAME_SECTION_NAME__), aligned(4)))
  = { };

This passes and the symbol for it can be seen within the nm output included in
the additional_notes.txt file attached to the bug.  Both of these files compile
with __LIBGCC_EH_FRAME_SECTION_NAME__ set seen below but fail the link.

crtbegin.i:

# 97 "../../../gcc/libgcc/config/i386/cygming-crtbegin.c"
static char __EH_FRAME_BEGIN__[]
  __attribute__((used, section(".eh_frame"), aligned(4)))
  = { };


__main_s.i:

#pragma GCC visibility pop
# 2216 "../../../gcc/libgcc/libgcc2.c" 2
extern unsigned char __EH_FRAME_BEGIN__[];



With all the target-specific blocks in the common cygwin/mingw headers, I
didn't want to go messing around with things without input since I was told
EH_FRAME_SECTION_NAME shouldn't be defined for mingw and having it undefined
will fail a number of blocks that are protected merely by DWARF2_UNWIND_INFO
being defined.  The patch merely restores things back to pre-5.0 but whether
the definitions were correct then or simply masked an underlying issue and
allowed linking to pass, I'm not sure.  I have the full build temps in case
anyone requires additional documentation.



More information about the Gcc-bugs mailing list