From f1c01f037070e4e041e84af7ff9fe1598996e384 Mon Sep 17 00:00:00 2001 From: macro Date: Mon, 15 Aug 2005 16:15:16 +0000 Subject: [PATCH] * configure.ac: Test for the name of the symbol used for the entry point; define ENTRY_POINT to the result. * configure: Regenerate. * config.h.in: Regenerate. * mf-heuristics.c: Replace _start with ENTRY_POINT throughout. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@103113 138bc75d-0d04-0410-961f-82ee72b054a4 --- libmudflap/ChangeLog | 8 ++++++ libmudflap/config.h.in | 3 ++ libmudflap/configure | 70 ++++++++++++++++++++++++++++++++++++++++++++++ libmudflap/configure.ac | 15 ++++++++++ libmudflap/mf-heuristics.c | 9 +++--- 5 files changed, 101 insertions(+), 4 deletions(-) diff --git a/libmudflap/ChangeLog b/libmudflap/ChangeLog index ad616633dcb..c42fa253600 100644 --- a/libmudflap/ChangeLog +++ b/libmudflap/ChangeLog @@ -1,3 +1,11 @@ +2005-08-15 Maciej W. Rozycki + + * configure.ac: Test for the name of the symbol used for the entry + point; define ENTRY_POINT to the result. + * configure: Regenerate. + * config.h.in: Regenerate. + * mf-heuristics.c: Replace _start with ENTRY_POINT throughout. + 2005-08-14 Ulrich Weigand * mf-runtime.c (__mf_state_1): Initialize to reentrant. diff --git a/libmudflap/config.h.in b/libmudflap/config.h.in index b14e2e90121..98c3f619462 100644 --- a/libmudflap/config.h.in +++ b/libmudflap/config.h.in @@ -1,5 +1,8 @@ /* config.h.in. Generated from configure.ac by autoheader. */ +/* Define to the name of the symbol used for the entry point. */ +#undef ENTRY_POINT + /* Define to 1 if you have the `addmntent' function. */ #undef HAVE_ADDMNTENT diff --git a/libmudflap/configure b/libmudflap/configure index 03b3be5d30a..3fe9a1a1841 100755 --- a/libmudflap/configure +++ b/libmudflap/configure @@ -6894,6 +6894,76 @@ echo "${ECHO_T}$ac_fdsections" >&6 +# Check for the name of the symbol used for the entry point. +echo "$as_me:$LINENO: checking for the name of the symbol used for the entry point" >&5 +echo $ECHO_N "checking for the name of the symbol used for the entry point... $ECHO_C" >&6 +if test "${mudflap_cv_entry_point+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +for name in _start __start unknown; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +extern char $name; +int +main () +{ +$name = 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +done +mudflap_cv_entry_point="$name" +fi +echo "$as_me:$LINENO: result: $mudflap_cv_entry_point" >&5 +echo "${ECHO_T}$mudflap_cv_entry_point" >&6 +if test "$mudflap_cv_entry_point" = unknown; then + { { echo "$as_me:$LINENO: error: none of the known symbol names works" >&5 +echo "$as_me: error: none of the known symbol names works" >&2;} + { (exit 1); exit 1; }; } +fi + +cat >>confdefs.h <<_ACEOF +#define ENTRY_POINT $mudflap_cv_entry_point +_ACEOF + + + if test ${multilib} = yes; then multilib_arg="--enable-multilib" else diff --git a/libmudflap/configure.ac b/libmudflap/configure.ac index 58a7c739b91..4d0ff1311fa 100644 --- a/libmudflap/configure.ac +++ b/libmudflap/configure.ac @@ -223,6 +223,21 @@ AC_MSG_RESULT($ac_fdsections) AC_SUBST(SECTION_FLAGS) +# Check for the name of the symbol used for the entry point. +AC_CACHE_CHECK([for the name of the symbol used for the entry point], + [mudflap_cv_entry_point], [ +for name in _start __start unknown; do + AC_LINK_IFELSE([AC_LANG_PROGRAM([extern char $name;], [$name = 0;])], + [break]) +done +mudflap_cv_entry_point="$name"]) +if test "$mudflap_cv_entry_point" = unknown; then + AC_MSG_ERROR([none of the known symbol names works]) +fi +AC_DEFINE_UNQUOTED([ENTRY_POINT], [$mudflap_cv_entry_point], + [Define to the name of the symbol used for the entry point.]) + + if test ${multilib} = yes; then multilib_arg="--enable-multilib" else diff --git a/libmudflap/mf-heuristics.c b/libmudflap/mf-heuristics.c index df2a0391eaf..9118bc6e61b 100644 --- a/libmudflap/mf-heuristics.c +++ b/libmudflap/mf-heuristics.c @@ -43,7 +43,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA extern char _end; -extern char _start; +extern char ENTRY_POINT; /* Run some quick validation of the given region. @@ -164,10 +164,11 @@ __mf_heuristic_check (uintptr_t ptr, uintptr_t ptr_high) } - /* The third heuristic is to approve all accesses between _start and _end, - which should include all text and initialized data. */ + /* The third heuristic is to approve all accesses between _start (or its + equivalent for the given target) and _end, which should include all + text and initialized data. */ if (__mf_opts.heur_start_end) - if (ptr >= (uintptr_t) & _start && ptr_high <= (uintptr_t) & _end) + if (ptr >= (uintptr_t) & ENTRY_POINT && ptr_high <= (uintptr_t) & _end) return 1; /* uncacheable */ return 0; /* unknown */ -- 2.11.0