/* Generic symbol file reading for the GNU debugger, GDB.
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+ 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
Contributed by Cygnus Support, using pieces from other GDB modules.
static void add_symbol_file_command (char *, int);
-static void cashier_psymtab (struct partial_symtab *);
-
bfd *symfile_bfd_open (char *);
int get_section_index (struct objfile *, char *);
return sap;
}
-
-/* Return a freshly allocated copy of ADDRS. The section names, if
- any, are also freshly allocated copies of those in ADDRS. */
-struct section_addr_info *
-copy_section_addr_info (struct section_addr_info *addrs)
-{
- struct section_addr_info *copy
- = alloc_section_addr_info (addrs->num_sections);
- int i;
-
- copy->num_sections = addrs->num_sections;
- for (i = 0; i < addrs->num_sections; i++)
- {
- copy->other[i].addr = addrs->other[i].addr;
- if (addrs->other[i].name)
- copy->other[i].name = xstrdup (addrs->other[i].name);
- else
- copy->other[i].name = NULL;
- copy->other[i].sectindex = addrs->other[i].sectindex;
- }
-
- return copy;
-}
-
-
-
/* Build (allocate and populate) a section_addr_info struct from
an existing section table. */
return sap;
}
+/* Create a section_addr_info from section offsets in OBJFILE. */
+
+struct section_addr_info *
+build_section_addr_info_from_objfile (const struct objfile *objfile)
+{
+ struct section_addr_info *sap;
+ int i;
+ struct bfd_section *sec;
+ int addr_bit = gdbarch_addr_bit (objfile->gdbarch);
+ CORE_ADDR mask = CORE_ADDR_MAX;
+
+ if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
+ mask = ((CORE_ADDR) 1 << addr_bit) - 1;
+
+ sap = alloc_section_addr_info (objfile->num_sections);
+ for (i = 0, sec = objfile->obfd->sections; sec != NULL; sec = sec->next)
+ if (bfd_get_section_flags (objfile->obfd, sec) & (SEC_ALLOC | SEC_LOAD))
+ {
+ sap->other[i].addr = (bfd_get_section_vma (objfile->obfd, sec)
+ + objfile->section_offsets->offsets[i]) & mask;
+ sap->other[i].name = xstrdup (bfd_get_section_name (objfile->obfd,
+ sec));
+ sap->other[i].sectindex = sec->index;
+ i++;
+ }
+ return sap;
+}
+
/* Free all memory allocated by build_section_addr_info_from_section_table. */
arg->lowest = start_addr + bfd_get_section_size (sect);
}
-/* Parse the user's idea of an offset for dynamic linking, into our idea
- of how to represent it for fast symbol reading. This is the default
- version of the sym_fns.sym_offsets function for symbol readers that
- don't need to do anything special. It allocates a section_offsets table
- for the objectfile OBJFILE and stuffs ADDR into all of the offsets. */
+/* Store struct section_addr_info as prepared (made relative and with SECTINDEX
+ filled-in) by addr_info_make_relative into SECTION_OFFSETS of NUM_SECTIONS
+ entries. */
void
-default_symfile_offsets (struct objfile *objfile,
- struct section_addr_info *addrs)
+relative_addr_info_to_section_offsets (struct section_offsets *section_offsets,
+ int num_sections,
+ struct section_addr_info *addrs)
{
int i;
- objfile->num_sections = bfd_count_sections (objfile->obfd);
- objfile->section_offsets = (struct section_offsets *)
- obstack_alloc (&objfile->objfile_obstack,
- SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
- memset (objfile->section_offsets, 0,
- SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
+ memset (section_offsets, 0, SIZEOF_N_SECTION_OFFSETS (num_sections));
- /* Now calculate offsets for section that were specified by the
- caller. */
+ /* Now calculate offsets for section that were specified by the caller. */
for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
{
- struct other_sections *osp ;
+ struct other_sections *osp;
- osp = &addrs->other[i] ;
+ osp = &addrs->other[i];
if (osp->addr == 0)
continue;
/* Record all sections in offsets */
/* The section_offsets in the objfile are here filled in using
the BFD index. */
- (objfile->section_offsets)->offsets[osp->sectindex] = osp->addr;
+ section_offsets->offsets[osp->sectindex] = osp->addr;
+ }
+}
+
+/* Relativize absolute addresses in ADDRS into offsets based on ABFD. Fill-in
+ also SECTINDEXes specific to ABFD there. This function can be used to
+ rebase ADDRS to start referencing different BFD than before. */
+
+void
+addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd)
+{
+ asection *lower_sect;
+ CORE_ADDR lower_offset;
+ int i;
+
+ /* Find lowest loadable section to be used as starting point for
+ continguous sections. */
+ lower_sect = NULL;
+ bfd_map_over_sections (abfd, find_lowest_section, &lower_sect);
+ if (lower_sect == NULL)
+ {
+ warning (_("no loadable sections found in added symbol-file %s"),
+ bfd_get_filename (abfd));
+ lower_offset = 0;
+ }
+ else
+ lower_offset = bfd_section_vma (bfd_get_filename (abfd), lower_sect);
+
+ /* Calculate offsets for the loadable sections.
+ FIXME! Sections must be in order of increasing loadable section
+ so that contiguous sections can use the lower-offset!!!
+
+ Adjust offsets if the segments are not contiguous.
+ If the section is contiguous, its offset should be set to
+ the offset of the highest loadable section lower than it
+ (the loadable section directly below it in memory).
+ this_offset = lower_offset = lower_addr - lower_orig_addr */
+
+ for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
+ {
+ asection *sect = bfd_get_section_by_name (abfd, addrs->other[i].name);
+
+ if (sect)
+ {
+ /* This is the index used by BFD. */
+ addrs->other[i].sectindex = sect->index;
+
+ if (addrs->other[i].addr != 0)
+ {
+ addrs->other[i].addr -= bfd_section_vma (abfd, sect);
+ lower_offset = addrs->other[i].addr;
+ }
+ else
+ addrs->other[i].addr = lower_offset;
+ }
+ else
+ {
+ warning (_("section %s not found in %s"), addrs->other[i].name,
+ bfd_get_filename (abfd));
+ addrs->other[i].addr = 0;
+
+ /* SECTINDEX is invalid if ADDR is zero. */
+ }
}
+}
+
+/* Parse the user's idea of an offset for dynamic linking, into our idea
+ of how to represent it for fast symbol reading. This is the default
+ version of the sym_fns.sym_offsets function for symbol readers that
+ don't need to do anything special. It allocates a section_offsets table
+ for the objectfile OBJFILE and stuffs ADDR into all of the offsets. */
+
+void
+default_symfile_offsets (struct objfile *objfile,
+ struct section_addr_info *addrs)
+{
+ objfile->num_sections = bfd_count_sections (objfile->obfd);
+ objfile->section_offsets = (struct section_offsets *)
+ obstack_alloc (&objfile->objfile_obstack,
+ SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
+ relative_addr_info_to_section_offsets (objfile->section_offsets,
+ objfile->num_sections, addrs);
/* For relocatable files, all loadable sections will start at zero.
The zero is meaningless, so try to pick arbitrary addresses such
We no longer warn if the lowest section is not a text segment (as
happens for the PA64 port. */
- if (!mainline && addrs && addrs->other[0].name)
- {
- asection *lower_sect;
- asection *sect;
- CORE_ADDR lower_offset;
- int i;
-
- /* Find lowest loadable section to be used as starting point for
- continguous sections. FIXME!! won't work without call to find
- .text first, but this assumes text is lowest section. */
- lower_sect = bfd_get_section_by_name (objfile->obfd, ".text");
- if (lower_sect == NULL)
- bfd_map_over_sections (objfile->obfd, find_lowest_section,
- &lower_sect);
- if (lower_sect == NULL)
- {
- warning (_("no loadable sections found in added symbol-file %s"),
- objfile->name);
- lower_offset = 0;
- }
- else
- lower_offset = bfd_section_vma (objfile->obfd, lower_sect);
-
- /* Calculate offsets for the loadable sections.
- FIXME! Sections must be in order of increasing loadable section
- so that contiguous sections can use the lower-offset!!!
-
- Adjust offsets if the segments are not contiguous.
- If the section is contiguous, its offset should be set to
- the offset of the highest loadable section lower than it
- (the loadable section directly below it in memory).
- this_offset = lower_offset = lower_addr - lower_orig_addr */
-
- for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
- {
- if (addrs->other[i].addr != 0)
- {
- sect = bfd_get_section_by_name (objfile->obfd,
- addrs->other[i].name);
- if (sect)
- {
- addrs->other[i].addr
- -= bfd_section_vma (objfile->obfd, sect);
- lower_offset = addrs->other[i].addr;
- /* This is the index used by BFD. */
- addrs->other[i].sectindex = sect->index ;
- }
- else
- {
- warning (_("section %s not found in %s"),
- addrs->other[i].name,
- objfile->name);
- addrs->other[i].addr = 0;
- }
- }
- else
- addrs->other[i].addr = lower_offset;
- }
- }
+ if (addrs && addrs->other[0].name)
+ addr_info_make_relative (addrs, objfile->obfd);
/* Initialize symbol reading routines for this objfile, allow complaints to
appear for this new file, and record how verbose to be, then do the
void
symbol_file_add_separate (bfd *bfd, int symfile_flags, struct objfile *objfile)
{
- /* Currently only one separate debug objfile is supported. */
- gdb_assert (objfile && objfile->separate_debug_objfile == NULL);
+ struct objfile *new_objfile;
+ struct section_addr_info *sap;
+ struct cleanup *my_cleanup;
+
+ /* Create section_addr_info. We can't directly use offsets from OBJFILE
+ because sections of BFD may not match sections of OBJFILE and because
+ vma may have been modified by tools such as prelink. */
+ sap = build_section_addr_info_from_objfile (objfile);
+ my_cleanup = make_cleanup_free_section_addr_info (sap);
- objfile->separate_debug_objfile =
- symbol_file_add_with_addrs_or_offsets
+ new_objfile = symbol_file_add_with_addrs_or_offsets
(bfd, symfile_flags,
- 0, /* No addr table. */
- objfile->section_offsets, objfile->num_sections,
+ sap, NULL, 0,
objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW
| OBJF_USERLOADED));
- objfile->separate_debug_objfile->separate_debug_objfile_backlink
- = objfile;
- /* Put the separate debug object before the normal one, this is so that
- usage of the ALL_OBJFILES_SAFE macro will stay safe. */
- put_objfile_before (objfile->separate_debug_objfile, 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
printf_unfiltered (_("No symbol file now.\n"));
}
-struct build_id
- {
- size_t size;
- gdb_byte data[1];
- };
-
-/* Locate NT_GNU_BUILD_ID from ABFD and return its content. */
-
-static struct build_id *
-build_id_bfd_get (bfd *abfd)
-{
- struct build_id *retval;
-
- if (!bfd_check_format (abfd, bfd_object)
- || bfd_get_flavour (abfd) != bfd_target_elf_flavour
- || elf_tdata (abfd)->build_id == NULL)
- return NULL;
-
- retval = xmalloc (sizeof *retval - 1 + elf_tdata (abfd)->build_id_size);
- retval->size = elf_tdata (abfd)->build_id_size;
- memcpy (retval->data, elf_tdata (abfd)->build_id, retval->size);
-
- return retval;
-}
-
-/* Return if FILENAME has NT_GNU_BUILD_ID matching the CHECK value. */
-
-static int
-build_id_verify (const char *filename, struct build_id *check)
-{
- bfd *abfd;
- struct build_id *found = NULL;
- int retval = 0;
-
- /* We expect to be silent on the non-existing files. */
- if (remote_filename_p (filename))
- abfd = remote_bfd_open (filename, gnutarget);
- else
- abfd = bfd_openr (filename, gnutarget);
- if (abfd == NULL)
- return 0;
-
- found = build_id_bfd_get (abfd);
-
- if (found == NULL)
- warning (_("File \"%s\" has no build-id, file skipped"), filename);
- else if (found->size != check->size
- || memcmp (found->data, check->data, found->size) != 0)
- warning (_("File \"%s\" has a different build-id, file skipped"), filename);
- else
- retval = 1;
-
- if (!bfd_close (abfd))
- warning (_("cannot close \"%s\": %s"), filename,
- bfd_errmsg (bfd_get_error ()));
-
- xfree (found);
-
- return retval;
-}
-
-static char *
-build_id_to_debug_filename (struct build_id *build_id)
-{
- char *link, *debugdir, *retval = NULL;
-
- /* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */
- link = alloca (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1
- + 2 * build_id->size + (sizeof ".debug" - 1) + 1);
-
- /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
- cause "/.build-id/..." lookups. */
-
- debugdir = debug_file_directory;
- do
- {
- char *s, *debugdir_end;
- gdb_byte *data = build_id->data;
- size_t size = build_id->size;
-
- while (*debugdir == DIRNAME_SEPARATOR)
- debugdir++;
-
- debugdir_end = strchr (debugdir, DIRNAME_SEPARATOR);
- if (debugdir_end == NULL)
- debugdir_end = &debugdir[strlen (debugdir)];
-
- memcpy (link, debugdir, debugdir_end - debugdir);
- s = &link[debugdir_end - debugdir];
- s += sprintf (s, "/.build-id/");
- if (size > 0)
- {
- size--;
- s += sprintf (s, "%02x", (unsigned) *data++);
- }
- if (size > 0)
- *s++ = '/';
- while (size-- > 0)
- s += sprintf (s, "%02x", (unsigned) *data++);
- strcpy (s, ".debug");
-
- /* lrealpath() is expensive even for the usually non-existent files. */
- if (access (link, F_OK) == 0)
- retval = lrealpath (link);
-
- if (retval != NULL && !build_id_verify (retval, build_id))
- {
- xfree (retval);
- retval = NULL;
- }
-
- if (retval != NULL)
- break;
-
- debugdir = debugdir_end;
- }
- while (*debugdir != 0);
-
- return retval;
-}
-
static char *
get_debug_link_info (struct objfile *objfile, unsigned long *crc32_out)
{
if (strcmp (name, parent_objfile->name) == 0)
return 0;
- if (remote_filename_p (name))
- abfd = remote_bfd_open (name, gnutarget);
- else
- abfd = bfd_openr (name, gnutarget);
+ abfd = bfd_open_maybe_remote (name);
if (!abfd)
return 0;
#define DEBUG_SUBDIRECTORY ".debug"
#endif
-char *
-find_separate_debug_file_by_buildid (struct objfile *objfile)
-{
- asection *sect;
- char *basename, *name_copy, *debugdir;
- char *dir = NULL;
- char *debugfile = NULL;
- char *canon_name = NULL;
- bfd_size_type debuglink_size;
- unsigned long crc32;
- int i;
- struct build_id *build_id;
-
- build_id = build_id_bfd_get (objfile->obfd);
- if (build_id != NULL)
- {
- char *build_id_name;
-
- build_id_name = build_id_to_debug_filename (build_id);
- xfree (build_id);
- /* Prevent looping on a stripped .debug file. */
- if (build_id_name != NULL && strcmp (build_id_name, objfile->name) == 0)
- {
- warning (_("\"%s\": separate debug info file has no debug info"),
- build_id_name);
- xfree (build_id_name);
- }
- else if (build_id_name != NULL)
- return build_id_name;
- }
- return NULL;
-}
-
char *
find_separate_debug_file_by_debuglink (struct objfile *objfile)
{
}
}
+/* If NAME is a remote name open the file using remote protocol, otherwise
+ open it normally. */
+
+bfd *
+bfd_open_maybe_remote (const char *name)
+{
+ if (remote_filename_p (name))
+ return remote_bfd_open (name, gnutarget);
+ else
+ return bfd_openr (name, gnutarget);
+}
+
+
/* Open the file specified by NAME and hand it off to BFD for
preliminary analysis. Return a newly initialized bfd *, which
includes a newly malloc'd` copy of NAME (tilde-expanded and made
if (!bfd_close (objfile->obfd))
error (_("Can't close BFD for %s: %s"), objfile->name,
bfd_errmsg (bfd_get_error ()));
- if (remote_filename_p (obfd_filename))
- objfile->obfd = remote_bfd_open (obfd_filename, gnutarget);
- else
- objfile->obfd = bfd_openr (obfd_filename, gnutarget);
+ objfile->obfd = bfd_open_maybe_remote (obfd_filename);
if (objfile->obfd == NULL)
error (_("Can't open %s to read symbols."), objfile->name);
else
clear_objfile_data (objfile);
- /* Free the separate debug objfile if there is one. It will be
+ /* Free the separate debug objfiles. It will be
automatically recreated by sym_read. */
- if (objfile->separate_debug_objfile)
- {
- /* Note: no need to clear separate_debug_objfile field as it is
- done by free_objfile. */
- free_objfile (objfile->separate_debug_objfile);
- }
+ free_objfile_separate_debug (objfile);
/* FIXME: Do we have to free a whole linked list, or is this
enough? */
symtab->dirname
symtab->free_code
symtab->free_ptr
- possibly free_named_symtabs (symtab->filename);
*/
struct symtab *
{
clear_symtab_users ();
}
-
-/* clear_symtab_users_once:
-
- This function is run after symbol reading, or from a cleanup.
- If an old symbol table was obsoleted, the old symbol table
- has been blown away, but the other GDB data structures that may
- reference it have not yet been cleared or re-directed. (The old
- symtab was zapped, and the cleanup queued, in free_named_symtab()
- below.)
-
- This function can be queued N times as a cleanup, or called
- directly; it will do all the work the first time, and then will be a
- no-op until the next time it is queued. This works by bumping a
- counter at queueing time. Much later when the cleanup is run, or at
- the end of symbol processing (in case the cleanup is discarded), if
- the queued count is greater than the "done-count", we do the work
- and set the done-count to the queued count. If the queued count is
- less than or equal to the done-count, we just ignore the call. This
- is needed because reading a single .o file will often replace many
- symtabs (one per .h file, for example), and we don't want to reset
- the breakpoints N times in the user's face.
-
- The reason we both queue a cleanup, and call it directly after symbol
- reading, is because the cleanup protects us in case of errors, but is
- discarded if symbol reading is successful. */
-
-#if 0
-/* FIXME: As free_named_symtabs is currently a big noop this function
- is no longer needed. */
-static void clear_symtab_users_once (void);
-
-static int clear_symtab_users_queued;
-static int clear_symtab_users_done;
-
-static void
-clear_symtab_users_once (void)
-{
- /* Enforce once-per-`do_cleanups'-semantics */
- if (clear_symtab_users_queued <= clear_symtab_users_done)
- return;
- clear_symtab_users_done = clear_symtab_users_queued;
-
- clear_symtab_users ();
-}
-#endif
-
-/* Delete the specified psymtab, and any others that reference it. */
-
-static void
-cashier_psymtab (struct partial_symtab *pst)
-{
- struct partial_symtab *ps, *pprev = NULL;
- int i;
-
- /* Find its previous psymtab in the chain */
- for (ps = pst->objfile->psymtabs; ps; ps = ps->next)
- {
- if (ps == pst)
- break;
- pprev = ps;
- }
-
- if (ps)
- {
- /* Unhook it from the chain. */
- if (ps == pst->objfile->psymtabs)
- pst->objfile->psymtabs = ps->next;
- else
- pprev->next = ps->next;
-
- /* FIXME, we can't conveniently deallocate the entries in the
- partial_symbol lists (global_psymbols/static_psymbols) that
- this psymtab points to. These just take up space until all
- the psymtabs are reclaimed. Ditto the dependencies list and
- filename, which are all in the objfile_obstack. */
-
- /* We need to cashier any psymtab that has this one as a dependency... */
- again:
- for (ps = pst->objfile->psymtabs; ps; ps = ps->next)
- {
- for (i = 0; i < ps->number_of_dependencies; i++)
- {
- if (ps->dependencies[i] == pst)
- {
- cashier_psymtab (ps);
- goto again; /* Must restart, chain has been munged. */
- }
- }
- }
- }
-}
-
-/* If a symtab or psymtab for filename NAME is found, free it along
- with any dependent breakpoints, displays, etc.
- Used when loading new versions of object modules with the "add-file"
- command. This is only called on the top-level symtab or psymtab's name;
- it is not called for subsidiary files such as .h files.
-
- Return value is 1 if we blew away the environment, 0 if not.
- FIXME. The return value appears to never be used.
-
- FIXME. I think this is not the best way to do this. We should
- work on being gentler to the environment while still cleaning up
- all stray pointers into the freed symtab. */
-
-int
-free_named_symtabs (char *name)
-{
-#if 0
- /* FIXME: With the new method of each objfile having it's own
- psymtab list, this function needs serious rethinking. In particular,
- why was it ever necessary to toss psymtabs with specific compilation
- unit filenames, as opposed to all psymtabs from a particular symbol
- file? -- fnf
- Well, the answer is that some systems permit reloading of particular
- compilation units. We want to blow away any old info about these
- compilation units, regardless of which objfiles they arrived in. --gnu. */
-
- struct symtab *s;
- struct symtab *prev;
- struct partial_symtab *ps;
- struct blockvector *bv;
- int blewit = 0;
-
- /* We only wack things if the symbol-reload switch is set. */
- if (!symbol_reloading)
- return 0;
-
- /* Some symbol formats have trouble providing file names... */
- if (name == 0 || *name == '\0')
- return 0;
-
- /* Look for a psymtab with the specified name. */
-
-again2:
- for (ps = partial_symtab_list; ps; ps = ps->next)
- {
- if (strcmp (name, ps->filename) == 0)
- {
- cashier_psymtab (ps); /* Blow it away...and its little dog, too. */
- goto again2; /* Must restart, chain has been munged */
- }
- }
-
- /* Look for a symtab with the specified name. */
-
- for (s = symtab_list; s; s = s->next)
- {
- if (strcmp (name, s->filename) == 0)
- break;
- prev = s;
- }
-
- if (s)
- {
- if (s == symtab_list)
- symtab_list = s->next;
- else
- prev->next = s->next;
-
- /* For now, queue a delete for all breakpoints, displays, etc., whether
- or not they depend on the symtab being freed. This should be
- changed so that only those data structures affected are deleted. */
-
- /* But don't delete anything if the symtab is empty.
- This test is necessary due to a bug in "dbxread.c" that
- causes empty symtabs to be created for N_SO symbols that
- contain the pathname of the object file. (This problem
- has been fixed in GDB 3.9x). */
-
- bv = BLOCKVECTOR (s);
- if (BLOCKVECTOR_NBLOCKS (bv) > 2
- || BLOCK_NSYMS (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK))
- || BLOCK_NSYMS (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)))
- {
- complaint (&symfile_complaints, _("Replacing old symbols for `%s'"),
- name);
- clear_symtab_users_queued++;
- make_cleanup (clear_symtab_users_once, 0);
- blewit = 1;
- }
- else
- complaint (&symfile_complaints, _("Empty symbol table found for `%s'"),
- name);
-
- free_symtab (s);
- }
- else
- {
- /* It is still possible that some breakpoints will be affected
- even though no symtab was found, since the file might have
- been compiled without debugging, and hence not be associated
- with a symtab. In order to handle this correctly, we would need
- to keep a list of text address ranges for undebuggable files.
- For now, we do nothing, since this is a fairly obscure case. */
- ;
- }
-
- /* FIXME, what about the minimal symbol table? */
- return blewit;
-#else
- return (0);
-#endif
-}
\f
/* Allocate and partially fill a partial symtab. It will be
completely filled at the end of the symbol list.
sectp->output_offset = 0;
}
+/* Default implementation for sym_relocate. */
+
+
+bfd_byte *
+default_symfile_relocate (struct objfile *objfile, asection *sectp,
+ bfd_byte *buf)
+{
+ bfd *abfd = objfile->obfd;
+
+ /* We're only interested in sections with relocation
+ information. */
+ if ((sectp->flags & SEC_RELOC) == 0)
+ return NULL;
+
+ /* We will handle section offsets properly elsewhere, so relocate as if
+ all sections begin at 0. */
+ bfd_map_over_sections (abfd, symfile_dummy_outputs, NULL);
+
+ return bfd_simple_get_relocated_section_contents (abfd, sectp, buf, NULL);
+}
+
/* Relocate the contents of a debug section SECTP in ABFD. The
contents are stored in BUF if it is non-NULL, or returned in a
malloc'd buffer otherwise.
debug section. */
bfd_byte *
-symfile_relocate_debug_section (bfd *abfd, asection *sectp, bfd_byte *buf)
+symfile_relocate_debug_section (struct objfile *objfile,
+ asection *sectp, bfd_byte *buf)
{
- /* We're only interested in sections with relocation
- information. */
- if ((sectp->flags & SEC_RELOC) == 0)
- return NULL;
-
- /* We will handle section offsets properly elsewhere, so relocate as if
- all sections begin at 0. */
- bfd_map_over_sections (abfd, symfile_dummy_outputs, NULL);
+ gdb_assert (objfile->sf->sym_relocate);
- return bfd_simple_get_relocated_section_contents (abfd, sectp, buf, NULL);
+ return (*objfile->sf->sym_relocate) (objfile, sectp, buf);
}
struct symfile_segment_data *
/* It doesn't make sense to call this function unless you have some
segment base addresses. */
- gdb_assert (segment_bases > 0);
+ gdb_assert (num_segment_bases > 0);
/* If we do not have segment mappings for the object file, we
can not relocate it by segments. */