Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Subject: [RFA] "etext/_etext" may be missing, add configure check
Date: Wed, 19 Sep 2007 19:34:00 -0000	[thread overview]
Message-ID: <20070919193448.GA15629@adacore.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1550 bytes --]

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  <brobecker@adacore.com>

        * 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

[-- Attachment #2: etext.diff --]
[-- Type: text/plain, Size: 2176 bytes --]

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 <stdlib.h>
+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

             reply	other threads:[~2007-09-19 19:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-19 19:34 Joel Brobecker [this message]
2007-09-19 19:46 ` Daniel Jacobowitz
2007-09-19 22:04   ` Joel Brobecker
2007-09-19 22:29     ` Joel Brobecker

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=20070919193448.GA15629@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@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