2009-07-01 Tristan Gingold <gingold@adacore.com>
[deliverable/binutils-gdb.git] / gdb / elfread.c
index 363702a99fc369fc8457a74330347791cb95fd14..6e79d4abbd0c92abd16317f1cb43c0d6f0c08357 100644 (file)
@@ -1,7 +1,7 @@
 /* Read ELF (Executable and Linking Format) object files for GDB.
 
    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
 
    Written by Fred Fish at Cygnus Support.
@@ -108,7 +108,7 @@ elf_symfile_segments (bfd *abfd)
       for (j = 0; j < num_segments; j++)
        if (segments[j]->p_memsz > 0
            && vma >= segments[j]->p_vaddr
-           && vma < segments[j]->p_vaddr + segments[j]->p_memsz)
+           && (vma - segments[j]->p_vaddr) < segments[j]->p_memsz)
          {
            data->segment_info[i] = j + 1;
            break;
@@ -172,7 +172,7 @@ record_minimal_symbol (char *name, CORE_ADDR address,
     address = gdbarch_smash_text_address (gdbarch, address);
 
   return prim_record_minimal_symbol_and_info
-    (name, address, ms_type, NULL, bfd_section->index, bfd_section, objfile);
+    (name, address, ms_type, bfd_section->index, bfd_section, objfile);
 }
 
 /*
@@ -324,8 +324,10 @@ elf_symtab_read (struct objfile *objfile, int type,
             interested in will have a section. */
          /* Bfd symbols are section relative. */
          symaddr = sym->value + sym->section->vma;
-         /* Relocate all non-absolute symbols by the section offset.  */
-         if (sym->section != &bfd_abs_section)
+         /* Relocate all non-absolute and non-TLS symbols by the
+            section offset.  */
+         if (sym->section != &bfd_abs_section
+             && !(sym->section->flags & SEC_THREAD_LOCAL))
            {
              symaddr += offset;
            }
@@ -425,10 +427,11 @@ elf_symtab_read (struct objfile *objfile, int type,
                          int max_index;
                          size_t size;
 
-                         max_index 
-                           = max (SECT_OFF_BSS (objfile),
-                                  max (SECT_OFF_DATA (objfile),
-                                       SECT_OFF_RODATA (objfile)));
+                         max_index = SECT_OFF_BSS (objfile);
+                         if (objfile->sect_index_data > max_index)
+                           max_index = objfile->sect_index_data;
+                         if (objfile->sect_index_rodata > max_index)
+                           max_index = objfile->sect_index_rodata;
 
                          /* max_index is the largest index we'll
                             use into this array, so we must
This page took 0.024997 seconds and 4 git commands to generate.