rd->relocs.reserve(shnum / 2);
- std::vector<Map_to_output>& map_sections(this->map_to_output());
+ const Output_sections& out_sections(this->output_sections());
+ const std::vector<Address>& out_offsets(this->section_offsets_);
const unsigned char *pshdrs = this->get_view(this->elf_file_.shoff(),
shnum * This::shdr_size,
if (sh_type != elfcpp::SHT_REL && sh_type != elfcpp::SHT_RELA)
continue;
- unsigned int shndx = shdr.get_sh_info();
+ unsigned int shndx = this->adjust_shndx(shdr.get_sh_info());
if (shndx >= shnum)
{
this->error(_("relocation section %u has bad info %u"),
continue;
}
- Output_section* os = map_sections[shndx].output_section;
+ Output_section* os = out_sections[shndx];
if (os == NULL)
continue;
&& !parameters->options().emit_relocs())
continue;
- if (shdr.get_sh_link() != this->symtab_shndx_)
+ if (this->adjust_shndx(shdr.get_sh_link()) != this->symtab_shndx_)
{
this->error(_("relocation section %u uses unexpected "
"symbol table %u"),
- i, shdr.get_sh_link());
+ i, this->adjust_shndx(shdr.get_sh_link()));
continue;
}
sr.sh_type = sh_type;
sr.reloc_count = reloc_count;
sr.output_section = os;
- sr.needs_special_offset_handling = map_sections[shndx].offset == -1;
+ sr.needs_special_offset_handling = out_offsets[shndx] == -1U;
sr.is_data_section_allocated = is_section_allocated;
}
}
// Write out the local symbols.
- this->write_local_symbols(of, layout->sympool(), layout->dynpool());
+ this->write_local_symbols(of, layout->sympool(), layout->dynpool(),
+ layout->symtab_xindex(), layout->dynsym_xindex());
// We should no longer need the local symbol values.
this->clear_local_symbols();
Views* pviews)
{
unsigned int shnum = this->shnum();
- const std::vector<Map_to_output>& map_sections(this->map_to_output());
+ const Output_sections& out_sections(this->output_sections());
+ const std::vector<Address>& out_offsets(this->section_offsets_);
File_read::Read_multiple rm;
bool is_sorted = true;
pvs->view = NULL;
- const Output_section* os = map_sections[i].output_section;
+ const Output_section* os = out_sections[i];
if (os == NULL)
continue;
- off_t output_offset = map_sections[i].offset;
+ Address output_offset = out_offsets[i];
typename This::Shdr shdr(p);
// In the normal case, this input section is simply mapped to
// the output section at offset OUTPUT_OFFSET.
- // However, if OUTPUT_OFFSET == -1, then input data is handled
+ // However, if OUTPUT_OFFSET == -1U, then input data is handled
// specially--e.g., a .eh_frame section. The relocation
// routines need to check for each reloc where it should be
// applied. For this case, we need an input/output view for the
// final data to the output file.
off_t output_section_offset;
- off_t output_section_size;
+ Address output_section_size;
if (!os->requires_postprocessing())
{
output_section_offset = os->offset();
- output_section_size = os->data_size();
+ output_section_size = convert_types<Address, off_t>(os->data_size());
}
else
{
output_section_offset = 0;
- output_section_size = os->postprocessing_buffer_size();
+ output_section_size =
+ convert_types<Address, off_t>(os->postprocessing_buffer_size());
}
off_t view_start;
section_size_type view_size;
- if (output_offset != -1)
+ if (output_offset != -1U)
{
view_start = output_section_offset + output_offset;
view_size = convert_to_section_size_type(shdr.get_sh_size());
if (view_size == 0)
continue;
- gold_assert(output_offset == -1
- || (output_offset >= 0
- && (output_offset + static_cast<off_t>(view_size)
- <= output_section_size)));
+ gold_assert(output_offset == -1U
+ || output_offset + view_size <= output_section_size);
unsigned char* view;
if (os->requires_postprocessing())
{
unsigned char* buffer = os->postprocessing_buffer();
view = buffer + view_start;
- if (output_offset != -1)
+ if (output_offset != -1U)
{
off_t sh_offset = shdr.get_sh_offset();
if (!rm.empty() && rm.back().file_offset > sh_offset)
}
else
{
- if (output_offset == -1)
+ if (output_offset == -1U)
view = of->get_input_output_view(view_start, view_size);
else
{
pvs->view = view;
pvs->address = os->address();
- if (output_offset != -1)
+ if (output_offset != -1U)
pvs->address += output_offset;
pvs->offset = view_start;
pvs->view_size = view_size;
- pvs->is_input_output_view = output_offset == -1;
+ pvs->is_input_output_view = output_offset == -1U;
pvs->is_postprocessing_view = os->requires_postprocessing();
}
unsigned int shnum = this->shnum();
Sized_target<size, big_endian>* target = this->sized_target();
- const std::vector<Map_to_output>& map_sections(this->map_to_output());
+ const Output_sections& out_sections(this->output_sections());
+ const std::vector<Address>& out_offsets(this->section_offsets_);
Relocate_info<size, big_endian> relinfo;
relinfo.options = &options;
if (sh_type != elfcpp::SHT_REL && sh_type != elfcpp::SHT_RELA)
continue;
- unsigned int index = shdr.get_sh_info();
+ unsigned int index = this->adjust_shndx(shdr.get_sh_info());
if (index >= this->shnum())
{
this->error(_("relocation section %u has bad info %u"),
continue;
}
- Output_section* os = map_sections[index].output_section;
+ Output_section* os = out_sections[index];
if (os == NULL)
{
// This relocation section is against a section which we
// discarded.
continue;
}
- off_t output_offset = map_sections[index].offset;
+ Address output_offset = out_offsets[index];
gold_assert((*pviews)[index].view != NULL);
if (parameters->options().relocatable())
gold_assert((*pviews)[i].view != NULL);
- if (shdr.get_sh_link() != this->symtab_shndx_)
+ if (this->adjust_shndx(shdr.get_sh_link()) != this->symtab_shndx_)
{
gold_error(_("relocation section %u uses unexpected "
"symbol table %u"),
- i, shdr.get_sh_link());
+ i, this->adjust_shndx(shdr.get_sh_link()));
continue;
}
continue;
}
- gold_assert(output_offset != -1
+ gold_assert(output_offset != -1U
|| this->relocs_must_follow_section_writes());
relinfo.reloc_shndx = i;
prelocs,
reloc_count,
os,
- output_offset == -1,
+ output_offset == -1U,
(*pviews)[index].view,
(*pviews)[index].address,
(*pviews)[index].view_size);
const unsigned char* prelocs,
size_t reloc_count,
Output_section* output_section,
- off_t offset_in_output_section,
+ typename elfcpp::Elf_types<size>::Elf_Addr offset_in_output_section,
unsigned char* view,
typename elfcpp::Elf_types<size>::Elf_Addr address,
section_size_type view_size,
const unsigned char* prelocs,
size_t reloc_count,
Output_section* output_section,
- off_t offset_in_output_section,
+ typename elfcpp::Elf_types<size>::Elf_Addr offset_in_output_section,
unsigned char* view,
typename elfcpp::Elf_types<size>::Elf_Addr address,
section_size_type view_size,