aboutsummaryrefslogtreecommitdiff
path: root/gdb/objfiles.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2012-12-18 06:19:54 +0000
committerJoel Brobecker <brobecker@gnat.com>2012-12-18 06:19:54 +0000
commit4141a416ddb921e600cf6d28b805f854ef3b60e9 (patch)
tree5cb6c7680fd1a540782a97a22b23c5e8c1deea8f /gdb/objfiles.c
parentc0fc7f8be2d688e3d533e0470c58cc52fa21ef7e (diff)
downloadgdb-4141a416ddb921e600cf6d28b805f854ef3b60e9.zip
gdb-4141a416ddb921e600cf6d28b805f854ef3b60e9.tar.gz
gdb-4141a416ddb921e600cf6d28b805f854ef3b60e9.tar.bz2
solib-darwin.c: handle PIE when attaching processes.
gdb/ChangeLog: * solib-darwin.c (darwin_current_sos): Fix indentation. (darwin_read_exec_load_addr): New function. (darwin_solib_create_inferior_hook): Rebase executable. * objfiles.c (objfile_rebase1, objfile_rebase): New functions. * objfiles.h (objfile_rebase1, objfile_rebase): Add prototypes.
Diffstat (limited to 'gdb/objfiles.c')
-rw-r--r--gdb/objfiles.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index feb387b..f75c434 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -882,6 +882,45 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets)
if (changed)
breakpoint_re_set ();
}
+
+/* Rebase (add to the offsets) OBJFILE by SLIDE. SEPARATE_DEBUG_OBJFILE is
+ not touched here.
+ Return non-zero iff any change happened. */
+
+static int
+objfile_rebase1 (struct objfile *objfile, CORE_ADDR slide)
+{
+ struct section_offsets *new_offsets =
+ ((struct section_offsets *)
+ alloca (SIZEOF_N_SECTION_OFFSETS (objfile->num_sections)));
+ int i;
+
+ for (i = 0; i < objfile->num_sections; ++i)
+ new_offsets->offsets[i] = slide;
+
+ return objfile_relocate1 (objfile, new_offsets);
+}
+
+/* Rebase (add to the offsets) OBJFILE by SLIDE. Process also OBJFILE's
+ SEPARATE_DEBUG_OBJFILEs. */
+
+void
+objfile_rebase (struct objfile *objfile, CORE_ADDR slide)
+{
+ struct objfile *debug_objfile;
+ int changed = 0;
+
+ changed |= objfile_rebase1 (objfile, slide);
+
+ for (debug_objfile = objfile->separate_debug_objfile;
+ debug_objfile;
+ debug_objfile = objfile_separate_debug_iterate (objfile, debug_objfile))
+ changed |= objfile_rebase1 (debug_objfile, slide);
+
+ /* Relocate breakpoints as necessary, after things are relocated. */
+ if (changed)
+ breakpoint_re_set ();
+}
/* Return non-zero if OBJFILE has partial symbols. */