From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14876 invoked by alias); 19 Sep 2007 19:34:58 -0000 Received: (qmail 14867 invoked by uid 22791); 19 Sep 2007 19:34:57 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 19 Sep 2007 19:34:53 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 388E92AB2D7 for ; Wed, 19 Sep 2007 15:34:51 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id FsvnXQIOSLRp for ; Wed, 19 Sep 2007 15:34:51 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id AFC7D2AAF3B for ; Wed, 19 Sep 2007 15:34:50 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 52D94E7B58; Wed, 19 Sep 2007 12:34:48 -0700 (PDT) Date: Wed, 19 Sep 2007 19:34:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFA] "etext/_etext" may be missing, add configure check Message-ID: <20070919193448.GA15629@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="X1bOJ3K7DJ5YkBrT" Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-09/txt/msg00257.txt.bz2 --X1bOJ3K7DJ5YkBrT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1550 Hello, When building GDB hosted on LynxOS 3 (in my attempts to build the gdbserver), I had a GDB link failure because of an undefined reference to the "etext" symbol. It comes from maint.c for the code taking care of profiling: #ifdef HAVE__ETEXT extern char _etext; #define TEXTEND &_etext #else extern char etext; #define TEXTEND &etext #endif I couldn't find anywhere either of these symbol, and a search on the internet didn't help either. I propose to add a check in configure for "etext", and then change the above to define TEXTEND only if at least either of the etext symbol is defined. Then we can add the definition of TEXT to the conditionalization that decides whether or not to include the profiling functionality. On a side-note, I also think that --enable-profiling=no should have deactivated this code as well, but that's a different thread. For now, I think it's more useful to auto-detect than force to find the appropriate option to set at configure time. 2007-09-19 Joel Brobecker * configure.ac: Add check for "etext". * configure, config.in: Regenerate. * maint.c (TEXTEND): Only define if either _etext or etext are available. Disable the profiling functionality if TEXTEND is not defined. This was tested on x86-linux, without any regressions. On LynxOS, it allows me to complete the GDB build (although it's a dummy GDB at this point, since my primary interest is in the gdbserver). Would that be OK to commit? -- Joel --X1bOJ3K7DJ5YkBrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="etext.diff" Content-length: 2176 Index: configure.ac =================================================================== RCS file: /cvs/src/src/gdb/configure.ac,v retrieving revision 1.51 diff -u -p -r1.51 configure.ac --- configure.ac 3 Sep 2007 20:47:37 -0000 1.51 +++ configure.ac 19 Sep 2007 19:22:07 -0000 @@ -242,6 +242,16 @@ if test $ac_cv_var__etext = yes; then AC_DEFINE(HAVE__ETEXT, 1, [Define to 1 if your system has the _etext variable. ]) fi +AC_CACHE_CHECK([for etext], ac_cv_var_etext, +[AC_TRY_LINK( +[#include +extern char etext; +], +[free (&etext);], ac_cv_var_etext=yes, ac_cv_var_etext=no)]) +if test $ac_cv_var_etext = yes; then + AC_DEFINE(HAVE_ETEXT, 1, + [Define to 1 if your system has the etext variable. ]) +fi if test "$enable_profiling" = yes ; then if test $ac_cv_func_monstartup = no || test $ac_cv_func__mcleanup = no; then AC_MSG_ERROR(--enable-profiling requires monstartup and _mcleanup) Index: config.in =================================================================== RCS file: /cvs/src/src/gdb/config.in,v retrieving revision 1.91 diff -u -p -r1.91 config.in --- config.in 18 Jun 2007 15:46:37 -0000 1.91 +++ config.in 19 Sep 2007 19:22:07 -0000 @@ -113,6 +113,9 @@ /* Define if ELF support should be included. */ #undef HAVE_ELF +/* Define to 1 if your system has the etext variable. */ +#undef HAVE_ETEXT + /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK Index: maint.c =================================================================== RCS file: /cvs/src/src/gdb/maint.c,v retrieving revision 1.60 diff -u -p -r1.60 maint.c --- maint.c 23 Aug 2007 18:08:36 -0000 1.60 +++ maint.c 19 Sep 2007 19:22:07 -0000 @@ -638,16 +638,16 @@ show_maintenance_profile_p (struct ui_fi fprintf_filtered (file, _("Internal profiling is %s.\n"), value); } -#if defined (HAVE_MONSTARTUP) && defined (HAVE__MCLEANUP) - #ifdef HAVE__ETEXT extern char _etext; #define TEXTEND &_etext -#else +#elif defined (HAVE_ETEXT) extern char etext; #define TEXTEND &etext #endif +#if defined (HAVE_MONSTARTUP) && defined (HAVE__MCLEANUP) && defined (TEXTEND) + static int profiling_state; static void --X1bOJ3K7DJ5YkBrT--