| OLD | NEW |
| 1 /* SuperH SH64-specific support for 64-bit ELF | 1 /* SuperH SH64-specific support for 64-bit ELF |
| 2 Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, | 2 Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |
| 3 2010, 2011 Free Software Foundation, Inc. | 3 2010, 2011, 2012 Free Software Foundation, Inc. |
| 4 | 4 |
| 5 This file is part of BFD, the Binary File Descriptor library. | 5 This file is part of BFD, the Binary File Descriptor library. |
| 6 | 6 |
| 7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
| 8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
| 9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
| 10 (at your option) any later version. | 10 (at your option) any later version. |
| 11 | 11 |
| 12 This program is distributed in the hope that it will be useful, | 12 This program is distributed in the hope that it will be useful, |
| 13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 | 1507 |
| 1508 /* A local symbol never has STO_SH5_ISA32, so we don't need | 1508 /* A local symbol never has STO_SH5_ISA32, so we don't need |
| 1509 datalabel processing here. Make sure this does not change | 1509 datalabel processing here. Make sure this does not change |
| 1510 without notice. */ | 1510 without notice. */ |
| 1511 if ((sym->st_other & STO_SH5_ISA32) != 0) | 1511 if ((sym->st_other & STO_SH5_ISA32) != 0) |
| 1512 ((*info->callbacks->reloc_dangerous) | 1512 ((*info->callbacks->reloc_dangerous) |
| 1513 (info, | 1513 (info, |
| 1514 _("Unexpected STO_SH5_ISA32 on local symbol is not handled"), | 1514 _("Unexpected STO_SH5_ISA32 on local symbol is not handled"), |
| 1515 input_bfd, input_section, rel->r_offset)); | 1515 input_bfd, input_section, rel->r_offset)); |
| 1516 | 1516 |
| 1517 » if (sec != NULL && elf_discarded_section (sec)) | 1517 » if (sec != NULL && discarded_section (sec)) |
| 1518 /* Handled below. */ | 1518 /* Handled below. */ |
| 1519 ; | 1519 ; |
| 1520 else if (info->relocatable) | 1520 else if (info->relocatable) |
| 1521 { | 1521 { |
| 1522 /* This is a relocatable link. We don't have to change | 1522 /* This is a relocatable link. We don't have to change |
| 1523 anything, unless the reloc is against a section symbol, | 1523 anything, unless the reloc is against a section symbol, |
| 1524 in which case we have to adjust according to where the | 1524 in which case we have to adjust according to where the |
| 1525 section symbol winds up in the output section. */ | 1525 section symbol winds up in the output section. */ |
| 1526 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) | 1526 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) |
| 1527 goto final_link_relocate; | 1527 goto final_link_relocate; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 { | 1654 { |
| 1655 if (! ((*info->callbacks->undefined_symbol) | 1655 if (! ((*info->callbacks->undefined_symbol) |
| 1656 (info, h->root.root.string, input_bfd, | 1656 (info, h->root.root.string, input_bfd, |
| 1657 input_section, rel->r_offset, | 1657 input_section, rel->r_offset, |
| 1658 (info->unresolved_syms_in_objects == RM_GENERATE_ERROR | 1658 (info->unresolved_syms_in_objects == RM_GENERATE_ERROR |
| 1659 || ELF_ST_VISIBILITY (h->other))))) | 1659 || ELF_ST_VISIBILITY (h->other))))) |
| 1660 return FALSE; | 1660 return FALSE; |
| 1661 } | 1661 } |
| 1662 } | 1662 } |
| 1663 | 1663 |
| 1664 if (sec != NULL && elf_discarded_section (sec)) | 1664 if (sec != NULL && discarded_section (sec)) |
| 1665 RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, | 1665 RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, |
| 1666 » » » » » rel, relend, howto, contents); | 1666 » » » » » rel, 1, relend, howto, 0, contents); |
| 1667 | 1667 |
| 1668 if (info->relocatable) | 1668 if (info->relocatable) |
| 1669 continue; | 1669 continue; |
| 1670 | 1670 |
| 1671 disp = (relocation | 1671 disp = (relocation |
| 1672 - input_section->output_section->vma | 1672 - input_section->output_section->vma |
| 1673 - input_section->output_offset | 1673 - input_section->output_offset |
| 1674 - rel->r_offset); | 1674 - rel->r_offset); |
| 1675 dropped = 0; | 1675 dropped = 0; |
| 1676 switch ((int)r_type) | 1676 switch ((int)r_type) |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1790 || info->symbolic | 1790 || info->symbolic |
| 1791 || h->dynindx == -1 | 1791 || h->dynindx == -1 |
| 1792 || h->plt.offset == (bfd_vma) -1 | 1792 || h->plt.offset == (bfd_vma) -1 |
| 1793 || h->got.offset != (bfd_vma) -1) | 1793 || h->got.offset != (bfd_vma) -1) |
| 1794 goto force_got; | 1794 goto force_got; |
| 1795 | 1795 |
| 1796 /* Relocation is to the entry for this symbol in the global | 1796 /* Relocation is to the entry for this symbol in the global |
| 1797 offset table extension for the procedure linkage table. */ | 1797 offset table extension for the procedure linkage table. */ |
| 1798 if (sgotplt == NULL) | 1798 if (sgotplt == NULL) |
| 1799 { | 1799 { |
| 1800 » sgotplt = bfd_get_section_by_name (dynobj, ".got.plt"); | 1800 » sgotplt = bfd_get_linker_section (dynobj, ".got.plt"); |
| 1801 BFD_ASSERT (sgotplt != NULL); | 1801 BFD_ASSERT (sgotplt != NULL); |
| 1802 } | 1802 } |
| 1803 | 1803 |
| 1804 relocation = (sgotplt->output_offset | 1804 relocation = (sgotplt->output_offset |
| 1805 + ((h->plt.offset / elf_sh64_sizeof_plt (info) | 1805 + ((h->plt.offset / elf_sh64_sizeof_plt (info) |
| 1806 - 1 + 3) * 8)); | 1806 - 1 + 3) * 8)); |
| 1807 | 1807 |
| 1808 relocation -= GOT_BIAS; | 1808 relocation -= GOT_BIAS; |
| 1809 | 1809 |
| 1810 goto final_link_relocate; | 1810 goto final_link_relocate; |
| 1811 | 1811 |
| 1812 force_got: | 1812 force_got: |
| 1813 case R_SH_GOT_LOW16: | 1813 case R_SH_GOT_LOW16: |
| 1814 case R_SH_GOT_MEDLOW16: | 1814 case R_SH_GOT_MEDLOW16: |
| 1815 case R_SH_GOT_MEDHI16: | 1815 case R_SH_GOT_MEDHI16: |
| 1816 case R_SH_GOT_HI16: | 1816 case R_SH_GOT_HI16: |
| 1817 case R_SH_GOT10BY4: | 1817 case R_SH_GOT10BY4: |
| 1818 case R_SH_GOT10BY8: | 1818 case R_SH_GOT10BY8: |
| 1819 /* Relocation is to the entry for this symbol in the global | 1819 /* Relocation is to the entry for this symbol in the global |
| 1820 offset table. */ | 1820 offset table. */ |
| 1821 if (sgot == NULL) | 1821 if (sgot == NULL) |
| 1822 { | 1822 { |
| 1823 » sgot = bfd_get_section_by_name (dynobj, ".got"); | 1823 » sgot = bfd_get_linker_section (dynobj, ".got"); |
| 1824 BFD_ASSERT (sgot != NULL); | 1824 BFD_ASSERT (sgot != NULL); |
| 1825 } | 1825 } |
| 1826 | 1826 |
| 1827 if (h != NULL) | 1827 if (h != NULL) |
| 1828 { | 1828 { |
| 1829 bfd_vma off; | 1829 bfd_vma off; |
| 1830 | 1830 |
| 1831 off = h->got.offset; | 1831 off = h->got.offset; |
| 1832 if (seen_stt_datalabel) | 1832 if (seen_stt_datalabel) |
| 1833 { | 1833 { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1907 else | 1907 else |
| 1908 { | 1908 { |
| 1909 bfd_put_64 (output_bfd, relocation, sgot->contents + off); | 1909 bfd_put_64 (output_bfd, relocation, sgot->contents + off); |
| 1910 | 1910 |
| 1911 if (info->shared) | 1911 if (info->shared) |
| 1912 { | 1912 { |
| 1913 asection *s; | 1913 asection *s; |
| 1914 Elf_Internal_Rela outrel; | 1914 Elf_Internal_Rela outrel; |
| 1915 bfd_byte *loc; | 1915 bfd_byte *loc; |
| 1916 | 1916 |
| 1917 » » s = bfd_get_section_by_name (dynobj, ".rela.got"); | 1917 » » s = bfd_get_linker_section (dynobj, ".rela.got"); |
| 1918 BFD_ASSERT (s != NULL); | 1918 BFD_ASSERT (s != NULL); |
| 1919 | 1919 |
| 1920 outrel.r_offset = (sgot->output_section->vma | 1920 outrel.r_offset = (sgot->output_section->vma |
| 1921 + sgot->output_offset | 1921 + sgot->output_offset |
| 1922 + off); | 1922 + off); |
| 1923 outrel.r_info = ELF64_R_INFO (0, R_SH_RELATIVE64); | 1923 outrel.r_info = ELF64_R_INFO (0, R_SH_RELATIVE64); |
| 1924 outrel.r_addend = relocation; | 1924 outrel.r_addend = relocation; |
| 1925 loc = s->contents; | 1925 loc = s->contents; |
| 1926 loc += s->reloc_count++ * sizeof (Elf64_External_Rela); | 1926 loc += s->reloc_count++ * sizeof (Elf64_External_Rela); |
| 1927 bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc); | 1927 bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1942 | 1942 |
| 1943 case R_SH_GOTOFF_LOW16: | 1943 case R_SH_GOTOFF_LOW16: |
| 1944 case R_SH_GOTOFF_MEDLOW16: | 1944 case R_SH_GOTOFF_MEDLOW16: |
| 1945 case R_SH_GOTOFF_MEDHI16: | 1945 case R_SH_GOTOFF_MEDHI16: |
| 1946 case R_SH_GOTOFF_HI16: | 1946 case R_SH_GOTOFF_HI16: |
| 1947 /* Relocation is relative to the start of the global offset | 1947 /* Relocation is relative to the start of the global offset |
| 1948 table. */ | 1948 table. */ |
| 1949 | 1949 |
| 1950 if (sgot == NULL) | 1950 if (sgot == NULL) |
| 1951 { | 1951 { |
| 1952 » sgot = bfd_get_section_by_name (dynobj, ".got"); | 1952 » sgot = bfd_get_linker_section (dynobj, ".got"); |
| 1953 BFD_ASSERT (sgot != NULL); | 1953 BFD_ASSERT (sgot != NULL); |
| 1954 } | 1954 } |
| 1955 | 1955 |
| 1956 /* Note that sgot->output_offset is not involved in this | 1956 /* Note that sgot->output_offset is not involved in this |
| 1957 calculation. We always want the start of .got. If we | 1957 calculation. We always want the start of .got. If we |
| 1958 defined _GLOBAL_OFFSET_TABLE in a different way, as is | 1958 defined _GLOBAL_OFFSET_TABLE in a different way, as is |
| 1959 permitted by the ABI, we might have to change this | 1959 permitted by the ABI, we might have to change this |
| 1960 calculation. */ | 1960 calculation. */ |
| 1961 relocation -= sgot->output_section->vma; | 1961 relocation -= sgot->output_section->vma; |
| 1962 | 1962 |
| 1963 relocation -= GOT_BIAS; | 1963 relocation -= GOT_BIAS; |
| 1964 | 1964 |
| 1965 addend = rel->r_addend; | 1965 addend = rel->r_addend; |
| 1966 | 1966 |
| 1967 goto final_link_relocate; | 1967 goto final_link_relocate; |
| 1968 | 1968 |
| 1969 case R_SH_GOTPC_LOW16: | 1969 case R_SH_GOTPC_LOW16: |
| 1970 case R_SH_GOTPC_MEDLOW16: | 1970 case R_SH_GOTPC_MEDLOW16: |
| 1971 case R_SH_GOTPC_MEDHI16: | 1971 case R_SH_GOTPC_MEDHI16: |
| 1972 case R_SH_GOTPC_HI16: | 1972 case R_SH_GOTPC_HI16: |
| 1973 /* Use global offset table as symbol value. */ | 1973 /* Use global offset table as symbol value. */ |
| 1974 | 1974 |
| 1975 if (sgot == NULL) | 1975 if (sgot == NULL) |
| 1976 { | 1976 { |
| 1977 » sgot = bfd_get_section_by_name (dynobj, ".got"); | 1977 » sgot = bfd_get_linker_section (dynobj, ".got"); |
| 1978 BFD_ASSERT (sgot != NULL); | 1978 BFD_ASSERT (sgot != NULL); |
| 1979 } | 1979 } |
| 1980 | 1980 |
| 1981 relocation = sgot->output_section->vma; | 1981 relocation = sgot->output_section->vma; |
| 1982 | 1982 |
| 1983 relocation += GOT_BIAS; | 1983 relocation += GOT_BIAS; |
| 1984 | 1984 |
| 1985 addend = rel->r_addend; | 1985 addend = rel->r_addend; |
| 1986 | 1986 |
| 1987 goto final_link_relocate; | 1987 goto final_link_relocate; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2005 if (h->plt.offset == (bfd_vma) -1) | 2005 if (h->plt.offset == (bfd_vma) -1) |
| 2006 { | 2006 { |
| 2007 /* We didn't make a PLT entry for this symbol. This | 2007 /* We didn't make a PLT entry for this symbol. This |
| 2008 happens when statically linking PIC code, or when | 2008 happens when statically linking PIC code, or when |
| 2009 using -Bsymbolic. */ | 2009 using -Bsymbolic. */ |
| 2010 goto final_link_relocate; | 2010 goto final_link_relocate; |
| 2011 } | 2011 } |
| 2012 | 2012 |
| 2013 if (splt == NULL) | 2013 if (splt == NULL) |
| 2014 { | 2014 { |
| 2015 » splt = bfd_get_section_by_name (dynobj, ".plt"); | 2015 » splt = bfd_get_linker_section (dynobj, ".plt"); |
| 2016 BFD_ASSERT (splt != NULL); | 2016 BFD_ASSERT (splt != NULL); |
| 2017 } | 2017 } |
| 2018 | 2018 |
| 2019 relocation = (splt->output_section->vma | 2019 relocation = (splt->output_section->vma |
| 2020 + splt->output_offset | 2020 + splt->output_offset |
| 2021 + h->plt.offset); | 2021 + h->plt.offset); |
| 2022 relocation++; | 2022 relocation++; |
| 2023 | 2023 |
| 2024 addend = rel->r_addend; | 2024 addend = rel->r_addend; |
| 2025 | 2025 |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2483 case R_SH_GOT_LOW16: | 2483 case R_SH_GOT_LOW16: |
| 2484 case R_SH_GOT_MEDLOW16: | 2484 case R_SH_GOT_MEDLOW16: |
| 2485 case R_SH_GOT_MEDHI16: | 2485 case R_SH_GOT_MEDHI16: |
| 2486 case R_SH_GOT_HI16: | 2486 case R_SH_GOT_HI16: |
| 2487 case R_SH_GOT10BY4: | 2487 case R_SH_GOT10BY4: |
| 2488 case R_SH_GOT10BY8: | 2488 case R_SH_GOT10BY8: |
| 2489 /* This symbol requires a global offset table entry. */ | 2489 /* This symbol requires a global offset table entry. */ |
| 2490 | 2490 |
| 2491 if (sgot == NULL) | 2491 if (sgot == NULL) |
| 2492 { | 2492 { |
| 2493 » sgot = bfd_get_section_by_name (dynobj, ".got"); | 2493 » sgot = bfd_get_linker_section (dynobj, ".got"); |
| 2494 BFD_ASSERT (sgot != NULL); | 2494 BFD_ASSERT (sgot != NULL); |
| 2495 } | 2495 } |
| 2496 | 2496 |
| 2497 if (srelgot == NULL | 2497 if (srelgot == NULL |
| 2498 && (h != NULL || info->shared)) | 2498 && (h != NULL || info->shared)) |
| 2499 { | 2499 { |
| 2500 » srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); | 2500 » srelgot = bfd_get_linker_section (dynobj, ".rela.got"); |
| 2501 if (srelgot == NULL) | 2501 if (srelgot == NULL) |
| 2502 { | 2502 { |
| 2503 » » srelgot = bfd_make_section_with_flags (dynobj, | 2503 » » flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS |
| 2504 » » » » » » » ".rela.got", | 2504 » » » » | SEC_IN_MEMORY | SEC_LINKER_CREATED |
| 2505 » » » » » » » (SEC_ALLOC | 2505 » » » » | SEC_READONLY); |
| 2506 » » » » » » » | SEC_LOAD | 2506 » » srelgot = bfd_make_section_anyway_with_flags (dynobj, |
| 2507 » » » » » » » | SEC_HAS_CONTENTS | 2507 » » » » » » » » ".rela.got", |
| 2508 » » » » » » » | SEC_IN_MEMORY | 2508 » » » » » » » » flags); |
| 2509 » » » » » » » | SEC_LINKER_CREATED | |
| 2510 » » » » » » » | SEC_READONLY)); | |
| 2511 if (srelgot == NULL | 2509 if (srelgot == NULL |
| 2512 || ! bfd_set_section_alignment (dynobj, srelgot, 2)) | 2510 || ! bfd_set_section_alignment (dynobj, srelgot, 2)) |
| 2513 return FALSE; | 2511 return FALSE; |
| 2514 } | 2512 } |
| 2515 } | 2513 } |
| 2516 | 2514 |
| 2517 if (h != NULL) | 2515 if (h != NULL) |
| 2518 { | 2516 { |
| 2519 if (h->type == STT_DATALABEL) | 2517 if (h->type == STT_DATALABEL) |
| 2520 { | 2518 { |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3152 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | 3150 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY |
| 3153 | SEC_LINKER_CREATED); | 3151 | SEC_LINKER_CREATED); |
| 3154 | 3152 |
| 3155 pltflags = flags; | 3153 pltflags = flags; |
| 3156 pltflags |= SEC_CODE; | 3154 pltflags |= SEC_CODE; |
| 3157 if (bed->plt_not_loaded) | 3155 if (bed->plt_not_loaded) |
| 3158 pltflags &= ~ (SEC_LOAD | SEC_HAS_CONTENTS); | 3156 pltflags &= ~ (SEC_LOAD | SEC_HAS_CONTENTS); |
| 3159 if (bed->plt_readonly) | 3157 if (bed->plt_readonly) |
| 3160 pltflags |= SEC_READONLY; | 3158 pltflags |= SEC_READONLY; |
| 3161 | 3159 |
| 3162 s = bfd_make_section_with_flags (abfd, ".plt", pltflags); | 3160 s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags); |
| 3163 if (s == NULL | 3161 if (s == NULL |
| 3164 || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment)) | 3162 || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment)) |
| 3165 return FALSE; | 3163 return FALSE; |
| 3166 | 3164 |
| 3167 if (bed->want_plt_sym) | 3165 if (bed->want_plt_sym) |
| 3168 { | 3166 { |
| 3169 /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the | 3167 /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the |
| 3170 .plt section. */ | 3168 .plt section. */ |
| 3171 struct elf_link_hash_entry *h; | 3169 struct elf_link_hash_entry *h; |
| 3172 struct bfd_link_hash_entry *bh = NULL; | 3170 struct bfd_link_hash_entry *bh = NULL; |
| 3173 | 3171 |
| 3174 if (! (_bfd_generic_link_add_one_symbol | 3172 if (! (_bfd_generic_link_add_one_symbol |
| 3175 (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s, | 3173 (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s, |
| 3176 (bfd_vma) 0, (const char *) NULL, FALSE, bed->collect, &bh))) | 3174 (bfd_vma) 0, (const char *) NULL, FALSE, bed->collect, &bh))) |
| 3177 return FALSE; | 3175 return FALSE; |
| 3178 | 3176 |
| 3179 h = (struct elf_link_hash_entry *) bh; | 3177 h = (struct elf_link_hash_entry *) bh; |
| 3180 h->def_regular = 1; | 3178 h->def_regular = 1; |
| 3181 h->type = STT_OBJECT; | 3179 h->type = STT_OBJECT; |
| 3182 elf_hash_table (info)->hplt = h; | 3180 elf_hash_table (info)->hplt = h; |
| 3183 | 3181 |
| 3184 if (info->shared | 3182 if (info->shared |
| 3185 && ! bfd_elf_link_record_dynamic_symbol (info, h)) | 3183 && ! bfd_elf_link_record_dynamic_symbol (info, h)) |
| 3186 return FALSE; | 3184 return FALSE; |
| 3187 } | 3185 } |
| 3188 | 3186 |
| 3189 s = bfd_make_section_with_flags (abfd, | 3187 s = bfd_make_section_anyway_with_flags (abfd, |
| 3190 » » » » bed->default_use_rela_p ? ".rela.plt" : ".rel
.plt", | 3188 » » » » » bed->default_use_rela_p |
| 3191 » » » » flags | SEC_READONLY); | 3189 » » » » » ? ".rela.plt" : ".rel.plt", |
| 3190 » » » » » flags | SEC_READONLY); |
| 3192 if (s == NULL | 3191 if (s == NULL |
| 3193 || ! bfd_set_section_alignment (abfd, s, ptralign)) | 3192 || ! bfd_set_section_alignment (abfd, s, ptralign)) |
| 3194 return FALSE; | 3193 return FALSE; |
| 3195 | 3194 |
| 3196 if (! _bfd_elf_create_got_section (abfd, info)) | 3195 if (! _bfd_elf_create_got_section (abfd, info)) |
| 3197 return FALSE; | 3196 return FALSE; |
| 3198 | 3197 |
| 3199 { | |
| 3200 const char *secname; | |
| 3201 char *relname; | |
| 3202 flagword secflags; | |
| 3203 asection *sec; | |
| 3204 | |
| 3205 for (sec = abfd->sections; sec; sec = sec->next) | |
| 3206 { | |
| 3207 secflags = bfd_get_section_flags (abfd, sec); | |
| 3208 if ((secflags & (SEC_DATA | SEC_LINKER_CREATED)) | |
| 3209 || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS)) | |
| 3210 continue; | |
| 3211 secname = bfd_get_section_name (abfd, sec); | |
| 3212 relname = (char *) bfd_malloc (strlen (secname) + 6); | |
| 3213 strcpy (relname, ".rela"); | |
| 3214 strcat (relname, secname); | |
| 3215 s = bfd_make_section_with_flags (abfd, relname, | |
| 3216 flags | SEC_READONLY); | |
| 3217 if (s == NULL | |
| 3218 || ! bfd_set_section_alignment (abfd, s, ptralign)) | |
| 3219 return FALSE; | |
| 3220 } | |
| 3221 } | |
| 3222 | |
| 3223 if (bed->want_dynbss) | 3198 if (bed->want_dynbss) |
| 3224 { | 3199 { |
| 3225 /* The .dynbss section is a place to put symbols which are defined | 3200 /* The .dynbss section is a place to put symbols which are defined |
| 3226 by dynamic objects, are referenced by regular objects, and are | 3201 by dynamic objects, are referenced by regular objects, and are |
| 3227 not functions. We must allocate space for them in the process | 3202 not functions. We must allocate space for them in the process |
| 3228 image and use a R_*_COPY reloc to tell the dynamic linker to | 3203 image and use a R_*_COPY reloc to tell the dynamic linker to |
| 3229 initialize them at run time. The linker script puts the .dynbss | 3204 initialize them at run time. The linker script puts the .dynbss |
| 3230 section into the .bss section of the final image. */ | 3205 section into the .bss section of the final image. */ |
| 3231 s = bfd_make_section_with_flags (abfd, ".dynbss", | 3206 s = bfd_make_section_anyway_with_flags (abfd, ".dynbss", |
| 3232 » » » » SEC_ALLOC | SEC_LINKER_CREATED); | 3207 » » » » » SEC_ALLOC | SEC_LINKER_CREATED); |
| 3233 if (s == NULL) | 3208 if (s == NULL) |
| 3234 return FALSE; | 3209 return FALSE; |
| 3235 | 3210 |
| 3236 /* The .rel[a].bss section holds copy relocs. This section is not | 3211 /* The .rel[a].bss section holds copy relocs. This section is not |
| 3237 normally needed. We need to create it here, though, so that the | 3212 normally needed. We need to create it here, though, so that the |
| 3238 linker will map it to an output section. We can't just create it | 3213 linker will map it to an output section. We can't just create it |
| 3239 only if we need it, because we will not know whether we need it | 3214 only if we need it, because we will not know whether we need it |
| 3240 until we have seen all the input files, and the first time the | 3215 until we have seen all the input files, and the first time the |
| 3241 main linker code calls BFD after examining all the input files | 3216 main linker code calls BFD after examining all the input files |
| 3242 (size_dynamic_sections) the input sections have already been | 3217 (size_dynamic_sections) the input sections have already been |
| 3243 mapped to the output sections. If the section turns out not to | 3218 mapped to the output sections. If the section turns out not to |
| 3244 be needed, we can discard it later. We will never need this | 3219 be needed, we can discard it later. We will never need this |
| 3245 section when generating a shared object, since they do not use | 3220 section when generating a shared object, since they do not use |
| 3246 copy relocs. */ | 3221 copy relocs. */ |
| 3247 if (! info->shared) | 3222 if (! info->shared) |
| 3248 { | 3223 { |
| 3249 » s = bfd_make_section_with_flags (abfd, | 3224 » s = bfd_make_section_anyway_with_flags (abfd, |
| 3250 » » » » » (bed->default_use_rela_p | 3225 » » » » » » (bed->default_use_rela_p |
| 3251 » » » » » ? ".rela.bss" : ".rel.bss"), | 3226 » » » » » » ? ".rela.bss" : ".rel.bss"), |
| 3252 » » » » » flags | SEC_READONLY); | 3227 » » » » » » flags | SEC_READONLY); |
| 3253 if (s == NULL | 3228 if (s == NULL |
| 3254 || ! bfd_set_section_alignment (abfd, s, ptralign)) | 3229 || ! bfd_set_section_alignment (abfd, s, ptralign)) |
| 3255 return FALSE; | 3230 return FALSE; |
| 3256 } | 3231 } |
| 3257 } | 3232 } |
| 3258 | 3233 |
| 3259 return TRUE; | 3234 return TRUE; |
| 3260 } | 3235 } |
| 3261 | 3236 |
| 3262 | 3237 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3298 object. In such a case, we don't actually need to build | 3273 object. In such a case, we don't actually need to build |
| 3299 a procedure linkage table, and we can just do a REL64 | 3274 a procedure linkage table, and we can just do a REL64 |
| 3300 reloc instead. */ | 3275 reloc instead. */ |
| 3301 BFD_ASSERT (h->needs_plt); | 3276 BFD_ASSERT (h->needs_plt); |
| 3302 return TRUE; | 3277 return TRUE; |
| 3303 } | 3278 } |
| 3304 | 3279 |
| 3305 /* Make sure this symbol is output as a dynamic symbol. */ | 3280 /* Make sure this symbol is output as a dynamic symbol. */ |
| 3306 if (h->dynindx == -1) | 3281 if (h->dynindx == -1) |
| 3307 { | 3282 { |
error: old chunk mismatch |
None
| OLD | NEW |