+ /* Data changed. */
+ return 1;
+}
+
+/* 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,
+ const struct section_offsets *new_offsets)
+{
+ int changed = 0;
+
+ changed |= objfile_relocate1 (objfile, new_offsets);
+
+ for (::objfile *debug_objfile : objfile->separate_debug_objfiles ())
+ {
+ if (debug_objfile == objfile)
+ continue;
+
+ section_addr_info objfile_addrs
+ = build_section_addr_info_from_objfile (objfile);
+
+ /* 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
+ == gdb_bfd_count_sections (debug_objfile->obfd));
+ std::vector<struct section_offsets>
+ new_debug_offsets (SIZEOF_N_SECTION_OFFSETS (debug_objfile->num_sections));
+ relative_addr_info_to_section_offsets (new_debug_offsets.data (),
+ debug_objfile->num_sections,
+ objfile_addrs);
+
+ changed |= objfile_relocate1 (debug_objfile, new_debug_offsets.data ());
+ }
+
+ /* Relocate breakpoints as necessary, after things are relocated. */
+ 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)
+{
+ int changed = 0;
+
+ for (::objfile *debug_objfile : objfile->separate_debug_objfiles ())
+ changed |= objfile_rebase1 (debug_objfile, slide);
+
+ /* Relocate breakpoints as necessary, after things are relocated. */
+ if (changed)
+ breakpoint_re_set ();