+/* Set the architecture-specific `struct link_map_offsets' fetcher for
+ GDBARCH to FLMO. Also, install SVR4 solib_ops into GDBARCH. */
+
+void
+set_solib_svr4_fetch_link_map_offsets (struct gdbarch *gdbarch,
+ struct link_map_offsets *(*flmo) (void))
+{
+ struct solib_svr4_ops *ops = gdbarch_data (gdbarch, solib_svr4_data);
+
+ ops->fetch_link_map_offsets = flmo;
+
+ set_solib_ops (gdbarch, &svr4_so_ops);
+}
+
+/* Fetch a link_map_offsets structure using the architecture-specific
+ `struct link_map_offsets' fetcher. */
+
+static struct link_map_offsets *
+svr4_fetch_link_map_offsets (void)
+{
+ struct solib_svr4_ops *ops = gdbarch_data (target_gdbarch, solib_svr4_data);
+
+ gdb_assert (ops->fetch_link_map_offsets);
+ return ops->fetch_link_map_offsets ();
+}
+
+/* Return 1 if a link map offset fetcher has been defined, 0 otherwise. */
+
+static int
+svr4_have_link_map_offsets (void)
+{
+ struct solib_svr4_ops *ops = gdbarch_data (target_gdbarch, solib_svr4_data);
+ return (ops->fetch_link_map_offsets != NULL);
+}
+\f
+
+/* Most OS'es that have SVR4-style ELF dynamic libraries define a
+ `struct r_debug' and a `struct link_map' that are binary compatible
+ with the origional SVR4 implementation. */
+
+/* Fetch (and possibly build) an appropriate `struct link_map_offsets'
+ for an ILP32 SVR4 system. */
+
+struct link_map_offsets *
+svr4_ilp32_fetch_link_map_offsets (void)
+{
+ static struct link_map_offsets lmo;
+ static struct link_map_offsets *lmp = NULL;
+
+ if (lmp == NULL)
+ {
+ lmp = &lmo;
+
+ lmo.r_version_offset = 0;
+ lmo.r_version_size = 4;
+ lmo.r_map_offset = 4;
+ lmo.r_brk_offset = 8;
+ lmo.r_ldsomap_offset = 20;
+
+ /* Everything we need is in the first 20 bytes. */
+ lmo.link_map_size = 20;
+ lmo.l_addr_offset = 0;
+ lmo.l_name_offset = 4;
+ lmo.l_ld_offset = 8;
+ lmo.l_next_offset = 12;
+ lmo.l_prev_offset = 16;
+ }
+
+ return lmp;
+}
+
+/* Fetch (and possibly build) an appropriate `struct link_map_offsets'
+ for an LP64 SVR4 system. */
+
+struct link_map_offsets *
+svr4_lp64_fetch_link_map_offsets (void)
+{
+ static struct link_map_offsets lmo;
+ static struct link_map_offsets *lmp = NULL;
+
+ if (lmp == NULL)
+ {
+ lmp = &lmo;
+
+ lmo.r_version_offset = 0;
+ lmo.r_version_size = 4;
+ lmo.r_map_offset = 8;
+ lmo.r_brk_offset = 16;
+ lmo.r_ldsomap_offset = 40;
+
+ /* Everything we need is in the first 40 bytes. */
+ lmo.link_map_size = 40;
+ lmo.l_addr_offset = 0;
+ lmo.l_name_offset = 8;
+ lmo.l_ld_offset = 16;
+ lmo.l_next_offset = 24;
+ lmo.l_prev_offset = 32;
+ }
+
+ return lmp;
+}
+\f
+
+struct target_so_ops svr4_so_ops;
+
+/* Lookup global symbol for ELF DSOs linked with -Bsymbolic. Those DSOs have a
+ different rule for symbol lookup. The lookup begins here in the DSO, not in
+ the main executable. */
+
+static struct symbol *
+elf_lookup_lib_symbol (const struct objfile *objfile,
+ const char *name,
+ const char *linkage_name,
+ const domain_enum domain)
+{
+ if (objfile->obfd == NULL
+ || scan_dyntag (DT_SYMBOLIC, objfile->obfd, NULL) != 1)
+ return NULL;
+
+ return lookup_global_symbol_from_objfile
+ (objfile, name, linkage_name, domain);
+}
+
+extern initialize_file_ftype _initialize_svr4_solib; /* -Wmissing-prototypes */