public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: Anthony Green <green@redhat.com>
Cc: libffi-discuss@sourceware.org, doko@ubuntu.com
Subject: Re: libffi/configure.ac does not correctly determine writable eh_frame
Date: Thu, 03 Feb 2011 23:07:00 -0000	[thread overview]
Message-ID: <mcrwrlg67le.fsf@google.com> (raw)
In-Reply-To: <m3sjw43ffs.fsf@redhat.com> (Anthony Green's message of "Thu, 03	Feb 2011 17:45:43 -0500")

Anthony Green <green@redhat.com> writes:

> Ian Lance Taylor <iant@google.com> writes:
>
>> In the version of libffi distributed with gcc, I see this in
>> configure.ac:
>>
>> 	echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
>> 	if $CC $CFLAGS -S -fpic -fexceptions -o conftest.s conftest.c > /dev/null 2>&1; then
>> 	    if grep '.section.*eh_frame.*"a"' conftest.s > /dev/null; then
>> 		libffi_cv_ro_eh_frame=yes
>> 	    elif grep '.section.*eh_frame.*#alloc' conftest.c \
>> 		 | grep -v '#write' > /dev/null; then
>> 		libffi_cv_ro_eh_frame=yes
>> 	    fi
>> 	fi
>>
>> This does not work with current gcc.  When that code is compiled, no
>> .eh_frame section is generated.  Therefore the configure script assumes
>> that a writable .eh_frame section is appropriate, even when it is not.
>>
>> This was detected due to a bug in gold; see http://gcc.gnu.org/PR47248
>> for more details.  However, this issue in libffi should be fixed
>> independently of the gold bug fix.
>
> Thanks Ian.  Any suggestions on what do I need to do to now to force an
> .eh_frame section?

Sorry, when I wrote the above note I was confused.  The object file
actually will get a .eh_frame section, because of the use of
-fexceptions.  What it won't get is a reference to .eh_frame in the
assembler file.  That is because gcc now generates CFI directives when
possible.  What you need to do know is use the compiler option
-fno-dwarf2-cfi-asm.  That will tell gcc to not use CFI directives, and
to use the .section eh_frame syntax instead.  In the context of gcc
mainline, you can assume that the compiler supports -fno-dwarf2-cfi-asm,
but of course in a more general syntax you would need to first test
whether the compiler supports that option.

That said, it would be even better if libffi could convert to using CFI
directives itself, which will avoid the whole question of what flags to
use for .eh_frame.  But I have to admit that I don't know all the
portability considerations that arise, nor do I know how portable libffi
is intended to be, nor do I know how critical it is to libffi operation
for exceptions to be handled correctly.  I note that
libffi/src/m68k/sysv.S is already using CFI directives.

Ian

      reply	other threads:[~2011-02-03 23:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-10 21:47 Ian Lance Taylor
2011-02-03 22:45 ` Anthony Green
2011-02-03 23:07   ` Ian Lance Taylor [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mcrwrlg67le.fsf@google.com \
    --to=iant@google.com \
    --cc=doko@ubuntu.com \
    --cc=green@redhat.com \
    --cc=libffi-discuss@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).