Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] "etext/_etext" may be missing, add configure check
@ 2007-09-19 19:34 Joel Brobecker
  2007-09-19 19:46 ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Joel Brobecker @ 2007-09-19 19:34 UTC (permalink / raw)
  To: gdb-patches

[-- 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA] "etext/_etext" may be missing, add configure check
  2007-09-19 19:34 [RFA] "etext/_etext" may be missing, add configure check Joel Brobecker
@ 2007-09-19 19:46 ` Daniel Jacobowitz
  2007-09-19 22:04   ` Joel Brobecker
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-09-19 19:46 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Wed, Sep 19, 2007 at 12:34:48PM -0700, Joel Brobecker wrote:
> 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.

Sure.

> On a side-note, I also think that --enable-profiling=no should
> have deactivated this code as well, but that's a different thread.

I don't.  That's supposed to disable automatic profiling and compiling
with -pg, not the manual profiling commands.

> 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.

OK.

> 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).

You don't need this, by the way.  Unlike the gdb subdirectory, the
gdb/gdbserver subdirectory is standalone.  You need the whole source
tree but you can run src/gdb/gdbserver/configure directly.  This
should be in the manual, or at least the README.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA] "etext/_etext" may be missing, add configure check
  2007-09-19 19:46 ` Daniel Jacobowitz
@ 2007-09-19 22:04   ` Joel Brobecker
  2007-09-19 22:29     ` Joel Brobecker
  0 siblings, 1 reply; 4+ messages in thread
From: Joel Brobecker @ 2007-09-19 22:04 UTC (permalink / raw)
  To: gdb-patches

> > On a side-note, I also think that --enable-profiling=no should
> > have deactivated this code as well, but that's a different thread.
> 
> I don't.  That's supposed to disable automatic profiling and compiling
> with -pg, not the manual profiling commands.

Oh, I see, I misunderstood the purpose of that switch... Thanks for
pointing this out.

> > 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.
> 
> OK.

Thanks. I just checked this change in.

> You don't need this, by the way.  Unlike the gdb subdirectory, the
> gdb/gdbserver subdirectory is standalone.  You need the whole source
> tree but you can run src/gdb/gdbserver/configure directly.  This
> should be in the manual, or at least the README.

I just double checked and it is indeed in the README (I read it too
quickly it appears). All this time I have spent watching our little
board build GDB, when it wasn't necessary :-/... Oh well, there is
still a little bit of a gain, since GDB now builds on LynxOS too.
Adding the native part shouldn't be too hard if anyone is interested.

Thanks again,
-- 
Joel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA] "etext/_etext" may be missing, add configure check
  2007-09-19 22:04   ` Joel Brobecker
@ 2007-09-19 22:29     ` Joel Brobecker
  0 siblings, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2007-09-19 22:29 UTC (permalink / raw)
  To: gdb-patches

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

> Oh well, there is still a little bit of a gain, since GDB now builds
> on LynxOS too.  Adding the native part shouldn't be too hard if anyone
> is interested.

Actually, while reviewing the changes that I made as I'm backing them
up before discarding, there is one tiny bit that also needs to be done
for GDB to build. I am posting it mostly for completeness than anything
else I'm not sure want to add lynxos-specific stuff unless someone wants
gdb-hosted support - no point in doing something is noone is going to
use it!

-- 
Joel

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

Index: configure.host
===================================================================
--- configure.host	(revision 14490)
+++ configure.host	(working copy)
@@ -112,6 +112,7 @@ mips64*-*-openbsd*)	gdb_host=obsd64 ;;
 
 powerpc-*-aix*)		gdb_host=aix ;;
 powerpc-*-linux*)	gdb_host=linux ;;
+powerpc-*-lynxos*)	gdb_host=lynxos ;;
 powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu)
 			gdb_host=nbsd ;;
 powerpc-*-openbsd*)	gdb_host=obsd ;;

[-- Attachment #3: lynxos.mh --]
[-- Type: text/plain, Size: 18 bytes --]

LOADLIBES = -lbsd

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-09-19 22:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-19 19:34 [RFA] "etext/_etext" may be missing, add configure check Joel Brobecker
2007-09-19 19:46 ` Daniel Jacobowitz
2007-09-19 22:04   ` Joel Brobecker
2007-09-19 22:29     ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox