This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Get versioned minsyms from dynamic symtab (Was: Re: How to call operator<< functions?)


On Linux, versioned ELF symbols are stored in the static symtab with an
(@)@VERSION suffix. We store such symbols with the suffix and thus fail
to find them when looking up the real name.

This causes failures such as the one described here:
http://www.sourceware.org/ml/gdb/2006-08/msg00244.html

In the general case, GDB doesn't use the dynamic symtab because it
contains usually only a subset of the static table information. The
attached patch make GDB store dynamic versioned symbols. 

Maybe this is harvests too much symbols, and we should limit it to the
dynamic symbols of the main executable. It's easy enough to do, we just
need to pass the 'mainline' flag to elf_symfile_read from
elf_symtab_read. 

I've no idea if this could break something on non-Linux platforms, I've
just tested on x86-linux.

I'm also attaching a little testsuite patch that fails for me on current
GDB and works with the patch.

Opinions?

2006-08-31  Frederic Riss  <frederic.riss@st.com>

	* elfread.c (elf_symtab_read): Read versioned symbols from 
	the dynamic symtab.

2006-08-31  Frederic Riss  <frederic.riss@st.com>

	* gdb.cp/userdef.exp: Test use of std::cout.


Index: elfread.c
===================================================================
RCS file: /cvs/src/src/gdb/elfread.c,v
retrieving revision 1.55
diff -u -p -r1.55 elfread.c
--- elfread.c	21 Feb 2006 20:38:48 -0000	1.55
+++ elfread.c	31 Aug 2006 10:50:17 -0000
@@ -211,9 +211,14 @@ elf_symtab_read (struct objfile *objfile
 
       /* If it is a nonstripped executable, do not enter dynamic
 	 symbols, as the dynamic symbol table is usually a subset
-	 of the main symbol table.  */
-      if (dynamic && !stripped)
+	 of the main symbol table.  
+	 The Linux ELF symbol versionning requires that the versioned
+	 static symbols are suffixed with (@)@VERSION, thus the
+	 entries we got from the static symtab for these symbols have
+	 suffixed names.  The entries in the dynamic symtab don't have
+	 the suffix (version info is stored in .gnu_version section).  */
+      if (dynamic && !stripped && !((elf_symbol_type *) sym)->version)
 	continue;
       if (sym->flags & BSF_FILE)
 	{

? testsuite-cout.patch
Index: gdb.cp/userdef.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/userdef.exp,v
retrieving revision 1.6
diff -u -p -r1.6 userdef.exp
--- gdb.cp/userdef.exp	10 Aug 2006 05:27:20 -0000	1.6
+++ gdb.cp/userdef.exp	31 Aug 2006 10:58:01 -0000
@@ -151,5 +151,8 @@ gdb_test "print *c" "\\\$\[0-9\]* = \\(M
 gdb_test "print &*c" "\\\$\[0-9\]* = \\(Member \\*\\) $hex"
 gdb_test "ptype &*c" "type = struct Member {\[\r\n \]+int z;\[\r\n\]+} &\\*"
 
+# Check that we're able to use std::cout
+gdb_test "print 'operator<<'(std::cout, one)" "\[\r\n\]+x = 9\[\r\n\]+y = 10\[\r\n\]+-------\[\r\n\]+\\\$\[0-9\]* = .*"
+
 gdb_exit
 return 0

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]