public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] debug compile: Replace confusing debug message
@ 2015-07-01 12:20 Jan Kratochvil
  2015-07-01 12:33 ` Phil Muldoon
  2015-07-01 14:10 ` Pedro Alves
  0 siblings, 2 replies; 5+ messages in thread
From: Jan Kratochvil @ 2015-07-01 12:20 UTC (permalink / raw)
  To: gdb-patches; +Cc: Phil Muldoon

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

Hi,

It was found that

(gdb) set debug compile 1
(gdb) compile code 1
[...]
allocated 0x7f bytes at 0x7ffff7ff9000 prot 5
allocated 0x38 bytes at 0x7ffff7ff8000 prot 1
lookup undefined ELF symbol "_GLOBAL_OFFSET_TABLE_"
allocated 0x10 bytes at 0x7ffff7ff7000 for registers
(gdb) _

the message 'lookup undefined ELF symbol' looks as an error to people,
including to myself once.

->
allocated 0x7f bytes at 0x7ffff7ff9000 prot 5
allocated 0x38 bytes at 0x7ffff7ff8000 prot 1
ELF symbol "_GLOBAL_OFFSET_TABLE_" relocated to zero
allocated 0x10 bytes at 0x7ffff7ff7000 for registers
(gdb) _


Jan

[-- Attachment #2: wording --]
[-- Type: text/plain, Size: 1591 bytes --]

2015-07-01  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* compile/compile-object-load.c (compile_object_load): Replace debug
	message "lookup undefined ELF symbol" by 3 more specific messages.

--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -731,14 +731,14 @@ compile_object_load (const char *object_file, const char *source_file,
 
       if (sym->flags != 0)
 	continue;
-      if (compile_debug)
-	fprintf_unfiltered (gdb_stdlog,
-			    "lookup undefined ELF symbol \"%s\"\n",
-			    sym->name);
       sym->flags = BSF_GLOBAL;
       sym->section = bfd_abs_section_ptr;
       if (strcmp (sym->name, "_GLOBAL_OFFSET_TABLE_") == 0)
 	{
+	  if (compile_debug)
+	    fprintf_unfiltered (gdb_stdlog,
+				"ELF symbol \"%s\" relocated to zero\n",
+				sym->name);
 	  sym->value = 0;
 	  continue;
 	}
@@ -748,10 +748,21 @@ compile_object_load (const char *object_file, const char *source_file,
 	{
 	case mst_text:
 	  sym->value = BMSYMBOL_VALUE_ADDRESS (bmsym);
+	  if (compile_debug)
+	    fprintf_unfiltered (gdb_stdlog,
+				"ELF mst_text symbol \"%s\" relocated to %s\n",
+				sym->name,
+				paddress (target_gdbarch (), sym->value));
 	  break;
 	case mst_text_gnu_ifunc:
 	  sym->value = gnu_ifunc_resolve_addr (target_gdbarch (),
 					       BMSYMBOL_VALUE_ADDRESS (bmsym));
+	  if (compile_debug)
+	    fprintf_unfiltered (gdb_stdlog,
+				"ELF mst_text_gnu_ifunc symbol \"%s\" "
+				"relocated to %s\n",
+				sym->name,
+				paddress (target_gdbarch (), sym->value));
 	  break;
 	default:
 	  warning (_("Could not find symbol \"%s\" "

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

* Re: [patch] debug compile: Replace confusing debug message
  2015-07-01 12:20 [patch] debug compile: Replace confusing debug message Jan Kratochvil
@ 2015-07-01 12:33 ` Phil Muldoon
  2015-07-01 14:10 ` Pedro Alves
  1 sibling, 0 replies; 5+ messages in thread
From: Phil Muldoon @ 2015-07-01 12:33 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches

On 01/07/15 13:20, Jan Kratochvil wrote:
> Hi,
>
> It was found that
>
> (gdb) set debug compile 1
> (gdb) compile code 1
> [...]
> allocated 0x7f bytes at 0x7ffff7ff9000 prot 5
> allocated 0x38 bytes at 0x7ffff7ff8000 prot 1
> lookup undefined ELF symbol "_GLOBAL_OFFSET_TABLE_"
> allocated 0x10 bytes at 0x7ffff7ff7000 for registers
> (gdb) _
>
> the message 'lookup undefined ELF symbol' looks as an error to people,
> including to myself once.
>
> ->
> allocated 0x7f bytes at 0x7ffff7ff9000 prot 5
> allocated 0x38 bytes at 0x7ffff7ff8000 prot 1
> ELF symbol "_GLOBAL_OFFSET_TABLE_" relocated to zero
> allocated 0x10 bytes at 0x7ffff7ff7000 for registers
> (gdb) _
>
Fine by me

Cheers

Phil

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

* Re: [patch] debug compile: Replace confusing debug message
  2015-07-01 12:20 [patch] debug compile: Replace confusing debug message Jan Kratochvil
  2015-07-01 12:33 ` Phil Muldoon
@ 2015-07-01 14:10 ` Pedro Alves
  2015-07-01 14:17   ` Jan Kratochvil
  1 sibling, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2015-07-01 14:10 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches; +Cc: Phil Muldoon

OK.

On 07/01/2015 01:20 PM, Jan Kratochvil wrote:

>        if (strcmp (sym->name, "_GLOBAL_OFFSET_TABLE_") == 0)
>  	{

It'd be nice to have a comment here mentioning why we need to do this.

Thanks,
Pedro Alves

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

* Re: [patch] debug compile: Replace confusing debug message
  2015-07-01 14:10 ` Pedro Alves
@ 2015-07-01 14:17   ` Jan Kratochvil
  2015-07-02  6:03     ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kratochvil @ 2015-07-01 14:17 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Phil Muldoon

On Wed, 01 Jul 2015 16:10:22 +0200, Pedro Alves wrote:
> OK.
> 
> On 07/01/2015 01:20 PM, Jan Kratochvil wrote:
> 
> >        if (strcmp (sym->name, "_GLOBAL_OFFSET_TABLE_") == 0)
> >  	{
> 
> It'd be nice to have a comment here mentioning why we need to do this.

I do not know, I think it is a GCC bug, with -mcmodel=large I have no idea why
GCC needs _GLOBAL_OFFSET_TABLE_.  I can write there this info.


Jan

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

* [commit] [patch] debug compile: Replace confusing debug message
  2015-07-01 14:17   ` Jan Kratochvil
@ 2015-07-02  6:03     ` Jan Kratochvil
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Kratochvil @ 2015-07-02  6:03 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Phil Muldoon

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

On Wed, 01 Jul 2015 16:17:03 +0200, Jan Kratochvil wrote:
> On Wed, 01 Jul 2015 16:10:22 +0200, Pedro Alves wrote:
> > It'd be nice to have a comment here mentioning why we need to do this.
> 
> I do not know, I think it is a GCC bug, with -mcmodel=large I have no idea why
> GCC needs _GLOBAL_OFFSET_TABLE_.  I can write there this info.

Checked in as attached.


Jan

[-- Attachment #2: Type: message/rfc822, Size: 3332 bytes --]

From: Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: [PATCH] debug compile: Replace confusing debug message
Date: Thu, 2 Jul 2015 08:01:35 +0200

It was found that from

(gdb) set debug compile 1
(gdb) compile code 1
[...]
allocated 0x7f bytes at 0x7ffff7ff9000 prot 5
allocated 0x38 bytes at 0x7ffff7ff8000 prot 1
lookup undefined ELF symbol "_GLOBAL_OFFSET_TABLE_"
allocated 0x10 bytes at 0x7ffff7ff7000 for registers
(gdb) _

the message 'lookup undefined ELF symbol' looks as an error to people,
including to myself once.

Change it to:

allocated 0x7f bytes at 0x7ffff7ff9000 prot 5
allocated 0x38 bytes at 0x7ffff7ff8000 prot 1
ELF symbol "_GLOBAL_OFFSET_TABLE_" relocated to zero
allocated 0x10 bytes at 0x7ffff7ff7000 for registers
(gdb) _

gdb/ChangeLog
2015-07-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* compile/compile-object-load.c (compile_object_load): Replace debug
	message "lookup undefined ELF symbol" by 3 more specific messages.
---
 gdb/ChangeLog                     |  5 +++++
 gdb/compile/compile-object-load.c | 23 +++++++++++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 38a1633..249181d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2015-07-02  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* compile/compile-object-load.c (compile_object_load): Replace debug
+	message "lookup undefined ELF symbol" by 3 more specific messages.
+
 2015-07-01  Kevin Buettner  <kevinb@redhat.com>
 
 	* rl78-tdep.c (struct gdbarch_tdep): Add new field, rl78_psw_type.
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 2b29b8b..8298748 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -731,14 +731,18 @@ compile_object_load (const char *object_file, const char *source_file,
 
       if (sym->flags != 0)
 	continue;
-      if (compile_debug)
-	fprintf_unfiltered (gdb_stdlog,
-			    "lookup undefined ELF symbol \"%s\"\n",
-			    sym->name);
       sym->flags = BSF_GLOBAL;
       sym->section = bfd_abs_section_ptr;
       if (strcmp (sym->name, "_GLOBAL_OFFSET_TABLE_") == 0)
 	{
+	  if (compile_debug)
+	    fprintf_unfiltered (gdb_stdlog,
+				"ELF symbol \"%s\" relocated to zero\n",
+				sym->name);
+
+	  /* It seems to be a GCC bug, with -mcmodel=large there should be no
+	     need for _GLOBAL_OFFSET_TABLE_.  Together with -fPIE the data
+	     remain PC-relative even with _GLOBAL_OFFSET_TABLE_ as zero.  */
 	  sym->value = 0;
 	  continue;
 	}
@@ -748,10 +752,21 @@ compile_object_load (const char *object_file, const char *source_file,
 	{
 	case mst_text:
 	  sym->value = BMSYMBOL_VALUE_ADDRESS (bmsym);
+	  if (compile_debug)
+	    fprintf_unfiltered (gdb_stdlog,
+				"ELF mst_text symbol \"%s\" relocated to %s\n",
+				sym->name,
+				paddress (target_gdbarch (), sym->value));
 	  break;
 	case mst_text_gnu_ifunc:
 	  sym->value = gnu_ifunc_resolve_addr (target_gdbarch (),
 					       BMSYMBOL_VALUE_ADDRESS (bmsym));
+	  if (compile_debug)
+	    fprintf_unfiltered (gdb_stdlog,
+				"ELF mst_text_gnu_ifunc symbol \"%s\" "
+				"relocated to %s\n",
+				sym->name,
+				paddress (target_gdbarch (), sym->value));
 	  break;
 	default:
 	  warning (_("Could not find symbol \"%s\" "
-- 
2.1.0

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

end of thread, other threads:[~2015-07-02  6:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-01 12:20 [patch] debug compile: Replace confusing debug message Jan Kratochvil
2015-07-01 12:33 ` Phil Muldoon
2015-07-01 14:10 ` Pedro Alves
2015-07-01 14:17   ` Jan Kratochvil
2015-07-02  6:03     ` [commit] " Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).