Index: gdb/minsyms.c =================================================================== RCS file: /cvs/src/src/gdb/minsyms.c,v retrieving revision 1.46 diff -u -p -r1.46 minsyms.c --- gdb/minsyms.c 19 Jul 2006 02:17:23 -0000 1.46 +++ gdb/minsyms.c 25 Aug 2006 01:42:27 -0000 @@ -50,6 +50,7 @@ #include "demangle.h" #include "value.h" #include "cp-abi.h" +#include "target.h" /* Accumulate the minimal symbols for each objfile in bunches of BUNCH_SIZE. At the end, copy them all into one newly allocated location on an objfile's @@ -202,10 +203,18 @@ lookup_minimal_symbol (const char *name, you want to test the linkage names with strcmp, do that. If you want to test the natural names with strcmp_iw, use SYMBOL_MATCHES_NATURAL_NAME. */ - if (strcmp (DEPRECATED_SYMBOL_NAME (msymbol), (name)) == 0 + if ((strcmp (DEPRECATED_SYMBOL_NAME (msymbol), (name)) == 0 || (SYMBOL_DEMANGLED_NAME (msymbol) != NULL && strcmp_iw (SYMBOL_DEMANGLED_NAME (msymbol), (name)) == 0)) + /* Ignore TLS based symbols if inferior does not run in + threaded mode. + https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=185337 + Otherwise we would resolve glibc TLS `errno' even for + nonthreaded programs without any TLS base set. */ + && ((SYMBOL_BFD_SECTION (msymbol)->flags + & SEC_THREAD_LOCAL) == 0 + || target_get_thread_local_address_p())) { switch (MSYMBOL_TYPE (msymbol)) { Index: gdb/testsuite/gdb.threads/tls-nopthread.c =================================================================== RCS file: gdb/testsuite/gdb.threads/tls-nopthread.c diff -N gdb/testsuite/gdb.threads/tls-nopthread.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/testsuite/gdb.threads/tls-nopthread.c 25 Aug 2006 01:42:52 -0000 @@ -0,0 +1,10 @@ +/* Test accessing TLS based variable without -lpthread / TLS setup. */ + +#include + +__thread int thread_local = 42; + +int main(void) +{ + return 0; +} Index: gdb/testsuite/gdb.threads/tls-nopthread.exp =================================================================== RCS file: gdb/testsuite/gdb.threads/tls-nopthread.exp diff -N gdb/testsuite/gdb.threads/tls-nopthread.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/testsuite/gdb.threads/tls-nopthread.exp 25 Aug 2006 01:42:52 -0000 @@ -0,0 +1,56 @@ +# tls.exp -- Expect script to test thread-local storage without TLS setup +# Copyright (C) 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +set testfile tls-nopthread +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +if [istarget "*-*-linux"] then { + set target_cflags "-D_MIT_POSIX_THREADS" +} else { + set target_cflags "" +} + +if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable []] != "" } { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir + +gdb_load ${binfile} +if ![runto_main] then { + fail "Can't run to main" + return 0 +} + +# formerly no debug: Cannot access memory at address 0x0 +# formerly with debug: Cannot find thread-local variables on this target +# patched no debug: Address of symbol "thread_local" is unknown. +# OR No symbol table is loaded. Use the "file" command. +# patched with debug: Cannot find thread-local variables on this target +gdb_test "p thread_local" {.*Address of symbol "thread_local" is unknown..*|.*No symbol table is loaded. Use the "file" command..*} "thread local storage" + +# Done! +# +gdb_exit + +return 0