os->set_needs_symtab_index();
}
-// An absolute relocation.
+// An absolute or relative relocation.
template<bool dynamic, int size, bool big_endian>
Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::Output_reloc(
unsigned int type,
Output_data* od,
- Address address)
+ Address address,
+ bool is_relative)
: address_(address), local_sym_index_(0), type_(type),
- is_relative_(false), is_symbolless_(false),
+ is_relative_(is_relative), is_symbolless_(false),
is_section_symbol_(false), use_plt_offset_(false), shndx_(INVALID_CODE)
{
// this->type_ is a bitfield; make sure TYPE fits.
unsigned int type,
Sized_relobj<size, big_endian>* relobj,
unsigned int shndx,
- Address address)
+ Address address,
+ bool is_relative)
: address_(address), local_sym_index_(0), type_(type),
- is_relative_(false), is_symbolless_(false),
+ is_relative_(is_relative), is_symbolless_(false),
is_section_symbol_(false), use_plt_offset_(false), shndx_(shndx)
{
gold_assert(shndx != INVALID_CODE);
const Sized_symbol<size>* sym;
sym = static_cast<const Sized_symbol<size>*>(this->u1_.gsym);
if (this->use_plt_offset_ && sym->has_plt_offset())
- {
- uint64_t plt_address =
- parameters->target().plt_address_for_global(sym);
- return plt_address + sym->plt_offset();
- }
+ return parameters->target().plt_address_for_global(sym);
else
return sym->value() + addend;
}
this->u1_.relobj->sized_relobj();
gold_assert(relobj != NULL);
if (this->use_plt_offset_)
- {
- uint64_t plt_address =
- parameters->target().plt_address_for_local(relobj, lsi);
- return plt_address + relobj->local_plt_offset(lsi);
- }
+ return parameters->target().plt_address_for_local(relobj, lsi);
const Symbol_value<size>* symval = relobj->local_symbol(lsi);
return symval->value(relobj, addend);
}
// RELATIVE relocation.
Symbol* gsym = this->u_.gsym;
if (this->use_plt_or_tls_offset_ && gsym->has_plt_offset())
- val = (parameters->target().plt_address_for_global(gsym)
- + gsym->plt_offset());
+ val = parameters->target().plt_address_for_global(gsym);
else
{
switch (parameters->size_and_endianness())
const unsigned int lsi = this->local_sym_index_;
bool is_tls = object->local_is_tls(lsi);
if (this->use_plt_or_tls_offset_ && !is_tls)
- {
- uint64_t plt_address =
- parameters->target().plt_address_for_local(object, lsi);
- val = plt_address + object->local_plt_offset(lsi);
- }
+ val = parameters->target().plt_address_for_local(object, lsi);
else
{
uint64_t lval = object->local_symbol_value(lsi, 0);
++p)
{
unsigned int symndx = p->first;
- gold_assert(symndx * 4 < this->data_size());
+ gold_assert(static_cast<off_t>(symndx) * 4 < this->data_size());
elfcpp::Swap<32, big_endian>::writeval(oview + symndx * 4, p->second);
}
}
// For a relaxed section, we use the current data size. Linker scripts
// get all the input sections, including relaxed one from an output
- // section and add them back to them same output section to compute the
+ // section and add them back to the same output section to compute the
// output section size. If we do not account for sizes of relaxed input
- // sections, an output section would be incorrectly sized.
+ // sections, an output section would be incorrectly sized.
off_t offset_in_section = this->current_data_size_for_child();
off_t aligned_offset_in_section = align_address(offset_in_section,
poris->addralign());
(*input_sections)[p->second].set_section_order_index(soi);
}
}
-
+
// Convert regular input sections into relaxed input sections. RELAXED_SECTIONS
// is a vector of pointers to Output_relaxed_input_section or its derived
// classes. The relaxed sections must correspond to existing input sections.
// this. If there is no checkpoint active, just search the current
// input section list and replace the sections there. If there is
// a checkpoint, also replace the sections there.
-
+
// By default, we look at the whole list.
size_t limit = this->input_sections_.size();
for (Output_merge_base::Input_sections::const_iterator is =
pomb->input_sections_begin();
is != pomb->input_sections_end();
- ++is)
+ ++is)
{
const Const_section_id& csid = *is;
this->lookup_maps_->add_merge_input_section(csid.first,
csid.second, pomb);
}
-
+
}
else if (p->is_relaxed_input_section())
{
{
section_offset_type output_offset;
bool found = posd->output_offset(object, shndx, offset, &output_offset);
- gold_assert(found);
+ gold_assert(found);
return output_offset != -1;
}
// Look at the Output_section_data_maps first.
const Output_section_data* posd = this->find_merge_section(object, shndx);
- if (posd == NULL)
+ if (posd == NULL)
posd = this->find_relaxed_input_section(object, shndx);
if (posd != NULL)
{
section_offset_type output_offset;
bool found = posd->output_offset(object, shndx, offset, &output_offset);
- gold_assert(found);
+ gold_assert(found);
return output_offset;
}
// Look at the Output_section_data_maps first.
const Output_section_data* posd = this->find_merge_section(object, shndx);
- if (posd == NULL)
+ if (posd == NULL)
posd = this->find_relaxed_input_section(object, shndx);
if (posd != NULL && posd->is_address_valid())
{
// in order to better support gcc, and we need to be compatible.
bool
match_file_name(const char* file_name) const
- { return Layout::match_file_name(this->input_section_.relobj(), file_name); }
+ {
+ if (this->input_section_.is_output_section_data())
+ return false;
+ return Layout::match_file_name(this->input_section_.relobj(), file_name);
+ }
// Returns 1 if THIS should appear before S in section order, -1 if S
// appears before THIS and 0 if they are not comparable.
return s1.index() < s2.index();
}
+ // Some input section names have special ordering requirements.
+ int o1 = Layout::special_ordering_of_input_section(s1.section_name().c_str());
+ int o2 = Layout::special_ordering_of_input_section(s2.section_name().c_str());
+ if (o1 != o2)
+ {
+ if (o1 < 0)
+ return false;
+ else if (o2 < 0)
+ return true;
+ else
+ return o1 < o2;
+ }
+
// A section with a priority follows a section without a priority.
bool s1_has_priority = s1.has_priority();
bool s2_has_priority = s2.has_priority();
// Keep input order if section ordering cannot determine order.
if (s1_secn_index == s2_secn_index)
return s1.index() < s2.index();
-
+
return s1_secn_index < s2_secn_index;
}
this->input_sections_.push_back(sis);
- // Update fast lookup maps if necessary.
+ // Update fast lookup maps if necessary.
if (this->lookup_maps_->is_valid())
{
if (sis.is_merge_section())
if (!this->is_max_align_known_)
{
for (int i = 0; i < static_cast<int>(ORDER_MAX); ++i)
- {
+ {
const Output_data_list* pdl = &this->output_lists_[i];
uint64_t addralign = Output_segment::maximum_alignment_list(pdl);
if (addralign > this->max_align_)