Bug 54568 - --eh-frame-hdr should also be enabled for static executable
Summary: --eh-frame-hdr should also be enabled for static executable
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-13 14:32 UTC by H.J. Lu
Modified: 2017-08-31 13:30 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-08-31 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2012-09-13 14:32:12 UTC
From

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24724#c15

--
On a system whose linker supports --eh-frame-hdr, we will use the version of
_Unwind_Find_FDE in unwind-dw2-fde-dip.c.  It will override the version in
unwind-dw2-fde.c by renaming it via #define.  This file is selected by
libgcc/config/t-eh-dw2-dip.  It will still call the version of
_Unwind_Find_FDE, but that function will only look through files registered by
__register_frame_info_bases.  __register_frame_info_bases is called by
crtstuff.c, but it is only called on systems whose linker does not support
--eh-frame-hdr.
--

On PT_GNU_EH_FRAME targets, even __register_frame_info_bases isn't
defined/used, we still include unwind-dw2-fde.c and call its
_Unwind_Find_FDE as _Unwind_Find_registered_FDE.  Should we skip
the whole thing?
Comment 1 H.J. Lu 2012-09-13 15:50:08 UTC
It is needed by crtbeginT.o for -static since PT_GNU_EH_FRAME isn't
used for static executables.  However, dl_iterate_phdr works fine
with libc.a from glibc.  Jakub, do you remember why PT_GNU_EH_FRAME
isn't used on static executables?
Comment 2 Jakub Jelinek 2012-09-13 16:11:12 UTC
Think about libraries built with older GCC versions or built with older binutils.  Those would still call the register routines instead of building .eh_frame_hdr.
Comment 3 H.J. Lu 2012-09-13 16:18:24 UTC
(In reply to comment #2)
> Think about libraries built with older GCC versions or built with older
> binutils.  Those would still call the register routines instead of building
> .eh_frame_hdr.

We are talking static executables here.  .eh-frame-hdr section is generated by
the linker to create static executable and we know --eh-frame-hdr works with
the linker.  Why shouldn't --eh-frame-hdr work for static executable linked
with libraries built with older GCC versions or built with older binutils?
Comment 4 H.J. Lu 2012-09-13 22:23:08 UTC
The old interface is needed for DSO and executable created by
the older binutils.  However, it has nothing to with -static.
Also for Android targets, there is no old DSO.
Comment 5 H.J. Lu 2017-08-31 13:30:35 UTC
-static -flto may not work without --eh-frame-hdr:

https://sourceware.org/ml/binutils/2017-08/msg00365.html

since LTO may pull in object files after crtend.o.