diff --git a/debugger/stabs.c b/debugger/stabs.c
index a72f8e678f56c8cfb352d37a05566b1e01daf5b0..3a5b77a17e4d6cbe27b5adcfbc379fd106bef369 100644
--- a/debugger/stabs.c
+++ b/debugger/stabs.c
@@ -1175,7 +1175,11 @@ DEBUG_ReadExecutableDbgInfo(void)
   Elf32_Dyn	      * dynpnt;
   struct r_debug      * dbg_hdr;
   struct link_map     * lpnt = NULL;
+#ifdef __GNUC__
+  extern Elf32_Dyn      _DYNAMIC[] __attribute__ ((weak));
+#else
   extern Elf32_Dyn      _DYNAMIC[];
+#endif
   int			rtn = FALSE;
   int                   rowcount;
 
@@ -1196,10 +1200,11 @@ DEBUG_ReadExecutableDbgInfo(void)
    * of the other shared libraries which might be loaded.  Perform the
    * same step for all of these.
    */
-  dynpnt = _DYNAMIC;
-  if( dynpnt == NULL )
+  if( (&_DYNAMIC == NULL) || (_DYNAMIC == NULL) )
       goto leave;
 
+  dynpnt = _DYNAMIC;
+
   /*
    * Now walk the dynamic section (of the executable, looking for a DT_DEBUG
    * entry.