+template<int size, bool big_endian>
+template<int sh_type>
+void
+Sized_relobj_file<size, big_endian>::split_stack_adjust_reltype(
+ const Symbol_table* symtab,
+ const unsigned char* pshdrs,
+ unsigned int shndx,
+ const unsigned char* prelocs,
+ size_t reloc_count,
+ unsigned char* view,
+ section_size_type view_size,
+ Reloc_symbol_changes** reloc_map,
+ const Sized_target<size, big_endian>* target)
+{
+ typedef typename Reloc_types<sh_type, size, big_endian>::Reloc Reltype;
+ const int reloc_size = Reloc_types<sh_type, size, big_endian>::reloc_size;
+
+ size_t local_count = this->local_symbol_count();
+
+ std::vector<section_offset_type> non_split_refs;
+
+ const unsigned char* pr = prelocs;
+ for (size_t i = 0; i < reloc_count; ++i, pr += reloc_size)
+ {
+ // Some supported targets have a non-standard r_info field.
+ // If this call is too slow, we can move this routine to
+ // target-reloc.h and templatize it on Classify_reloc.
+ unsigned int r_sym = target->get_r_sym(pr);
+ if (r_sym < local_count)
+ continue;
+
+ const Symbol* gsym = this->global_symbol(r_sym);
+ gold_assert(gsym != NULL);
+ if (gsym->is_forwarder())
+ gsym = symtab->resolve_forwards(gsym);
+
+ // See if this relocation refers to a function defined in an
+ // object compiled without -fsplit-stack. Note that we don't
+ // care about the type of relocation--this means that in some
+ // cases we will ask for a large stack unnecessarily, but this
+ // is not fatal. FIXME: Some targets have symbols which are
+ // functions but are not type STT_FUNC, e.g., STT_ARM_TFUNC.
+ if (!gsym->is_undefined()
+ && gsym->source() == Symbol::FROM_OBJECT
+ && !gsym->object()->uses_split_stack())
+ {
+ if (parameters->target().is_call_to_non_split(gsym, pr, view,
+ view_size))
+ {
+ Reltype reloc(pr);
+ section_offset_type offset =
+ convert_to_section_size_type(reloc.get_r_offset());
+ non_split_refs.push_back(offset);
+ }
+ }
+ }
+
+ if (non_split_refs.empty())
+ return;
+
+ // At this point, every entry in NON_SPLIT_REFS indicates a
+ // relocation which refers to a function in an object compiled
+ // without -fsplit-stack. We now have to convert that list into a
+ // set of offsets to functions. First, we find all the functions.
+
+ Function_offsets function_offsets;
+ this->find_functions(pshdrs, shndx, &function_offsets);
+ if (function_offsets.empty())
+ return;
+
+ // Now get a list of the function with references to non split-stack
+ // code.
+
+ Function_offsets calls_non_split;
+ for (std::vector<section_offset_type>::const_iterator p
+ = non_split_refs.begin();
+ p != non_split_refs.end();
+ ++p)
+ {
+ Function_offsets::const_iterator low = function_offsets.lower_bound(*p);
+ if (low == function_offsets.end())
+ --low;
+ else if (low->first == *p)
+ ;
+ else if (low == function_offsets.begin())
+ continue;
+ else
+ --low;