Bug 778414: ensure the linker supports @unwind sections in libffi. r=glandium

This fixes clang builds on OpenBSD/amd64, since clang itself supports
@unwind sections but OpenBSD's ld 2.15 doesn't. Previously the test
yielded true, thus producing a broken libffi.
This commit is contained in:
Landry Breuil 2012-08-28 23:00:40 +02:00
parent d121441887
commit 6c017dca38
3 changed files with 142 additions and 11 deletions

View File

@ -12427,16 +12427,32 @@ $as_echo "#define FFI_MMAP_EXEC_WRIT 1" >>confdefs.h
esac
if test x$TARGET = xX86_64; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler supports unwind section type" >&5
$as_echo_n "checking assembler supports unwind section type... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking toolchain supports unwind section type" >&5
$as_echo_n "checking toolchain supports unwind section type... " >&6; }
if test "${libffi_cv_as_x86_64_unwind_section_type+set}" = set; then :
$as_echo_n "(cached) " >&6
else
libffi_cv_as_x86_64_unwind_section_type=yes
echo '.section .eh_frame,"a",@unwind' > conftest.s
if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then
libffi_cv_as_x86_64_unwind_section_type=no
cat > conftest1.s << EOF
.text
.globl foo
foo:
jmp bar
.section .eh_frame,"a",@unwind
bar:
EOF
cat > conftest2.c << EOF
extern void foo();
int main(){foo();}
EOF
libffi_cv_as_x86_64_unwind_section_type=no
# we ensure that we can compile _and_ link an assembly file containing an @unwind section
# since the compiler can support it and not the linker (ie old binutils)
if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \
$CC conftest2.c conftest1.o > /dev/null 2>&1 ; then
libffi_cv_as_x86_64_unwind_section_type=yes
fi
fi

View File

@ -332,12 +332,28 @@ case "$target" in
esac
if test x$TARGET = xX86_64; then
AC_CACHE_CHECK([assembler supports unwind section type],
AC_CACHE_CHECK([toolchain supports unwind section type],
libffi_cv_as_x86_64_unwind_section_type, [
libffi_cv_as_x86_64_unwind_section_type=yes
echo '.section .eh_frame,"a",@unwind' > conftest.s
if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then
libffi_cv_as_x86_64_unwind_section_type=no
cat > conftest1.s << EOF
.text
.globl foo
foo:
jmp bar
.section .eh_frame,"a",@unwind
bar:
EOF
cat > conftest2.c << EOF
extern void foo();
int main(){foo();}
EOF
libffi_cv_as_x86_64_unwind_section_type=no
# we ensure that we can compile _and_ link an assembly file containing an @unwind section
# since the compiler can support it and not the linker (ie old binutils)
if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \
$CC conftest2.c conftest1.o > /dev/null 2>&1 ; then
libffi_cv_as_x86_64_unwind_section_type=yes
fi
])
if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then

View File

@ -0,0 +1,99 @@
diff --git a/js/src/ctypes/libffi/configure b/js/src/ctypes/libffi/configure
--- a/js/src/ctypes/libffi/configure
+++ b/js/src/ctypes/libffi/configure
@@ -12422,26 +12422,42 @@ case "$target" in
*-apple-darwin1* | *-*-freebsd* | *-*-openbsd* | *-pc-solaris*)
$as_echo "#define FFI_MMAP_EXEC_WRIT 1" >>confdefs.h
;;
esac
if test x$TARGET = xX86_64; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler supports unwind section type" >&5
-$as_echo_n "checking assembler supports unwind section type... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking toolchain supports unwind section type" >&5
+$as_echo_n "checking toolchain supports unwind section type... " >&6; }
if test "${libffi_cv_as_x86_64_unwind_section_type+set}" = set; then :
$as_echo_n "(cached) " >&6
else
- libffi_cv_as_x86_64_unwind_section_type=yes
- echo '.section .eh_frame,"a",@unwind' > conftest.s
- if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then
- libffi_cv_as_x86_64_unwind_section_type=no
+ cat > conftest1.s << EOF
+.text
+.globl foo
+foo:
+jmp bar
+.section .eh_frame,"a",@unwind
+bar:
+EOF
+
+ cat > conftest2.c << EOF
+extern void foo();
+int main(){foo();}
+EOF
+
+ libffi_cv_as_x86_64_unwind_section_type=no
+ # we ensure that we can compile _and_ link an assembly file containing an @unwind section
+ # since the compiler can support it and not the linker (ie old binutils)
+ if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \
+ $CC conftest2.c conftest1.o > /dev/null 2>&1 ; then
+ libffi_cv_as_x86_64_unwind_section_type=yes
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_as_x86_64_unwind_section_type" >&5
$as_echo "$libffi_cv_as_x86_64_unwind_section_type" >&6; }
if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then
$as_echo "#define HAVE_AS_X86_64_UNWIND_SECTION_TYPE 1" >>confdefs.h
diff --git a/js/src/ctypes/libffi/configure.ac b/js/src/ctypes/libffi/configure.ac
--- a/js/src/ctypes/libffi/configure.ac
+++ b/js/src/ctypes/libffi/configure.ac
@@ -327,22 +327,38 @@ case "$target" in
*-apple-darwin1* | *-*-freebsd* | *-*-openbsd* | *-pc-solaris*)
AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
[Cannot use malloc on this target, so, we revert to
alternative means])
;;
esac
if test x$TARGET = xX86_64; then
- AC_CACHE_CHECK([assembler supports unwind section type],
+ AC_CACHE_CHECK([toolchain supports unwind section type],
libffi_cv_as_x86_64_unwind_section_type, [
- libffi_cv_as_x86_64_unwind_section_type=yes
- echo '.section .eh_frame,"a",@unwind' > conftest.s
- if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then
- libffi_cv_as_x86_64_unwind_section_type=no
+ cat > conftest1.s << EOF
+.text
+.globl foo
+foo:
+jmp bar
+.section .eh_frame,"a",@unwind
+bar:
+EOF
+
+ cat > conftest2.c << EOF
+extern void foo();
+int main(){foo();}
+EOF
+
+ libffi_cv_as_x86_64_unwind_section_type=no
+ # we ensure that we can compile _and_ link an assembly file containing an @unwind section
+ # since the compiler can support it and not the linker (ie old binutils)
+ if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \
+ $CC conftest2.c conftest1.o > /dev/null 2>&1 ; then
+ libffi_cv_as_x86_64_unwind_section_type=yes
fi
])
if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then
AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1,
[Define if your assembler supports unwind section type.])
fi
fi