PATCH: PR debug/54568: --eh-frame-hdr should also be enabled for static executable

H.J. Lu hjl.tools@gmail.com
Fri Sep 14 13:59:00 GMT 2012


On Fri, Sep 14, 2012 at 5:26 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Sep 14, 2012 at 05:12:19AM -0700, H.J. Lu wrote:
>> On Fri, Sep 14, 2012 at 2:41 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>> > Well, there is.  For more than 2 years after the addition of --eh-frame-hdr
>> > support dl_iterate_phdr in libc.a would simply always fail, you aren't
>> > adding any kind of check that old glibc (2001-2003ish) isn't used.
>> > Even in newer glibcs, it relies on AT_* aux vector values provided by the
>> > kernel, if they are not provided for whatever reason, it would fail.
>
>> It was implemented in
>>
>> http://sourceware.org/ml/libc-alpha/2003-10/msg00098.html
>>
>> for glibc 2.3.0 and we can check
>
> Yeah, I know, but that is still later than 2001 when it was implemented for
> dynamically linked executables.
> USE_PT_GNU_EH_FRAME is defined even for glibc 2.2.something (if DT_CONFIG
> macro is defined in headers).

Here is a patch to add an option to use --eh-frame-hdr on static.
It won't enable it for uclibc since it is > glibc 2.2.

>> AT_PHDR:         0x400040
>> AT_PHNUM:        10
>>
>> with LD_SHOW_AUXV.
>
> I was worried about some loaders that wouldn't pass the aux vector down.
> E.g. valgrind's loader does, but perhaps others wouldn't need to.

Those loaders are broken for binaries, static or dynamic, which use AUXV,
independent of this change, and they should be fixed.  It shouldn't block
using --eh-frame-hdr for -static.

> Anyway, IMHO statically linked binaries aren't something one should spend
> too much time on, they shouldn't be used (with very few exceptions) at all.
>

Android doesn't need those legacy stuff.  We have to keep it
since GCC doesn't pass --eh-frame-hdr for -static.  At minimum,
I'd like a configure option to use --eh-frame-hdr for -static, even if
it is off by default.

OK to install?

Thanks.

-- 
H.J.
---
gcc/

2012-09-14  H.J. Lu  <hongjiu.lu@intel.com>

	PR debug/54568
	* configure.ac: Add --enable-eh-frame-hdr-for-static.  Set
	USE_EH_FRAME_HDR_FOR_STATIC if PT_GNU_EH_FRAME is supported for
	static executable.
	* config.in: Regenerated.
	* configure: Likewise.

	* config/gnu-user.h (LINK_EH_SPEC): Defined as "--eh-frame-hdr "
	if USE_EH_FRAME_HDR_FOR_STATIC is defined.
	* config/sol2.h (LINK_EH_SPEC): Likewise.
	* config/openbsd.h (LINK_EH_SPEC): Likewise.
	* config/alpha/elf.h (LINK_EH_SPEC): Likewise.
	* config/freebsd.h (LINK_EH_SPEC): Likewise.
	* config/rs6000/sysv4.h (LINK_EH_SPEC): Likewise.

gcc/testsuite/

2012-09-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR debug/54568
	* g++.dg/eh/spec3-static.C: New test.

libgcc/

2012-09-14  H.J. Lu  <hongjiu.lu@intel.com>

	PR debug/54568
	* crtstuff.c (USE_PT_GNU_EH_FRAME): Check CRTSTUFFT_O together
	with USE_EH_FRAME_HDR_FOR_STATIC.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-pr54568.patch
Type: application/octet-stream
Size: 11435 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120914/22f6073e/attachment.obj>


More information about the Gcc-patches mailing list