+2008-09-29 Cary Coutant <ccoutant@google.com>
+
+ * mapfile.cc (Mapfile::print_input_section): Change -1U to -1ULL.
+ * object.cc (Sized_relobj::do_layout): Use constant invalid_address
+ instead of -1U.
+ (Sized_relobj::do_finalize_local_symbols): Likewise.
+ (Sized_relobj::map_to_kept_section): Likewise.
+ * object.h (Sized_relobj::invalid_address): New constant.
+ (Sized_relobj::do_output_section_offset): Check for invalid_address
+ and return -1ULL.
+ * output.cc (Output_reloc::local_section_offset): Use constant
+ invalid_address instead of -1U.
+ (Output_reloc::get_address): Likewise.
+ (Output_section::output_address): Change -1U to -1ULL.
+ * output.h (Output_reloc::invalid_address): New constant.
+ * reloc.cc (Sized_relobj::write_sections): Use constant
+ invalid_address instead of -1U.
+ (Sized_relobj::relocate_sections): Likewise.
+ * symtab.cc (Symbol_table::sized_finalize_symbol): Handle symbol
+ values for merge sections.
+ * target-reloc.h (relocate_for_relocatable): Use constant
+ invalid_address instead of -1U.
+
2008-09-19 Cary Coutant <ccoutant@google.com>
Add plugin functionality for link-time optimization (LTO).
{
os = relobj->output_section(shndx);
addr = relobj->output_section_offset(shndx);
- if (addr != -1U)
+ if (addr != -1ULL)
addr += os->address();
}
{
// Do not include this section in the link.
out_sections[i] = NULL;
- out_section_offsets[i] = -1U;
+ out_section_offsets[i] = invalid_address;
continue;
}
out_sections[i] = os;
if (offset == -1)
- out_section_offsets[i] = -1U;
+ out_section_offsets[i] = invalid_address;
else
out_section_offsets[i] = convert_types<Address, off_t>(offset);
if (data_section == NULL)
{
out_sections[i] = NULL;
- out_section_offsets[i] = -1U;
+ out_section_offsets[i] = invalid_address;
continue;
}
Output_section* os = layout->layout_reloc(this, i, shdr, data_section,
rr);
out_sections[i] = os;
- out_section_offsets[i] = -1U;
+ out_section_offsets[i] = invalid_address;
}
// Handle the .eh_frame sections at the end.
&offset);
out_sections[i] = os;
if (offset == -1)
- out_section_offsets[i] = -1U;
+ out_section_offsets[i] = invalid_address;
else
out_section_offsets[i] = convert_types<Address, off_t>(offset);
// so we leave the input value unchanged here.
continue;
}
- else if (out_offsets[shndx] == -1U)
+ else if (out_offsets[shndx] == invalid_address)
{
// This is a SHF_MERGE section or one which otherwise
// requires special handling. We get the output address
*found = true;
Output_section* os = kept->object_->output_section(kept->shndx_);
Address offset = kept->object_->get_output_section_offset(kept->shndx_);
- gold_assert(os != NULL && offset != -1U);
+ gold_assert(os != NULL && offset != invalid_address);
return os->address() + offset;
}
*found = false;
typedef std::vector<Symbol*> Symbols;
typedef std::vector<Symbol_value<size> > Local_values;
+ static const Address invalid_address = static_cast<Address>(0) - 1;
+
Sized_relobj(const std::string& name, Input_file* input_file, off_t offset,
const typename elfcpp::Ehdr<size, big_endian>&);
// Get the offset of a section.
uint64_t
do_output_section_offset(unsigned int shndx) const
- { return this->get_output_section_offset(shndx); }
+ {
+ Address off = this->get_output_section_offset(shndx);
+ if (off == invalid_address)
+ return -1ULL;
+ return off;
+ }
// Set the offset of a section.
void
// for TLS symbols, indexed by symbol number.
Local_got_offsets local_got_offsets_;
// For each input section, the offset of the input section in its
- // output section. This is -1U if the input section requires a
+ // output section. This is INVALID_ADDRESS if the input section requires a
// special mapping.
std::vector<Address> section_offsets_;
// Table mapping discarded comdat sections to corresponding kept sections.
Output_section* os = this->u1_.relobj->output_section(lsi);
gold_assert(os != NULL);
Address offset = this->u1_.relobj->get_output_section_offset(lsi);
- if (offset != -1U)
+ if (offset != invalid_address)
return offset + addend;
// This is a merge section.
offset = os->output_address(this->u1_.relobj, lsi, addend);
- gold_assert(offset != -1U);
+ gold_assert(offset != invalid_address);
return offset;
}
Output_section* os = this->u2_.relobj->output_section(this->shndx_);
gold_assert(os != NULL);
Address off = this->u2_.relobj->get_output_section_offset(this->shndx_);
- if (off != -1U)
+ if (off != invalid_address)
address += os->address() + off;
else
{
address = os->output_address(this->u2_.relobj, this->shndx_,
address);
- gold_assert(address != -1U);
+ gold_assert(address != invalid_address);
}
}
else if (this->u2_.od != NULL)
if (p->output_offset(object, shndx, offset, &output_offset))
{
if (output_offset == -1)
- return -1U;
+ return -1ULL;
return addr + output_offset;
}
addr += p->data_size();
typedef typename elfcpp::Elf_types<size>::Elf_Addr Address;
typedef typename elfcpp::Elf_types<size>::Elf_Addr Addend;
+ static const Address invalid_address = static_cast<Address>(0) - 1;
+
// An uninitialized entry. We need this because we want to put
// instances of this class into an STL container.
Output_reloc()
// Add a new input section SHNDX, named NAME, with header SHDR, from
// object OBJECT. RELOC_SHNDX is the index of a relocation section
- // which applies to this section, or 0 if none, or -1U if more than
+ // which applies to this section, or 0 if none, or -1 if more than
// one. HAVE_SECTIONS_SCRIPT is true if we have a SECTIONS clause
// in a linker script; in that case we need to keep track of input
// sections associated with an output section. Return the offset
// In the normal case, this input section is simply mapped to
// the output section at offset OUTPUT_OFFSET.
- // However, if OUTPUT_OFFSET == -1U, then input data is handled
- // specially--e.g., a .eh_frame section. The relocation
+ // However, if OUTPUT_OFFSET == INVALID_ADDRESS, 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
// entire contents of the section in the output file. We don't
off_t view_start;
section_size_type view_size;
- if (output_offset != -1U)
+ if (output_offset != invalid_address)
{
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 == -1U
+ gold_assert(output_offset == invalid_address
|| output_offset + view_size <= output_section_size);
unsigned char* view;
{
unsigned char* buffer = os->postprocessing_buffer();
view = buffer + view_start;
- if (output_offset != -1U)
+ if (output_offset != invalid_address)
{
off_t sh_offset = shdr.get_sh_offset();
if (!rm.empty() && rm.back().file_offset > sh_offset)
}
else
{
- if (output_offset == -1U)
+ if (output_offset == invalid_address)
view = of->get_input_output_view(view_start, view_size);
else
{
pvs->view = view;
pvs->address = os->address();
- if (output_offset != -1U)
+ if (output_offset != invalid_address)
pvs->address += output_offset;
pvs->offset = view_start;
pvs->view_size = view_size;
- pvs->is_input_output_view = output_offset == -1U;
+ pvs->is_input_output_view = output_offset == invalid_address;
pvs->is_postprocessing_view = os->requires_postprocessing();
}
continue;
}
- gold_assert(output_offset != -1U
+ gold_assert(output_offset != invalid_address
|| this->relocs_must_follow_section_writes());
relinfo.reloc_shndx = i;
prelocs,
reloc_count,
os,
- output_offset == -1U,
+ output_offset == invalid_address,
(*pviews)[index].view,
(*pviews)[index].address,
(*pviews)[index].view_size);
}
uint64_t secoff64 = relobj->output_section_offset(shndx);
- Value_type secoff = convert_types<Value_type, uint64_t>(secoff64);
- if (sym->type() == elfcpp::STT_TLS)
- value = sym->value() + os->tls_offset() + secoff;
- else
- value = sym->value() + os->address() + secoff;
+ if (secoff64 == -1ULL)
+ {
+ // The section needs special handling (e.g., a merge section).
+ value = os->output_address(relobj, shndx, sym->value());
+ }
+ else
+ {
+ Value_type secoff =
+ convert_types<Value_type, uint64_t>(secoff64);
+ if (sym->type() == elfcpp::STT_TLS)
+ value = sym->value() + os->tls_offset() + secoff;
+ else
+ value = sym->value() + os->address() + secoff;
+ }
}
}
break;
typedef typename Reloc_types<sh_type, size, big_endian>::Reloc_write
Reltype_write;
const int reloc_size = Reloc_types<sh_type, size, big_endian>::reloc_size;
+ const Address invalid_address = static_cast<Address>(0) - 1;
Sized_relobj<size, big_endian>* const object = relinfo->object;
const unsigned int local_count = object->local_symbol_count();
Address offset = reloc.get_r_offset();
Address new_offset;
- if (offset_in_output_section != -1U)
+ if (offset_in_output_section != invalid_address)
new_offset = offset + offset_in_output_section;
else
{
if (!parameters->options().relocatable())
{
new_offset += view_address;
- if (offset_in_output_section != -1U)
+ if (offset_in_output_section != invalid_address)
new_offset -= offset_in_output_section;
}