diff options
Diffstat (limited to 'gold')
-rw-r--r-- | gold/ChangeLog | 23 | ||||
-rw-r--r-- | gold/mapfile.cc | 2 | ||||
-rw-r--r-- | gold/object.cc | 14 | ||||
-rw-r--r-- | gold/object.h | 11 | ||||
-rw-r--r-- | gold/output.cc | 10 | ||||
-rw-r--r-- | gold/output.h | 4 | ||||
-rw-r--r-- | gold/reloc.cc | 20 | ||||
-rw-r--r-- | gold/symtab.cc | 19 | ||||
-rw-r--r-- | gold/target-reloc.h | 5 |
9 files changed, 75 insertions, 33 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index 6b1a4f6..ff9dd44 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,26 @@ +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). diff --git a/gold/mapfile.cc b/gold/mapfile.cc index 9cec366..a3ba52b 100644 --- a/gold/mapfile.cc +++ b/gold/mapfile.cc @@ -253,7 +253,7 @@ Mapfile::print_input_section(Relobj* relobj, unsigned int shndx) { os = relobj->output_section(shndx); addr = relobj->output_section_offset(shndx); - if (addr != -1U) + if (addr != -1ULL) addr += os->address(); } diff --git a/gold/object.cc b/gold/object.cc index d8f5ec8..f7dcda8 100644 --- a/gold/object.cc +++ b/gold/object.cc @@ -926,7 +926,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab, { // Do not include this section in the link. out_sections[i] = NULL; - out_section_offsets[i] = -1U; + out_section_offsets[i] = invalid_address; continue; } @@ -967,7 +967,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab, 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); @@ -1004,7 +1004,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab, if (data_section == NULL) { out_sections[i] = NULL; - out_section_offsets[i] = -1U; + out_section_offsets[i] = invalid_address; continue; } @@ -1014,7 +1014,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab, 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. @@ -1042,7 +1042,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab, &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); @@ -1266,7 +1266,7 @@ Sized_relobj<size, big_endian>::do_finalize_local_symbols(unsigned int index, // 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 @@ -1573,7 +1573,7 @@ Sized_relobj<size, big_endian>::map_to_kept_section( *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; diff --git a/gold/object.h b/gold/object.h index 1c4fc67..fcb5d31 100644 --- a/gold/object.h +++ b/gold/object.h @@ -1202,6 +1202,8 @@ class Sized_relobj : public Relobj 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>&); @@ -1457,7 +1459,12 @@ class Sized_relobj : public Relobj // 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 @@ -1699,7 +1706,7 @@ class Sized_relobj : public Relobj // 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. diff --git a/gold/output.cc b/gold/output.cc index 2a46195..f6a6f1d 100644 --- a/gold/output.cc +++ b/gold/output.cc @@ -838,11 +838,11 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>:: 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; } @@ -858,13 +858,13 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::get_address() const 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) @@ -2043,7 +2043,7 @@ Output_section::output_address(const Relobj* object, unsigned int shndx, 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(); diff --git a/gold/output.h b/gold/output.h index 1c95881..9f075be 100644 --- a/gold/output.h +++ b/gold/output.h @@ -874,6 +874,8 @@ class Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian> 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() @@ -1915,7 +1917,7 @@ class Output_section : public Output_data // 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 diff --git a/gold/reloc.cc b/gold/reloc.cc index daa0ea8..481617d 100644 --- a/gold/reloc.cc +++ b/gold/reloc.cc @@ -586,8 +586,8 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs, // 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 @@ -619,7 +619,7 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs, 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()); @@ -633,7 +633,7 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs, 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; @@ -641,7 +641,7 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs, { 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) @@ -652,7 +652,7 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs, } else { - if (output_offset == -1U) + if (output_offset == invalid_address) view = of->get_input_output_view(view_start, view_size); else { @@ -667,11 +667,11 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs, 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(); } @@ -772,7 +772,7 @@ Sized_relobj<size, big_endian>::relocate_sections( continue; } - gold_assert(output_offset != -1U + gold_assert(output_offset != invalid_address || this->relocs_must_follow_section_writes()); relinfo.reloc_shndx = i; @@ -784,7 +784,7 @@ Sized_relobj<size, big_endian>::relocate_sections( prelocs, reloc_count, os, - output_offset == -1U, + output_offset == invalid_address, (*pviews)[index].view, (*pviews)[index].address, (*pviews)[index].view_size); diff --git a/gold/symtab.cc b/gold/symtab.cc index 3bb88d8..c2de3bc 100644 --- a/gold/symtab.cc +++ b/gold/symtab.cc @@ -2136,11 +2136,20 @@ Symbol_table::sized_finalize_symbol(Symbol* unsized_sym) } 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; diff --git a/gold/target-reloc.h b/gold/target-reloc.h index 1cdc244..935d76b 100644 --- a/gold/target-reloc.h +++ b/gold/target-reloc.h @@ -450,6 +450,7 @@ relocate_for_relocatable( 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(); @@ -524,7 +525,7 @@ relocate_for_relocatable( 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 { @@ -543,7 +544,7 @@ relocate_for_relocatable( 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; } |