ld: Set non_ir_ref_regular for --undefined SYMBOL
[deliverable/binutils-gdb.git] / gdb / minsyms.c
index 496dba029675bad6b91e5941fe296393b2ab7e39..4409e6f8b3a3791e6d5d533afabe323799bb8cf3 100644 (file)
@@ -73,8 +73,9 @@ msymbol_is_function (struct objfile *objfile, minimal_symbol *minsym,
     case mst_data_gnu_ifunc:
       {
        struct gdbarch *gdbarch = get_objfile_arch (objfile);
-       CORE_ADDR pc = gdbarch_convert_from_func_ptr_addr (gdbarch, msym_addr,
-                                                          target_stack);
+       CORE_ADDR pc
+         = gdbarch_convert_from_func_ptr_addr (gdbarch, msym_addr,
+                                               current_top_target ());
        if (pc != msym_addr)
          {
            if (func_address_p != NULL)
@@ -655,6 +656,27 @@ frob_address (struct objfile *objfile, CORE_ADDR *pc)
   return 0;
 }
 
+/* Helper for lookup_minimal_symbol_by_pc_section.  Convert a
+   lookup_msym_prefer to a minimal_symbol_type.  */
+
+static minimal_symbol_type
+msym_prefer_to_msym_type (lookup_msym_prefer prefer)
+{
+  switch (prefer)
+    {
+    case lookup_msym_prefer::TEXT:
+      return mst_text;
+    case lookup_msym_prefer::TRAMPOLINE:
+      return mst_solib_trampoline;
+    case lookup_msym_prefer::GNU_IFUNC:
+      return mst_text_gnu_ifunc;
+    }
+
+  /* Assert here instead of in a default switch case above so that
+     -Wswitch warns if a new enumerator is added.  */
+  gdb_assert_not_reached ("unhandled lookup_msym_prefer");
+}
+
 /* Search through the minimal symbol table for each objfile and find
    the symbol whose address is the largest address that is still less
    than or equal to PC, and matches SECTION (which is not NULL).
@@ -682,7 +704,6 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
   struct minimal_symbol *best_symbol = NULL;
   struct objfile *best_objfile = NULL;
   struct bound_minimal_symbol result;
-  enum minimal_symbol_type want_type;
 
   if (section == NULL)
     {
@@ -691,18 +712,7 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
        return {};
     }
 
-  switch (prefer)
-    {
-    case lookup_msym_prefer::TEXT:
-      want_type = mst_text;
-      break;
-    case lookup_msym_prefer::TRAMPOLINE:
-      want_type = mst_solib_trampoline;
-      break;
-    case lookup_msym_prefer::GNU_IFUNC:
-      want_type = mst_text_gnu_ifunc;
-      break;
-    }
+  minimal_symbol_type want_type = msym_prefer_to_msym_type (prefer);
 
   /* We can not require the symbol found to be in section, because
      e.g. IRIX 6.5 mdebug relies on this code returning an absolute
@@ -990,24 +1000,6 @@ static const struct gnu_ifunc_fns stub_gnu_ifunc_fns =
 
 const struct gnu_ifunc_fns *gnu_ifunc_fns_p = &stub_gnu_ifunc_fns;
 
-/* See minsyms.h.  */
-
-struct bound_minimal_symbol
-lookup_minimal_symbol_and_objfile (const char *name)
-{
-  struct bound_minimal_symbol result;
-  struct objfile *objfile;
-
-  ALL_OBJFILES (objfile)
-    {
-      result = lookup_minimal_symbol (name, NULL, objfile);
-      if (result.minsym != NULL)
-        return result;
-    }
-
-  memset (&result, 0, sizeof (result));
-  return result;
-}
 \f
 
 /* Return leading symbol character for a BFD.  If BFD is NULL,
@@ -1419,10 +1411,8 @@ void
 terminate_minimal_symbol_table (struct objfile *objfile)
 {
   if (! objfile->per_bfd->msymbols)
-    objfile->per_bfd->msymbols
-      = ((struct minimal_symbol *)
-        obstack_alloc (&objfile->per_bfd->storage_obstack,
-                       sizeof (struct minimal_symbol)));
+    objfile->per_bfd->msymbols = XOBNEW (&objfile->per_bfd->storage_obstack,
+                                        minimal_symbol);
 
   {
     struct minimal_symbol *m
This page took 0.024174 seconds and 4 git commands to generate.