+ // BE8 swapping
+ if (parameters->options().be8())
+ {
+ section_size_type span_start, span_end;
+ elfcpp::Shdr<32, big_endian>
+ shdr(pshdrs + i * elfcpp::Elf_sizes<32>::shdr_size);
+ Mapping_symbol_position section_start(i, 0);
+ typename Mapping_symbols_info::const_iterator p =
+ this->mapping_symbols_info_.lower_bound(section_start);
+ unsigned char* view = (*pviews)[i].view;
+ Arm_address view_address = (*pviews)[i].address;
+ section_size_type view_size = (*pviews)[i].view_size;
+ while (p != this->mapping_symbols_info_.end()
+ && p->first.first == i)
+ {
+ typename Mapping_symbols_info::const_iterator next =
+ this->mapping_symbols_info_.upper_bound(p->first);
+
+ // Only swap arm or thumb code.
+ if ((p->second == 'a') || (p->second == 't'))
+ {
+ Output_section* os = this->output_section(i);
+ gold_assert(os != NULL);
+ Arm_address section_address =
+ this->simple_input_section_output_address(i, os);
+ span_start = convert_to_section_size_type(p->first.second);
+ if (next != this->mapping_symbols_info_.end()
+ && next->first.first == i)
+ span_end =
+ convert_to_section_size_type(next->first.second);
+ else
+ span_end =
+ convert_to_section_size_type(shdr.get_sh_size());
+ unsigned char* section_view =
+ view + (section_address - view_address);
+ uint64_t section_size = this->section_size(i);
+
+ gold_assert(section_address >= view_address
+ && ((section_address + section_size)
+ <= (view_address + view_size)));
+
+ // Set Output view for swapping
+ unsigned char *oview = section_view + span_start;
+ unsigned int index = 0;
+ if (p->second == 'a')
+ {
+ while (index + 3 < (span_end - span_start))
+ {
+ typedef typename elfcpp::Swap<32, big_endian>
+ ::Valtype Valtype;
+ Valtype* wv =
+ reinterpret_cast<Valtype*>(oview+index);
+ uint32_t val = elfcpp::Swap<32, false>::readval(wv);
+ elfcpp::Swap<32, true>::writeval(wv, val);
+ index += 4;
+ }
+ }
+ else if (p->second == 't')
+ {
+ while (index + 1 < (span_end - span_start))
+ {
+ typedef typename elfcpp::Swap<16, big_endian>
+ ::Valtype Valtype;
+ Valtype* wv =
+ reinterpret_cast<Valtype*>(oview+index);
+ uint16_t val = elfcpp::Swap<16, false>::readval(wv);
+ elfcpp::Swap<16, true>::writeval(wv, val);
+ index += 2;
+ }
+ }
+ }
+ p = next;
+ }
+ }