+
+/* See minsyms.h. */
+
+CORE_ADDR
+minimal_symbol_upper_bound (struct bound_minimal_symbol minsym)
+{
+ int i;
+ short section;
+ struct obj_section *obj_section;
+ CORE_ADDR result;
+ struct minimal_symbol *msymbol;
+
+ gdb_assert (minsym.minsym != NULL);
+
+ /* If the minimal symbol has a size, use it. Otherwise use the
+ lesser of the next minimal symbol in the same section, or the end
+ of the section, as the end of the function. */
+
+ if (MSYMBOL_SIZE (minsym.minsym) != 0)
+ return BMSYMBOL_VALUE_ADDRESS (minsym) + MSYMBOL_SIZE (minsym.minsym);
+
+ /* Step over other symbols at this same address, and symbols in
+ other sections, to find the next symbol in this section with a
+ different address. */
+
+ msymbol = minsym.minsym;
+ section = MSYMBOL_SECTION (msymbol);
+ for (i = 1; MSYMBOL_LINKAGE_NAME (msymbol + i) != NULL; i++)
+ {
+ if ((MSYMBOL_VALUE_RAW_ADDRESS (msymbol + i)
+ != MSYMBOL_VALUE_RAW_ADDRESS (msymbol))
+ && MSYMBOL_SECTION (msymbol + i) == section)
+ break;
+ }
+
+ obj_section = MSYMBOL_OBJ_SECTION (minsym.objfile, minsym.minsym);
+ if (MSYMBOL_LINKAGE_NAME (msymbol + i) != NULL
+ && (MSYMBOL_VALUE_ADDRESS (minsym.objfile, msymbol + i)
+ < obj_section_endaddr (obj_section)))
+ result = MSYMBOL_VALUE_ADDRESS (minsym.objfile, msymbol + i);
+ else
+ /* We got the start address from the last msymbol in the objfile.
+ So the end address is the end of the section. */
+ result = obj_section_endaddr (obj_section);
+
+ return result;
+}