• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisioneff458138e2978ee9a3aef4ebee40d53da11e764 (tree)
Zeit2008-09-30 06:10:26
AutorCary Coutant <ccoutant@goog...>
CommiterCary Coutant

Log Message

* 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.

Ändern Zusammenfassung

Diff

--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,26 @@
1+2008-09-29 Cary Coutant <ccoutant@google.com>
2+
3+ * mapfile.cc (Mapfile::print_input_section): Change -1U to -1ULL.
4+ * object.cc (Sized_relobj::do_layout): Use constant invalid_address
5+ instead of -1U.
6+ (Sized_relobj::do_finalize_local_symbols): Likewise.
7+ (Sized_relobj::map_to_kept_section): Likewise.
8+ * object.h (Sized_relobj::invalid_address): New constant.
9+ (Sized_relobj::do_output_section_offset): Check for invalid_address
10+ and return -1ULL.
11+ * output.cc (Output_reloc::local_section_offset): Use constant
12+ invalid_address instead of -1U.
13+ (Output_reloc::get_address): Likewise.
14+ (Output_section::output_address): Change -1U to -1ULL.
15+ * output.h (Output_reloc::invalid_address): New constant.
16+ * reloc.cc (Sized_relobj::write_sections): Use constant
17+ invalid_address instead of -1U.
18+ (Sized_relobj::relocate_sections): Likewise.
19+ * symtab.cc (Symbol_table::sized_finalize_symbol): Handle symbol
20+ values for merge sections.
21+ * target-reloc.h (relocate_for_relocatable): Use constant
22+ invalid_address instead of -1U.
23+
124 2008-09-19 Cary Coutant <ccoutant@google.com>
225
326 Add plugin functionality for link-time optimization (LTO).
--- a/gold/mapfile.cc
+++ b/gold/mapfile.cc
@@ -253,7 +253,7 @@ Mapfile::print_input_section(Relobj* relobj, unsigned int shndx)
253253 {
254254 os = relobj->output_section(shndx);
255255 addr = relobj->output_section_offset(shndx);
256- if (addr != -1U)
256+ if (addr != -1ULL)
257257 addr += os->address();
258258 }
259259
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -926,7 +926,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
926926 {
927927 // Do not include this section in the link.
928928 out_sections[i] = NULL;
929- out_section_offsets[i] = -1U;
929+ out_section_offsets[i] = invalid_address;
930930 continue;
931931 }
932932
@@ -967,7 +967,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
967967
968968 out_sections[i] = os;
969969 if (offset == -1)
970- out_section_offsets[i] = -1U;
970+ out_section_offsets[i] = invalid_address;
971971 else
972972 out_section_offsets[i] = convert_types<Address, off_t>(offset);
973973
@@ -1004,7 +1004,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
10041004 if (data_section == NULL)
10051005 {
10061006 out_sections[i] = NULL;
1007- out_section_offsets[i] = -1U;
1007+ out_section_offsets[i] = invalid_address;
10081008 continue;
10091009 }
10101010
@@ -1014,7 +1014,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
10141014 Output_section* os = layout->layout_reloc(this, i, shdr, data_section,
10151015 rr);
10161016 out_sections[i] = os;
1017- out_section_offsets[i] = -1U;
1017+ out_section_offsets[i] = invalid_address;
10181018 }
10191019
10201020 // Handle the .eh_frame sections at the end.
@@ -1042,7 +1042,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
10421042 &offset);
10431043 out_sections[i] = os;
10441044 if (offset == -1)
1045- out_section_offsets[i] = -1U;
1045+ out_section_offsets[i] = invalid_address;
10461046 else
10471047 out_section_offsets[i] = convert_types<Address, off_t>(offset);
10481048
@@ -1266,7 +1266,7 @@ Sized_relobj<size, big_endian>::do_finalize_local_symbols(unsigned int index,
12661266 // so we leave the input value unchanged here.
12671267 continue;
12681268 }
1269- else if (out_offsets[shndx] == -1U)
1269+ else if (out_offsets[shndx] == invalid_address)
12701270 {
12711271 // This is a SHF_MERGE section or one which otherwise
12721272 // requires special handling. We get the output address
@@ -1573,7 +1573,7 @@ Sized_relobj<size, big_endian>::map_to_kept_section(
15731573 *found = true;
15741574 Output_section* os = kept->object_->output_section(kept->shndx_);
15751575 Address offset = kept->object_->get_output_section_offset(kept->shndx_);
1576- gold_assert(os != NULL && offset != -1U);
1576+ gold_assert(os != NULL && offset != invalid_address);
15771577 return os->address() + offset;
15781578 }
15791579 *found = false;
--- a/gold/object.h
+++ b/gold/object.h
@@ -1202,6 +1202,8 @@ class Sized_relobj : public Relobj
12021202 typedef std::vector<Symbol*> Symbols;
12031203 typedef std::vector<Symbol_value<size> > Local_values;
12041204
1205+ static const Address invalid_address = static_cast<Address>(0) - 1;
1206+
12051207 Sized_relobj(const std::string& name, Input_file* input_file, off_t offset,
12061208 const typename elfcpp::Ehdr<size, big_endian>&);
12071209
@@ -1457,7 +1459,12 @@ class Sized_relobj : public Relobj
14571459 // Get the offset of a section.
14581460 uint64_t
14591461 do_output_section_offset(unsigned int shndx) const
1460- { return this->get_output_section_offset(shndx); }
1462+ {
1463+ Address off = this->get_output_section_offset(shndx);
1464+ if (off == invalid_address)
1465+ return -1ULL;
1466+ return off;
1467+ }
14611468
14621469 // Set the offset of a section.
14631470 void
@@ -1699,7 +1706,7 @@ class Sized_relobj : public Relobj
16991706 // for TLS symbols, indexed by symbol number.
17001707 Local_got_offsets local_got_offsets_;
17011708 // For each input section, the offset of the input section in its
1702- // output section. This is -1U if the input section requires a
1709+ // output section. This is INVALID_ADDRESS if the input section requires a
17031710 // special mapping.
17041711 std::vector<Address> section_offsets_;
17051712 // Table mapping discarded comdat sections to corresponding kept sections.
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -838,11 +838,11 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::
838838 Output_section* os = this->u1_.relobj->output_section(lsi);
839839 gold_assert(os != NULL);
840840 Address offset = this->u1_.relobj->get_output_section_offset(lsi);
841- if (offset != -1U)
841+ if (offset != invalid_address)
842842 return offset + addend;
843843 // This is a merge section.
844844 offset = os->output_address(this->u1_.relobj, lsi, addend);
845- gold_assert(offset != -1U);
845+ gold_assert(offset != invalid_address);
846846 return offset;
847847 }
848848
@@ -858,13 +858,13 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::get_address() const
858858 Output_section* os = this->u2_.relobj->output_section(this->shndx_);
859859 gold_assert(os != NULL);
860860 Address off = this->u2_.relobj->get_output_section_offset(this->shndx_);
861- if (off != -1U)
861+ if (off != invalid_address)
862862 address += os->address() + off;
863863 else
864864 {
865865 address = os->output_address(this->u2_.relobj, this->shndx_,
866866 address);
867- gold_assert(address != -1U);
867+ gold_assert(address != invalid_address);
868868 }
869869 }
870870 else if (this->u2_.od != NULL)
@@ -2043,7 +2043,7 @@ Output_section::output_address(const Relobj* object, unsigned int shndx,
20432043 if (p->output_offset(object, shndx, offset, &output_offset))
20442044 {
20452045 if (output_offset == -1)
2046- return -1U;
2046+ return -1ULL;
20472047 return addr + output_offset;
20482048 }
20492049 addr += p->data_size();
--- a/gold/output.h
+++ b/gold/output.h
@@ -874,6 +874,8 @@ class Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>
874874 typedef typename elfcpp::Elf_types<size>::Elf_Addr Address;
875875 typedef typename elfcpp::Elf_types<size>::Elf_Addr Addend;
876876
877+ static const Address invalid_address = static_cast<Address>(0) - 1;
878+
877879 // An uninitialized entry. We need this because we want to put
878880 // instances of this class into an STL container.
879881 Output_reloc()
@@ -1915,7 +1917,7 @@ class Output_section : public Output_data
19151917
19161918 // Add a new input section SHNDX, named NAME, with header SHDR, from
19171919 // object OBJECT. RELOC_SHNDX is the index of a relocation section
1918- // which applies to this section, or 0 if none, or -1U if more than
1920+ // which applies to this section, or 0 if none, or -1 if more than
19191921 // one. HAVE_SECTIONS_SCRIPT is true if we have a SECTIONS clause
19201922 // in a linker script; in that case we need to keep track of input
19211923 // sections associated with an output section. Return the offset
--- a/gold/reloc.cc
+++ b/gold/reloc.cc
@@ -586,8 +586,8 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs,
586586 // In the normal case, this input section is simply mapped to
587587 // the output section at offset OUTPUT_OFFSET.
588588
589- // However, if OUTPUT_OFFSET == -1U, then input data is handled
590- // specially--e.g., a .eh_frame section. The relocation
589+ // However, if OUTPUT_OFFSET == INVALID_ADDRESS, then input data is
590+ // handled specially--e.g., a .eh_frame section. The relocation
591591 // routines need to check for each reloc where it should be
592592 // applied. For this case, we need an input/output view for the
593593 // 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,
619619
620620 off_t view_start;
621621 section_size_type view_size;
622- if (output_offset != -1U)
622+ if (output_offset != invalid_address)
623623 {
624624 view_start = output_section_offset + output_offset;
625625 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,
633633 if (view_size == 0)
634634 continue;
635635
636- gold_assert(output_offset == -1U
636+ gold_assert(output_offset == invalid_address
637637 || output_offset + view_size <= output_section_size);
638638
639639 unsigned char* view;
@@ -641,7 +641,7 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs,
641641 {
642642 unsigned char* buffer = os->postprocessing_buffer();
643643 view = buffer + view_start;
644- if (output_offset != -1U)
644+ if (output_offset != invalid_address)
645645 {
646646 off_t sh_offset = shdr.get_sh_offset();
647647 if (!rm.empty() && rm.back().file_offset > sh_offset)
@@ -652,7 +652,7 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs,
652652 }
653653 else
654654 {
655- if (output_offset == -1U)
655+ if (output_offset == invalid_address)
656656 view = of->get_input_output_view(view_start, view_size);
657657 else
658658 {
@@ -667,11 +667,11 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs,
667667
668668 pvs->view = view;
669669 pvs->address = os->address();
670- if (output_offset != -1U)
670+ if (output_offset != invalid_address)
671671 pvs->address += output_offset;
672672 pvs->offset = view_start;
673673 pvs->view_size = view_size;
674- pvs->is_input_output_view = output_offset == -1U;
674+ pvs->is_input_output_view = output_offset == invalid_address;
675675 pvs->is_postprocessing_view = os->requires_postprocessing();
676676 }
677677
@@ -772,7 +772,7 @@ Sized_relobj<size, big_endian>::relocate_sections(
772772 continue;
773773 }
774774
775- gold_assert(output_offset != -1U
775+ gold_assert(output_offset != invalid_address
776776 || this->relocs_must_follow_section_writes());
777777
778778 relinfo.reloc_shndx = i;
@@ -784,7 +784,7 @@ Sized_relobj<size, big_endian>::relocate_sections(
784784 prelocs,
785785 reloc_count,
786786 os,
787- output_offset == -1U,
787+ output_offset == invalid_address,
788788 (*pviews)[index].view,
789789 (*pviews)[index].address,
790790 (*pviews)[index].view_size);
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -2136,11 +2136,20 @@ Symbol_table::sized_finalize_symbol(Symbol* unsized_sym)
21362136 }
21372137
21382138 uint64_t secoff64 = relobj->output_section_offset(shndx);
2139- Value_type secoff = convert_types<Value_type, uint64_t>(secoff64);
2140- if (sym->type() == elfcpp::STT_TLS)
2141- value = sym->value() + os->tls_offset() + secoff;
2142- else
2143- value = sym->value() + os->address() + secoff;
2139+ if (secoff64 == -1ULL)
2140+ {
2141+ // The section needs special handling (e.g., a merge section).
2142+ value = os->output_address(relobj, shndx, sym->value());
2143+ }
2144+ else
2145+ {
2146+ Value_type secoff =
2147+ convert_types<Value_type, uint64_t>(secoff64);
2148+ if (sym->type() == elfcpp::STT_TLS)
2149+ value = sym->value() + os->tls_offset() + secoff;
2150+ else
2151+ value = sym->value() + os->address() + secoff;
2152+ }
21442153 }
21452154 }
21462155 break;
--- a/gold/target-reloc.h
+++ b/gold/target-reloc.h
@@ -450,6 +450,7 @@ relocate_for_relocatable(
450450 typedef typename Reloc_types<sh_type, size, big_endian>::Reloc_write
451451 Reltype_write;
452452 const int reloc_size = Reloc_types<sh_type, size, big_endian>::reloc_size;
453+ const Address invalid_address = static_cast<Address>(0) - 1;
453454
454455 Sized_relobj<size, big_endian>* const object = relinfo->object;
455456 const unsigned int local_count = object->local_symbol_count();
@@ -524,7 +525,7 @@ relocate_for_relocatable(
524525
525526 Address offset = reloc.get_r_offset();
526527 Address new_offset;
527- if (offset_in_output_section != -1U)
528+ if (offset_in_output_section != invalid_address)
528529 new_offset = offset + offset_in_output_section;
529530 else
530531 {
@@ -543,7 +544,7 @@ relocate_for_relocatable(
543544 if (!parameters->options().relocatable())
544545 {
545546 new_offset += view_address;
546- if (offset_in_output_section != -1U)
547+ if (offset_in_output_section != invalid_address)
547548 new_offset -= offset_in_output_section;
548549 }
549550