diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2010-01-09 09:11:00 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2010-01-09 09:11:00 +0000 |
commit | 567995e103055787c86c42096397015a55e02fd4 (patch) | |
tree | a0de58b90d278e233552c471b8111ccd2203a108 /gdb/objfiles.c | |
parent | a2beed37dbcc39524abf8a86b2133ea49f766205 (diff) | |
download | gdb-567995e103055787c86c42096397015a55e02fd4.zip gdb-567995e103055787c86c42096397015a55e02fd4.tar.gz gdb-567995e103055787c86c42096397015a55e02fd4.tar.bz2 |
gdb/
Fix displacement of separate debug info files.
* objfiles.c (objfile_relocate): Rename to ...
(objfile_relocate1): ... here and make it static. Extend the comment.
(objfile_relocate): New function.
* solib-spu.c (spu_relocate_main_executable): Explicitly check if
SYMFILE_OBJFILE is NULL. Remove variables objfile and old_chain.
Remove following of SEPARATE_DEBUG_OBJFILE. new_offsets is now
allocated using alloca.
* symfile.c (copy_section_addr_info): Remove.
(build_section_addr_info_from_objfile): Make it global. New variables
addr_bit and mask, use them.
* symfile.h (build_section_addr_info_from_objfile): New prototype.
(copy_section_addr_info): Remove.
Diffstat (limited to 'gdb/objfiles.c')
-rw-r--r-- | gdb/objfiles.c | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 9f779a4..d1e441b 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -693,9 +693,10 @@ free_all_objfiles (void) } /* Relocate OBJFILE to NEW_OFFSETS. There should be OBJFILE->NUM_SECTIONS - entries in new_offsets. */ -void -objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets) + entries in new_offsets. SEPARATE_DEBUG_OBJFILE is not touched here. */ + +static void +objfile_relocate1 (struct objfile *objfile, struct section_offsets *new_offsets) { struct obj_section *s; struct section_offsets *delta = @@ -849,6 +850,54 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets) exec_set_section_address (bfd_get_filename (objfile->obfd), idx, obj_section_addr (s)); } +} + +/* Relocate OBJFILE to NEW_OFFSETS. There should be OBJFILE->NUM_SECTIONS + entries in new_offsets. Process also OBJFILE's SEPARATE_DEBUG_OBJFILEs. + + The number and ordering of sections does differ between the two objfiles. + Only their names match. Also the file offsets will differ (objfile being + possibly prelinked but separate_debug_objfile is probably not prelinked) but + the in-memory absolute address as specified by NEW_OFFSETS must match both + files. */ + +void +objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets) +{ + struct objfile *debug_objfile; + + objfile_relocate1 (objfile, new_offsets); + + for (debug_objfile = objfile->separate_debug_objfile; + debug_objfile; + debug_objfile = objfile_separate_debug_iterate (objfile, debug_objfile)) + { + struct section_addr_info *objfile_addrs; + struct section_offsets *new_debug_offsets; + int new_debug_num_sections; + struct cleanup *my_cleanups; + + objfile_addrs = build_section_addr_info_from_objfile (objfile); + my_cleanups = make_cleanup (xfree, objfile_addrs); + + /* Here OBJFILE_ADDRS contain the correct absolute addresses, the + relative ones must be already created according to debug_objfile. */ + + addr_info_make_relative (objfile_addrs, debug_objfile->obfd); + + gdb_assert (debug_objfile->num_sections + == bfd_count_sections (debug_objfile->obfd)); + new_debug_offsets = xmalloc (SIZEOF_N_SECTION_OFFSETS + (debug_objfile->num_sections)); + make_cleanup (xfree, new_debug_offsets); + relative_addr_info_to_section_offsets (new_debug_offsets, + debug_objfile->num_sections, + objfile_addrs); + + objfile_relocate1 (debug_objfile, new_debug_offsets); + + do_cleanups (my_cleanups); + } /* Relocate breakpoints as necessary, after things are relocated. */ breakpoint_re_set (); |