bfd/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Sun, 17 Apr 2011 18:38:46 +0000 (18:38 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Sun, 17 Apr 2011 18:38:46 +0000 (18:38 +0000)
* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Do not check for
SEC_LOAD.

gdb/
Fix convert_code_addr_to_desc_addr for ppc64 files after eu-strip.
* elfread.c (elf_symfile_read): New variable synth_abfd, pass it to
bfd_get_synthetic_symtab.
* jit.c (jit_register_code): Pass NULL to the new parameter parent.
* machoread.c (macho_add_oso_symfile): Pass main_objfile to the new
parameter parent, remove the call to add_separate_debug_objfile.
* solib.c (solib_read_symbols): Pass NULL to the new parameter parent.
* symfile-mem.c (symbol_file_add_from_memory): Likewise.
* symfile.c (symbol_file_add_with_addrs_or_offsets): New parameter
parent, new comment for it, call add_separate_debug_objfile for it.
(symbol_file_add_separate): Pass objfile as the parameter parent,
remove the call to add_separate_debug_objfile.
(symbol_file_add_from_bfd): New parameter parent, pass it.
(symbol_file_add): Pass NULL to the new parameter parent.
* symfile.h (symbol_file_add_from_bfd): New parameter parent.

gdb/testsuite/
* gdb.base/eu-strip-infcall.c: New file.
* gdb.base/eu-strip-infcall.exp: New file.

13 files changed:
bfd/ChangeLog
bfd/elf64-ppc.c
gdb/ChangeLog
gdb/elfread.c
gdb/jit.c
gdb/machoread.c
gdb/solib.c
gdb/symfile-mem.c
gdb/symfile.c
gdb/symfile.h
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/eu-strip-infcall.c [new file with mode: 0644]
gdb/testsuite/gdb.base/eu-strip-infcall.exp [new file with mode: 0644]

index 8fa9ce10a99ed7e6c047021a218917b3236114c6..c02b2bd3880de28c14b1478bb14649b60a7610f5 100644 (file)
@@ -1,3 +1,8 @@
+2011-04-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Do not check for
+       SEC_LOAD.
+
 2011-04-15  Sergio Durigan Junior  <sergiodj@redhat.com>
 
        * elf-bfd.h (struct sdt_note): New struct.
index eb07b1fb7c7bf19690c32dc2cf6326a313f846a0..13ae9a227cf5f8df2759f932b81f788850538758 100644 (file)
@@ -3317,8 +3317,9 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd,
                {
                  if (sec->vma > ent)
                    break;
-                 if ((sec->flags & SEC_ALLOC) == 0
-                     || (sec->flags & SEC_LOAD) == 0)
+                 /* SEC_LOAD may not be set if SEC is from a separate debug
+                    info file.  */
+                 if ((sec->flags & SEC_ALLOC) == 0)
                    break;
                  if ((sec->flags & SEC_CODE) != 0)
                    s->section = sec;
index b44889e70df6c7f1141a28201341c066dc8f710f..5c06df203f1bb85d7b70302930e01ffefe25843f 100644 (file)
@@ -1,3 +1,21 @@
+2011-04-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       Fix convert_code_addr_to_desc_addr for ppc64 files after eu-strip.
+       * elfread.c (elf_symfile_read): New variable synth_abfd, pass it to
+       bfd_get_synthetic_symtab.
+       * jit.c (jit_register_code): Pass NULL to the new parameter parent.
+       * machoread.c (macho_add_oso_symfile): Pass main_objfile to the new
+       parameter parent, remove the call to add_separate_debug_objfile.
+       * solib.c (solib_read_symbols): Pass NULL to the new parameter parent.
+       * symfile-mem.c (symbol_file_add_from_memory): Likewise.
+       * symfile.c (symbol_file_add_with_addrs_or_offsets): New parameter
+       parent, new comment for it, call add_separate_debug_objfile for it.
+       (symbol_file_add_separate): Pass objfile as the parameter parent,
+       remove the call to add_separate_debug_objfile.
+       (symbol_file_add_from_bfd): New parameter parent, pass it.
+       (symbol_file_add): Pass NULL to the new parameter parent.
+       * symfile.h (symbol_file_add_from_bfd): New parameter parent.
+
 2011-04-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * elfread.c (elf_symtab_read): Do not ignore .L symbols if they are
index 2d589a42905b7a9702792ac43c1af675a4ebed84..f691b8f92ccc724671200524f94177cd1075bdcc 100644 (file)
@@ -1234,7 +1234,7 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
 static void
 elf_symfile_read (struct objfile *objfile, int symfile_flags)
 {
-  bfd *abfd = objfile->obfd;
+  bfd *synth_abfd, *abfd = objfile->obfd;
   struct elfinfo ei;
   struct cleanup *back_to;
   long symcount = 0, dynsymcount = 0, synthcount, storage_needed;
@@ -1305,9 +1305,26 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
       elf_rel_plt_read (objfile, dyn_symbol_table);
     }
 
+  /* Contrary to binutils --strip-debug/--only-keep-debug the strip command from
+     elfutils (eu-strip) moves even the .symtab section into the .debug file.
+
+     bfd_get_synthetic_symtab on ppc64 for each function descriptor ELF symbol
+     'name' creates a new BSF_SYNTHETIC ELF symbol '.name' with its code
+     address.  But with eu-strip files bfd_get_synthetic_symtab would fail to
+     read the code address from .opd while it reads the .symtab section from
+     a separate debug info file as the .opd section is SHT_NOBITS there.
+
+     With SYNTH_ABFD the .opd section will be read from the original
+     backlinked binary where it is valid.  */
+
+  if (objfile->separate_debug_objfile_backlink)
+    synth_abfd = objfile->separate_debug_objfile_backlink->obfd;
+  else
+    synth_abfd = abfd;
+
   /* Add synthetic symbols - for instance, names for any PLT entries.  */
 
-  synthcount = bfd_get_synthetic_symtab (abfd, symcount, symbol_table,
+  synthcount = bfd_get_synthetic_symtab (synth_abfd, symcount, symbol_table,
                                         dynsymcount, dyn_symbol_table,
                                         &synthsyms);
   if (synthcount > 0)
index e451024c49bcbcdb0b5b2ce0ad6b3a9346fa3f6f..be123a542ccff6e95aac28216343d26277247006 100644 (file)
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -296,7 +296,7 @@ JITed symbol file is not an object file, ignoring it.\n"));
       }
 
   /* This call takes ownership of sai.  */
-  objfile = symbol_file_add_from_bfd (nbfd, 0, sai, OBJF_SHARED);
+  objfile = symbol_file_add_from_bfd (nbfd, 0, sai, OBJF_SHARED, NULL);
 
   /* Remember a mapping from entry_addr to objfile.  */
   entry_addr_ptr = xmalloc (sizeof (CORE_ADDR));
index dbf9ae4c6e351e80188bc16d0d6c66f8db71adae..28cb958c83c0e24b4b2c580f46d88297a19edc0c 100644 (file)
@@ -397,8 +397,8 @@ macho_add_oso_symfile (oso_el *oso, bfd *abfd,
   objfile = symbol_file_add_from_bfd
     (abfd, symfile_flags & ~(SYMFILE_MAINLINE | SYMFILE_VERBOSE), NULL,
      main_objfile->flags & (OBJF_REORDERED | OBJF_SHARED
-                            | OBJF_READNOW | OBJF_USERLOADED));
-  add_separate_debug_objfile (objfile, main_objfile);
+                           | OBJF_READNOW | OBJF_USERLOADED),
+     main_objfile);
 
   current_oso.main_objfile = NULL;
   if (current_oso.symbol_table)
index 819eb7dab75d16fb752e62b1f88ee34dfe19ce05..a9f46e00099a931aceb4923373d25e5c11be23bd 100644 (file)
@@ -648,7 +648,8 @@ solib_read_symbols (struct so_list *so, int flags)
          sap = build_section_addr_info_from_section_table (so->sections,
                                                            so->sections_end);
          so->objfile = symbol_file_add_from_bfd (so->abfd,
-                                                 flags, sap, OBJF_SHARED);
+                                                 flags, sap, OBJF_SHARED,
+                                                 NULL);
          so->objfile->addr_low = so->addr_low;
          free_section_addr_info (sap);
        }
index f3e3f63b5c8ca47f8cd0ae9780d0fd15eeb846f7..6da5a1c3d398d348e31095675d56f91818d19239 100644 (file)
@@ -109,7 +109,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name,
       }
 
   objf = symbol_file_add_from_bfd (nbfd, from_tty ? SYMFILE_VERBOSE : 0,
-                                   sai, OBJF_SHARED);
+                                   sai, OBJF_SHARED, NULL);
 
   /* This might change our ideas about frames already looked at.  */
   reinit_frame_cache ();
index 4e1109e1dfc54b391a61ca5185858e4a94adb916..cec687092c22acb02394769fa0bd951124536301 100644 (file)
@@ -1067,6 +1067,9 @@ new_symfile_objfile (struct objfile *objfile, int add_flags)
    syms_from_objfile, above.
    ADDRS is ignored when SYMFILE_MAINLINE bit is set in ADD_FLAGS.
 
+   PARENT is the original objfile if ABFD is a separate debug info file.
+   Otherwise PARENT is NULL.
+
    Upon success, returns a pointer to the objfile that was added.
    Upon failure, jumps back to command level (never returns).  */
 
@@ -1076,7 +1079,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
                                        struct section_addr_info *addrs,
                                        struct section_offsets *offsets,
                                        int num_offsets,
-                                       int flags)
+                                       int flags, struct objfile *parent)
 {
   struct objfile *objfile;
   struct cleanup *my_cleanups;
@@ -1106,6 +1109,9 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
   objfile = allocate_objfile (abfd, flags);
   discard_cleanups (my_cleanups);
 
+  if (parent)
+    add_separate_debug_objfile (objfile, parent);
+
   /* We either created a new mapped symbol table, mapped an existing
      symbol table file which has not had initial symbol reading
      performed, or need to read an unmapped symbol table.  */
@@ -1196,11 +1202,10 @@ symbol_file_add_separate (bfd *bfd, int symfile_flags, struct objfile *objfile)
     (bfd, symfile_flags,
      sap, NULL, 0,
      objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW
-                      | OBJF_USERLOADED));
+                      | OBJF_USERLOADED),
+     objfile);
 
   do_cleanups (my_cleanup);
-
-  add_separate_debug_objfile (new_objfile, objfile);
 }
 
 /* Process the symbol file ABFD, as either the main file or as a
@@ -1211,10 +1216,10 @@ symbol_file_add_separate (bfd *bfd, int symfile_flags, struct objfile *objfile)
 struct objfile *
 symbol_file_add_from_bfd (bfd *abfd, int add_flags,
                           struct section_addr_info *addrs,
-                          int flags)
+                          int flags, struct objfile *parent)
 {
   return symbol_file_add_with_addrs_or_offsets (abfd, add_flags, addrs, 0, 0,
-                                                flags);
+                                                flags, parent);
 }
 
 
@@ -1226,7 +1231,7 @@ symbol_file_add (char *name, int add_flags, struct section_addr_info *addrs,
                 int flags)
 {
   return symbol_file_add_from_bfd (symfile_bfd_open (name), add_flags, addrs,
-                                   flags);
+                                   flags, NULL);
 }
 
 
index 89254829bd35325309a2ba0382411d86937942b3..1485e424bd81cd496323bb869dfadd0cef5fa948 100644 (file)
@@ -434,7 +434,7 @@ extern struct objfile *symbol_file_add (char *, int,
 
 extern struct objfile *symbol_file_add_from_bfd (bfd *, int,
                                                  struct section_addr_info *,
-                                                 int);
+                                                 int, struct objfile *parent);
 
 extern void symbol_file_add_separate (bfd *, int, struct objfile *);
 
index f1f8d3c7adde3015826de96fa632a635f1f37ca9..15e8b6c8cde6c8ba54a309e7f6303988730f6cea 100644 (file)
@@ -1,3 +1,8 @@
+2011-04-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * gdb.base/eu-strip-infcall.c: New file.
+       * gdb.base/eu-strip-infcall.exp: New file.
+
 2011-04-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * gdb.base/callfuncs.c (Lcallfunc, callfunc): New functions.
diff --git a/gdb/testsuite/gdb.base/eu-strip-infcall.c b/gdb/testsuite/gdb.base/eu-strip-infcall.c
new file mode 100644 (file)
index 0000000..59a5511
--- /dev/null
@@ -0,0 +1,34 @@
+/* Copyright 2011 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   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 3 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, see <http://www.gnu.org/licenses/>.  */
+
+int
+func (void)
+{
+  return 1;
+}
+
+int
+callfunc (int (*funcp) (void))
+{
+  return funcp () * 2;
+}
+
+int
+main (void)
+{
+  return callfunc (func);
+}
diff --git a/gdb/testsuite/gdb.base/eu-strip-infcall.exp b/gdb/testsuite/gdb.base/eu-strip-infcall.exp
new file mode 100644 (file)
index 0000000..61c05cb
--- /dev/null
@@ -0,0 +1,36 @@
+# Copyright (C) 2011 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 3 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, see <http://www.gnu.org/licenses/>.
+
+set testfile eu-strip-infcall
+set binfile ${objdir}/${subdir}/${testfile}
+
+if {[build_executable ${testfile}.exp $testfile] == -1} {
+    return -1
+}
+
+set test "eu-strip"
+set status [remote_exec build "eu-strip -f ${binfile}.debug $binfile"]
+if {[lindex $status 0] != 0} {
+    untested ${testfile}.exp
+    return 0
+}
+
+clean_restart $testfile
+
+if ![runto_main] {
+    return -1
+}
+
+gdb_test "p callfunc (func)" " = 2" "infcall"
This page took 0.071225 seconds and 4 git commands to generate.