GNU Binutils with patches for OS216
Revision | eff458138e2978ee9a3aef4ebee40d53da11e764 (tree) |
---|---|
Zeit | 2008-09-30 06:10:26 |
Autor | Cary Coutant <ccoutant@goog...> |
Commiter | Cary Coutant |
* 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.
@@ -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 | + | |
1 | 24 | 2008-09-19 Cary Coutant <ccoutant@google.com> |
2 | 25 | |
3 | 26 | Add plugin functionality for link-time optimization (LTO). |
@@ -253,7 +253,7 @@ Mapfile::print_input_section(Relobj* relobj, unsigned int shndx) | ||
253 | 253 | { |
254 | 254 | os = relobj->output_section(shndx); |
255 | 255 | addr = relobj->output_section_offset(shndx); |
256 | - if (addr != -1U) | |
256 | + if (addr != -1ULL) | |
257 | 257 | addr += os->address(); |
258 | 258 | } |
259 | 259 |
@@ -926,7 +926,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab, | ||
926 | 926 | { |
927 | 927 | // Do not include this section in the link. |
928 | 928 | out_sections[i] = NULL; |
929 | - out_section_offsets[i] = -1U; | |
929 | + out_section_offsets[i] = invalid_address; | |
930 | 930 | continue; |
931 | 931 | } |
932 | 932 |
@@ -967,7 +967,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab, | ||
967 | 967 | |
968 | 968 | out_sections[i] = os; |
969 | 969 | if (offset == -1) |
970 | - out_section_offsets[i] = -1U; | |
970 | + out_section_offsets[i] = invalid_address; | |
971 | 971 | else |
972 | 972 | out_section_offsets[i] = convert_types<Address, off_t>(offset); |
973 | 973 |
@@ -1004,7 +1004,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab, | ||
1004 | 1004 | if (data_section == NULL) |
1005 | 1005 | { |
1006 | 1006 | out_sections[i] = NULL; |
1007 | - out_section_offsets[i] = -1U; | |
1007 | + out_section_offsets[i] = invalid_address; | |
1008 | 1008 | continue; |
1009 | 1009 | } |
1010 | 1010 |
@@ -1014,7 +1014,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab, | ||
1014 | 1014 | Output_section* os = layout->layout_reloc(this, i, shdr, data_section, |
1015 | 1015 | rr); |
1016 | 1016 | out_sections[i] = os; |
1017 | - out_section_offsets[i] = -1U; | |
1017 | + out_section_offsets[i] = invalid_address; | |
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | // Handle the .eh_frame sections at the end. |
@@ -1042,7 +1042,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab, | ||
1042 | 1042 | &offset); |
1043 | 1043 | out_sections[i] = os; |
1044 | 1044 | if (offset == -1) |
1045 | - out_section_offsets[i] = -1U; | |
1045 | + out_section_offsets[i] = invalid_address; | |
1046 | 1046 | else |
1047 | 1047 | out_section_offsets[i] = convert_types<Address, off_t>(offset); |
1048 | 1048 |
@@ -1266,7 +1266,7 @@ Sized_relobj<size, big_endian>::do_finalize_local_symbols(unsigned int index, | ||
1266 | 1266 | // so we leave the input value unchanged here. |
1267 | 1267 | continue; |
1268 | 1268 | } |
1269 | - else if (out_offsets[shndx] == -1U) | |
1269 | + else if (out_offsets[shndx] == invalid_address) | |
1270 | 1270 | { |
1271 | 1271 | // This is a SHF_MERGE section or one which otherwise |
1272 | 1272 | // requires special handling. We get the output address |
@@ -1573,7 +1573,7 @@ Sized_relobj<size, big_endian>::map_to_kept_section( | ||
1573 | 1573 | *found = true; |
1574 | 1574 | Output_section* os = kept->object_->output_section(kept->shndx_); |
1575 | 1575 | 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); | |
1577 | 1577 | return os->address() + offset; |
1578 | 1578 | } |
1579 | 1579 | *found = false; |
@@ -1202,6 +1202,8 @@ class Sized_relobj : public Relobj | ||
1202 | 1202 | typedef std::vector<Symbol*> Symbols; |
1203 | 1203 | typedef std::vector<Symbol_value<size> > Local_values; |
1204 | 1204 | |
1205 | + static const Address invalid_address = static_cast<Address>(0) - 1; | |
1206 | + | |
1205 | 1207 | Sized_relobj(const std::string& name, Input_file* input_file, off_t offset, |
1206 | 1208 | const typename elfcpp::Ehdr<size, big_endian>&); |
1207 | 1209 |
@@ -1457,7 +1459,12 @@ class Sized_relobj : public Relobj | ||
1457 | 1459 | // Get the offset of a section. |
1458 | 1460 | uint64_t |
1459 | 1461 | 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 | + } | |
1461 | 1468 | |
1462 | 1469 | // Set the offset of a section. |
1463 | 1470 | void |
@@ -1699,7 +1706,7 @@ class Sized_relobj : public Relobj | ||
1699 | 1706 | // for TLS symbols, indexed by symbol number. |
1700 | 1707 | Local_got_offsets local_got_offsets_; |
1701 | 1708 | // 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 | |
1703 | 1710 | // special mapping. |
1704 | 1711 | std::vector<Address> section_offsets_; |
1705 | 1712 | // Table mapping discarded comdat sections to corresponding kept sections. |
@@ -838,11 +838,11 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>:: | ||
838 | 838 | Output_section* os = this->u1_.relobj->output_section(lsi); |
839 | 839 | gold_assert(os != NULL); |
840 | 840 | Address offset = this->u1_.relobj->get_output_section_offset(lsi); |
841 | - if (offset != -1U) | |
841 | + if (offset != invalid_address) | |
842 | 842 | return offset + addend; |
843 | 843 | // This is a merge section. |
844 | 844 | offset = os->output_address(this->u1_.relobj, lsi, addend); |
845 | - gold_assert(offset != -1U); | |
845 | + gold_assert(offset != invalid_address); | |
846 | 846 | return offset; |
847 | 847 | } |
848 | 848 |
@@ -858,13 +858,13 @@ Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::get_address() const | ||
858 | 858 | Output_section* os = this->u2_.relobj->output_section(this->shndx_); |
859 | 859 | gold_assert(os != NULL); |
860 | 860 | Address off = this->u2_.relobj->get_output_section_offset(this->shndx_); |
861 | - if (off != -1U) | |
861 | + if (off != invalid_address) | |
862 | 862 | address += os->address() + off; |
863 | 863 | else |
864 | 864 | { |
865 | 865 | address = os->output_address(this->u2_.relobj, this->shndx_, |
866 | 866 | address); |
867 | - gold_assert(address != -1U); | |
867 | + gold_assert(address != invalid_address); | |
868 | 868 | } |
869 | 869 | } |
870 | 870 | else if (this->u2_.od != NULL) |
@@ -2043,7 +2043,7 @@ Output_section::output_address(const Relobj* object, unsigned int shndx, | ||
2043 | 2043 | if (p->output_offset(object, shndx, offset, &output_offset)) |
2044 | 2044 | { |
2045 | 2045 | if (output_offset == -1) |
2046 | - return -1U; | |
2046 | + return -1ULL; | |
2047 | 2047 | return addr + output_offset; |
2048 | 2048 | } |
2049 | 2049 | addr += p->data_size(); |
@@ -874,6 +874,8 @@ class Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian> | ||
874 | 874 | typedef typename elfcpp::Elf_types<size>::Elf_Addr Address; |
875 | 875 | typedef typename elfcpp::Elf_types<size>::Elf_Addr Addend; |
876 | 876 | |
877 | + static const Address invalid_address = static_cast<Address>(0) - 1; | |
878 | + | |
877 | 879 | // An uninitialized entry. We need this because we want to put |
878 | 880 | // instances of this class into an STL container. |
879 | 881 | Output_reloc() |
@@ -1915,7 +1917,7 @@ class Output_section : public Output_data | ||
1915 | 1917 | |
1916 | 1918 | // Add a new input section SHNDX, named NAME, with header SHDR, from |
1917 | 1919 | // 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 | |
1919 | 1921 | // one. HAVE_SECTIONS_SCRIPT is true if we have a SECTIONS clause |
1920 | 1922 | // in a linker script; in that case we need to keep track of input |
1921 | 1923 | // sections associated with an output section. Return the offset |
@@ -586,8 +586,8 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs, | ||
586 | 586 | // In the normal case, this input section is simply mapped to |
587 | 587 | // the output section at offset OUTPUT_OFFSET. |
588 | 588 | |
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 | |
591 | 591 | // routines need to check for each reloc where it should be |
592 | 592 | // applied. For this case, we need an input/output view for the |
593 | 593 | // 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, | ||
619 | 619 | |
620 | 620 | off_t view_start; |
621 | 621 | section_size_type view_size; |
622 | - if (output_offset != -1U) | |
622 | + if (output_offset != invalid_address) | |
623 | 623 | { |
624 | 624 | view_start = output_section_offset + output_offset; |
625 | 625 | 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, | ||
633 | 633 | if (view_size == 0) |
634 | 634 | continue; |
635 | 635 | |
636 | - gold_assert(output_offset == -1U | |
636 | + gold_assert(output_offset == invalid_address | |
637 | 637 | || output_offset + view_size <= output_section_size); |
638 | 638 | |
639 | 639 | unsigned char* view; |
@@ -641,7 +641,7 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs, | ||
641 | 641 | { |
642 | 642 | unsigned char* buffer = os->postprocessing_buffer(); |
643 | 643 | view = buffer + view_start; |
644 | - if (output_offset != -1U) | |
644 | + if (output_offset != invalid_address) | |
645 | 645 | { |
646 | 646 | off_t sh_offset = shdr.get_sh_offset(); |
647 | 647 | if (!rm.empty() && rm.back().file_offset > sh_offset) |
@@ -652,7 +652,7 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs, | ||
652 | 652 | } |
653 | 653 | else |
654 | 654 | { |
655 | - if (output_offset == -1U) | |
655 | + if (output_offset == invalid_address) | |
656 | 656 | view = of->get_input_output_view(view_start, view_size); |
657 | 657 | else |
658 | 658 | { |
@@ -667,11 +667,11 @@ Sized_relobj<size, big_endian>::write_sections(const unsigned char* pshdrs, | ||
667 | 667 | |
668 | 668 | pvs->view = view; |
669 | 669 | pvs->address = os->address(); |
670 | - if (output_offset != -1U) | |
670 | + if (output_offset != invalid_address) | |
671 | 671 | pvs->address += output_offset; |
672 | 672 | pvs->offset = view_start; |
673 | 673 | pvs->view_size = view_size; |
674 | - pvs->is_input_output_view = output_offset == -1U; | |
674 | + pvs->is_input_output_view = output_offset == invalid_address; | |
675 | 675 | pvs->is_postprocessing_view = os->requires_postprocessing(); |
676 | 676 | } |
677 | 677 |
@@ -772,7 +772,7 @@ Sized_relobj<size, big_endian>::relocate_sections( | ||
772 | 772 | continue; |
773 | 773 | } |
774 | 774 | |
775 | - gold_assert(output_offset != -1U | |
775 | + gold_assert(output_offset != invalid_address | |
776 | 776 | || this->relocs_must_follow_section_writes()); |
777 | 777 | |
778 | 778 | relinfo.reloc_shndx = i; |
@@ -784,7 +784,7 @@ Sized_relobj<size, big_endian>::relocate_sections( | ||
784 | 784 | prelocs, |
785 | 785 | reloc_count, |
786 | 786 | os, |
787 | - output_offset == -1U, | |
787 | + output_offset == invalid_address, | |
788 | 788 | (*pviews)[index].view, |
789 | 789 | (*pviews)[index].address, |
790 | 790 | (*pviews)[index].view_size); |
@@ -2136,11 +2136,20 @@ Symbol_table::sized_finalize_symbol(Symbol* unsized_sym) | ||
2136 | 2136 | } |
2137 | 2137 | |
2138 | 2138 | 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 | + } | |
2144 | 2153 | } |
2145 | 2154 | } |
2146 | 2155 | break; |
@@ -450,6 +450,7 @@ relocate_for_relocatable( | ||
450 | 450 | typedef typename Reloc_types<sh_type, size, big_endian>::Reloc_write |
451 | 451 | Reltype_write; |
452 | 452 | const int reloc_size = Reloc_types<sh_type, size, big_endian>::reloc_size; |
453 | + const Address invalid_address = static_cast<Address>(0) - 1; | |
453 | 454 | |
454 | 455 | Sized_relobj<size, big_endian>* const object = relinfo->object; |
455 | 456 | const unsigned int local_count = object->local_symbol_count(); |
@@ -524,7 +525,7 @@ relocate_for_relocatable( | ||
524 | 525 | |
525 | 526 | Address offset = reloc.get_r_offset(); |
526 | 527 | Address new_offset; |
527 | - if (offset_in_output_section != -1U) | |
528 | + if (offset_in_output_section != invalid_address) | |
528 | 529 | new_offset = offset + offset_in_output_section; |
529 | 530 | else |
530 | 531 | { |
@@ -543,7 +544,7 @@ relocate_for_relocatable( | ||
543 | 544 | if (!parameters->options().relocatable()) |
544 | 545 | { |
545 | 546 | new_offset += view_address; |
546 | - if (offset_in_output_section != -1U) | |
547 | + if (offset_in_output_section != invalid_address) | |
547 | 548 | new_offset -= offset_in_output_section; |
548 | 549 | } |
549 | 550 |