1 |
/* SPARC-specific support for 32-bit ELF |
/* SPARC-specific support for 32-bit ELF |
2 |
Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 |
Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
3 |
Free Software Foundation, Inc. |
2003, 2004, 2005 Free Software Foundation, Inc. |
4 |
|
|
5 |
This file is part of BFD, the Binary File Descriptor library. |
This file is part of BFD, the Binary File Descriptor library. |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or modify |
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 |
it under the terms of the GNU General Public License as published by |
9 |
the Free Software Foundation; either version 2 of the License, or |
the Free Software Foundation; either version 2 of the License, or |
10 |
(at your option) any later version. |
(at your option) any later version. |
11 |
|
|
12 |
This program is distributed in the hope that it will be useful, |
This program is distributed in the hope that it will be useful, |
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
GNU General Public License for more details. |
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
18 |
along with this program; if not, write to the Free Software |
along with this program; if not, write to the Free Software |
19 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
20 |
|
|
21 |
#include "bfd.h" |
#include "bfd.h" |
22 |
#include "sysdep.h" |
#include "sysdep.h" |
30 |
PARAMS ((bfd *, bfd_reloc_code_real_type)); |
PARAMS ((bfd *, bfd_reloc_code_real_type)); |
31 |
static void elf32_sparc_info_to_howto |
static void elf32_sparc_info_to_howto |
32 |
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); |
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); |
33 |
static boolean elf32_sparc_check_relocs |
static bfd_boolean elf32_sparc_check_relocs |
34 |
PARAMS ((bfd *, struct bfd_link_info *, asection *, |
PARAMS ((bfd *, struct bfd_link_info *, asection *, |
35 |
const Elf_Internal_Rela *)); |
const Elf_Internal_Rela *)); |
36 |
static boolean elf32_sparc_adjust_dynamic_symbol |
static bfd_boolean elf32_sparc_adjust_dynamic_symbol |
37 |
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); |
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); |
38 |
static boolean elf32_sparc_size_dynamic_sections |
static bfd_boolean allocate_dynrelocs |
39 |
|
PARAMS ((struct elf_link_hash_entry *, PTR)); |
40 |
|
static bfd_boolean readonly_dynrelocs |
41 |
|
PARAMS ((struct elf_link_hash_entry *, PTR)); |
42 |
|
static bfd_boolean elf32_sparc_omit_section_dynsym |
43 |
|
PARAMS ((bfd *, struct bfd_link_info *, asection *)); |
44 |
|
static bfd_boolean elf32_sparc_size_dynamic_sections |
45 |
PARAMS ((bfd *, struct bfd_link_info *)); |
PARAMS ((bfd *, struct bfd_link_info *)); |
46 |
static boolean elf32_sparc_relax_section |
static bfd_boolean elf32_sparc_new_section_hook |
47 |
PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *)); |
PARAMS ((bfd *, asection *)); |
48 |
static boolean elf32_sparc_relocate_section |
static bfd_boolean elf32_sparc_relax_section |
49 |
|
PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *)); |
50 |
|
static bfd_vma dtpoff_base |
51 |
|
PARAMS ((struct bfd_link_info *)); |
52 |
|
static bfd_vma tpoff |
53 |
|
PARAMS ((struct bfd_link_info *, bfd_vma)); |
54 |
|
static bfd_boolean elf32_sparc_relocate_section |
55 |
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, |
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, |
56 |
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); |
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); |
57 |
static boolean elf32_sparc_finish_dynamic_symbol |
static bfd_boolean elf32_sparc_finish_dynamic_symbol |
58 |
PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, |
PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, |
59 |
Elf_Internal_Sym *)); |
Elf_Internal_Sym *)); |
60 |
static boolean elf32_sparc_finish_dynamic_sections |
static bfd_boolean elf32_sparc_finish_dynamic_sections |
61 |
PARAMS ((bfd *, struct bfd_link_info *)); |
PARAMS ((bfd *, struct bfd_link_info *)); |
62 |
static boolean elf32_sparc_merge_private_bfd_data PARAMS ((bfd *, bfd *)); |
static bfd_boolean elf32_sparc_merge_private_bfd_data |
63 |
static boolean elf32_sparc_object_p |
PARAMS ((bfd *, bfd *)); |
64 |
|
static struct bfd_hash_entry *link_hash_newfunc |
65 |
|
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); |
66 |
|
static struct bfd_link_hash_table *elf32_sparc_link_hash_table_create |
67 |
|
PARAMS ((bfd *)); |
68 |
|
static bfd_boolean create_got_section |
69 |
|
PARAMS ((bfd *, struct bfd_link_info *)); |
70 |
|
static bfd_boolean elf32_sparc_create_dynamic_sections |
71 |
|
PARAMS ((bfd *, struct bfd_link_info *)); |
72 |
|
static void elf32_sparc_copy_indirect_symbol |
73 |
|
PARAMS ((const struct elf_backend_data *, struct elf_link_hash_entry *, |
74 |
|
struct elf_link_hash_entry *)); |
75 |
|
static int elf32_sparc_tls_transition |
76 |
|
PARAMS ((struct bfd_link_info *, bfd *, int, int)); |
77 |
|
|
78 |
|
static bfd_boolean elf32_sparc_mkobject |
79 |
|
PARAMS ((bfd *)); |
80 |
|
static bfd_boolean elf32_sparc_object_p |
81 |
PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
82 |
static void elf32_sparc_final_write_processing |
static void elf32_sparc_final_write_processing |
83 |
PARAMS ((bfd *, boolean)); |
PARAMS ((bfd *, bfd_boolean)); |
84 |
static enum elf_reloc_type_class elf32_sparc_reloc_type_class |
static enum elf_reloc_type_class elf32_sparc_reloc_type_class |
85 |
PARAMS ((const Elf_Internal_Rela *)); |
PARAMS ((const Elf_Internal_Rela *)); |
86 |
static asection * elf32_sparc_gc_mark_hook |
static asection * elf32_sparc_gc_mark_hook |
87 |
PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, |
PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, |
88 |
struct elf_link_hash_entry *, Elf_Internal_Sym *)); |
struct elf_link_hash_entry *, Elf_Internal_Sym *)); |
89 |
static boolean elf32_sparc_gc_sweep_hook |
static bfd_boolean elf32_sparc_gc_sweep_hook |
90 |
PARAMS ((bfd *, struct bfd_link_info *, asection *, |
PARAMS ((bfd *, struct bfd_link_info *, asection *, |
91 |
const Elf_Internal_Rela *)); |
const Elf_Internal_Rela *)); |
92 |
|
|
96 |
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
97 |
static bfd_reloc_status_type sparc_elf_wdisp16_reloc |
static bfd_reloc_status_type sparc_elf_wdisp16_reloc |
98 |
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
99 |
|
static bfd_reloc_status_type sparc_elf_hix22_reloc |
100 |
|
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
101 |
|
static bfd_reloc_status_type sparc_elf_lox10_reloc |
102 |
|
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); |
103 |
|
|
104 |
reloc_howto_type _bfd_sparc_elf_howto_table[] = |
reloc_howto_type _bfd_sparc_elf_howto_table[] = |
105 |
{ |
{ |
106 |
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true), |
HOWTO(R_SPARC_NONE, 0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", FALSE,0,0x00000000,TRUE), |
107 |
HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_8", false,0,0x000000ff,true), |
HOWTO(R_SPARC_8, 0,0, 8,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_8", FALSE,0,0x000000ff,TRUE), |
108 |
HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_16", false,0,0x0000ffff,true), |
HOWTO(R_SPARC_16, 0,1,16,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_16", FALSE,0,0x0000ffff,TRUE), |
109 |
HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_32", false,0,0xffffffff,true), |
HOWTO(R_SPARC_32, 0,2,32,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_32", FALSE,0,0xffffffff,TRUE), |
110 |
HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP8", false,0,0x000000ff,true), |
HOWTO(R_SPARC_DISP8, 0,0, 8,TRUE, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP8", FALSE,0,0x000000ff,TRUE), |
111 |
HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP16", false,0,0x0000ffff,true), |
HOWTO(R_SPARC_DISP16, 0,1,16,TRUE, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP16", FALSE,0,0x0000ffff,TRUE), |
112 |
HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP32", false,0,0xffffffff,true), |
HOWTO(R_SPARC_DISP32, 0,2,32,TRUE, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP32", FALSE,0,0xffffffff,TRUE), |
113 |
HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP30", false,0,0x3fffffff,true), |
HOWTO(R_SPARC_WDISP30, 2,2,30,TRUE, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP30", FALSE,0,0x3fffffff,TRUE), |
114 |
HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP22", false,0,0x003fffff,true), |
HOWTO(R_SPARC_WDISP22, 2,2,22,TRUE, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP22", FALSE,0,0x003fffff,TRUE), |
115 |
HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HI22", false,0,0x003fffff,true), |
HOWTO(R_SPARC_HI22, 10,2,22,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HI22", FALSE,0,0x003fffff,TRUE), |
116 |
HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_22", false,0,0x003fffff,true), |
HOWTO(R_SPARC_22, 0,2,22,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_22", FALSE,0,0x003fffff,TRUE), |
117 |
HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_13", false,0,0x00001fff,true), |
HOWTO(R_SPARC_13, 0,2,13,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_13", FALSE,0,0x00001fff,TRUE), |
118 |
HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LO10", false,0,0x000003ff,true), |
HOWTO(R_SPARC_LO10, 0,2,10,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LO10", FALSE,0,0x000003ff,TRUE), |
119 |
HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT10", false,0,0x000003ff,true), |
HOWTO(R_SPARC_GOT10, 0,2,10,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT10", FALSE,0,0x000003ff,TRUE), |
120 |
HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_GOT13", false,0,0x00001fff,true), |
HOWTO(R_SPARC_GOT13, 0,2,13,FALSE,0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_GOT13", FALSE,0,0x00001fff,TRUE), |
121 |
HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT22", false,0,0x003fffff,true), |
HOWTO(R_SPARC_GOT22, 10,2,22,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT22", FALSE,0,0x003fffff,TRUE), |
122 |
HOWTO(R_SPARC_PC10, 0,2,10,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_PC10", false,0,0x000003ff,true), |
HOWTO(R_SPARC_PC10, 0,2,10,TRUE, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_PC10", FALSE,0,0x000003ff,TRUE), |
123 |
HOWTO(R_SPARC_PC22, 10,2,22,true, 0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_PC22", false,0,0x003fffff,true), |
HOWTO(R_SPARC_PC22, 10,2,22,TRUE, 0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_PC22", FALSE,0,0x003fffff,TRUE), |
124 |
HOWTO(R_SPARC_WPLT30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WPLT30", false,0,0x3fffffff,true), |
HOWTO(R_SPARC_WPLT30, 2,2,30,TRUE, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WPLT30", FALSE,0,0x3fffffff,TRUE), |
125 |
HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_COPY", false,0,0x00000000,true), |
HOWTO(R_SPARC_COPY, 0,0,00,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_COPY", FALSE,0,0x00000000,TRUE), |
126 |
HOWTO(R_SPARC_GLOB_DAT, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GLOB_DAT",false,0,0x00000000,true), |
HOWTO(R_SPARC_GLOB_DAT, 0,0,00,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GLOB_DAT",FALSE,0,0x00000000,TRUE), |
127 |
HOWTO(R_SPARC_JMP_SLOT, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_JMP_SLOT",false,0,0x00000000,true), |
HOWTO(R_SPARC_JMP_SLOT, 0,0,00,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_JMP_SLOT",FALSE,0,0x00000000,TRUE), |
128 |
HOWTO(R_SPARC_RELATIVE, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_RELATIVE",false,0,0x00000000,true), |
HOWTO(R_SPARC_RELATIVE, 0,0,00,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_RELATIVE",FALSE,0,0x00000000,TRUE), |
129 |
HOWTO(R_SPARC_UA32, 0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_UA32", false,0,0xffffffff,true), |
HOWTO(R_SPARC_UA32, 0,2,32,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_UA32", FALSE,0,0xffffffff,TRUE), |
130 |
HOWTO(R_SPARC_PLT32, 0,0,00,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_PLT32", false,0,0xffffffff,true), |
HOWTO(R_SPARC_PLT32, 0,0,00,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_PLT32", FALSE,0,0xffffffff,TRUE), |
131 |
HOWTO(R_SPARC_HIPLT22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_HIPLT22", false,0,0x00000000,true), |
HOWTO(R_SPARC_HIPLT22, 0,0,00,FALSE,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_HIPLT22", FALSE,0,0x00000000,TRUE), |
132 |
HOWTO(R_SPARC_LOPLT10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_LOPLT10", false,0,0x00000000,true), |
HOWTO(R_SPARC_LOPLT10, 0,0,00,FALSE,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_LOPLT10", FALSE,0,0x00000000,TRUE), |
133 |
HOWTO(R_SPARC_PCPLT32, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT32", false,0,0x00000000,true), |
HOWTO(R_SPARC_PCPLT32, 0,0,00,FALSE,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT32", FALSE,0,0x00000000,TRUE), |
134 |
HOWTO(R_SPARC_PCPLT22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT22", false,0,0x00000000,true), |
HOWTO(R_SPARC_PCPLT22, 0,0,00,FALSE,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT22", FALSE,0,0x00000000,TRUE), |
135 |
HOWTO(R_SPARC_PCPLT10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT10", false,0,0x00000000,true), |
HOWTO(R_SPARC_PCPLT10, 0,0,00,FALSE,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PCPLT10", FALSE,0,0x00000000,TRUE), |
136 |
HOWTO(R_SPARC_10, 0,2,10,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_10", false,0,0x000003ff,true), |
HOWTO(R_SPARC_10, 0,2,10,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_10", FALSE,0,0x000003ff,TRUE), |
137 |
HOWTO(R_SPARC_11, 0,2,11,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_11", false,0,0x000007ff,true), |
HOWTO(R_SPARC_11, 0,2,11,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_11", FALSE,0,0x000007ff,TRUE), |
138 |
/* These are for sparc64 in a 64 bit environment. |
/* These are for sparc64 in a 64 bit environment. |
139 |
Values need to be here because the table is indexed by reloc number. */ |
Values need to be here because the table is indexed by reloc number. */ |
140 |
HOWTO(R_SPARC_64, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_64", false,0,0x00000000,true), |
HOWTO(R_SPARC_64, 0,0,00,FALSE,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_64", FALSE,0,0x00000000,TRUE), |
141 |
HOWTO(R_SPARC_OLO10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_OLO10", false,0,0x00000000,true), |
HOWTO(R_SPARC_OLO10, 0,0,00,FALSE,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_OLO10", FALSE,0,0x00000000,TRUE), |
142 |
HOWTO(R_SPARC_HH22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_HH22", false,0,0x00000000,true), |
HOWTO(R_SPARC_HH22, 0,0,00,FALSE,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_HH22", FALSE,0,0x00000000,TRUE), |
143 |
HOWTO(R_SPARC_HM10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_HM10", false,0,0x00000000,true), |
HOWTO(R_SPARC_HM10, 0,0,00,FALSE,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_HM10", FALSE,0,0x00000000,TRUE), |
144 |
HOWTO(R_SPARC_LM22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_LM22", false,0,0x00000000,true), |
HOWTO(R_SPARC_LM22, 0,0,00,FALSE,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_LM22", FALSE,0,0x00000000,TRUE), |
145 |
HOWTO(R_SPARC_PC_HH22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PC_HH22", false,0,0x00000000,true), |
HOWTO(R_SPARC_PC_HH22, 0,0,00,FALSE,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PC_HH22", FALSE,0,0x00000000,TRUE), |
146 |
HOWTO(R_SPARC_PC_HM10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PC_HM10", false,0,0x00000000,true), |
HOWTO(R_SPARC_PC_HM10, 0,0,00,FALSE,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PC_HM10", FALSE,0,0x00000000,TRUE), |
147 |
HOWTO(R_SPARC_PC_LM22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PC_LM22", false,0,0x00000000,true), |
HOWTO(R_SPARC_PC_LM22, 0,0,00,FALSE,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_PC_LM22", FALSE,0,0x00000000,TRUE), |
148 |
/* End sparc64 in 64 bit environment values. |
/* End sparc64 in 64 bit environment values. |
149 |
The following are for sparc64 in a 32 bit environment. */ |
The following are for sparc64 in a 32 bit environment. */ |
150 |
HOWTO(R_SPARC_WDISP16, 2,2,16,true, 0,complain_overflow_signed, sparc_elf_wdisp16_reloc,"R_SPARC_WDISP16", false,0,0x00000000,true), |
HOWTO(R_SPARC_WDISP16, 2,2,16,TRUE, 0,complain_overflow_signed, sparc_elf_wdisp16_reloc,"R_SPARC_WDISP16", FALSE,0,0x00000000,TRUE), |
151 |
HOWTO(R_SPARC_WDISP19, 2,2,19,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP19", false,0,0x0007ffff,true), |
HOWTO(R_SPARC_WDISP19, 2,2,19,TRUE, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP19", FALSE,0,0x0007ffff,TRUE), |
152 |
HOWTO(R_SPARC_UNUSED_42, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_UNUSED_42",false,0,0x00000000,true), |
HOWTO(R_SPARC_UNUSED_42, 0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_UNUSED_42",FALSE,0,0x00000000,TRUE), |
153 |
HOWTO(R_SPARC_7, 0,2, 7,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_7", false,0,0x0000007f,true), |
HOWTO(R_SPARC_7, 0,2, 7,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_7", FALSE,0,0x0000007f,TRUE), |
154 |
HOWTO(R_SPARC_5, 0,2, 5,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_5", false,0,0x0000001f,true), |
HOWTO(R_SPARC_5, 0,2, 5,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_5", FALSE,0,0x0000001f,TRUE), |
155 |
HOWTO(R_SPARC_6, 0,2, 6,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_6", false,0,0x0000003f,true), |
HOWTO(R_SPARC_6, 0,2, 6,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_6", FALSE,0,0x0000003f,TRUE), |
156 |
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true), |
HOWTO(R_SPARC_NONE, 0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", FALSE,0,0x00000000,TRUE), |
157 |
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true), |
HOWTO(R_SPARC_NONE, 0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", FALSE,0,0x00000000,TRUE), |
158 |
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true), |
HOWTO(R_SPARC_NONE, 0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", FALSE,0,0x00000000,TRUE), |
159 |
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true), |
HOWTO(R_SPARC_NONE, 0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", FALSE,0,0x00000000,TRUE), |
160 |
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true), |
HOWTO(R_SPARC_NONE, 0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", FALSE,0,0x00000000,TRUE), |
161 |
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true), |
HOWTO(R_SPARC_NONE, 0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", FALSE,0,0x00000000,TRUE), |
162 |
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true), |
HOWTO(R_SPARC_NONE, 0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", FALSE,0,0x00000000,TRUE), |
163 |
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true), |
HOWTO(R_SPARC_NONE, 0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", FALSE,0,0x00000000,TRUE), |
164 |
HOWTO(R_SPARC_UA64, 0,0, 0,false,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_UA64", false,0,0x00000000,true), |
HOWTO(R_SPARC_UA64, 0,0, 0,FALSE,0,complain_overflow_dont, sparc_elf_notsupported_reloc, "R_SPARC_UA64", FALSE,0,0x00000000,TRUE), |
165 |
HOWTO(R_SPARC_UA16, 0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_UA16", false,0,0x0000ffff,true), |
HOWTO(R_SPARC_UA16, 0,1,16,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_UA16", FALSE,0,0x0000ffff,TRUE), |
166 |
HOWTO(R_SPARC_REV32, 0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_REV32", false,0,0xffffffff,true), |
HOWTO(R_SPARC_TLS_GD_HI22,10,2,22,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_GD_HI22",FALSE,0,0x003fffff,TRUE), |
167 |
|
HOWTO(R_SPARC_TLS_GD_LO10,0,2,10,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_GD_LO10",FALSE,0,0x000003ff,TRUE), |
168 |
|
HOWTO(R_SPARC_TLS_GD_ADD,0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_GD_ADD",FALSE,0,0x00000000,TRUE), |
169 |
|
HOWTO(R_SPARC_TLS_GD_CALL,2,2,30,TRUE,0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_TLS_GD_CALL",FALSE,0,0x3fffffff,TRUE), |
170 |
|
HOWTO(R_SPARC_TLS_LDM_HI22,10,2,22,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_LDM_HI22",FALSE,0,0x003fffff,TRUE), |
171 |
|
HOWTO(R_SPARC_TLS_LDM_LO10,0,2,10,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_LDM_LO10",FALSE,0,0x000003ff,TRUE), |
172 |
|
HOWTO(R_SPARC_TLS_LDM_ADD,0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_LDM_ADD",FALSE,0,0x00000000,TRUE), |
173 |
|
HOWTO(R_SPARC_TLS_LDM_CALL,2,2,30,TRUE,0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_TLS_LDM_CALL",FALSE,0,0x3fffffff,TRUE), |
174 |
|
HOWTO(R_SPARC_TLS_LDO_HIX22,0,2,0,FALSE,0,complain_overflow_bitfield,sparc_elf_hix22_reloc,"R_SPARC_TLS_LDO_HIX22",FALSE,0,0x003fffff, FALSE), |
175 |
|
HOWTO(R_SPARC_TLS_LDO_LOX10,0,2,0,FALSE,0,complain_overflow_dont, sparc_elf_lox10_reloc, "R_SPARC_TLS_LDO_LOX10",FALSE,0,0x000003ff, FALSE), |
176 |
|
HOWTO(R_SPARC_TLS_LDO_ADD,0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_LDO_ADD",FALSE,0,0x00000000,TRUE), |
177 |
|
HOWTO(R_SPARC_TLS_IE_HI22,10,2,22,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_IE_HI22",FALSE,0,0x003fffff,TRUE), |
178 |
|
HOWTO(R_SPARC_TLS_IE_LO10,0,2,10,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_IE_LO10",FALSE,0,0x000003ff,TRUE), |
179 |
|
HOWTO(R_SPARC_TLS_IE_LD,0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_IE_LD",FALSE,0,0x00000000,TRUE), |
180 |
|
HOWTO(R_SPARC_TLS_IE_LDX,0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_IE_LDX",FALSE,0,0x00000000,TRUE), |
181 |
|
HOWTO(R_SPARC_TLS_IE_ADD,0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_IE_ADD",FALSE,0,0x00000000,TRUE), |
182 |
|
HOWTO(R_SPARC_TLS_LE_HIX22,0,2,0,FALSE,0,complain_overflow_bitfield,sparc_elf_hix22_reloc, "R_SPARC_TLS_LE_HIX22",FALSE,0,0x003fffff, FALSE), |
183 |
|
HOWTO(R_SPARC_TLS_LE_LOX10,0,2,0,FALSE,0,complain_overflow_dont, sparc_elf_lox10_reloc, "R_SPARC_TLS_LE_LOX10",FALSE,0,0x000003ff, FALSE), |
184 |
|
HOWTO(R_SPARC_TLS_DTPMOD32,0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_DTPMOD32",FALSE,0,0x00000000,TRUE), |
185 |
|
HOWTO(R_SPARC_TLS_DTPMOD64,0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_DTPMOD64",FALSE,0,0x00000000,TRUE), |
186 |
|
HOWTO(R_SPARC_TLS_DTPOFF32,0,2,32,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,"R_SPARC_TLS_DTPOFF32",FALSE,0,0xffffffff,TRUE), |
187 |
|
HOWTO(R_SPARC_TLS_DTPOFF64,0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_DTPOFF64",FALSE,0,0x00000000,TRUE), |
188 |
|
HOWTO(R_SPARC_TLS_TPOFF32,0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_TPOFF32",FALSE,0,0x00000000,TRUE), |
189 |
|
HOWTO(R_SPARC_TLS_TPOFF64,0,0, 0,FALSE,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_TLS_TPOFF64",FALSE,0,0x00000000,TRUE) |
190 |
}; |
}; |
191 |
static reloc_howto_type elf32_sparc_vtinherit_howto = |
static reloc_howto_type elf32_sparc_vtinherit_howto = |
192 |
HOWTO (R_SPARC_GNU_VTINHERIT, 0,2,0,false,0,complain_overflow_dont, NULL, "R_SPARC_GNU_VTINHERIT", false,0, 0, false); |
HOWTO (R_SPARC_GNU_VTINHERIT, 0,2,0,FALSE,0,complain_overflow_dont, NULL, "R_SPARC_GNU_VTINHERIT", FALSE,0, 0, FALSE); |
193 |
static reloc_howto_type elf32_sparc_vtentry_howto = |
static reloc_howto_type elf32_sparc_vtentry_howto = |
194 |
HOWTO (R_SPARC_GNU_VTENTRY, 0,2,0,false,0,complain_overflow_dont, _bfd_elf_rel_vtable_reloc_fn,"R_SPARC_GNU_VTENTRY", false,0,0, false); |
HOWTO (R_SPARC_GNU_VTENTRY, 0,2,0,FALSE,0,complain_overflow_dont, _bfd_elf_rel_vtable_reloc_fn,"R_SPARC_GNU_VTENTRY", FALSE,0,0, FALSE); |
195 |
|
static reloc_howto_type elf32_sparc_rev32_howto = |
196 |
|
HOWTO(R_SPARC_REV32, 0,2,32,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_REV32", FALSE,0,0xffffffff,TRUE); |
197 |
|
|
198 |
struct elf_reloc_map { |
struct elf_reloc_map { |
199 |
bfd_reloc_code_real_type bfd_reloc_val; |
bfd_reloc_code_real_type bfd_reloc_val; |
245 |
{ BFD_RELOC_SPARC_7, R_SPARC_7 }, |
{ BFD_RELOC_SPARC_7, R_SPARC_7 }, |
246 |
{ BFD_RELOC_SPARC_5, R_SPARC_5 }, |
{ BFD_RELOC_SPARC_5, R_SPARC_5 }, |
247 |
{ BFD_RELOC_SPARC_6, R_SPARC_6 }, |
{ BFD_RELOC_SPARC_6, R_SPARC_6 }, |
248 |
{ BFD_RELOC_SPARC_REV32, R_SPARC_REV32 }, |
{ BFD_RELOC_SPARC_TLS_GD_HI22, R_SPARC_TLS_GD_HI22 }, |
249 |
|
{ BFD_RELOC_SPARC_TLS_GD_LO10, R_SPARC_TLS_GD_LO10 }, |
250 |
|
{ BFD_RELOC_SPARC_TLS_GD_ADD, R_SPARC_TLS_GD_ADD }, |
251 |
|
{ BFD_RELOC_SPARC_TLS_GD_CALL, R_SPARC_TLS_GD_CALL }, |
252 |
|
{ BFD_RELOC_SPARC_TLS_LDM_HI22, R_SPARC_TLS_LDM_HI22 }, |
253 |
|
{ BFD_RELOC_SPARC_TLS_LDM_LO10, R_SPARC_TLS_LDM_LO10 }, |
254 |
|
{ BFD_RELOC_SPARC_TLS_LDM_ADD, R_SPARC_TLS_LDM_ADD }, |
255 |
|
{ BFD_RELOC_SPARC_TLS_LDM_CALL, R_SPARC_TLS_LDM_CALL }, |
256 |
|
{ BFD_RELOC_SPARC_TLS_LDO_HIX22, R_SPARC_TLS_LDO_HIX22 }, |
257 |
|
{ BFD_RELOC_SPARC_TLS_LDO_LOX10, R_SPARC_TLS_LDO_LOX10 }, |
258 |
|
{ BFD_RELOC_SPARC_TLS_LDO_ADD, R_SPARC_TLS_LDO_ADD }, |
259 |
|
{ BFD_RELOC_SPARC_TLS_IE_HI22, R_SPARC_TLS_IE_HI22 }, |
260 |
|
{ BFD_RELOC_SPARC_TLS_IE_LO10, R_SPARC_TLS_IE_LO10 }, |
261 |
|
{ BFD_RELOC_SPARC_TLS_IE_LD, R_SPARC_TLS_IE_LD }, |
262 |
|
{ BFD_RELOC_SPARC_TLS_IE_LDX, R_SPARC_TLS_IE_LDX }, |
263 |
|
{ BFD_RELOC_SPARC_TLS_IE_ADD, R_SPARC_TLS_IE_ADD }, |
264 |
|
{ BFD_RELOC_SPARC_TLS_LE_HIX22, R_SPARC_TLS_LE_HIX22 }, |
265 |
|
{ BFD_RELOC_SPARC_TLS_LE_LOX10, R_SPARC_TLS_LE_LOX10 }, |
266 |
|
{ BFD_RELOC_SPARC_TLS_DTPMOD32, R_SPARC_TLS_DTPMOD32 }, |
267 |
|
{ BFD_RELOC_SPARC_TLS_DTPMOD64, R_SPARC_TLS_DTPMOD64 }, |
268 |
|
{ BFD_RELOC_SPARC_TLS_DTPOFF32, R_SPARC_TLS_DTPOFF32 }, |
269 |
|
{ BFD_RELOC_SPARC_TLS_DTPOFF64, R_SPARC_TLS_DTPOFF64 }, |
270 |
|
{ BFD_RELOC_SPARC_TLS_TPOFF32, R_SPARC_TLS_TPOFF32 }, |
271 |
|
{ BFD_RELOC_SPARC_TLS_TPOFF64, R_SPARC_TLS_TPOFF64 }, |
272 |
{ BFD_RELOC_VTABLE_INHERIT, R_SPARC_GNU_VTINHERIT }, |
{ BFD_RELOC_VTABLE_INHERIT, R_SPARC_GNU_VTINHERIT }, |
273 |
{ BFD_RELOC_VTABLE_ENTRY, R_SPARC_GNU_VTENTRY }, |
{ BFD_RELOC_VTABLE_ENTRY, R_SPARC_GNU_VTENTRY }, |
274 |
|
{ BFD_RELOC_SPARC_REV32, R_SPARC_REV32 } |
275 |
}; |
}; |
276 |
|
|
277 |
static reloc_howto_type * |
static reloc_howto_type * |
289 |
case BFD_RELOC_VTABLE_ENTRY: |
case BFD_RELOC_VTABLE_ENTRY: |
290 |
return &elf32_sparc_vtentry_howto; |
return &elf32_sparc_vtentry_howto; |
291 |
|
|
292 |
|
case BFD_RELOC_SPARC_REV32: |
293 |
|
return &elf32_sparc_rev32_howto; |
294 |
|
|
295 |
default: |
default: |
296 |
for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct elf_reloc_map); i++) |
for (i = 0; |
297 |
{ |
i < sizeof (sparc_reloc_map) / sizeof (struct elf_reloc_map); |
298 |
if (sparc_reloc_map[i].bfd_reloc_val == code) |
i++) |
299 |
return &_bfd_sparc_elf_howto_table[(int) sparc_reloc_map[i].elf_reloc_val]; |
{ |
300 |
} |
if (sparc_reloc_map[i].bfd_reloc_val == code) |
301 |
|
return (_bfd_sparc_elf_howto_table |
302 |
|
+ (int) sparc_reloc_map[i].elf_reloc_val); |
303 |
|
} |
304 |
} |
} |
305 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
306 |
return NULL; |
return NULL; |
325 |
cache_ptr->howto = &elf32_sparc_vtentry_howto; |
cache_ptr->howto = &elf32_sparc_vtentry_howto; |
326 |
break; |
break; |
327 |
|
|
328 |
|
case R_SPARC_REV32: |
329 |
|
cache_ptr->howto = &elf32_sparc_rev32_howto; |
330 |
|
break; |
331 |
|
|
332 |
default: |
default: |
333 |
BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_SPARC_max_std); |
BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_SPARC_max_std); |
334 |
cache_ptr->howto = &_bfd_sparc_elf_howto_table[ELF32_R_TYPE(dst->r_info)]; |
cache_ptr->howto = &_bfd_sparc_elf_howto_table[ELF32_R_TYPE(dst->r_info)]; |
389 |
if (output_bfd != NULL) |
if (output_bfd != NULL) |
390 |
return bfd_reloc_continue; |
return bfd_reloc_continue; |
391 |
|
|
392 |
if (reloc_entry->address > input_section->_cooked_size) |
if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) |
393 |
return bfd_reloc_outofrange; |
return bfd_reloc_outofrange; |
394 |
|
|
395 |
relocation = (symbol->value |
relocation = (symbol->value |
411 |
else |
else |
412 |
return bfd_reloc_ok; |
return bfd_reloc_ok; |
413 |
} |
} |
414 |
|
|
415 |
|
/* Handle the HIX22 reloc. */ |
416 |
|
|
417 |
|
static bfd_reloc_status_type |
418 |
|
sparc_elf_hix22_reloc (abfd, |
419 |
|
reloc_entry, |
420 |
|
symbol, |
421 |
|
data, |
422 |
|
input_section, |
423 |
|
output_bfd, |
424 |
|
error_message) |
425 |
|
bfd *abfd; |
426 |
|
arelent *reloc_entry; |
427 |
|
asymbol *symbol; |
428 |
|
PTR data; |
429 |
|
asection *input_section; |
430 |
|
bfd *output_bfd; |
431 |
|
char **error_message ATTRIBUTE_UNUSED; |
432 |
|
{ |
433 |
|
bfd_vma relocation; |
434 |
|
bfd_vma insn; |
435 |
|
|
436 |
|
if (output_bfd != (bfd *) NULL |
437 |
|
&& (symbol->flags & BSF_SECTION_SYM) == 0) |
438 |
|
{ |
439 |
|
reloc_entry->address += input_section->output_offset; |
440 |
|
return bfd_reloc_ok; |
441 |
|
} |
442 |
|
|
443 |
|
if (output_bfd != NULL) |
444 |
|
return bfd_reloc_continue; |
445 |
|
|
446 |
|
if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) |
447 |
|
return bfd_reloc_outofrange; |
448 |
|
|
449 |
|
relocation = (symbol->value |
450 |
|
+ symbol->section->output_section->vma |
451 |
|
+ symbol->section->output_offset); |
452 |
|
relocation += reloc_entry->addend; |
453 |
|
insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address); |
454 |
|
|
455 |
|
insn = (insn &~ (bfd_vma) 0x3fffff) | (((~relocation) >> 10) & 0x3fffff); |
456 |
|
bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address); |
457 |
|
|
458 |
|
return bfd_reloc_ok; |
459 |
|
} |
460 |
|
|
461 |
|
/* Handle the LOX10 reloc. */ |
462 |
|
|
463 |
|
static bfd_reloc_status_type |
464 |
|
sparc_elf_lox10_reloc (abfd, |
465 |
|
reloc_entry, |
466 |
|
symbol, |
467 |
|
data, |
468 |
|
input_section, |
469 |
|
output_bfd, |
470 |
|
error_message) |
471 |
|
bfd *abfd; |
472 |
|
arelent *reloc_entry; |
473 |
|
asymbol *symbol; |
474 |
|
PTR data; |
475 |
|
asection *input_section; |
476 |
|
bfd *output_bfd; |
477 |
|
char **error_message ATTRIBUTE_UNUSED; |
478 |
|
{ |
479 |
|
bfd_vma relocation; |
480 |
|
bfd_vma insn; |
481 |
|
|
482 |
|
if (output_bfd != (bfd *) NULL |
483 |
|
&& (symbol->flags & BSF_SECTION_SYM) == 0) |
484 |
|
{ |
485 |
|
reloc_entry->address += input_section->output_offset; |
486 |
|
return bfd_reloc_ok; |
487 |
|
} |
488 |
|
|
489 |
|
if (output_bfd != NULL) |
490 |
|
return bfd_reloc_continue; |
491 |
|
|
492 |
|
if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) |
493 |
|
return bfd_reloc_outofrange; |
494 |
|
|
495 |
|
relocation = (symbol->value |
496 |
|
+ symbol->section->output_section->vma |
497 |
|
+ symbol->section->output_offset); |
498 |
|
relocation += reloc_entry->addend; |
499 |
|
insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address); |
500 |
|
|
501 |
|
insn = (insn &~ (bfd_vma) 0x1fff) | 0x1c00 | (relocation & 0x3ff); |
502 |
|
bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address); |
503 |
|
|
504 |
|
return bfd_reloc_ok; |
505 |
|
} |
506 |
|
|
507 |
|
/* Support for core dump NOTE sections. */ |
508 |
|
|
509 |
|
static bfd_boolean |
510 |
|
elf32_sparc_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) |
511 |
|
{ |
512 |
|
switch (note->descsz) |
513 |
|
{ |
514 |
|
default: |
515 |
|
return FALSE; |
516 |
|
|
517 |
|
case 260: /* Solaris prpsinfo_t. */ |
518 |
|
elf_tdata (abfd)->core_program |
519 |
|
= _bfd_elfcore_strndup (abfd, note->descdata + 84, 16); |
520 |
|
elf_tdata (abfd)->core_command |
521 |
|
= _bfd_elfcore_strndup (abfd, note->descdata + 100, 80); |
522 |
|
break; |
523 |
|
|
524 |
|
case 336: /* Solaris psinfo_t. */ |
525 |
|
elf_tdata (abfd)->core_program |
526 |
|
= _bfd_elfcore_strndup (abfd, note->descdata + 88, 16); |
527 |
|
elf_tdata (abfd)->core_command |
528 |
|
= _bfd_elfcore_strndup (abfd, note->descdata + 104, 80); |
529 |
|
break; |
530 |
|
} |
531 |
|
|
532 |
|
return TRUE; |
533 |
|
} |
534 |
|
|
535 |
|
|
536 |
/* Functions for the SPARC ELF linker. */ |
/* Functions for the SPARC ELF linker. */ |
537 |
|
|
560 |
/* nop. */ |
/* nop. */ |
561 |
#define PLT_ENTRY_WORD2 SPARC_NOP |
#define PLT_ENTRY_WORD2 SPARC_NOP |
562 |
|
|
563 |
|
/* The SPARC linker needs to keep track of the number of relocs that it |
564 |
|
decides to copy as dynamic relocs in check_relocs for each symbol. |
565 |
|
This is so that it can later discard them if they are found to be |
566 |
|
unnecessary. We store the information in a field extending the |
567 |
|
regular ELF linker hash table. */ |
568 |
|
|
569 |
|
struct elf32_sparc_dyn_relocs |
570 |
|
{ |
571 |
|
struct elf32_sparc_dyn_relocs *next; |
572 |
|
|
573 |
|
/* The input section of the reloc. */ |
574 |
|
asection *sec; |
575 |
|
|
576 |
|
/* Total number of relocs copied for the input section. */ |
577 |
|
bfd_size_type count; |
578 |
|
|
579 |
|
/* Number of pc-relative relocs copied for the input section. */ |
580 |
|
bfd_size_type pc_count; |
581 |
|
}; |
582 |
|
|
583 |
|
/* SPARC ELF linker hash entry. */ |
584 |
|
|
585 |
|
struct elf32_sparc_link_hash_entry |
586 |
|
{ |
587 |
|
struct elf_link_hash_entry elf; |
588 |
|
|
589 |
|
/* Track dynamic relocs copied for this symbol. */ |
590 |
|
struct elf32_sparc_dyn_relocs *dyn_relocs; |
591 |
|
|
592 |
|
#define GOT_UNKNOWN 0 |
593 |
|
#define GOT_NORMAL 1 |
594 |
|
#define GOT_TLS_GD 2 |
595 |
|
#define GOT_TLS_IE 3 |
596 |
|
unsigned char tls_type; |
597 |
|
}; |
598 |
|
|
599 |
|
#define elf32_sparc_hash_entry(ent) ((struct elf32_sparc_link_hash_entry *)(ent)) |
600 |
|
|
601 |
|
struct elf32_sparc_obj_tdata |
602 |
|
{ |
603 |
|
struct elf_obj_tdata root; |
604 |
|
|
605 |
|
/* tls_type for each local got entry. */ |
606 |
|
char *local_got_tls_type; |
607 |
|
|
608 |
|
/* TRUE if TLS GD relocs has been seen for this object. */ |
609 |
|
bfd_boolean has_tlsgd; |
610 |
|
}; |
611 |
|
|
612 |
|
#define elf32_sparc_tdata(abfd) \ |
613 |
|
((struct elf32_sparc_obj_tdata *) (abfd)->tdata.any) |
614 |
|
|
615 |
|
#define elf32_sparc_local_got_tls_type(abfd) \ |
616 |
|
(elf32_sparc_tdata (abfd)->local_got_tls_type) |
617 |
|
|
618 |
|
static bfd_boolean |
619 |
|
elf32_sparc_mkobject (abfd) |
620 |
|
bfd *abfd; |
621 |
|
{ |
622 |
|
bfd_size_type amt = sizeof (struct elf32_sparc_obj_tdata); |
623 |
|
abfd->tdata.any = bfd_zalloc (abfd, amt); |
624 |
|
if (abfd->tdata.any == NULL) |
625 |
|
return FALSE; |
626 |
|
return TRUE; |
627 |
|
} |
628 |
|
|
629 |
|
/* SPARC ELF linker hash table. */ |
630 |
|
|
631 |
|
struct elf32_sparc_link_hash_table |
632 |
|
{ |
633 |
|
struct elf_link_hash_table elf; |
634 |
|
|
635 |
|
/* Short-cuts to get to dynamic linker sections. */ |
636 |
|
asection *sgot; |
637 |
|
asection *srelgot; |
638 |
|
asection *splt; |
639 |
|
asection *srelplt; |
640 |
|
asection *sdynbss; |
641 |
|
asection *srelbss; |
642 |
|
|
643 |
|
union { |
644 |
|
bfd_signed_vma refcount; |
645 |
|
bfd_vma offset; |
646 |
|
} tls_ldm_got; |
647 |
|
|
648 |
|
/* Small local sym to section mapping cache. */ |
649 |
|
struct sym_sec_cache sym_sec; |
650 |
|
}; |
651 |
|
|
652 |
|
/* Get the SPARC ELF linker hash table from a link_info structure. */ |
653 |
|
|
654 |
|
#define elf32_sparc_hash_table(p) \ |
655 |
|
((struct elf32_sparc_link_hash_table *) ((p)->hash)) |
656 |
|
|
657 |
|
/* Create an entry in an i386 ELF linker hash table. */ |
658 |
|
|
659 |
|
static struct bfd_hash_entry * |
660 |
|
link_hash_newfunc (entry, table, string) |
661 |
|
struct bfd_hash_entry *entry; |
662 |
|
struct bfd_hash_table *table; |
663 |
|
const char *string; |
664 |
|
{ |
665 |
|
/* Allocate the structure if it has not already been allocated by a |
666 |
|
subclass. */ |
667 |
|
if (entry == NULL) |
668 |
|
{ |
669 |
|
entry = bfd_hash_allocate (table, |
670 |
|
sizeof (struct elf32_sparc_link_hash_entry)); |
671 |
|
if (entry == NULL) |
672 |
|
return entry; |
673 |
|
} |
674 |
|
|
675 |
|
/* Call the allocation method of the superclass. */ |
676 |
|
entry = _bfd_elf_link_hash_newfunc (entry, table, string); |
677 |
|
if (entry != NULL) |
678 |
|
{ |
679 |
|
struct elf32_sparc_link_hash_entry *eh; |
680 |
|
|
681 |
|
eh = (struct elf32_sparc_link_hash_entry *) entry; |
682 |
|
eh->dyn_relocs = NULL; |
683 |
|
eh->tls_type = GOT_UNKNOWN; |
684 |
|
} |
685 |
|
|
686 |
|
return entry; |
687 |
|
} |
688 |
|
|
689 |
|
/* Create a SPARC ELF linker hash table. */ |
690 |
|
|
691 |
|
static struct bfd_link_hash_table * |
692 |
|
elf32_sparc_link_hash_table_create (abfd) |
693 |
|
bfd *abfd; |
694 |
|
{ |
695 |
|
struct elf32_sparc_link_hash_table *ret; |
696 |
|
bfd_size_type amt = sizeof (struct elf32_sparc_link_hash_table); |
697 |
|
|
698 |
|
ret = (struct elf32_sparc_link_hash_table *) bfd_zmalloc (amt); |
699 |
|
if (ret == NULL) |
700 |
|
return NULL; |
701 |
|
|
702 |
|
if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc)) |
703 |
|
{ |
704 |
|
free (ret); |
705 |
|
return NULL; |
706 |
|
} |
707 |
|
|
708 |
|
return &ret->elf.root; |
709 |
|
} |
710 |
|
|
711 |
|
/* Create .got and .rela.got sections in DYNOBJ, and set up |
712 |
|
shortcuts to them in our hash table. */ |
713 |
|
|
714 |
|
static bfd_boolean |
715 |
|
create_got_section (dynobj, info) |
716 |
|
bfd *dynobj; |
717 |
|
struct bfd_link_info *info; |
718 |
|
{ |
719 |
|
struct elf32_sparc_link_hash_table *htab; |
720 |
|
|
721 |
|
if (! _bfd_elf_create_got_section (dynobj, info)) |
722 |
|
return FALSE; |
723 |
|
|
724 |
|
htab = elf32_sparc_hash_table (info); |
725 |
|
htab->sgot = bfd_get_section_by_name (dynobj, ".got"); |
726 |
|
BFD_ASSERT (htab->sgot != NULL); |
727 |
|
|
728 |
|
htab->srelgot = bfd_make_section (dynobj, ".rela.got"); |
729 |
|
if (htab->srelgot == NULL |
730 |
|
|| ! bfd_set_section_flags (dynobj, htab->srelgot, SEC_ALLOC |
731 |
|
| SEC_LOAD |
732 |
|
| SEC_HAS_CONTENTS |
733 |
|
| SEC_IN_MEMORY |
734 |
|
| SEC_LINKER_CREATED |
735 |
|
| SEC_READONLY) |
736 |
|
|| ! bfd_set_section_alignment (dynobj, htab->srelgot, 2)) |
737 |
|
return FALSE; |
738 |
|
return TRUE; |
739 |
|
} |
740 |
|
|
741 |
|
/* Create .plt, .rela.plt, .got, .rela.got, .dynbss, and |
742 |
|
.rela.bss sections in DYNOBJ, and set up shortcuts to them in our |
743 |
|
hash table. */ |
744 |
|
|
745 |
|
static bfd_boolean |
746 |
|
elf32_sparc_create_dynamic_sections (dynobj, info) |
747 |
|
bfd *dynobj; |
748 |
|
struct bfd_link_info *info; |
749 |
|
{ |
750 |
|
struct elf32_sparc_link_hash_table *htab; |
751 |
|
|
752 |
|
htab = elf32_sparc_hash_table (info); |
753 |
|
if (!htab->sgot && !create_got_section (dynobj, info)) |
754 |
|
return FALSE; |
755 |
|
|
756 |
|
if (!_bfd_elf_create_dynamic_sections (dynobj, info)) |
757 |
|
return FALSE; |
758 |
|
|
759 |
|
htab->splt = bfd_get_section_by_name (dynobj, ".plt"); |
760 |
|
htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt"); |
761 |
|
htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss"); |
762 |
|
if (!info->shared) |
763 |
|
htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss"); |
764 |
|
|
765 |
|
if (!htab->splt || !htab->srelplt || !htab->sdynbss |
766 |
|
|| (!info->shared && !htab->srelbss)) |
767 |
|
abort (); |
768 |
|
|
769 |
|
return TRUE; |
770 |
|
} |
771 |
|
|
772 |
|
/* Copy the extra info we tack onto an elf_link_hash_entry. */ |
773 |
|
|
774 |
|
static void |
775 |
|
elf32_sparc_copy_indirect_symbol (bed, dir, ind) |
776 |
|
const struct elf_backend_data *bed; |
777 |
|
struct elf_link_hash_entry *dir, *ind; |
778 |
|
{ |
779 |
|
struct elf32_sparc_link_hash_entry *edir, *eind; |
780 |
|
|
781 |
|
edir = (struct elf32_sparc_link_hash_entry *) dir; |
782 |
|
eind = (struct elf32_sparc_link_hash_entry *) ind; |
783 |
|
|
784 |
|
if (eind->dyn_relocs != NULL) |
785 |
|
{ |
786 |
|
if (edir->dyn_relocs != NULL) |
787 |
|
{ |
788 |
|
struct elf32_sparc_dyn_relocs **pp; |
789 |
|
struct elf32_sparc_dyn_relocs *p; |
790 |
|
|
791 |
|
if (ind->root.type == bfd_link_hash_indirect) |
792 |
|
abort (); |
793 |
|
|
794 |
|
/* Add reloc counts against the weak sym to the strong sym |
795 |
|
list. Merge any entries against the same section. */ |
796 |
|
for (pp = &eind->dyn_relocs; (p = *pp) != NULL; ) |
797 |
|
{ |
798 |
|
struct elf32_sparc_dyn_relocs *q; |
799 |
|
|
800 |
|
for (q = edir->dyn_relocs; q != NULL; q = q->next) |
801 |
|
if (q->sec == p->sec) |
802 |
|
{ |
803 |
|
q->pc_count += p->pc_count; |
804 |
|
q->count += p->count; |
805 |
|
*pp = p->next; |
806 |
|
break; |
807 |
|
} |
808 |
|
if (q == NULL) |
809 |
|
pp = &p->next; |
810 |
|
} |
811 |
|
*pp = edir->dyn_relocs; |
812 |
|
} |
813 |
|
|
814 |
|
edir->dyn_relocs = eind->dyn_relocs; |
815 |
|
eind->dyn_relocs = NULL; |
816 |
|
} |
817 |
|
|
818 |
|
if (ind->root.type == bfd_link_hash_indirect |
819 |
|
&& dir->got.refcount <= 0) |
820 |
|
{ |
821 |
|
edir->tls_type = eind->tls_type; |
822 |
|
eind->tls_type = GOT_UNKNOWN; |
823 |
|
} |
824 |
|
_bfd_elf_link_hash_copy_indirect (bed, dir, ind); |
825 |
|
} |
826 |
|
|
827 |
|
static int |
828 |
|
elf32_sparc_tls_transition (info, abfd, r_type, is_local) |
829 |
|
struct bfd_link_info *info; |
830 |
|
bfd *abfd; |
831 |
|
int r_type; |
832 |
|
int is_local; |
833 |
|
{ |
834 |
|
if (r_type == R_SPARC_TLS_GD_HI22 |
835 |
|
&& ! elf32_sparc_tdata (abfd)->has_tlsgd) |
836 |
|
r_type = R_SPARC_REV32; |
837 |
|
|
838 |
|
if (info->shared) |
839 |
|
return r_type; |
840 |
|
|
841 |
|
switch (r_type) |
842 |
|
{ |
843 |
|
case R_SPARC_TLS_GD_HI22: |
844 |
|
if (is_local) |
845 |
|
return R_SPARC_TLS_LE_HIX22; |
846 |
|
return R_SPARC_TLS_IE_HI22; |
847 |
|
case R_SPARC_TLS_GD_LO10: |
848 |
|
if (is_local) |
849 |
|
return R_SPARC_TLS_LE_LOX10; |
850 |
|
return R_SPARC_TLS_IE_LO10; |
851 |
|
case R_SPARC_TLS_IE_HI22: |
852 |
|
if (is_local) |
853 |
|
return R_SPARC_TLS_LE_HIX22; |
854 |
|
return r_type; |
855 |
|
case R_SPARC_TLS_IE_LO10: |
856 |
|
if (is_local) |
857 |
|
return R_SPARC_TLS_LE_LOX10; |
858 |
|
return r_type; |
859 |
|
case R_SPARC_TLS_LDM_HI22: |
860 |
|
return R_SPARC_TLS_LE_HIX22; |
861 |
|
case R_SPARC_TLS_LDM_LO10: |
862 |
|
return R_SPARC_TLS_LE_LOX10; |
863 |
|
} |
864 |
|
|
865 |
|
return r_type; |
866 |
|
} |
867 |
|
|
868 |
/* Look through the relocs for a section during the first phase, and |
/* Look through the relocs for a section during the first phase, and |
869 |
allocate space in the global offset table or procedure linkage |
allocate space in the global offset table or procedure linkage |
870 |
table. */ |
table. */ |
871 |
|
|
872 |
static boolean |
static bfd_boolean |
873 |
elf32_sparc_check_relocs (abfd, info, sec, relocs) |
elf32_sparc_check_relocs (abfd, info, sec, relocs) |
874 |
bfd *abfd; |
bfd *abfd; |
875 |
struct bfd_link_info *info; |
struct bfd_link_info *info; |
876 |
asection *sec; |
asection *sec; |
877 |
const Elf_Internal_Rela *relocs; |
const Elf_Internal_Rela *relocs; |
878 |
{ |
{ |
879 |
bfd *dynobj; |
struct elf32_sparc_link_hash_table *htab; |
880 |
Elf_Internal_Shdr *symtab_hdr; |
Elf_Internal_Shdr *symtab_hdr; |
881 |
struct elf_link_hash_entry **sym_hashes; |
struct elf_link_hash_entry **sym_hashes; |
882 |
bfd_vma *local_got_offsets; |
bfd_vma *local_got_offsets; |
883 |
const Elf_Internal_Rela *rel; |
const Elf_Internal_Rela *rel; |
884 |
const Elf_Internal_Rela *rel_end; |
const Elf_Internal_Rela *rel_end; |
|
asection *sgot; |
|
|
asection *srelgot; |
|
885 |
asection *sreloc; |
asection *sreloc; |
886 |
|
bfd_boolean checked_tlsgd = FALSE; |
887 |
|
|
888 |
if (info->relocateable) |
if (info->relocatable) |
889 |
return true; |
return TRUE; |
890 |
|
|
891 |
dynobj = elf_hash_table (info)->dynobj; |
htab = elf32_sparc_hash_table (info); |
892 |
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
893 |
sym_hashes = elf_sym_hashes (abfd); |
sym_hashes = elf_sym_hashes (abfd); |
894 |
local_got_offsets = elf_local_got_offsets (abfd); |
local_got_offsets = elf_local_got_offsets (abfd); |
895 |
|
|
|
sgot = NULL; |
|
|
srelgot = NULL; |
|
896 |
sreloc = NULL; |
sreloc = NULL; |
897 |
|
|
898 |
rel_end = relocs + sec->reloc_count; |
rel_end = relocs + sec->reloc_count; |
899 |
for (rel = relocs; rel < rel_end; rel++) |
for (rel = relocs; rel < rel_end; rel++) |
900 |
{ |
{ |
901 |
|
unsigned int r_type; |
902 |
unsigned long r_symndx; |
unsigned long r_symndx; |
903 |
struct elf_link_hash_entry *h; |
struct elf_link_hash_entry *h; |
904 |
|
|
905 |
r_symndx = ELF32_R_SYM (rel->r_info); |
r_symndx = ELF32_R_SYM (rel->r_info); |
906 |
|
r_type = ELF32_R_TYPE (rel->r_info); |
907 |
|
|
908 |
|
if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr)) |
909 |
|
{ |
910 |
|
(*_bfd_error_handler) (_("%B: bad symbol index: %d"), |
911 |
|
abfd, r_symndx); |
912 |
|
return FALSE; |
913 |
|
} |
914 |
|
|
915 |
if (r_symndx < symtab_hdr->sh_info) |
if (r_symndx < symtab_hdr->sh_info) |
916 |
h = NULL; |
h = NULL; |
917 |
else |
else |
918 |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
919 |
|
|
920 |
switch (ELF32_R_TYPE (rel->r_info)) |
/* Compatibility with old R_SPARC_REV32 reloc conflicting |
921 |
|
with R_SPARC_TLS_GD_HI22. */ |
922 |
|
if (! checked_tlsgd) |
923 |
|
switch (r_type) |
924 |
|
{ |
925 |
|
case R_SPARC_TLS_GD_HI22: |
926 |
|
{ |
927 |
|
const Elf_Internal_Rela *relt; |
928 |
|
|
929 |
|
for (relt = rel + 1; relt < rel_end; relt++) |
930 |
|
if (ELF32_R_TYPE (relt->r_info) == R_SPARC_TLS_GD_LO10 |
931 |
|
|| ELF32_R_TYPE (relt->r_info) == R_SPARC_TLS_GD_ADD |
932 |
|
|| ELF32_R_TYPE (relt->r_info) == R_SPARC_TLS_GD_CALL) |
933 |
|
break; |
934 |
|
checked_tlsgd = TRUE; |
935 |
|
elf32_sparc_tdata (abfd)->has_tlsgd = relt < rel_end; |
936 |
|
} |
937 |
|
break; |
938 |
|
case R_SPARC_TLS_GD_LO10: |
939 |
|
case R_SPARC_TLS_GD_ADD: |
940 |
|
case R_SPARC_TLS_GD_CALL: |
941 |
|
checked_tlsgd = TRUE; |
942 |
|
elf32_sparc_tdata (abfd)->has_tlsgd = TRUE; |
943 |
|
break; |
944 |
|
} |
945 |
|
|
946 |
|
r_type = elf32_sparc_tls_transition (info, abfd, r_type, h == NULL); |
947 |
|
switch (r_type) |
948 |
{ |
{ |
949 |
|
case R_SPARC_TLS_LDM_HI22: |
950 |
|
case R_SPARC_TLS_LDM_LO10: |
951 |
|
htab->tls_ldm_got.refcount += 1; |
952 |
|
break; |
953 |
|
|
954 |
|
case R_SPARC_TLS_LE_HIX22: |
955 |
|
case R_SPARC_TLS_LE_LOX10: |
956 |
|
if (info->shared) |
957 |
|
goto r_sparc_plt32; |
958 |
|
break; |
959 |
|
|
960 |
|
case R_SPARC_TLS_IE_HI22: |
961 |
|
case R_SPARC_TLS_IE_LO10: |
962 |
|
if (info->shared) |
963 |
|
info->flags |= DF_STATIC_TLS; |
964 |
|
/* Fall through */ |
965 |
|
|
966 |
case R_SPARC_GOT10: |
case R_SPARC_GOT10: |
967 |
case R_SPARC_GOT13: |
case R_SPARC_GOT13: |
968 |
case R_SPARC_GOT22: |
case R_SPARC_GOT22: |
969 |
|
case R_SPARC_TLS_GD_HI22: |
970 |
|
case R_SPARC_TLS_GD_LO10: |
971 |
/* This symbol requires a global offset table entry. */ |
/* This symbol requires a global offset table entry. */ |
972 |
|
{ |
973 |
|
int tls_type, old_tls_type; |
974 |
|
|
975 |
if (dynobj == NULL) |
switch (r_type) |
976 |
{ |
{ |
977 |
/* Create the .got section. */ |
default: |
978 |
elf_hash_table (info)->dynobj = dynobj = abfd; |
case R_SPARC_GOT10: |
979 |
if (! _bfd_elf_create_got_section (dynobj, info)) |
case R_SPARC_GOT13: |
980 |
return false; |
case R_SPARC_GOT22: |
981 |
} |
tls_type = GOT_NORMAL; |
982 |
|
break; |
983 |
if (sgot == NULL) |
case R_SPARC_TLS_GD_HI22: |
984 |
{ |
case R_SPARC_TLS_GD_LO10: |
985 |
sgot = bfd_get_section_by_name (dynobj, ".got"); |
tls_type = GOT_TLS_GD; |
986 |
BFD_ASSERT (sgot != NULL); |
break; |
987 |
} |
case R_SPARC_TLS_IE_HI22: |
988 |
|
case R_SPARC_TLS_IE_LO10: |
989 |
|
tls_type = GOT_TLS_IE; |
990 |
|
break; |
991 |
|
} |
992 |
|
|
993 |
if (srelgot == NULL |
if (h != NULL) |
994 |
&& (h != NULL || info->shared)) |
{ |
995 |
{ |
h->got.refcount += 1; |
996 |
srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); |
old_tls_type = elf32_sparc_hash_entry(h)->tls_type; |
997 |
if (srelgot == NULL) |
} |
998 |
{ |
else |
999 |
srelgot = bfd_make_section (dynobj, ".rela.got"); |
{ |
1000 |
if (srelgot == NULL |
bfd_signed_vma *local_got_refcounts; |
|
|| ! bfd_set_section_flags (dynobj, srelgot, |
|
|
(SEC_ALLOC |
|
|
| SEC_LOAD |
|
|
| SEC_HAS_CONTENTS |
|
|
| SEC_IN_MEMORY |
|
|
| SEC_LINKER_CREATED |
|
|
| SEC_READONLY)) |
|
|
|| ! bfd_set_section_alignment (dynobj, srelgot, 2)) |
|
|
return false; |
|
|
} |
|
|
} |
|
1001 |
|
|
1002 |
if (h != NULL) |
/* This is a global offset table entry for a local symbol. */ |
1003 |
{ |
local_got_refcounts = elf_local_got_refcounts (abfd); |
1004 |
if (h->got.offset != (bfd_vma) -1) |
if (local_got_refcounts == NULL) |
1005 |
{ |
{ |
1006 |
/* We have already allocated space in the .got. */ |
bfd_size_type size; |
|
break; |
|
|
} |
|
|
h->got.offset = sgot->_raw_size; |
|
1007 |
|
|
1008 |
/* Make sure this symbol is output as a dynamic symbol. */ |
size = symtab_hdr->sh_info; |
1009 |
if (h->dynindx == -1) |
size *= (sizeof (bfd_signed_vma) + sizeof(char)); |
1010 |
{ |
local_got_refcounts = ((bfd_signed_vma *) |
1011 |
if (! bfd_elf32_link_record_dynamic_symbol (info, h)) |
bfd_zalloc (abfd, size)); |
1012 |
return false; |
if (local_got_refcounts == NULL) |
1013 |
} |
return FALSE; |
1014 |
|
elf_local_got_refcounts (abfd) = local_got_refcounts; |
1015 |
|
elf32_sparc_local_got_tls_type (abfd) |
1016 |
|
= (char *) (local_got_refcounts + symtab_hdr->sh_info); |
1017 |
|
} |
1018 |
|
local_got_refcounts[r_symndx] += 1; |
1019 |
|
old_tls_type = elf32_sparc_local_got_tls_type (abfd) [r_symndx]; |
1020 |
|
} |
1021 |
|
|
1022 |
srelgot->_raw_size += sizeof (Elf32_External_Rela); |
/* If a TLS symbol is accessed using IE at least once, |
1023 |
} |
there is no point to use dynamic model for it. */ |
1024 |
else |
if (old_tls_type != tls_type && old_tls_type != GOT_UNKNOWN |
1025 |
{ |
&& (old_tls_type != GOT_TLS_GD |
1026 |
/* This is a global offset table entry for a local |
|| tls_type != GOT_TLS_IE)) |
1027 |
symbol. */ |
{ |
1028 |
if (local_got_offsets == NULL) |
if (old_tls_type == GOT_TLS_IE && tls_type == GOT_TLS_GD) |
1029 |
{ |
tls_type = old_tls_type; |
1030 |
bfd_size_type size; |
else |
1031 |
register unsigned int i; |
{ |
1032 |
|
(*_bfd_error_handler) |
1033 |
|
(_("%B: `%s' accessed both as normal and thread local symbol"), |
1034 |
|
abfd, h ? h->root.root.string : "<local>"); |
1035 |
|
return FALSE; |
1036 |
|
} |
1037 |
|
} |
1038 |
|
|
1039 |
size = symtab_hdr->sh_info; |
if (old_tls_type != tls_type) |
1040 |
size *= sizeof (bfd_vma); |
{ |
1041 |
local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size); |
if (h != NULL) |
1042 |
if (local_got_offsets == NULL) |
elf32_sparc_hash_entry (h)->tls_type = tls_type; |
1043 |
return false; |
else |
1044 |
elf_local_got_offsets (abfd) = local_got_offsets; |
elf32_sparc_local_got_tls_type (abfd) [r_symndx] = tls_type; |
1045 |
for (i = 0; i < symtab_hdr->sh_info; i++) |
} |
1046 |
local_got_offsets[i] = (bfd_vma) -1; |
} |
|
} |
|
|
if (local_got_offsets[r_symndx] != (bfd_vma) -1) |
|
|
{ |
|
|
/* We have already allocated space in the .got. */ |
|
|
break; |
|
|
} |
|
|
local_got_offsets[r_symndx] = sgot->_raw_size; |
|
1047 |
|
|
1048 |
if (info->shared) |
if (htab->sgot == NULL) |
1049 |
{ |
{ |
1050 |
/* If we are generating a shared object, we need to |
if (htab->elf.dynobj == NULL) |
1051 |
output a R_SPARC_RELATIVE reloc so that the |
htab->elf.dynobj = abfd; |
1052 |
dynamic linker can adjust this GOT entry. */ |
if (!create_got_section (htab->elf.dynobj, info)) |
1053 |
srelgot->_raw_size += sizeof (Elf32_External_Rela); |
return FALSE; |
|
} |
|
1054 |
} |
} |
|
|
|
|
sgot->_raw_size += 4; |
|
|
|
|
|
/* If the .got section is more than 0x1000 bytes, we add |
|
|
0x1000 to the value of _GLOBAL_OFFSET_TABLE_, so that 13 |
|
|
bit relocations have a greater chance of working. */ |
|
|
if (sgot->_raw_size >= 0x1000 |
|
|
&& elf_hash_table (info)->hgot->root.u.def.value == 0) |
|
|
elf_hash_table (info)->hgot->root.u.def.value = 0x1000; |
|
|
|
|
1055 |
break; |
break; |
1056 |
|
|
1057 |
|
case R_SPARC_TLS_GD_CALL: |
1058 |
|
case R_SPARC_TLS_LDM_CALL: |
1059 |
|
if (info->shared) |
1060 |
|
{ |
1061 |
|
/* These are basically R_SPARC_TLS_WPLT30 relocs against |
1062 |
|
__tls_get_addr. */ |
1063 |
|
struct bfd_link_hash_entry *bh = NULL; |
1064 |
|
if (! _bfd_generic_link_add_one_symbol (info, abfd, |
1065 |
|
"__tls_get_addr", 0, |
1066 |
|
bfd_und_section_ptr, 0, |
1067 |
|
NULL, FALSE, FALSE, |
1068 |
|
&bh)) |
1069 |
|
return FALSE; |
1070 |
|
h = (struct elf_link_hash_entry *) bh; |
1071 |
|
} |
1072 |
|
else |
1073 |
|
break; |
1074 |
|
/* Fall through */ |
1075 |
|
|
1076 |
case R_SPARC_PLT32: |
case R_SPARC_PLT32: |
1077 |
case R_SPARC_WPLT30: |
case R_SPARC_WPLT30: |
1078 |
/* This symbol requires a procedure linkage table entry. We |
/* This symbol requires a procedure linkage table entry. We |
1079 |
actually build the entry in adjust_dynamic_symbol, |
actually build the entry in adjust_dynamic_symbol, |
1080 |
because this might be a case of linking PIC code without |
because this might be a case of linking PIC code without |
1081 |
linking in any dynamic objects, in which case we don't |
linking in any dynamic objects, in which case we don't |
1082 |
need to generate a procedure linkage table after all. */ |
need to generate a procedure linkage table after all. */ |
1083 |
|
|
1084 |
if (h == NULL) |
if (h == NULL) |
1085 |
{ |
{ |
1086 |
/* The Solaris native assembler will generate a WPLT30 |
/* The Solaris native assembler will generate a WPLT30 |
1087 |
reloc for a local symbol if you assemble a call from |
reloc for a local symbol if you assemble a call from |
1088 |
one section to another when using -K pic. We treat |
one section to another when using -K pic. We treat |
1089 |
it as WDISP30. */ |
it as WDISP30. */ |
1090 |
if (ELF32_R_TYPE (rel->r_info) != R_SPARC_WPLT30) |
if (ELF32_R_TYPE (rel->r_info) == R_SPARC_PLT32) |
1091 |
goto r_sparc_plt32; |
goto r_sparc_plt32; |
1092 |
break; |
break; |
1093 |
} |
} |
1094 |
|
|
1095 |
/* Make sure this symbol is output as a dynamic symbol. */ |
h->needs_plt = 1; |
|
if (h->dynindx == -1) |
|
|
{ |
|
|
if (! bfd_elf32_link_record_dynamic_symbol (info, h)) |
|
|
return false; |
|
|
} |
|
|
|
|
|
h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; |
|
1096 |
|
|
1097 |
if (ELF32_R_TYPE (rel->r_info) != R_SPARC_WPLT30) |
if (ELF32_R_TYPE (rel->r_info) == R_SPARC_PLT32) |
1098 |
goto r_sparc_plt32; |
goto r_sparc_plt32; |
1099 |
|
h->plt.refcount += 1; |
1100 |
break; |
break; |
1101 |
|
|
1102 |
case R_SPARC_PC10: |
case R_SPARC_PC10: |
1103 |
case R_SPARC_PC22: |
case R_SPARC_PC22: |
1104 |
if (h != NULL) |
if (h != NULL) |
1105 |
h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF; |
h->non_got_ref = 1; |
1106 |
|
|
1107 |
if (h != NULL |
if (h != NULL |
1108 |
&& strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) |
&& strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) |
1109 |
break; |
break; |
1110 |
/* Fall through. */ |
/* Fall through. */ |
1111 |
|
|
1112 |
case R_SPARC_DISP8: |
case R_SPARC_DISP8: |
1113 |
case R_SPARC_DISP16: |
case R_SPARC_DISP16: |
1114 |
case R_SPARC_DISP32: |
case R_SPARC_DISP32: |
1116 |
case R_SPARC_WDISP22: |
case R_SPARC_WDISP22: |
1117 |
case R_SPARC_WDISP19: |
case R_SPARC_WDISP19: |
1118 |
case R_SPARC_WDISP16: |
case R_SPARC_WDISP16: |
|
if (h != NULL) |
|
|
h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF; |
|
|
|
|
|
/* If we are linking with -Bsymbolic, we do not need to copy |
|
|
a PC relative reloc against a global symbol which is |
|
|
defined in an object we are including in the link (i.e., |
|
|
DEF_REGULAR is set). FIXME: At this point we have not |
|
|
seen all the input files, so it is possible that |
|
|
DEF_REGULAR is not set now but will be set later (it is |
|
|
never cleared). This needs to be handled as in |
|
|
elf32-i386.c. */ |
|
|
if (h == NULL |
|
|
|| (info->symbolic |
|
|
&& (h->elf_link_hash_flags |
|
|
& ELF_LINK_HASH_DEF_REGULAR) != 0)) |
|
|
break; |
|
|
/* Fall through. */ |
|
1119 |
case R_SPARC_8: |
case R_SPARC_8: |
1120 |
case R_SPARC_16: |
case R_SPARC_16: |
1121 |
case R_SPARC_32: |
case R_SPARC_32: |
1126 |
case R_SPARC_UA16: |
case R_SPARC_UA16: |
1127 |
case R_SPARC_UA32: |
case R_SPARC_UA32: |
1128 |
if (h != NULL) |
if (h != NULL) |
1129 |
h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF; |
h->non_got_ref = 1; |
1130 |
|
|
1131 |
r_sparc_plt32: |
r_sparc_plt32: |
1132 |
if (info->shared && (sec->flags & SEC_ALLOC)) |
if (h != NULL && !info->shared) |
1133 |
{ |
{ |
1134 |
|
/* We may need a .plt entry if the function this reloc |
1135 |
|
refers to is in a shared lib. */ |
1136 |
|
h->plt.refcount += 1; |
1137 |
|
} |
1138 |
|
|
1139 |
|
/* If we are creating a shared library, and this is a reloc |
1140 |
|
against a global symbol, or a non PC relative reloc |
1141 |
|
against a local symbol, then we need to copy the reloc |
1142 |
|
into the shared library. However, if we are linking with |
1143 |
|
-Bsymbolic, we do not need to copy a reloc against a |
1144 |
|
global symbol which is defined in an object we are |
1145 |
|
including in the link (i.e., DEF_REGULAR is set). At |
1146 |
|
this point we have not seen all the input files, so it is |
1147 |
|
possible that DEF_REGULAR is not set now but will be set |
1148 |
|
later (it is never cleared). In case of a weak definition, |
1149 |
|
DEF_REGULAR may be cleared later by a strong definition in |
1150 |
|
a shared library. We account for that possibility below by |
1151 |
|
storing information in the relocs_copied field of the hash |
1152 |
|
table entry. A similar situation occurs when creating |
1153 |
|
shared libraries and symbol visibility changes render the |
1154 |
|
symbol local. |
1155 |
|
|
1156 |
|
If on the other hand, we are creating an executable, we |
1157 |
|
may need to keep relocations for symbols satisfied by a |
1158 |
|
dynamic library if we manage to avoid copy relocs for the |
1159 |
|
symbol. */ |
1160 |
|
if ((info->shared |
1161 |
|
&& (sec->flags & SEC_ALLOC) != 0 |
1162 |
|
&& (! _bfd_sparc_elf_howto_table[r_type].pc_relative |
1163 |
|
|| (h != NULL |
1164 |
|
&& (! info->symbolic |
1165 |
|
|| h->root.type == bfd_link_hash_defweak |
1166 |
|
|| !h->def_regular)))) |
1167 |
|
|| (!info->shared |
1168 |
|
&& (sec->flags & SEC_ALLOC) != 0 |
1169 |
|
&& h != NULL |
1170 |
|
&& (h->root.type == bfd_link_hash_defweak |
1171 |
|
|| !h->def_regular))) |
1172 |
|
{ |
1173 |
|
struct elf32_sparc_dyn_relocs *p; |
1174 |
|
struct elf32_sparc_dyn_relocs **head; |
1175 |
|
|
1176 |
/* When creating a shared object, we must copy these |
/* When creating a shared object, we must copy these |
1177 |
relocs into the output file. We create a reloc |
relocs into the output file. We create a reloc |
1178 |
section in dynobj and make room for the reloc. */ |
section in dynobj and make room for the reloc. */ |
1179 |
if (sreloc == NULL) |
if (sreloc == NULL) |
1180 |
{ |
{ |
1181 |
const char *name; |
const char *name; |
1182 |
|
bfd *dynobj; |
1183 |
|
|
1184 |
name = (bfd_elf_string_from_elf_section |
name = (bfd_elf_string_from_elf_section |
1185 |
(abfd, |
(abfd, |
1186 |
elf_elfheader (abfd)->e_shstrndx, |
elf_elfheader (abfd)->e_shstrndx, |
1187 |
elf_section_data (sec)->rel_hdr.sh_name)); |
elf_section_data (sec)->rel_hdr.sh_name)); |
1188 |
if (name == NULL) |
if (name == NULL) |
1189 |
return false; |
return FALSE; |
1190 |
|
|
1191 |
BFD_ASSERT (strncmp (name, ".rela", 5) == 0 |
BFD_ASSERT (strncmp (name, ".rela", 5) == 0 |
1192 |
&& strcmp (bfd_get_section_name (abfd, sec), |
&& strcmp (bfd_get_section_name (abfd, sec), |
1193 |
name + 5) == 0); |
name + 5) == 0); |
1194 |
|
|
1195 |
|
if (htab->elf.dynobj == NULL) |
1196 |
|
htab->elf.dynobj = abfd; |
1197 |
|
dynobj = htab->elf.dynobj; |
1198 |
|
|
1199 |
sreloc = bfd_get_section_by_name (dynobj, name); |
sreloc = bfd_get_section_by_name (dynobj, name); |
1200 |
if (sreloc == NULL) |
if (sreloc == NULL) |
1201 |
{ |
{ |
1209 |
if (sreloc == NULL |
if (sreloc == NULL |
1210 |
|| ! bfd_set_section_flags (dynobj, sreloc, flags) |
|| ! bfd_set_section_flags (dynobj, sreloc, flags) |
1211 |
|| ! bfd_set_section_alignment (dynobj, sreloc, 2)) |
|| ! bfd_set_section_alignment (dynobj, sreloc, 2)) |
1212 |
return false; |
return FALSE; |
1213 |
} |
} |
1214 |
if (sec->flags & SEC_READONLY) |
elf_section_data (sec)->sreloc = sreloc; |
1215 |
info->flags |= DF_TEXTREL; |
} |
1216 |
|
|
1217 |
|
/* If this is a global symbol, we count the number of |
1218 |
|
relocations we need for this symbol. */ |
1219 |
|
if (h != NULL) |
1220 |
|
head = &((struct elf32_sparc_link_hash_entry *) h)->dyn_relocs; |
1221 |
|
else |
1222 |
|
{ |
1223 |
|
/* Track dynamic relocs needed for local syms too. |
1224 |
|
We really need local syms available to do this |
1225 |
|
easily. Oh well. */ |
1226 |
|
|
1227 |
|
asection *s; |
1228 |
|
s = bfd_section_from_r_symndx (abfd, &htab->sym_sec, |
1229 |
|
sec, r_symndx); |
1230 |
|
if (s == NULL) |
1231 |
|
return FALSE; |
1232 |
|
|
1233 |
|
head = ((struct elf32_sparc_dyn_relocs **) |
1234 |
|
&elf_section_data (s)->local_dynrel); |
1235 |
} |
} |
1236 |
|
|
1237 |
sreloc->_raw_size += sizeof (Elf32_External_Rela); |
p = *head; |
1238 |
|
if (p == NULL || p->sec != sec) |
1239 |
|
{ |
1240 |
|
bfd_size_type amt = sizeof *p; |
1241 |
|
p = ((struct elf32_sparc_dyn_relocs *) |
1242 |
|
bfd_alloc (htab->elf.dynobj, amt)); |
1243 |
|
if (p == NULL) |
1244 |
|
return FALSE; |
1245 |
|
p->next = *head; |
1246 |
|
*head = p; |
1247 |
|
p->sec = sec; |
1248 |
|
p->count = 0; |
1249 |
|
p->pc_count = 0; |
1250 |
|
} |
1251 |
|
|
1252 |
|
p->count += 1; |
1253 |
|
if (_bfd_sparc_elf_howto_table[r_type].pc_relative) |
1254 |
|
p->pc_count += 1; |
1255 |
} |
} |
1256 |
|
|
1257 |
break; |
break; |
1258 |
|
|
1259 |
case R_SPARC_GNU_VTINHERIT: |
case R_SPARC_GNU_VTINHERIT: |
1260 |
if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) |
if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) |
1261 |
return false; |
return FALSE; |
1262 |
break; |
break; |
1263 |
|
|
1264 |
case R_SPARC_GNU_VTENTRY: |
case R_SPARC_GNU_VTENTRY: |
1265 |
if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend)) |
if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) |
1266 |
return false; |
return FALSE; |
1267 |
break; |
break; |
1268 |
|
|
1269 |
default: |
default: |
1270 |
break; |
break; |
1271 |
} |
} |
1272 |
} |
} |
1273 |
|
|
1274 |
return true; |
return TRUE; |
1275 |
} |
} |
1276 |
|
|
1277 |
static asection * |
static asection * |
1288 |
{ |
{ |
1289 |
case R_SPARC_GNU_VTINHERIT: |
case R_SPARC_GNU_VTINHERIT: |
1290 |
case R_SPARC_GNU_VTENTRY: |
case R_SPARC_GNU_VTENTRY: |
1291 |
break; |
break; |
1292 |
|
|
1293 |
default: |
default: |
1294 |
switch (h->root.type) |
switch (h->root.type) |
1295 |
{ |
{ |
1296 |
case bfd_link_hash_defined: |
case bfd_link_hash_defined: |
1297 |
case bfd_link_hash_defweak: |
case bfd_link_hash_defweak: |
1298 |
return h->root.u.def.section; |
return h->root.u.def.section; |
1299 |
|
|
1300 |
case bfd_link_hash_common: |
case bfd_link_hash_common: |
1301 |
return h->root.u.c.p->section; |
return h->root.u.c.p->section; |
1302 |
|
|
1303 |
default: |
default: |
1304 |
break; |
break; |
1305 |
} |
} |
1306 |
} |
} |
1307 |
} |
} |
1308 |
else |
else |
1312 |
} |
} |
1313 |
|
|
1314 |
/* Update the got entry reference counts for the section being removed. */ |
/* Update the got entry reference counts for the section being removed. */ |
1315 |
static boolean |
static bfd_boolean |
1316 |
elf32_sparc_gc_sweep_hook (abfd, info, sec, relocs) |
elf32_sparc_gc_sweep_hook (abfd, info, sec, relocs) |
1317 |
bfd *abfd; |
bfd *abfd; |
1318 |
struct bfd_link_info *info ATTRIBUTE_UNUSED; |
struct bfd_link_info *info ATTRIBUTE_UNUSED; |
1319 |
asection *sec; |
asection *sec; |
1320 |
const Elf_Internal_Rela *relocs; |
const Elf_Internal_Rela *relocs; |
1321 |
{ |
{ |
|
|
|
1322 |
Elf_Internal_Shdr *symtab_hdr; |
Elf_Internal_Shdr *symtab_hdr; |
1323 |
struct elf_link_hash_entry **sym_hashes; |
struct elf_link_hash_entry **sym_hashes; |
1324 |
bfd_signed_vma *local_got_refcounts; |
bfd_signed_vma *local_got_refcounts; |
1325 |
const Elf_Internal_Rela *rel, *relend; |
const Elf_Internal_Rela *rel, *relend; |
1326 |
unsigned long r_symndx; |
|
1327 |
struct elf_link_hash_entry *h; |
elf_section_data (sec)->local_dynrel = NULL; |
1328 |
|
|
1329 |
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
1330 |
sym_hashes = elf_sym_hashes (abfd); |
sym_hashes = elf_sym_hashes (abfd); |
1332 |
|
|
1333 |
relend = relocs + sec->reloc_count; |
relend = relocs + sec->reloc_count; |
1334 |
for (rel = relocs; rel < relend; rel++) |
for (rel = relocs; rel < relend; rel++) |
1335 |
switch (ELF32_R_TYPE (rel->r_info)) |
{ |
1336 |
{ |
unsigned long r_symndx; |
1337 |
case R_SPARC_GOT10: |
unsigned int r_type; |
1338 |
case R_SPARC_GOT13: |
struct elf_link_hash_entry *h = NULL; |
|
case R_SPARC_GOT22: |
|
|
r_symndx = ELF32_R_SYM (rel->r_info); |
|
|
if (r_symndx >= symtab_hdr->sh_info) |
|
|
{ |
|
|
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
|
|
if (h->got.refcount > 0) |
|
|
h->got.refcount--; |
|
|
} |
|
|
else |
|
|
{ |
|
|
if (local_got_refcounts[r_symndx] > 0) |
|
|
local_got_refcounts[r_symndx]--; |
|
|
} |
|
|
break; |
|
1339 |
|
|
1340 |
case R_SPARC_PLT32: |
r_symndx = ELF32_R_SYM (rel->r_info); |
1341 |
case R_SPARC_HIPLT22: |
if (r_symndx >= symtab_hdr->sh_info) |
1342 |
case R_SPARC_LOPLT10: |
{ |
1343 |
case R_SPARC_PCPLT32: |
struct elf32_sparc_link_hash_entry *eh; |
1344 |
case R_SPARC_PCPLT10: |
struct elf32_sparc_dyn_relocs **pp; |
1345 |
r_symndx = ELF32_R_SYM (rel->r_info); |
struct elf32_sparc_dyn_relocs *p; |
|
if (r_symndx >= symtab_hdr->sh_info) |
|
|
{ |
|
|
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
|
|
if (h->plt.refcount > 0) |
|
|
h->plt.refcount--; |
|
|
} |
|
|
break; |
|
1346 |
|
|
1347 |
default: |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
1348 |
break; |
while (h->root.type == bfd_link_hash_indirect |
1349 |
} |
|| h->root.type == bfd_link_hash_warning) |
1350 |
|
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
1351 |
|
eh = (struct elf32_sparc_link_hash_entry *) h; |
1352 |
|
for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next) |
1353 |
|
if (p->sec == sec) |
1354 |
|
{ |
1355 |
|
/* Everything must go for SEC. */ |
1356 |
|
*pp = p->next; |
1357 |
|
break; |
1358 |
|
} |
1359 |
|
} |
1360 |
|
|
1361 |
return true; |
r_type = ELF32_R_TYPE (rel->r_info); |
1362 |
|
r_type = elf32_sparc_tls_transition (info, abfd, r_type, h != NULL); |
1363 |
|
switch (r_type) |
1364 |
|
{ |
1365 |
|
case R_SPARC_TLS_LDM_HI22: |
1366 |
|
case R_SPARC_TLS_LDM_LO10: |
1367 |
|
if (elf32_sparc_hash_table (info)->tls_ldm_got.refcount > 0) |
1368 |
|
elf32_sparc_hash_table (info)->tls_ldm_got.refcount -= 1; |
1369 |
|
break; |
1370 |
|
|
1371 |
|
case R_SPARC_TLS_GD_HI22: |
1372 |
|
case R_SPARC_TLS_GD_LO10: |
1373 |
|
case R_SPARC_TLS_IE_HI22: |
1374 |
|
case R_SPARC_TLS_IE_LO10: |
1375 |
|
case R_SPARC_GOT10: |
1376 |
|
case R_SPARC_GOT13: |
1377 |
|
case R_SPARC_GOT22: |
1378 |
|
if (h != NULL) |
1379 |
|
{ |
1380 |
|
if (h->got.refcount > 0) |
1381 |
|
h->got.refcount--; |
1382 |
|
} |
1383 |
|
else |
1384 |
|
{ |
1385 |
|
if (local_got_refcounts[r_symndx] > 0) |
1386 |
|
local_got_refcounts[r_symndx]--; |
1387 |
|
} |
1388 |
|
break; |
1389 |
|
|
1390 |
|
case R_SPARC_PC10: |
1391 |
|
case R_SPARC_PC22: |
1392 |
|
if (h != NULL |
1393 |
|
&& strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) |
1394 |
|
break; |
1395 |
|
/* Fall through. */ |
1396 |
|
|
1397 |
|
case R_SPARC_DISP8: |
1398 |
|
case R_SPARC_DISP16: |
1399 |
|
case R_SPARC_DISP32: |
1400 |
|
case R_SPARC_WDISP30: |
1401 |
|
case R_SPARC_WDISP22: |
1402 |
|
case R_SPARC_WDISP19: |
1403 |
|
case R_SPARC_WDISP16: |
1404 |
|
case R_SPARC_8: |
1405 |
|
case R_SPARC_16: |
1406 |
|
case R_SPARC_32: |
1407 |
|
case R_SPARC_HI22: |
1408 |
|
case R_SPARC_22: |
1409 |
|
case R_SPARC_13: |
1410 |
|
case R_SPARC_LO10: |
1411 |
|
case R_SPARC_UA16: |
1412 |
|
case R_SPARC_UA32: |
1413 |
|
case R_SPARC_PLT32: |
1414 |
|
if (info->shared) |
1415 |
|
break; |
1416 |
|
/* Fall through. */ |
1417 |
|
|
1418 |
|
case R_SPARC_WPLT30: |
1419 |
|
if (h != NULL) |
1420 |
|
{ |
1421 |
|
if (h->plt.refcount > 0) |
1422 |
|
h->plt.refcount--; |
1423 |
|
} |
1424 |
|
break; |
1425 |
|
|
1426 |
|
default: |
1427 |
|
break; |
1428 |
|
} |
1429 |
|
} |
1430 |
|
|
1431 |
|
return TRUE; |
1432 |
} |
} |
1433 |
|
|
1434 |
/* Adjust a symbol defined by a dynamic object and referenced by a |
/* Adjust a symbol defined by a dynamic object and referenced by a |
1437 |
change the definition to something the rest of the link can |
change the definition to something the rest of the link can |
1438 |
understand. */ |
understand. */ |
1439 |
|
|
1440 |
static boolean |
static bfd_boolean |
1441 |
elf32_sparc_adjust_dynamic_symbol (info, h) |
elf32_sparc_adjust_dynamic_symbol (info, h) |
1442 |
struct bfd_link_info *info; |
struct bfd_link_info *info; |
1443 |
struct elf_link_hash_entry *h; |
struct elf_link_hash_entry *h; |
1444 |
{ |
{ |
1445 |
bfd *dynobj; |
struct elf32_sparc_link_hash_table *htab; |
1446 |
|
struct elf32_sparc_link_hash_entry * eh; |
1447 |
|
struct elf32_sparc_dyn_relocs *p; |
1448 |
asection *s; |
asection *s; |
1449 |
unsigned int power_of_two; |
unsigned int power_of_two; |
1450 |
|
|
1451 |
dynobj = elf_hash_table (info)->dynobj; |
htab = elf32_sparc_hash_table (info); |
1452 |
|
|
1453 |
/* Make sure we know what is going on here. */ |
/* Make sure we know what is going on here. */ |
1454 |
BFD_ASSERT (dynobj != NULL |
BFD_ASSERT (htab->elf.dynobj != NULL |
1455 |
&& ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) |
&& (h->needs_plt |
1456 |
|| h->weakdef != NULL |
|| h->u.weakdef != NULL |
1457 |
|| ((h->elf_link_hash_flags |
|| (h->def_dynamic |
1458 |
& ELF_LINK_HASH_DEF_DYNAMIC) != 0 |
&& h->ref_regular |
1459 |
&& (h->elf_link_hash_flags |
&& !h->def_regular))); |
|
& ELF_LINK_HASH_REF_REGULAR) != 0 |
|
|
&& (h->elf_link_hash_flags |
|
|
& ELF_LINK_HASH_DEF_REGULAR) == 0))); |
|
1460 |
|
|
1461 |
/* If this is a function, put it in the procedure linkage table. We |
/* If this is a function, put it in the procedure linkage table. We |
1462 |
will fill in the contents of the procedure linkage table later |
will fill in the contents of the procedure linkage table later |
1466 |
some of their functions as STT_NOTYPE when they really should be |
some of their functions as STT_NOTYPE when they really should be |
1467 |
STT_FUNC. */ |
STT_FUNC. */ |
1468 |
if (h->type == STT_FUNC |
if (h->type == STT_FUNC |
1469 |
|| (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0 |
|| h->needs_plt |
1470 |
|| (h->type == STT_NOTYPE |
|| (h->type == STT_NOTYPE |
1471 |
&& (h->root.type == bfd_link_hash_defined |
&& (h->root.type == bfd_link_hash_defined |
1472 |
|| h->root.type == bfd_link_hash_defweak) |
|| h->root.type == bfd_link_hash_defweak) |
1473 |
&& (h->root.u.def.section->flags & SEC_CODE) != 0)) |
&& (h->root.u.def.section->flags & SEC_CODE) != 0)) |
1474 |
{ |
{ |
1475 |
if (! elf_hash_table (info)->dynamic_sections_created |
if (h->plt.refcount <= 0 |
1476 |
|| ((!info->shared || info->symbolic || h->dynindx == -1) |
|| (! info->shared |
1477 |
&& (h->elf_link_hash_flags |
&& !h->def_dynamic |
1478 |
& ELF_LINK_HASH_DEF_REGULAR) != 0)) |
&& !h->ref_dynamic |
1479 |
|
&& h->root.type != bfd_link_hash_undefweak |
1480 |
|
&& h->root.type != bfd_link_hash_undefined)) |
1481 |
{ |
{ |
1482 |
/* This case can occur if we saw a WPLT30 reloc in an input |
/* This case can occur if we saw a WPLT30 reloc in an input |
1483 |
file, but none of the input files were dynamic objects. |
file, but the symbol was never referred to by a dynamic |
1484 |
Or, when linking the main application or a -Bsymbolic |
object, or if all references were garbage collected. In |
1485 |
shared library against PIC code. Or when a global symbol |
such a case, we don't actually need to build a procedure |
1486 |
has been made private, e.g. via versioning. |
linkage table, and we can just do a WDISP30 reloc instead. */ |
1487 |
|
h->plt.offset = (bfd_vma) -1; |
1488 |
In these cases we know what value the symbol will resolve |
h->needs_plt = 0; |
|
to, so we don't actually need to build a procedure linkage |
|
|
table, and we can just do a WDISP30 reloc instead. */ |
|
|
|
|
|
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; |
|
|
return true; |
|
1489 |
} |
} |
1490 |
|
|
1491 |
s = bfd_get_section_by_name (dynobj, ".plt"); |
return TRUE; |
|
BFD_ASSERT (s != NULL); |
|
|
|
|
|
/* The first four entries in .plt are reserved. */ |
|
|
if (s->_raw_size == 0) |
|
|
s->_raw_size = 4 * PLT_ENTRY_SIZE; |
|
|
|
|
|
/* The procedure linkage table has a maximum size. */ |
|
|
if (s->_raw_size >= 0x400000) |
|
|
{ |
|
|
bfd_set_error (bfd_error_bad_value); |
|
|
return false; |
|
|
} |
|
|
|
|
|
/* If this symbol is not defined in a regular file, and we are |
|
|
not generating a shared library, then set the symbol to this |
|
|
location in the .plt. This is required to make function |
|
|
pointers compare as equal between the normal executable and |
|
|
the shared library. */ |
|
|
if (! info->shared |
|
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) |
|
|
{ |
|
|
h->root.u.def.section = s; |
|
|
h->root.u.def.value = s->_raw_size; |
|
|
} |
|
|
|
|
|
h->plt.offset = s->_raw_size; |
|
|
|
|
|
/* Make room for this entry. */ |
|
|
s->_raw_size += PLT_ENTRY_SIZE; |
|
|
|
|
|
/* We also need to make an entry in the .rela.plt section. */ |
|
|
|
|
|
s = bfd_get_section_by_name (dynobj, ".rela.plt"); |
|
|
BFD_ASSERT (s != NULL); |
|
|
s->_raw_size += sizeof (Elf32_External_Rela); |
|
|
|
|
|
return true; |
|
1492 |
} |
} |
1493 |
|
else |
1494 |
|
h->plt.offset = (bfd_vma) -1; |
1495 |
|
|
1496 |
/* If this is a weak symbol, and there is a real definition, the |
/* If this is a weak symbol, and there is a real definition, the |
1497 |
processor independent code will have arranged for us to see the |
processor independent code will have arranged for us to see the |
1498 |
real definition first, and we can just use the same value. */ |
real definition first, and we can just use the same value. */ |
1499 |
if (h->weakdef != NULL) |
if (h->u.weakdef != NULL) |
1500 |
{ |
{ |
1501 |
BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined |
BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined |
1502 |
|| h->weakdef->root.type == bfd_link_hash_defweak); |
|| h->u.weakdef->root.type == bfd_link_hash_defweak); |
1503 |
h->root.u.def.section = h->weakdef->root.u.def.section; |
h->root.u.def.section = h->u.weakdef->root.u.def.section; |
1504 |
h->root.u.def.value = h->weakdef->root.u.def.value; |
h->root.u.def.value = h->u.weakdef->root.u.def.value; |
1505 |
return true; |
return TRUE; |
1506 |
} |
} |
1507 |
|
|
1508 |
/* This is a reference to a symbol defined by a dynamic object which |
/* This is a reference to a symbol defined by a dynamic object which |
1513 |
For such cases we need not do anything here; the relocations will |
For such cases we need not do anything here; the relocations will |
1514 |
be handled correctly by relocate_section. */ |
be handled correctly by relocate_section. */ |
1515 |
if (info->shared) |
if (info->shared) |
1516 |
return true; |
return TRUE; |
1517 |
|
|
1518 |
/* If there are no references to this symbol that do not use the |
/* If there are no references to this symbol that do not use the |
1519 |
GOT, we don't need to generate a copy reloc. */ |
GOT, we don't need to generate a copy reloc. */ |
1520 |
if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0) |
if (!h->non_got_ref) |
1521 |
return true; |
return TRUE; |
1522 |
|
|
1523 |
|
eh = (struct elf32_sparc_link_hash_entry *) h; |
1524 |
|
for (p = eh->dyn_relocs; p != NULL; p = p->next) |
1525 |
|
{ |
1526 |
|
s = p->sec->output_section; |
1527 |
|
if (s != NULL && (s->flags & SEC_READONLY) != 0) |
1528 |
|
break; |
1529 |
|
} |
1530 |
|
|
1531 |
|
/* If we didn't find any dynamic relocs in read-only sections, then |
1532 |
|
we'll be keeping the dynamic relocs and avoiding the copy reloc. */ |
1533 |
|
if (p == NULL) |
1534 |
|
{ |
1535 |
|
h->non_got_ref = 0; |
1536 |
|
return TRUE; |
1537 |
|
} |
1538 |
|
|
1539 |
/* We must allocate the symbol in our .dynbss section, which will |
/* We must allocate the symbol in our .dynbss section, which will |
1540 |
become part of the .bss section of the executable. There will be |
become part of the .bss section of the executable. There will be |
1546 |
both the dynamic object and the regular object will refer to the |
both the dynamic object and the regular object will refer to the |
1547 |
same memory location for the variable. */ |
same memory location for the variable. */ |
1548 |
|
|
|
s = bfd_get_section_by_name (dynobj, ".dynbss"); |
|
|
BFD_ASSERT (s != NULL); |
|
|
|
|
1549 |
/* We must generate a R_SPARC_COPY reloc to tell the dynamic linker |
/* We must generate a R_SPARC_COPY reloc to tell the dynamic linker |
1550 |
to copy the initial value out of the dynamic object and into the |
to copy the initial value out of the dynamic object and into the |
1551 |
runtime process image. We need to remember the offset into the |
runtime process image. We need to remember the offset into the |
1552 |
.rel.bss section we are going to use. */ |
.rel.bss section we are going to use. */ |
1553 |
if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) |
if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) |
1554 |
{ |
{ |
1555 |
asection *srel; |
htab->srelbss->size += sizeof (Elf32_External_Rela); |
1556 |
|
h->needs_copy = 1; |
|
srel = bfd_get_section_by_name (dynobj, ".rela.bss"); |
|
|
BFD_ASSERT (srel != NULL); |
|
|
srel->_raw_size += sizeof (Elf32_External_Rela); |
|
|
h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; |
|
1557 |
} |
} |
1558 |
|
|
1559 |
/* We need to figure out the alignment required for this symbol. I |
/* We need to figure out the alignment required for this symbol. I |
1563 |
power_of_two = 3; |
power_of_two = 3; |
1564 |
|
|
1565 |
/* Apply the required alignment. */ |
/* Apply the required alignment. */ |
1566 |
s->_raw_size = BFD_ALIGN (s->_raw_size, |
s = htab->sdynbss; |
1567 |
(bfd_size_type) (1 << power_of_two)); |
s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); |
1568 |
if (power_of_two > bfd_get_section_alignment (dynobj, s)) |
if (power_of_two > bfd_get_section_alignment (dynobj, s)) |
1569 |
{ |
{ |
1570 |
if (! bfd_set_section_alignment (dynobj, s, power_of_two)) |
if (! bfd_set_section_alignment (dynobj, s, power_of_two)) |
1571 |
return false; |
return FALSE; |
1572 |
} |
} |
1573 |
|
|
1574 |
/* Define the symbol as being at this point in the section. */ |
/* Define the symbol as being at this point in the section. */ |
1575 |
h->root.u.def.section = s; |
h->root.u.def.section = s; |
1576 |
h->root.u.def.value = s->_raw_size; |
h->root.u.def.value = s->size; |
1577 |
|
|
1578 |
/* Increment the section size to make room for the symbol. */ |
/* Increment the section size to make room for the symbol. */ |
1579 |
s->_raw_size += h->size; |
s->size += h->size; |
1580 |
|
|
1581 |
|
return TRUE; |
1582 |
|
} |
1583 |
|
|
1584 |
|
/* Allocate space in .plt, .got and associated reloc sections for |
1585 |
|
dynamic relocs. */ |
1586 |
|
|
1587 |
|
static bfd_boolean |
1588 |
|
allocate_dynrelocs (h, inf) |
1589 |
|
struct elf_link_hash_entry *h; |
1590 |
|
PTR inf; |
1591 |
|
{ |
1592 |
|
struct bfd_link_info *info; |
1593 |
|
struct elf32_sparc_link_hash_table *htab; |
1594 |
|
struct elf32_sparc_link_hash_entry *eh; |
1595 |
|
struct elf32_sparc_dyn_relocs *p; |
1596 |
|
|
1597 |
|
if (h->root.type == bfd_link_hash_indirect) |
1598 |
|
return TRUE; |
1599 |
|
|
1600 |
|
if (h->root.type == bfd_link_hash_warning) |
1601 |
|
/* When warning symbols are created, they **replace** the "real" |
1602 |
|
entry in the hash table, thus we never get to see the real |
1603 |
|
symbol in a hash traversal. So look at it now. */ |
1604 |
|
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
1605 |
|
|
1606 |
|
info = (struct bfd_link_info *) inf; |
1607 |
|
htab = elf32_sparc_hash_table (info); |
1608 |
|
|
1609 |
|
if (htab->elf.dynamic_sections_created |
1610 |
|
&& h->plt.refcount > 0) |
1611 |
|
{ |
1612 |
|
/* Make sure this symbol is output as a dynamic symbol. |
1613 |
|
Undefined weak syms won't yet be marked as dynamic. */ |
1614 |
|
if (h->dynindx == -1 |
1615 |
|
&& !h->forced_local) |
1616 |
|
{ |
1617 |
|
if (! bfd_elf_link_record_dynamic_symbol (info, h)) |
1618 |
|
return FALSE; |
1619 |
|
} |
1620 |
|
|
1621 |
|
if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h)) |
1622 |
|
{ |
1623 |
|
asection *s = htab->splt; |
1624 |
|
|
1625 |
|
/* The first four entries in .plt are reserved. */ |
1626 |
|
if (s->size == 0) |
1627 |
|
s->size = 4 * PLT_ENTRY_SIZE; |
1628 |
|
|
1629 |
|
/* The procedure linkage table has a maximum size. */ |
1630 |
|
if (s->size >= 0x400000) |
1631 |
|
{ |
1632 |
|
bfd_set_error (bfd_error_bad_value); |
1633 |
|
return FALSE; |
1634 |
|
} |
1635 |
|
|
1636 |
|
h->plt.offset = s->size; |
1637 |
|
|
1638 |
|
/* If this symbol is not defined in a regular file, and we are |
1639 |
|
not generating a shared library, then set the symbol to this |
1640 |
|
location in the .plt. This is required to make function |
1641 |
|
pointers compare as equal between the normal executable and |
1642 |
|
the shared library. */ |
1643 |
|
if (! info->shared |
1644 |
|
&& !h->def_regular) |
1645 |
|
{ |
1646 |
|
h->root.u.def.section = s; |
1647 |
|
h->root.u.def.value = h->plt.offset; |
1648 |
|
} |
1649 |
|
|
1650 |
|
/* Make room for this entry. */ |
1651 |
|
s->size += PLT_ENTRY_SIZE; |
1652 |
|
|
1653 |
|
/* We also need to make an entry in the .rela.plt section. */ |
1654 |
|
htab->srelplt->size += sizeof (Elf32_External_Rela); |
1655 |
|
} |
1656 |
|
else |
1657 |
|
{ |
1658 |
|
h->plt.offset = (bfd_vma) -1; |
1659 |
|
h->needs_plt = 0; |
1660 |
|
} |
1661 |
|
} |
1662 |
|
else |
1663 |
|
{ |
1664 |
|
h->plt.offset = (bfd_vma) -1; |
1665 |
|
h->needs_plt = 0; |
1666 |
|
} |
1667 |
|
|
1668 |
|
/* If R_SPARC_TLS_IE_{HI22,LO10} symbol is now local to the binary, |
1669 |
|
make it a R_SPARC_TLS_LE_{HI22,LO10} requiring no TLS entry. */ |
1670 |
|
if (h->got.refcount > 0 |
1671 |
|
&& !info->shared |
1672 |
|
&& h->dynindx == -1 |
1673 |
|
&& elf32_sparc_hash_entry(h)->tls_type == GOT_TLS_IE) |
1674 |
|
h->got.offset = (bfd_vma) -1; |
1675 |
|
else if (h->got.refcount > 0) |
1676 |
|
{ |
1677 |
|
asection *s; |
1678 |
|
bfd_boolean dyn; |
1679 |
|
int tls_type = elf32_sparc_hash_entry(h)->tls_type; |
1680 |
|
|
1681 |
|
/* Make sure this symbol is output as a dynamic symbol. |
1682 |
|
Undefined weak syms won't yet be marked as dynamic. */ |
1683 |
|
if (h->dynindx == -1 |
1684 |
|
&& !h->forced_local) |
1685 |
|
{ |
1686 |
|
if (! bfd_elf_link_record_dynamic_symbol (info, h)) |
1687 |
|
return FALSE; |
1688 |
|
} |
1689 |
|
|
1690 |
|
s = htab->sgot; |
1691 |
|
h->got.offset = s->size; |
1692 |
|
s->size += 4; |
1693 |
|
/* R_SPARC_TLS_GD_HI{22,LO10} needs 2 consecutive GOT slots. */ |
1694 |
|
if (tls_type == GOT_TLS_GD) |
1695 |
|
s->size += 4; |
1696 |
|
dyn = htab->elf.dynamic_sections_created; |
1697 |
|
/* R_SPARC_TLS_IE_{HI22,LO10} needs one dynamic relocation, |
1698 |
|
R_SPARC_TLS_GD_{HI22,LO10} needs one if local symbol and two if |
1699 |
|
global. */ |
1700 |
|
if ((tls_type == GOT_TLS_GD && h->dynindx == -1) |
1701 |
|
|| tls_type == GOT_TLS_IE) |
1702 |
|
htab->srelgot->size += sizeof (Elf32_External_Rela); |
1703 |
|
else if (tls_type == GOT_TLS_GD) |
1704 |
|
htab->srelgot->size += 2 * sizeof (Elf32_External_Rela); |
1705 |
|
else if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)) |
1706 |
|
htab->srelgot->size += sizeof (Elf32_External_Rela); |
1707 |
|
} |
1708 |
|
else |
1709 |
|
h->got.offset = (bfd_vma) -1; |
1710 |
|
|
1711 |
|
eh = (struct elf32_sparc_link_hash_entry *) h; |
1712 |
|
if (eh->dyn_relocs == NULL) |
1713 |
|
return TRUE; |
1714 |
|
|
1715 |
|
/* In the shared -Bsymbolic case, discard space allocated for |
1716 |
|
dynamic pc-relative relocs against symbols which turn out to be |
1717 |
|
defined in regular objects. For the normal shared case, discard |
1718 |
|
space for pc-relative relocs that have become local due to symbol |
1719 |
|
visibility changes. */ |
1720 |
|
|
1721 |
|
if (info->shared) |
1722 |
|
{ |
1723 |
|
if (h->def_regular |
1724 |
|
&& (h->forced_local |
1725 |
|
|| info->symbolic)) |
1726 |
|
{ |
1727 |
|
struct elf32_sparc_dyn_relocs **pp; |
1728 |
|
|
1729 |
|
for (pp = &eh->dyn_relocs; (p = *pp) != NULL; ) |
1730 |
|
{ |
1731 |
|
p->count -= p->pc_count; |
1732 |
|
p->pc_count = 0; |
1733 |
|
if (p->count == 0) |
1734 |
|
*pp = p->next; |
1735 |
|
else |
1736 |
|
pp = &p->next; |
1737 |
|
} |
1738 |
|
} |
1739 |
|
} |
1740 |
|
else |
1741 |
|
{ |
1742 |
|
/* For the non-shared case, discard space for relocs against |
1743 |
|
symbols which turn out to need copy relocs or are not |
1744 |
|
dynamic. */ |
1745 |
|
|
1746 |
|
if (!h->non_got_ref |
1747 |
|
&& ((h->def_dynamic |
1748 |
|
&& !h->def_regular) |
1749 |
|
|| (htab->elf.dynamic_sections_created |
1750 |
|
&& (h->root.type == bfd_link_hash_undefweak |
1751 |
|
|| h->root.type == bfd_link_hash_undefined)))) |
1752 |
|
{ |
1753 |
|
/* Make sure this symbol is output as a dynamic symbol. |
1754 |
|
Undefined weak syms won't yet be marked as dynamic. */ |
1755 |
|
if (h->dynindx == -1 |
1756 |
|
&& !h->forced_local) |
1757 |
|
{ |
1758 |
|
if (! bfd_elf_link_record_dynamic_symbol (info, h)) |
1759 |
|
return FALSE; |
1760 |
|
} |
1761 |
|
|
1762 |
|
/* If that succeeded, we know we'll be keeping all the |
1763 |
|
relocs. */ |
1764 |
|
if (h->dynindx != -1) |
1765 |
|
goto keep; |
1766 |
|
} |
1767 |
|
|
1768 |
|
eh->dyn_relocs = NULL; |
1769 |
|
|
1770 |
return true; |
keep: ; |
1771 |
|
} |
1772 |
|
|
1773 |
|
/* Finally, allocate space. */ |
1774 |
|
for (p = eh->dyn_relocs; p != NULL; p = p->next) |
1775 |
|
{ |
1776 |
|
asection *sreloc = elf_section_data (p->sec)->sreloc; |
1777 |
|
sreloc->size += p->count * sizeof (Elf32_External_Rela); |
1778 |
|
} |
1779 |
|
|
1780 |
|
return TRUE; |
1781 |
|
} |
1782 |
|
|
1783 |
|
/* Find any dynamic relocs that apply to read-only sections. */ |
1784 |
|
|
1785 |
|
static bfd_boolean |
1786 |
|
readonly_dynrelocs (h, inf) |
1787 |
|
struct elf_link_hash_entry *h; |
1788 |
|
PTR inf; |
1789 |
|
{ |
1790 |
|
struct elf32_sparc_link_hash_entry *eh; |
1791 |
|
struct elf32_sparc_dyn_relocs *p; |
1792 |
|
|
1793 |
|
if (h->root.type == bfd_link_hash_warning) |
1794 |
|
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
1795 |
|
|
1796 |
|
eh = (struct elf32_sparc_link_hash_entry *) h; |
1797 |
|
for (p = eh->dyn_relocs; p != NULL; p = p->next) |
1798 |
|
{ |
1799 |
|
asection *s = p->sec->output_section; |
1800 |
|
|
1801 |
|
if (s != NULL && (s->flags & SEC_READONLY) != 0) |
1802 |
|
{ |
1803 |
|
struct bfd_link_info *info = (struct bfd_link_info *) inf; |
1804 |
|
|
1805 |
|
info->flags |= DF_TEXTREL; |
1806 |
|
|
1807 |
|
/* Not an error, just cut short the traversal. */ |
1808 |
|
return FALSE; |
1809 |
|
} |
1810 |
|
} |
1811 |
|
return TRUE; |
1812 |
|
} |
1813 |
|
|
1814 |
|
/* Return true if the dynamic symbol for a given section should be |
1815 |
|
omitted when creating a shared library. */ |
1816 |
|
|
1817 |
|
static bfd_boolean |
1818 |
|
elf32_sparc_omit_section_dynsym (bfd *output_bfd, |
1819 |
|
struct bfd_link_info *info, |
1820 |
|
asection *p) |
1821 |
|
{ |
1822 |
|
/* We keep the .got section symbol so that explicit relocations |
1823 |
|
against the _GLOBAL_OFFSET_TABLE_ symbol emitted in PIC mode |
1824 |
|
can be turned into relocations against the .got symbol. */ |
1825 |
|
if (strcmp (p->name, ".got") == 0) |
1826 |
|
return FALSE; |
1827 |
|
|
1828 |
|
return _bfd_elf_link_omit_section_dynsym (output_bfd, info, p); |
1829 |
} |
} |
1830 |
|
|
1831 |
/* Set the sizes of the dynamic sections. */ |
/* Set the sizes of the dynamic sections. */ |
1832 |
|
|
1833 |
static boolean |
static bfd_boolean |
1834 |
elf32_sparc_size_dynamic_sections (output_bfd, info) |
elf32_sparc_size_dynamic_sections (output_bfd, info) |
1835 |
bfd *output_bfd ATTRIBUTE_UNUSED; |
bfd *output_bfd ATTRIBUTE_UNUSED; |
1836 |
struct bfd_link_info *info; |
struct bfd_link_info *info; |
1837 |
{ |
{ |
1838 |
|
struct elf32_sparc_link_hash_table *htab; |
1839 |
bfd *dynobj; |
bfd *dynobj; |
1840 |
asection *s; |
asection *s; |
1841 |
boolean relplt; |
bfd *ibfd; |
1842 |
|
|
1843 |
dynobj = elf_hash_table (info)->dynobj; |
htab = elf32_sparc_hash_table (info); |
1844 |
|
dynobj = htab->elf.dynobj; |
1845 |
BFD_ASSERT (dynobj != NULL); |
BFD_ASSERT (dynobj != NULL); |
1846 |
|
|
1847 |
if (elf_hash_table (info)->dynamic_sections_created) |
if (elf_hash_table (info)->dynamic_sections_created) |
1848 |
{ |
{ |
1849 |
/* Set the contents of the .interp section to the interpreter. */ |
/* Set the contents of the .interp section to the interpreter. */ |
1850 |
if (! info->shared) |
if (info->executable) |
1851 |
{ |
{ |
1852 |
s = bfd_get_section_by_name (dynobj, ".interp"); |
s = bfd_get_section_by_name (dynobj, ".interp"); |
1853 |
BFD_ASSERT (s != NULL); |
BFD_ASSERT (s != NULL); |
1854 |
s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; |
s->size = sizeof ELF_DYNAMIC_INTERPRETER; |
1855 |
s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; |
s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; |
1856 |
} |
} |
1857 |
|
} |
1858 |
|
|
1859 |
/* Make space for the trailing nop in .plt. */ |
/* Set up .got offsets for local syms, and space for local dynamic |
1860 |
s = bfd_get_section_by_name (dynobj, ".plt"); |
relocs. */ |
1861 |
BFD_ASSERT (s != NULL); |
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) |
1862 |
if (s->_raw_size > 0) |
{ |
1863 |
s->_raw_size += 4; |
bfd_signed_vma *local_got; |
1864 |
|
bfd_signed_vma *end_local_got; |
1865 |
|
char *local_tls_type; |
1866 |
|
bfd_size_type locsymcount; |
1867 |
|
Elf_Internal_Shdr *symtab_hdr; |
1868 |
|
asection *srel; |
1869 |
|
|
1870 |
|
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour) |
1871 |
|
continue; |
1872 |
|
|
1873 |
|
for (s = ibfd->sections; s != NULL; s = s->next) |
1874 |
|
{ |
1875 |
|
struct elf32_sparc_dyn_relocs *p; |
1876 |
|
|
1877 |
|
for (p = *((struct elf32_sparc_dyn_relocs **) |
1878 |
|
&elf_section_data (s)->local_dynrel); |
1879 |
|
p != NULL; |
1880 |
|
p = p->next) |
1881 |
|
{ |
1882 |
|
if (!bfd_is_abs_section (p->sec) |
1883 |
|
&& bfd_is_abs_section (p->sec->output_section)) |
1884 |
|
{ |
1885 |
|
/* Input section has been discarded, either because |
1886 |
|
it is a copy of a linkonce section or due to |
1887 |
|
linker script /DISCARD/, so we'll be discarding |
1888 |
|
the relocs too. */ |
1889 |
|
} |
1890 |
|
else if (p->count != 0) |
1891 |
|
{ |
1892 |
|
srel = elf_section_data (p->sec)->sreloc; |
1893 |
|
srel->size += p->count * sizeof (Elf32_External_Rela); |
1894 |
|
if ((p->sec->output_section->flags & SEC_READONLY) != 0) |
1895 |
|
info->flags |= DF_TEXTREL; |
1896 |
|
} |
1897 |
|
} |
1898 |
|
} |
1899 |
|
|
1900 |
|
local_got = elf_local_got_refcounts (ibfd); |
1901 |
|
if (!local_got) |
1902 |
|
continue; |
1903 |
|
|
1904 |
|
symtab_hdr = &elf_tdata (ibfd)->symtab_hdr; |
1905 |
|
locsymcount = symtab_hdr->sh_info; |
1906 |
|
end_local_got = local_got + locsymcount; |
1907 |
|
local_tls_type = elf32_sparc_local_got_tls_type (ibfd); |
1908 |
|
s = htab->sgot; |
1909 |
|
srel = htab->srelgot; |
1910 |
|
for (; local_got < end_local_got; ++local_got, ++local_tls_type) |
1911 |
|
{ |
1912 |
|
if (*local_got > 0) |
1913 |
|
{ |
1914 |
|
*local_got = s->size; |
1915 |
|
s->size += 4; |
1916 |
|
if (*local_tls_type == GOT_TLS_GD) |
1917 |
|
s->size += 4; |
1918 |
|
if (info->shared |
1919 |
|
|| *local_tls_type == GOT_TLS_GD |
1920 |
|
|| *local_tls_type == GOT_TLS_IE) |
1921 |
|
srel->size += sizeof (Elf32_External_Rela); |
1922 |
|
} |
1923 |
|
else |
1924 |
|
*local_got = (bfd_vma) -1; |
1925 |
|
} |
1926 |
|
} |
1927 |
|
|
1928 |
|
if (htab->tls_ldm_got.refcount > 0) |
1929 |
|
{ |
1930 |
|
/* Allocate 2 got entries and 1 dynamic reloc for |
1931 |
|
R_SPARC_TLS_LDM_{HI22,LO10} relocs. */ |
1932 |
|
htab->tls_ldm_got.offset = htab->sgot->size; |
1933 |
|
htab->sgot->size += 8; |
1934 |
|
htab->srelgot->size += sizeof (Elf32_External_Rela); |
1935 |
} |
} |
1936 |
else |
else |
1937 |
|
htab->tls_ldm_got.offset = -1; |
1938 |
|
|
1939 |
|
/* Allocate global sym .plt and .got entries, and space for global |
1940 |
|
sym dynamic relocs. */ |
1941 |
|
elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info); |
1942 |
|
|
1943 |
|
if (elf_hash_table (info)->dynamic_sections_created) |
1944 |
{ |
{ |
1945 |
/* We may have created entries in the .rela.got section. |
/* Make space for the trailing nop in .plt. */ |
1946 |
However, if we are not creating the dynamic sections, we will |
if (htab->splt->size > 0) |
1947 |
not actually use these entries. Reset the size of .rela.got, |
htab->splt->size += 4; |
1948 |
which will cause it to get stripped from the output file |
|
1949 |
below. */ |
/* If the .got section is more than 0x1000 bytes, we add |
1950 |
s = bfd_get_section_by_name (dynobj, ".rela.got"); |
0x1000 to the value of _GLOBAL_OFFSET_TABLE_, so that 13 |
1951 |
if (s != NULL) |
bit relocations have a greater chance of working. */ |
1952 |
s->_raw_size = 0; |
if (htab->sgot->size >= 0x1000 |
1953 |
|
&& elf_hash_table (info)->hgot->root.u.def.value == 0) |
1954 |
|
elf_hash_table (info)->hgot->root.u.def.value = 0x1000; |
1955 |
} |
} |
1956 |
|
|
1957 |
/* The check_relocs and adjust_dynamic_symbol entry points have |
/* The check_relocs and adjust_dynamic_symbol entry points have |
1958 |
determined the sizes of the various dynamic sections. Allocate |
determined the sizes of the various dynamic sections. Allocate |
1959 |
memory for them. */ |
memory for them. */ |
|
relplt = false; |
|
1960 |
for (s = dynobj->sections; s != NULL; s = s->next) |
for (s = dynobj->sections; s != NULL; s = s->next) |
1961 |
{ |
{ |
1962 |
const char *name; |
const char *name; |
1963 |
boolean strip; |
bfd_boolean strip = FALSE; |
1964 |
|
|
1965 |
if ((s->flags & SEC_LINKER_CREATED) == 0) |
if ((s->flags & SEC_LINKER_CREATED) == 0) |
1966 |
continue; |
continue; |
1969 |
of the dynobj section names depend upon the input files. */ |
of the dynobj section names depend upon the input files. */ |
1970 |
name = bfd_get_section_name (dynobj, s); |
name = bfd_get_section_name (dynobj, s); |
1971 |
|
|
|
strip = false; |
|
|
|
|
1972 |
if (strncmp (name, ".rela", 5) == 0) |
if (strncmp (name, ".rela", 5) == 0) |
1973 |
{ |
{ |
1974 |
if (s->_raw_size == 0) |
if (s->size == 0) |
1975 |
{ |
{ |
1976 |
/* If we don't need this section, strip it from the |
/* If we don't need this section, strip it from the |
1977 |
output file. This is to handle .rela.bss and |
output file. This is to handle .rela.bss and |
1982 |
adjust_dynamic_symbol is called, and it is that |
adjust_dynamic_symbol is called, and it is that |
1983 |
function which decides whether anything needs to go |
function which decides whether anything needs to go |
1984 |
into these sections. */ |
into these sections. */ |
1985 |
strip = true; |
strip = TRUE; |
1986 |
} |
} |
1987 |
else |
else |
1988 |
{ |
{ |
|
if (strcmp (name, ".rela.plt") == 0) |
|
|
relplt = true; |
|
|
|
|
1989 |
/* We use the reloc_count field as a counter if we need |
/* We use the reloc_count field as a counter if we need |
1990 |
to copy relocs into the output file. */ |
to copy relocs into the output file. */ |
1991 |
s->reloc_count = 0; |
s->reloc_count = 0; |
1992 |
} |
} |
1993 |
} |
} |
1994 |
else if (strcmp (name, ".plt") != 0 |
else if (s != htab->splt && s != htab->sgot) |
|
&& strcmp (name, ".got") != 0) |
|
1995 |
{ |
{ |
1996 |
/* It's not one of our sections, so don't allocate space. */ |
/* It's not one of our sections, so don't allocate space. */ |
1997 |
continue; |
continue; |
2009 |
are written out, but at the moment this does not happen. Thus in |
are written out, but at the moment this does not happen. Thus in |
2010 |
order to prevent writing out garbage, we initialise the section's |
order to prevent writing out garbage, we initialise the section's |
2011 |
contents to zero. */ |
contents to zero. */ |
2012 |
s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size); |
s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); |
2013 |
if (s->contents == NULL && s->_raw_size != 0) |
if (s->contents == NULL && s->size != 0) |
2014 |
return false; |
return FALSE; |
2015 |
} |
} |
2016 |
|
|
2017 |
if (elf_hash_table (info)->dynamic_sections_created) |
if (elf_hash_table (info)->dynamic_sections_created) |
2022 |
the .dynamic section. The DT_DEBUG entry is filled in by the |
the .dynamic section. The DT_DEBUG entry is filled in by the |
2023 |
dynamic linker and used by the debugger. */ |
dynamic linker and used by the debugger. */ |
2024 |
#define add_dynamic_entry(TAG, VAL) \ |
#define add_dynamic_entry(TAG, VAL) \ |
2025 |
bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) |
_bfd_elf_add_dynamic_entry (info, TAG, VAL) |
2026 |
|
|
2027 |
if (!info->shared) |
if (info->executable) |
2028 |
{ |
{ |
2029 |
if (!add_dynamic_entry (DT_DEBUG, 0)) |
if (!add_dynamic_entry (DT_DEBUG, 0)) |
2030 |
return false; |
return FALSE; |
2031 |
} |
} |
2032 |
|
|
2033 |
if (relplt) |
if (htab->srelplt->size != 0) |
2034 |
{ |
{ |
2035 |
if (!add_dynamic_entry (DT_PLTGOT, 0) |
if (!add_dynamic_entry (DT_PLTGOT, 0) |
2036 |
|| !add_dynamic_entry (DT_PLTRELSZ, 0) |
|| !add_dynamic_entry (DT_PLTRELSZ, 0) |
2037 |
|| !add_dynamic_entry (DT_PLTREL, DT_RELA) |
|| !add_dynamic_entry (DT_PLTREL, DT_RELA) |
2038 |
|| !add_dynamic_entry (DT_JMPREL, 0)) |
|| !add_dynamic_entry (DT_JMPREL, 0)) |
2039 |
return false; |
return FALSE; |
2040 |
} |
} |
2041 |
|
|
2042 |
if (!add_dynamic_entry (DT_RELA, 0) |
if (!add_dynamic_entry (DT_RELA, 0) |
2043 |
|| !add_dynamic_entry (DT_RELASZ, 0) |
|| !add_dynamic_entry (DT_RELASZ, 0) |
2044 |
|| !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela))) |
|| !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela))) |
2045 |
return false; |
return FALSE; |
2046 |
|
|
2047 |
|
/* If any dynamic relocs apply to a read-only section, |
2048 |
|
then we need a DT_TEXTREL entry. */ |
2049 |
|
if ((info->flags & DF_TEXTREL) == 0) |
2050 |
|
elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, |
2051 |
|
(PTR) info); |
2052 |
|
|
2053 |
if (info->flags & DF_TEXTREL) |
if (info->flags & DF_TEXTREL) |
2054 |
{ |
{ |
2055 |
if (!add_dynamic_entry (DT_TEXTREL, 0)) |
if (!add_dynamic_entry (DT_TEXTREL, 0)) |
2056 |
return false; |
return FALSE; |
2057 |
} |
} |
2058 |
} |
} |
2059 |
#undef add_dynamic_entry |
#undef add_dynamic_entry |
2060 |
|
|
2061 |
return true; |
return TRUE; |
2062 |
} |
} |
2063 |
|
|
2064 |
#define SET_SEC_DO_RELAX(section) do { elf_section_data(section)->tdata = (void *)1; } while (0) |
struct elf32_sparc_section_data |
2065 |
#define SEC_DO_RELAX(section) (elf_section_data(section)->tdata == (void *)1) |
{ |
2066 |
|
struct bfd_elf_section_data elf; |
2067 |
|
unsigned int do_relax; |
2068 |
|
}; |
2069 |
|
|
2070 |
|
#define sec_do_relax(sec) \ |
2071 |
|
((struct elf32_sparc_section_data *) elf_section_data (sec))->do_relax |
2072 |
|
|
2073 |
static boolean |
static bfd_boolean |
2074 |
|
elf32_sparc_new_section_hook (abfd, sec) |
2075 |
|
bfd *abfd; |
2076 |
|
asection *sec; |
2077 |
|
{ |
2078 |
|
struct elf32_sparc_section_data *sdata; |
2079 |
|
bfd_size_type amt = sizeof (*sdata); |
2080 |
|
|
2081 |
|
sdata = (struct elf32_sparc_section_data *) bfd_zalloc (abfd, amt); |
2082 |
|
if (sdata == NULL) |
2083 |
|
return FALSE; |
2084 |
|
sec->used_by_bfd = (PTR) sdata; |
2085 |
|
|
2086 |
|
return _bfd_elf_new_section_hook (abfd, sec); |
2087 |
|
} |
2088 |
|
|
2089 |
|
static bfd_boolean |
2090 |
elf32_sparc_relax_section (abfd, section, link_info, again) |
elf32_sparc_relax_section (abfd, section, link_info, again) |
2091 |
bfd *abfd ATTRIBUTE_UNUSED; |
bfd *abfd ATTRIBUTE_UNUSED; |
2092 |
asection *section ATTRIBUTE_UNUSED; |
asection *section ATTRIBUTE_UNUSED; |
2093 |
struct bfd_link_info *link_info ATTRIBUTE_UNUSED; |
struct bfd_link_info *link_info ATTRIBUTE_UNUSED; |
2094 |
boolean *again; |
bfd_boolean *again; |
2095 |
{ |
{ |
2096 |
*again = false; |
*again = FALSE; |
2097 |
SET_SEC_DO_RELAX (section); |
sec_do_relax (section) = 1; |
2098 |
return true; |
return TRUE; |
2099 |
} |
} |
2100 |
|
|
2101 |
/* This is the condition under which finish_dynamic_symbol will be called |
/* Return the base VMA address which should be subtracted from real addresses |
2102 |
from elflink.h. If elflink.h doesn't call our finish_dynamic_symbol |
when resolving @dtpoff relocation. |
2103 |
routine, we'll need to do something about initializing any .plt and .got |
This is PT_TLS segment p_vaddr. */ |
2104 |
entries in relocate_section. */ |
|
2105 |
#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \ |
static bfd_vma |
2106 |
((DYN) \ |
dtpoff_base (info) |
2107 |
&& ((INFO)->shared \ |
struct bfd_link_info *info; |
2108 |
|| ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \ |
{ |
2109 |
&& ((H)->dynindx != -1 \ |
/* If tls_sec is NULL, we should have signalled an error already. */ |
2110 |
|| ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)) |
if (elf_hash_table (info)->tls_sec == NULL) |
2111 |
|
return 0; |
2112 |
|
return elf_hash_table (info)->tls_sec->vma; |
2113 |
|
} |
2114 |
|
|
2115 |
|
/* Return the relocation value for @tpoff relocation |
2116 |
|
if STT_TLS virtual address is ADDRESS. */ |
2117 |
|
|
2118 |
|
static bfd_vma |
2119 |
|
tpoff (info, address) |
2120 |
|
struct bfd_link_info *info; |
2121 |
|
bfd_vma address; |
2122 |
|
{ |
2123 |
|
struct elf_link_hash_table *htab = elf_hash_table (info); |
2124 |
|
|
2125 |
|
/* If tls_sec is NULL, we should have signalled an error already. */ |
2126 |
|
if (htab->tls_sec == NULL) |
2127 |
|
return 0; |
2128 |
|
return address - htab->tls_size - htab->tls_sec->vma; |
2129 |
|
} |
2130 |
|
|
2131 |
/* Relocate a SPARC ELF section. */ |
/* Relocate a SPARC ELF section. */ |
2132 |
|
|
2133 |
static boolean |
static bfd_boolean |
2134 |
elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section, |
elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section, |
2135 |
contents, relocs, local_syms, local_sections) |
contents, relocs, local_syms, local_sections) |
2136 |
bfd *output_bfd; |
bfd *output_bfd; |
2142 |
Elf_Internal_Sym *local_syms; |
Elf_Internal_Sym *local_syms; |
2143 |
asection **local_sections; |
asection **local_sections; |
2144 |
{ |
{ |
2145 |
bfd *dynobj; |
struct elf32_sparc_link_hash_table *htab; |
2146 |
Elf_Internal_Shdr *symtab_hdr; |
Elf_Internal_Shdr *symtab_hdr; |
2147 |
struct elf_link_hash_entry **sym_hashes; |
struct elf_link_hash_entry **sym_hashes; |
2148 |
bfd_vma *local_got_offsets; |
bfd_vma *local_got_offsets; |
2149 |
bfd_vma got_base; |
bfd_vma got_base; |
|
asection *sgot; |
|
|
asection *splt; |
|
2150 |
asection *sreloc; |
asection *sreloc; |
2151 |
Elf_Internal_Rela *rel; |
Elf_Internal_Rela *rel; |
2152 |
Elf_Internal_Rela *relend; |
Elf_Internal_Rela *relend; |
2153 |
|
|
2154 |
dynobj = elf_hash_table (info)->dynobj; |
if (info->relocatable) |
2155 |
|
return TRUE; |
2156 |
|
|
2157 |
|
htab = elf32_sparc_hash_table (info); |
2158 |
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; |
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; |
2159 |
sym_hashes = elf_sym_hashes (input_bfd); |
sym_hashes = elf_sym_hashes (input_bfd); |
2160 |
local_got_offsets = elf_local_got_offsets (input_bfd); |
local_got_offsets = elf_local_got_offsets (input_bfd); |
2164 |
else |
else |
2165 |
got_base = elf_hash_table (info)->hgot->root.u.def.value; |
got_base = elf_hash_table (info)->hgot->root.u.def.value; |
2166 |
|
|
2167 |
sgot = NULL; |
sreloc = elf_section_data (input_section)->sreloc; |
|
splt = NULL; |
|
|
sreloc = NULL; |
|
2168 |
|
|
2169 |
rel = relocs; |
rel = relocs; |
2170 |
relend = relocs + input_section->reloc_count; |
relend = relocs + input_section->reloc_count; |
2171 |
for (; rel < relend; rel++) |
for (; rel < relend; rel++) |
2172 |
{ |
{ |
2173 |
int r_type; |
int r_type, tls_type; |
2174 |
reloc_howto_type *howto; |
reloc_howto_type *howto; |
2175 |
unsigned long r_symndx; |
unsigned long r_symndx; |
2176 |
struct elf_link_hash_entry *h; |
struct elf_link_hash_entry *h; |
2178 |
asection *sec; |
asection *sec; |
2179 |
bfd_vma relocation, off; |
bfd_vma relocation, off; |
2180 |
bfd_reloc_status_type r; |
bfd_reloc_status_type r; |
2181 |
boolean is_plt = false; |
bfd_boolean is_plt = FALSE; |
2182 |
boolean unresolved_reloc; |
bfd_boolean unresolved_reloc; |
2183 |
|
|
2184 |
r_type = ELF32_R_TYPE (rel->r_info); |
r_type = ELF32_R_TYPE (rel->r_info); |
2185 |
|
|
2186 |
if (r_type == R_SPARC_GNU_VTINHERIT |
if (r_type == R_SPARC_GNU_VTINHERIT |
2187 |
|| r_type == R_SPARC_GNU_VTENTRY) |
|| r_type == R_SPARC_GNU_VTENTRY) |
2188 |
continue; |
continue; |
2189 |
|
|
2190 |
if (r_type < 0 || r_type >= (int) R_SPARC_max_std) |
if (r_type < 0 || r_type >= (int) R_SPARC_max_std) |
2191 |
{ |
{ |
2192 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
2193 |
return false; |
return FALSE; |
2194 |
} |
} |
2195 |
howto = _bfd_sparc_elf_howto_table + r_type; |
howto = _bfd_sparc_elf_howto_table + r_type; |
2196 |
|
|
|
r_symndx = ELF32_R_SYM (rel->r_info); |
|
|
|
|
|
if (info->relocateable) |
|
|
{ |
|
|
/* This is a relocateable link. We don't have to change |
|
|
anything, unless the reloc is against a section symbol, |
|
|
in which case we have to adjust according to where the |
|
|
section symbol winds up in the output section. */ |
|
|
if (r_symndx < symtab_hdr->sh_info) |
|
|
{ |
|
|
sym = local_syms + r_symndx; |
|
|
if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) |
|
|
{ |
|
|
sec = local_sections[r_symndx]; |
|
|
rel->r_addend += sec->output_offset + sym->st_value; |
|
|
} |
|
|
} |
|
|
|
|
|
continue; |
|
|
} |
|
|
|
|
2197 |
/* This is a final link. */ |
/* This is a final link. */ |
2198 |
|
r_symndx = ELF32_R_SYM (rel->r_info); |
2199 |
h = NULL; |
h = NULL; |
2200 |
sym = NULL; |
sym = NULL; |
2201 |
sec = NULL; |
sec = NULL; |
2202 |
unresolved_reloc = false; |
unresolved_reloc = FALSE; |
2203 |
if (r_symndx < symtab_hdr->sh_info) |
if (r_symndx < symtab_hdr->sh_info) |
2204 |
{ |
{ |
2205 |
sym = local_syms + r_symndx; |
sym = local_syms + r_symndx; |
2206 |
sec = local_sections[r_symndx]; |
sec = local_sections[r_symndx]; |
2207 |
relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); |
relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); |
2208 |
} |
} |
2209 |
else |
else |
2210 |
{ |
{ |
2211 |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
bfd_boolean warned ATTRIBUTE_UNUSED; |
|
while (h->root.type == bfd_link_hash_indirect |
|
|
|| h->root.type == bfd_link_hash_warning) |
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
|
2212 |
|
|
2213 |
relocation = 0; |
RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, |
2214 |
if (h->root.type == bfd_link_hash_defined |
r_symndx, symtab_hdr, sym_hashes, |
2215 |
|| h->root.type == bfd_link_hash_defweak) |
h, sec, relocation, |
2216 |
{ |
unresolved_reloc, warned); |
|
sec = h->root.u.def.section; |
|
|
if (sec->output_section == NULL) |
|
|
/* Set a flag that will be cleared later if we find a |
|
|
relocation value for this symbol. output_section |
|
|
is typically NULL for symbols satisfied by a shared |
|
|
library. */ |
|
|
unresolved_reloc = true; |
|
|
else |
|
|
relocation = (h->root.u.def.value |
|
|
+ sec->output_section->vma |
|
|
+ sec->output_offset); |
|
|
} |
|
|
else if (h->root.type == bfd_link_hash_undefweak) |
|
|
; |
|
|
else if (info->shared |
|
|
&& (!info->symbolic || info->allow_shlib_undefined) |
|
|
&& !info->no_undefined |
|
|
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) |
|
|
; |
|
|
else |
|
|
{ |
|
|
if (! ((*info->callbacks->undefined_symbol) |
|
|
(info, h->root.root.string, input_bfd, |
|
|
input_section, rel->r_offset, |
|
|
(!info->shared || info->no_undefined |
|
|
|| ELF_ST_VISIBILITY (h->other))))) |
|
|
return false; |
|
|
} |
|
2217 |
} |
} |
2218 |
|
|
2219 |
switch (r_type) |
switch (r_type) |
2222 |
case R_SPARC_GOT13: |
case R_SPARC_GOT13: |
2223 |
case R_SPARC_GOT22: |
case R_SPARC_GOT22: |
2224 |
/* Relocation is to the entry for this symbol in the global |
/* Relocation is to the entry for this symbol in the global |
2225 |
offset table. */ |
offset table. */ |
2226 |
if (sgot == NULL) |
if (htab->sgot == NULL) |
2227 |
{ |
abort (); |
|
sgot = bfd_get_section_by_name (dynobj, ".got"); |
|
|
BFD_ASSERT (sgot != NULL); |
|
|
} |
|
2228 |
|
|
2229 |
if (h != NULL) |
if (h != NULL) |
2230 |
{ |
{ |
2231 |
boolean dyn; |
bfd_boolean dyn; |
2232 |
|
|
2233 |
off = h->got.offset; |
off = h->got.offset; |
2234 |
BFD_ASSERT (off != (bfd_vma) -1); |
BFD_ASSERT (off != (bfd_vma) -1); |
2235 |
dyn = elf_hash_table (info)->dynamic_sections_created; |
dyn = elf_hash_table (info)->dynamic_sections_created; |
2236 |
|
|
2237 |
if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h) |
if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) |
2238 |
|| (info->shared |
|| (info->shared |
2239 |
&& (info->symbolic |
&& (info->symbolic |
2240 |
|| h->dynindx == -1 |
|| h->dynindx == -1 |
2241 |
|| (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL)) |
|| h->forced_local) |
2242 |
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))) |
&& h->def_regular)) |
2243 |
{ |
{ |
2244 |
/* This is actually a static link, or it is a |
/* This is actually a static link, or it is a |
2245 |
-Bsymbolic link and the symbol is defined |
-Bsymbolic link and the symbol is defined |
2246 |
locally, or the symbol was forced to be local |
locally, or the symbol was forced to be local |
2247 |
because of a version file. We must initialize |
because of a version file. We must initialize |
2248 |
this entry in the global offset table. Since the |
this entry in the global offset table. Since the |
2249 |
offset must always be a multiple of 4, we use the |
offset must always be a multiple of 4, we use the |
2250 |
least significant bit to record whether we have |
least significant bit to record whether we have |
2251 |
initialized it already. |
initialized it already. |
2252 |
|
|
2253 |
When doing a dynamic link, we create a .rela.got |
When doing a dynamic link, we create a .rela.got |
2254 |
relocation entry to initialize the value. This |
relocation entry to initialize the value. This |
2258 |
else |
else |
2259 |
{ |
{ |
2260 |
bfd_put_32 (output_bfd, relocation, |
bfd_put_32 (output_bfd, relocation, |
2261 |
sgot->contents + off); |
htab->sgot->contents + off); |
2262 |
h->got.offset |= 1; |
h->got.offset |= 1; |
2263 |
} |
} |
2264 |
} |
} |
2265 |
else |
else |
2266 |
unresolved_reloc = false; |
unresolved_reloc = FALSE; |
2267 |
} |
} |
2268 |
else |
else |
2269 |
{ |
{ |
2279 |
off &= ~1; |
off &= ~1; |
2280 |
else |
else |
2281 |
{ |
{ |
|
bfd_put_32 (output_bfd, relocation, sgot->contents + off); |
|
2282 |
|
|
2283 |
if (info->shared) |
if (info->shared) |
2284 |
{ |
{ |
2285 |
asection *srelgot; |
asection *s; |
2286 |
Elf_Internal_Rela outrel; |
Elf_Internal_Rela outrel; |
2287 |
|
bfd_byte *loc; |
2288 |
|
|
2289 |
/* We need to generate a R_SPARC_RELATIVE reloc |
/* We need to generate a R_SPARC_RELATIVE reloc |
2290 |
for the dynamic linker. */ |
for the dynamic linker. */ |
2291 |
srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); |
s = htab->srelgot; |
2292 |
BFD_ASSERT (srelgot != NULL); |
BFD_ASSERT (s != NULL); |
2293 |
|
|
2294 |
outrel.r_offset = (sgot->output_section->vma |
outrel.r_offset = (htab->sgot->output_section->vma |
2295 |
+ sgot->output_offset |
+ htab->sgot->output_offset |
2296 |
+ off); |
+ off); |
2297 |
outrel.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE); |
outrel.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE); |
2298 |
outrel.r_addend = 0; |
outrel.r_addend = relocation; |
2299 |
bfd_elf32_swap_reloca_out (output_bfd, &outrel, |
relocation = 0; |
2300 |
(((Elf32_External_Rela *) |
loc = s->contents; |
2301 |
srelgot->contents) |
loc += s->reloc_count++ * sizeof (Elf32_External_Rela); |
2302 |
+ srelgot->reloc_count)); |
bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); |
|
++srelgot->reloc_count; |
|
2303 |
} |
} |
2304 |
|
|
2305 |
|
bfd_put_32 (output_bfd, relocation, |
2306 |
|
htab->sgot->contents + off); |
2307 |
local_got_offsets[r_symndx] |= 1; |
local_got_offsets[r_symndx] |= 1; |
2308 |
} |
} |
2309 |
} |
} |
2310 |
relocation = sgot->output_offset + off - got_base; |
relocation = htab->sgot->output_offset + off - got_base; |
2311 |
break; |
break; |
2312 |
|
|
2313 |
case R_SPARC_PLT32: |
case R_SPARC_PLT32: |
2318 |
} |
} |
2319 |
/* Fall through. */ |
/* Fall through. */ |
2320 |
case R_SPARC_WPLT30: |
case R_SPARC_WPLT30: |
2321 |
|
r_sparc_wplt30: |
2322 |
/* Relocation is to the entry for this symbol in the |
/* Relocation is to the entry for this symbol in the |
2323 |
procedure linkage table. */ |
procedure linkage table. */ |
2324 |
|
|
2325 |
/* The Solaris native assembler will generate a WPLT30 reloc |
/* The Solaris native assembler will generate a WPLT30 reloc |
2326 |
for a local symbol if you assemble a call from one |
for a local symbol if you assemble a call from one |
2329 |
if (h == NULL) |
if (h == NULL) |
2330 |
break; |
break; |
2331 |
|
|
2332 |
if (h->plt.offset == (bfd_vma) -1) |
if (h->plt.offset == (bfd_vma) -1 || htab->splt == NULL) |
2333 |
{ |
{ |
2334 |
/* We didn't make a PLT entry for this symbol. This |
/* We didn't make a PLT entry for this symbol. This |
2335 |
happens when statically linking PIC code, or when |
happens when statically linking PIC code, or when |
2336 |
using -Bsymbolic. */ |
using -Bsymbolic. */ |
2337 |
break; |
break; |
2338 |
} |
} |
2339 |
|
|
2340 |
if (splt == NULL) |
relocation = (htab->splt->output_section->vma |
2341 |
{ |
+ htab->splt->output_offset |
|
splt = bfd_get_section_by_name (dynobj, ".plt"); |
|
|
BFD_ASSERT (splt != NULL); |
|
|
} |
|
|
|
|
|
relocation = (splt->output_section->vma |
|
|
+ splt->output_offset |
|
2342 |
+ h->plt.offset); |
+ h->plt.offset); |
2343 |
unresolved_reloc = false; |
unresolved_reloc = FALSE; |
2344 |
if (r_type == R_SPARC_PLT32) |
if (r_type == R_SPARC_PLT32) |
2345 |
{ |
{ |
2346 |
r_type = R_SPARC_32; |
r_type = R_SPARC_32; |
2347 |
is_plt = true; |
is_plt = TRUE; |
2348 |
goto r_sparc_plt32; |
goto r_sparc_plt32; |
2349 |
} |
} |
2350 |
break; |
break; |
2362 |
case R_SPARC_WDISP22: |
case R_SPARC_WDISP22: |
2363 |
case R_SPARC_WDISP19: |
case R_SPARC_WDISP19: |
2364 |
case R_SPARC_WDISP16: |
case R_SPARC_WDISP16: |
|
if (h == NULL |
|
|
|| (info->symbolic |
|
|
&& (h->elf_link_hash_flags |
|
|
& ELF_LINK_HASH_DEF_REGULAR) != 0)) |
|
|
break; |
|
|
/* Fall through. */ |
|
2365 |
case R_SPARC_8: |
case R_SPARC_8: |
2366 |
case R_SPARC_16: |
case R_SPARC_16: |
2367 |
case R_SPARC_32: |
case R_SPARC_32: |
2372 |
case R_SPARC_UA16: |
case R_SPARC_UA16: |
2373 |
case R_SPARC_UA32: |
case R_SPARC_UA32: |
2374 |
r_sparc_plt32: |
r_sparc_plt32: |
2375 |
if (info->shared |
/* r_symndx will be zero only for relocs against symbols |
2376 |
&& r_symndx != 0 |
from removed linkonce sections, or sections discarded by |
2377 |
&& (input_section->flags & SEC_ALLOC)) |
a linker script. */ |
2378 |
|
if (r_symndx == 0 |
2379 |
|
|| (input_section->flags & SEC_ALLOC) == 0) |
2380 |
|
break; |
2381 |
|
|
2382 |
|
if ((info->shared |
2383 |
|
&& (h == NULL |
2384 |
|
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT |
2385 |
|
|| h->root.type != bfd_link_hash_undefweak) |
2386 |
|
&& (! howto->pc_relative |
2387 |
|
|| (h != NULL |
2388 |
|
&& h->dynindx != -1 |
2389 |
|
&& (! info->symbolic |
2390 |
|
|| !h->def_regular)))) |
2391 |
|
|| (!info->shared |
2392 |
|
&& h != NULL |
2393 |
|
&& h->dynindx != -1 |
2394 |
|
&& !h->non_got_ref |
2395 |
|
&& ((h->def_dynamic |
2396 |
|
&& !h->def_regular) |
2397 |
|
|| h->root.type == bfd_link_hash_undefweak |
2398 |
|
|| h->root.type == bfd_link_hash_undefined))) |
2399 |
{ |
{ |
2400 |
Elf_Internal_Rela outrel; |
Elf_Internal_Rela outrel; |
2401 |
boolean skip, relocate = false; |
bfd_byte *loc; |
2402 |
|
bfd_boolean skip, relocate = FALSE; |
2403 |
|
|
2404 |
/* When generating a shared object, these relocations |
/* When generating a shared object, these relocations |
2405 |
are copied into the output file to be resolved at run |
are copied into the output file to be resolved at run |
2406 |
time. */ |
time. */ |
|
|
|
|
if (sreloc == NULL) |
|
|
{ |
|
|
const char *name; |
|
2407 |
|
|
2408 |
name = (bfd_elf_string_from_elf_section |
BFD_ASSERT (sreloc != NULL); |
|
(input_bfd, |
|
|
elf_elfheader (input_bfd)->e_shstrndx, |
|
|
elf_section_data (input_section)->rel_hdr.sh_name)); |
|
|
if (name == NULL) |
|
|
return false; |
|
2409 |
|
|
2410 |
BFD_ASSERT (strncmp (name, ".rela", 5) == 0 |
skip = FALSE; |
|
&& strcmp (bfd_get_section_name (input_bfd, |
|
|
input_section), |
|
|
name + 5) == 0); |
|
|
|
|
|
sreloc = bfd_get_section_by_name (dynobj, name); |
|
|
BFD_ASSERT (sreloc != NULL); |
|
|
} |
|
|
|
|
|
skip = false; |
|
2411 |
|
|
2412 |
outrel.r_offset = |
outrel.r_offset = |
2413 |
_bfd_elf_section_offset (output_bfd, info, input_section, |
_bfd_elf_section_offset (output_bfd, info, input_section, |
2414 |
rel->r_offset); |
rel->r_offset); |
2415 |
if (outrel.r_offset == (bfd_vma) -1) |
if (outrel.r_offset == (bfd_vma) -1) |
2416 |
skip = true; |
skip = TRUE; |
2417 |
else if (outrel.r_offset == (bfd_vma) -2) |
else if (outrel.r_offset == (bfd_vma) -2) |
2418 |
skip = true, relocate = true; |
skip = TRUE, relocate = TRUE; |
2419 |
outrel.r_offset += (input_section->output_section->vma |
outrel.r_offset += (input_section->output_section->vma |
2420 |
+ input_section->output_offset); |
+ input_section->output_offset); |
2421 |
|
|
2448 |
FIXME: Add code tracking needed dynamic relocs as |
FIXME: Add code tracking needed dynamic relocs as |
2449 |
e.g. i386 has. */ |
e.g. i386 has. */ |
2450 |
if (h->dynindx == -1) |
if (h->dynindx == -1) |
2451 |
skip = true, relocate = true; |
skip = TRUE, relocate = TRUE; |
2452 |
break; |
break; |
2453 |
} |
} |
2454 |
|
|
2455 |
if (skip) |
if (skip) |
2456 |
memset (&outrel, 0, sizeof outrel); |
memset (&outrel, 0, sizeof outrel); |
2457 |
/* h->dynindx may be -1 if the symbol was marked to |
/* h->dynindx may be -1 if the symbol was marked to |
2458 |
become local. */ |
become local. */ |
2459 |
else if (h != NULL && ! is_plt |
else if (h != NULL && ! is_plt |
2460 |
&& ((! info->symbolic && h->dynindx != -1) |
&& ((! info->symbolic && h->dynindx != -1) |
2461 |
|| (h->elf_link_hash_flags |
|| !h->def_regular)) |
|
& ELF_LINK_HASH_DEF_REGULAR) == 0)) |
|
2462 |
{ |
{ |
2463 |
BFD_ASSERT (h->dynindx != -1); |
BFD_ASSERT (h->dynindx != -1); |
2464 |
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); |
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); |
2476 |
long indx; |
long indx; |
2477 |
|
|
2478 |
if (is_plt) |
if (is_plt) |
2479 |
sec = splt; |
sec = htab->splt; |
2480 |
else if (h == NULL) |
|
2481 |
sec = local_sections[r_symndx]; |
if (bfd_is_abs_section (sec)) |
|
else |
|
|
{ |
|
|
BFD_ASSERT (h->root.type == bfd_link_hash_defined |
|
|
|| (h->root.type |
|
|
== bfd_link_hash_defweak)); |
|
|
sec = h->root.u.def.section; |
|
|
} |
|
|
if (sec != NULL && bfd_is_abs_section (sec)) |
|
2482 |
indx = 0; |
indx = 0; |
2483 |
else if (sec == NULL || sec->owner == NULL) |
else if (sec == NULL || sec->owner == NULL) |
2484 |
{ |
{ |
2485 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
2486 |
return false; |
return FALSE; |
2487 |
} |
} |
2488 |
else |
else |
2489 |
{ |
{ |
2498 |
{ |
{ |
2499 |
BFD_FAIL (); |
BFD_FAIL (); |
2500 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
2501 |
(_("%s: probably compiled without -fPIC?"), |
(_("%B: probably compiled without -fPIC?"), |
2502 |
bfd_archive_filename (input_bfd)); |
input_bfd); |
2503 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
2504 |
return false; |
return FALSE; |
2505 |
} |
} |
2506 |
} |
} |
2507 |
|
|
2510 |
} |
} |
2511 |
} |
} |
2512 |
|
|
2513 |
bfd_elf32_swap_reloca_out (output_bfd, &outrel, |
loc = sreloc->contents; |
2514 |
(((Elf32_External_Rela *) |
loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela); |
2515 |
sreloc->contents) |
bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); |
|
+ sreloc->reloc_count)); |
|
|
++sreloc->reloc_count; |
|
2516 |
|
|
2517 |
/* This reloc will be computed at runtime, so there's no |
/* This reloc will be computed at runtime, so there's no |
2518 |
need to do anything now. */ |
need to do anything now. */ |
2519 |
if (! relocate) |
if (! relocate) |
2520 |
continue; |
continue; |
2521 |
} |
} |
2522 |
break; |
break; |
2523 |
|
|
2524 |
|
case R_SPARC_TLS_GD_HI22: |
2525 |
|
if (! elf32_sparc_tdata (input_bfd)->has_tlsgd) |
2526 |
|
{ |
2527 |
|
/* R_SPARC_REV32 used the same reloc number as |
2528 |
|
R_SPARC_TLS_GD_HI22. */ |
2529 |
|
r_type = R_SPARC_REV32; |
2530 |
|
break; |
2531 |
|
} |
2532 |
|
/* Fall through */ |
2533 |
|
|
2534 |
|
case R_SPARC_TLS_GD_LO10: |
2535 |
|
case R_SPARC_TLS_IE_HI22: |
2536 |
|
case R_SPARC_TLS_IE_LO10: |
2537 |
|
r_type = elf32_sparc_tls_transition (info, input_bfd, r_type, |
2538 |
|
h == NULL); |
2539 |
|
tls_type = GOT_UNKNOWN; |
2540 |
|
if (h == NULL && local_got_offsets) |
2541 |
|
tls_type = elf32_sparc_local_got_tls_type (input_bfd) [r_symndx]; |
2542 |
|
else if (h != NULL) |
2543 |
|
{ |
2544 |
|
tls_type = elf32_sparc_hash_entry(h)->tls_type; |
2545 |
|
if (!info->shared && h->dynindx == -1 && tls_type == GOT_TLS_IE) |
2546 |
|
switch (ELF32_R_TYPE (rel->r_info)) |
2547 |
|
{ |
2548 |
|
case R_SPARC_TLS_GD_HI22: |
2549 |
|
case R_SPARC_TLS_IE_HI22: |
2550 |
|
r_type = R_SPARC_TLS_LE_HIX22; |
2551 |
|
break; |
2552 |
|
default: |
2553 |
|
r_type = R_SPARC_TLS_LE_LOX10; |
2554 |
|
break; |
2555 |
|
} |
2556 |
|
} |
2557 |
|
if (tls_type == GOT_TLS_IE) |
2558 |
|
switch (r_type) |
2559 |
|
{ |
2560 |
|
case R_SPARC_TLS_GD_HI22: |
2561 |
|
r_type = R_SPARC_TLS_IE_HI22; |
2562 |
|
break; |
2563 |
|
case R_SPARC_TLS_GD_LO10: |
2564 |
|
r_type = R_SPARC_TLS_IE_LO10; |
2565 |
|
break; |
2566 |
|
} |
2567 |
|
|
2568 |
|
if (r_type == R_SPARC_TLS_LE_HIX22) |
2569 |
|
{ |
2570 |
|
relocation = tpoff (info, relocation); |
2571 |
|
break; |
2572 |
|
} |
2573 |
|
if (r_type == R_SPARC_TLS_LE_LOX10) |
2574 |
|
{ |
2575 |
|
/* Change add into xor. */ |
2576 |
|
relocation = tpoff (info, relocation); |
2577 |
|
bfd_put_32 (output_bfd, (bfd_get_32 (input_bfd, |
2578 |
|
contents + rel->r_offset) |
2579 |
|
| 0x80182000), contents + rel->r_offset); |
2580 |
|
break; |
2581 |
|
} |
2582 |
|
|
2583 |
|
if (h != NULL) |
2584 |
|
{ |
2585 |
|
off = h->got.offset; |
2586 |
|
h->got.offset |= 1; |
2587 |
|
} |
2588 |
|
else |
2589 |
|
{ |
2590 |
|
BFD_ASSERT (local_got_offsets != NULL); |
2591 |
|
off = local_got_offsets[r_symndx]; |
2592 |
|
local_got_offsets[r_symndx] |= 1; |
2593 |
|
} |
2594 |
|
|
2595 |
|
r_sparc_tlsldm: |
2596 |
|
if (htab->sgot == NULL) |
2597 |
|
abort (); |
2598 |
|
|
2599 |
|
if ((off & 1) != 0) |
2600 |
|
off &= ~1; |
2601 |
|
else |
2602 |
|
{ |
2603 |
|
Elf_Internal_Rela outrel; |
2604 |
|
Elf32_External_Rela *loc; |
2605 |
|
int dr_type, indx; |
2606 |
|
|
2607 |
|
if (htab->srelgot == NULL) |
2608 |
|
abort (); |
2609 |
|
|
2610 |
|
bfd_put_32 (output_bfd, 0, htab->sgot->contents + off); |
2611 |
|
outrel.r_offset = (htab->sgot->output_section->vma |
2612 |
|
+ htab->sgot->output_offset + off); |
2613 |
|
indx = h && h->dynindx != -1 ? h->dynindx : 0; |
2614 |
|
if (r_type == R_SPARC_TLS_IE_HI22 |
2615 |
|
|| r_type == R_SPARC_TLS_IE_LO10) |
2616 |
|
dr_type = R_SPARC_TLS_TPOFF32; |
2617 |
|
else |
2618 |
|
dr_type = R_SPARC_TLS_DTPMOD32; |
2619 |
|
if (dr_type == R_SPARC_TLS_TPOFF32 && indx == 0) |
2620 |
|
outrel.r_addend = relocation - dtpoff_base (info); |
2621 |
|
else |
2622 |
|
outrel.r_addend = 0; |
2623 |
|
outrel.r_info = ELF32_R_INFO (indx, dr_type); |
2624 |
|
loc = (Elf32_External_Rela *) htab->srelgot->contents; |
2625 |
|
loc += htab->srelgot->reloc_count++; |
2626 |
|
bfd_elf32_swap_reloca_out (output_bfd, &outrel, |
2627 |
|
(bfd_byte *) loc); |
2628 |
|
|
2629 |
|
if (r_type == R_SPARC_TLS_GD_HI22 |
2630 |
|
|| r_type == R_SPARC_TLS_GD_LO10) |
2631 |
|
{ |
2632 |
|
if (indx == 0) |
2633 |
|
{ |
2634 |
|
BFD_ASSERT (! unresolved_reloc); |
2635 |
|
bfd_put_32 (output_bfd, |
2636 |
|
relocation - dtpoff_base (info), |
2637 |
|
htab->sgot->contents + off + 4); |
2638 |
|
} |
2639 |
|
else |
2640 |
|
{ |
2641 |
|
bfd_put_32 (output_bfd, 0, |
2642 |
|
htab->sgot->contents + off + 4); |
2643 |
|
outrel.r_info = ELF32_R_INFO (indx, |
2644 |
|
R_SPARC_TLS_DTPOFF32); |
2645 |
|
outrel.r_offset += 4; |
2646 |
|
htab->srelgot->reloc_count++; |
2647 |
|
loc++; |
2648 |
|
bfd_elf32_swap_reloca_out (output_bfd, &outrel, |
2649 |
|
(bfd_byte *) loc); |
2650 |
|
} |
2651 |
|
} |
2652 |
|
else if (dr_type == R_SPARC_TLS_DTPMOD32) |
2653 |
|
{ |
2654 |
|
bfd_put_32 (output_bfd, 0, |
2655 |
|
htab->sgot->contents + off + 4); |
2656 |
|
} |
2657 |
|
} |
2658 |
|
|
2659 |
|
if (off >= (bfd_vma) -2) |
2660 |
|
abort (); |
2661 |
|
|
2662 |
|
relocation = htab->sgot->output_offset + off - got_base; |
2663 |
|
unresolved_reloc = FALSE; |
2664 |
|
howto = _bfd_sparc_elf_howto_table + r_type; |
2665 |
|
break; |
2666 |
|
|
2667 |
|
case R_SPARC_TLS_LDM_HI22: |
2668 |
|
case R_SPARC_TLS_LDM_LO10: |
2669 |
|
if (! info->shared) |
2670 |
|
{ |
2671 |
|
bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset); |
2672 |
|
continue; |
2673 |
|
} |
2674 |
|
off = htab->tls_ldm_got.offset; |
2675 |
|
htab->tls_ldm_got.offset |= 1; |
2676 |
|
goto r_sparc_tlsldm; |
2677 |
|
|
2678 |
|
case R_SPARC_TLS_LDO_HIX22: |
2679 |
|
case R_SPARC_TLS_LDO_LOX10: |
2680 |
|
if (info->shared) |
2681 |
|
relocation -= dtpoff_base (info); |
2682 |
|
else |
2683 |
|
relocation = tpoff (info, relocation); |
2684 |
|
break; |
2685 |
|
|
2686 |
|
case R_SPARC_TLS_LE_HIX22: |
2687 |
|
case R_SPARC_TLS_LE_LOX10: |
2688 |
|
if (info->shared) |
2689 |
|
{ |
2690 |
|
Elf_Internal_Rela outrel; |
2691 |
|
bfd_boolean skip, relocate = FALSE; |
2692 |
|
|
2693 |
|
BFD_ASSERT (sreloc != NULL); |
2694 |
|
skip = FALSE; |
2695 |
|
outrel.r_offset = |
2696 |
|
_bfd_elf_section_offset (output_bfd, info, input_section, |
2697 |
|
rel->r_offset); |
2698 |
|
if (outrel.r_offset == (bfd_vma) -1) |
2699 |
|
skip = TRUE; |
2700 |
|
else if (outrel.r_offset == (bfd_vma) -2) |
2701 |
|
skip = TRUE, relocate = TRUE; |
2702 |
|
outrel.r_offset += (input_section->output_section->vma |
2703 |
|
+ input_section->output_offset); |
2704 |
|
if (skip) |
2705 |
|
memset (&outrel, 0, sizeof outrel); |
2706 |
|
else |
2707 |
|
{ |
2708 |
|
outrel.r_info = ELF32_R_INFO (0, r_type); |
2709 |
|
outrel.r_addend = relocation - dtpoff_base (info) |
2710 |
|
+ rel->r_addend; |
2711 |
|
} |
2712 |
|
|
2713 |
|
bfd_elf32_swap_reloca_out (output_bfd, &outrel, |
2714 |
|
(bfd_byte *) (((Elf32_External_Rela *) |
2715 |
|
sreloc->contents) |
2716 |
|
+ sreloc->reloc_count)); |
2717 |
|
++sreloc->reloc_count; |
2718 |
|
continue; |
2719 |
|
} |
2720 |
|
relocation = tpoff (info, relocation); |
2721 |
|
break; |
2722 |
|
|
2723 |
|
case R_SPARC_TLS_LDM_CALL: |
2724 |
|
if (! info->shared) |
2725 |
|
{ |
2726 |
|
/* mov %g0, %o0 */ |
2727 |
|
bfd_put_32 (output_bfd, 0x90100000, contents + rel->r_offset); |
2728 |
|
continue; |
2729 |
|
} |
2730 |
|
/* Fall through */ |
2731 |
|
|
2732 |
|
case R_SPARC_TLS_GD_CALL: |
2733 |
|
tls_type = GOT_UNKNOWN; |
2734 |
|
if (h == NULL && local_got_offsets) |
2735 |
|
tls_type = elf32_sparc_local_got_tls_type (input_bfd) [r_symndx]; |
2736 |
|
else if (h != NULL) |
2737 |
|
tls_type = elf32_sparc_hash_entry(h)->tls_type; |
2738 |
|
if (! info->shared |
2739 |
|
|| (r_type == R_SPARC_TLS_GD_CALL && tls_type == GOT_TLS_IE)) |
2740 |
|
{ |
2741 |
|
bfd_vma insn; |
2742 |
|
|
2743 |
|
if (!info->shared && (h == NULL || h->dynindx == -1)) |
2744 |
|
{ |
2745 |
|
/* GD -> LE */ |
2746 |
|
bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset); |
2747 |
|
continue; |
2748 |
|
} |
2749 |
|
|
2750 |
|
/* GD -> IE */ |
2751 |
|
if (rel + 1 < relend |
2752 |
|
&& ELF32_R_TYPE (rel[1].r_info) == R_SPARC_TLS_GD_ADD |
2753 |
|
&& rel[1].r_offset == rel->r_offset + 4 |
2754 |
|
&& ELF32_R_SYM (rel[1].r_info) == r_symndx |
2755 |
|
&& (((insn = bfd_get_32 (input_bfd, |
2756 |
|
contents + rel[1].r_offset)) |
2757 |
|
>> 25) & 0x1f) == 8) |
2758 |
|
{ |
2759 |
|
/* We have |
2760 |
|
call __tls_get_addr, %tgd_call(foo) |
2761 |
|
add %reg1, %reg2, %o0, %tgd_add(foo) |
2762 |
|
and change it into IE: |
2763 |
|
ld [%reg1 + %reg2], %o0, %tie_ld(foo) |
2764 |
|
add %g7, %o0, %o0, %tie_add(foo). |
2765 |
|
add is 0x80000000 | (rd << 25) | (rs1 << 14) | rs2, |
2766 |
|
ld is 0xc0000000 | (rd << 25) | (rs1 << 14) | rs2. */ |
2767 |
|
bfd_put_32 (output_bfd, insn | 0xc0000000, |
2768 |
|
contents + rel->r_offset); |
2769 |
|
bfd_put_32 (output_bfd, 0x9001c008, |
2770 |
|
contents + rel->r_offset + 4); |
2771 |
|
rel++; |
2772 |
|
continue; |
2773 |
|
} |
2774 |
|
|
2775 |
|
bfd_put_32 (output_bfd, 0x9001c008, contents + rel->r_offset); |
2776 |
|
continue; |
2777 |
|
} |
2778 |
|
|
2779 |
|
h = (struct elf_link_hash_entry *) |
2780 |
|
bfd_link_hash_lookup (info->hash, "__tls_get_addr", FALSE, |
2781 |
|
FALSE, TRUE); |
2782 |
|
BFD_ASSERT (h != NULL); |
2783 |
|
r_type = R_SPARC_WPLT30; |
2784 |
|
howto = _bfd_sparc_elf_howto_table + r_type; |
2785 |
|
goto r_sparc_wplt30; |
2786 |
|
|
2787 |
|
case R_SPARC_TLS_GD_ADD: |
2788 |
|
tls_type = GOT_UNKNOWN; |
2789 |
|
if (h == NULL && local_got_offsets) |
2790 |
|
tls_type = elf32_sparc_local_got_tls_type (input_bfd) [r_symndx]; |
2791 |
|
else if (h != NULL) |
2792 |
|
tls_type = elf32_sparc_hash_entry(h)->tls_type; |
2793 |
|
if (! info->shared || tls_type == GOT_TLS_IE) |
2794 |
|
{ |
2795 |
|
/* add %reg1, %reg2, %reg3, %tgd_add(foo) |
2796 |
|
changed into IE: |
2797 |
|
ld [%reg1 + %reg2], %reg3, %tie_ld(foo) |
2798 |
|
or LE: |
2799 |
|
add %g7, %reg2, %reg3. */ |
2800 |
|
bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset); |
2801 |
|
if ((h != NULL && h->dynindx != -1) || info->shared) |
2802 |
|
relocation = insn | 0xc0000000; |
2803 |
|
else |
2804 |
|
relocation = (insn & ~0x7c000) | 0x1c000; |
2805 |
|
bfd_put_32 (output_bfd, relocation, contents + rel->r_offset); |
2806 |
|
} |
2807 |
|
continue; |
2808 |
|
|
2809 |
|
case R_SPARC_TLS_LDM_ADD: |
2810 |
|
if (! info->shared) |
2811 |
|
bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset); |
2812 |
|
continue; |
2813 |
|
|
2814 |
|
case R_SPARC_TLS_LDO_ADD: |
2815 |
|
if (! info->shared) |
2816 |
|
{ |
2817 |
|
/* Change rs1 into %g7. */ |
2818 |
|
bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset); |
2819 |
|
insn = (insn & ~0x7c000) | 0x1c000; |
2820 |
|
bfd_put_32 (output_bfd, insn, contents + rel->r_offset); |
2821 |
|
} |
2822 |
|
continue; |
2823 |
|
|
2824 |
|
case R_SPARC_TLS_IE_LD: |
2825 |
|
case R_SPARC_TLS_IE_LDX: |
2826 |
|
if (! info->shared && (h == NULL || h->dynindx == -1)) |
2827 |
|
{ |
2828 |
|
bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset); |
2829 |
|
int rs2 = insn & 0x1f; |
2830 |
|
int rd = (insn >> 25) & 0x1f; |
2831 |
|
|
2832 |
|
if (rs2 == rd) |
2833 |
|
relocation = SPARC_NOP; |
2834 |
|
else |
2835 |
|
relocation = 0x80100000 | (insn & 0x3e00001f); |
2836 |
|
bfd_put_32 (output_bfd, relocation, contents + rel->r_offset); |
2837 |
|
} |
2838 |
|
continue; |
2839 |
|
|
2840 |
|
case R_SPARC_TLS_IE_ADD: |
2841 |
|
/* Totally useless relocation. */ |
2842 |
|
continue; |
2843 |
|
|
2844 |
|
case R_SPARC_TLS_DTPOFF32: |
2845 |
|
relocation -= dtpoff_base (info); |
2846 |
|
break; |
2847 |
|
|
2848 |
default: |
default: |
2849 |
break; |
break; |
2850 |
} |
} |
2854 |
not process them. */ |
not process them. */ |
2855 |
if (unresolved_reloc |
if (unresolved_reloc |
2856 |
&& !((input_section->flags & SEC_DEBUGGING) != 0 |
&& !((input_section->flags & SEC_DEBUGGING) != 0 |
2857 |
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0)) |
&& h->def_dynamic)) |
2858 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
2859 |
(_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"), |
(_("%B(%A+0x%lx): unresolvable relocation against symbol `%s'"), |
2860 |
bfd_archive_filename (input_bfd), |
input_bfd, |
2861 |
bfd_get_section_name (input_bfd, input_section), |
input_section, |
2862 |
(long) rel->r_offset, |
(long) rel->r_offset, |
2863 |
h->root.root.string); |
h->root.root.string); |
2864 |
|
|
2894 |
bfd_putl32 (/*input_bfd,*/ x, contents + rel->r_offset); |
bfd_putl32 (/*input_bfd,*/ x, contents + rel->r_offset); |
2895 |
r = bfd_reloc_ok; |
r = bfd_reloc_ok; |
2896 |
} |
} |
2897 |
|
else if (r_type == R_SPARC_TLS_LDO_HIX22 |
2898 |
|
|| r_type == R_SPARC_TLS_LE_HIX22) |
2899 |
|
{ |
2900 |
|
bfd_vma x; |
2901 |
|
|
2902 |
|
relocation += rel->r_addend; |
2903 |
|
relocation = relocation ^ 0xffffffff; |
2904 |
|
|
2905 |
|
x = bfd_get_32 (input_bfd, contents + rel->r_offset); |
2906 |
|
x = (x & ~(bfd_vma) 0x3fffff) | ((relocation >> 10) & 0x3fffff); |
2907 |
|
bfd_put_32 (input_bfd, x, contents + rel->r_offset); |
2908 |
|
r = bfd_reloc_ok; |
2909 |
|
} |
2910 |
|
else if (r_type == R_SPARC_TLS_LDO_LOX10 |
2911 |
|
|| r_type == R_SPARC_TLS_LE_LOX10) |
2912 |
|
{ |
2913 |
|
bfd_vma x; |
2914 |
|
|
2915 |
|
relocation += rel->r_addend; |
2916 |
|
relocation = (relocation & 0x3ff) | 0x1c00; |
2917 |
|
|
2918 |
|
x = bfd_get_32 (input_bfd, contents + rel->r_offset); |
2919 |
|
x = (x & ~(bfd_vma) 0x1fff) | relocation; |
2920 |
|
bfd_put_32 (input_bfd, x, contents + rel->r_offset); |
2921 |
|
|
2922 |
|
r = bfd_reloc_ok; |
2923 |
|
} |
2924 |
else if ((r_type == R_SPARC_WDISP30 || r_type == R_SPARC_WPLT30) |
else if ((r_type == R_SPARC_WDISP30 || r_type == R_SPARC_WPLT30) |
2925 |
&& SEC_DO_RELAX (input_section) |
&& sec_do_relax (input_section) |
2926 |
&& rel->r_offset + 4 < input_section->_raw_size) |
&& rel->r_offset + 4 < input_section->size) |
2927 |
{ |
{ |
2928 |
#define G0 0 |
#define G0 0 |
2929 |
#define O7 15 |
#define O7 15 |
3028 |
const char *name; |
const char *name; |
3029 |
|
|
3030 |
if (h != NULL) |
if (h != NULL) |
3031 |
name = h->root.root.string; |
name = NULL; |
3032 |
else |
else |
3033 |
{ |
{ |
3034 |
name = bfd_elf_string_from_elf_section (input_bfd, |
name = bfd_elf_string_from_elf_section (input_bfd, |
3035 |
symtab_hdr->sh_link, |
symtab_hdr->sh_link, |
3036 |
sym->st_name); |
sym->st_name); |
3037 |
if (name == NULL) |
if (name == NULL) |
3038 |
return false; |
return FALSE; |
3039 |
if (*name == '\0') |
if (*name == '\0') |
3040 |
name = bfd_section_name (input_bfd, sec); |
name = bfd_section_name (input_bfd, sec); |
3041 |
} |
} |
3042 |
if (! ((*info->callbacks->reloc_overflow) |
if (! ((*info->callbacks->reloc_overflow) |
3043 |
(info, name, howto->name, (bfd_vma) 0, |
(info, (h ? &h->root : NULL), name, howto->name, |
3044 |
input_bfd, input_section, rel->r_offset))) |
(bfd_vma) 0, input_bfd, input_section, |
3045 |
return false; |
rel->r_offset))) |
3046 |
|
return FALSE; |
3047 |
} |
} |
3048 |
break; |
break; |
3049 |
} |
} |
3050 |
} |
} |
3051 |
} |
} |
3052 |
|
|
3053 |
return true; |
return TRUE; |
3054 |
} |
} |
3055 |
|
|
3056 |
/* Finish up dynamic symbol handling. We set the contents of various |
/* Finish up dynamic symbol handling. We set the contents of various |
3057 |
dynamic sections here. */ |
dynamic sections here. */ |
3058 |
|
|
3059 |
static boolean |
static bfd_boolean |
3060 |
elf32_sparc_finish_dynamic_symbol (output_bfd, info, h, sym) |
elf32_sparc_finish_dynamic_symbol (output_bfd, info, h, sym) |
3061 |
bfd *output_bfd; |
bfd *output_bfd; |
3062 |
struct bfd_link_info *info; |
struct bfd_link_info *info; |
3064 |
Elf_Internal_Sym *sym; |
Elf_Internal_Sym *sym; |
3065 |
{ |
{ |
3066 |
bfd *dynobj; |
bfd *dynobj; |
3067 |
|
struct elf32_sparc_link_hash_table *htab; |
3068 |
|
|
3069 |
dynobj = elf_hash_table (info)->dynobj; |
htab = elf32_sparc_hash_table (info); |
3070 |
|
dynobj = htab->elf.dynobj; |
3071 |
|
|
3072 |
if (h->plt.offset != (bfd_vma) -1) |
if (h->plt.offset != (bfd_vma) -1) |
3073 |
{ |
{ |
3074 |
asection *splt; |
asection *splt; |
3075 |
asection *srela; |
asection *srela; |
3076 |
Elf_Internal_Rela rela; |
Elf_Internal_Rela rela; |
3077 |
|
bfd_byte *loc; |
3078 |
|
|
3079 |
/* This symbol has an entry in the procedure linkage table. Set |
/* This symbol has an entry in the procedure linkage table. Set |
3080 |
it up. */ |
it up. */ |
3081 |
|
|
3082 |
BFD_ASSERT (h->dynindx != -1); |
BFD_ASSERT (h->dynindx != -1); |
3083 |
|
|
3084 |
splt = bfd_get_section_by_name (dynobj, ".plt"); |
splt = htab->splt; |
3085 |
srela = bfd_get_section_by_name (dynobj, ".rela.plt"); |
srela = htab->srelplt; |
3086 |
BFD_ASSERT (splt != NULL && srela != NULL); |
BFD_ASSERT (splt != NULL && srela != NULL); |
3087 |
|
|
3088 |
/* Fill in the entry in the procedure linkage table. */ |
/* Fill in the entry in the procedure linkage table. */ |
3102 |
+ h->plt.offset); |
+ h->plt.offset); |
3103 |
rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_JMP_SLOT); |
rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_JMP_SLOT); |
3104 |
rela.r_addend = 0; |
rela.r_addend = 0; |
3105 |
bfd_elf32_swap_reloca_out (output_bfd, &rela, |
loc = srela->contents; |
3106 |
((Elf32_External_Rela *) srela->contents |
loc += (h->plt.offset / PLT_ENTRY_SIZE - 4) * sizeof (Elf32_External_Rela); |
3107 |
+ h->plt.offset / PLT_ENTRY_SIZE - 4)); |
bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); |
3108 |
|
|
3109 |
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) |
if (!h->def_regular) |
3110 |
{ |
{ |
3111 |
/* Mark the symbol as undefined, rather than as defined in |
/* Mark the symbol as undefined, rather than as defined in |
3112 |
the .plt section. Leave the value alone. */ |
the .plt section. Leave the value alone. */ |
3115 |
Otherwise, the PLT entry would provide a definition for |
Otherwise, the PLT entry would provide a definition for |
3116 |
the symbol even if the symbol wasn't defined anywhere, |
the symbol even if the symbol wasn't defined anywhere, |
3117 |
and so the symbol would never be NULL. */ |
and so the symbol would never be NULL. */ |
3118 |
if ((h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR_NONWEAK) |
if (!h->ref_regular_nonweak) |
|
== 0) |
|
3119 |
sym->st_value = 0; |
sym->st_value = 0; |
3120 |
} |
} |
3121 |
} |
} |
3122 |
|
|
3123 |
if (h->got.offset != (bfd_vma) -1) |
if (h->got.offset != (bfd_vma) -1 |
3124 |
|
&& elf32_sparc_hash_entry(h)->tls_type != GOT_TLS_GD |
3125 |
|
&& elf32_sparc_hash_entry(h)->tls_type != GOT_TLS_IE) |
3126 |
{ |
{ |
3127 |
asection *sgot; |
asection *sgot; |
3128 |
asection *srela; |
asection *srela; |
3129 |
Elf_Internal_Rela rela; |
Elf_Internal_Rela rela; |
3130 |
|
bfd_byte *loc; |
3131 |
|
|
3132 |
/* This symbol has an entry in the global offset table. Set it |
/* This symbol has an entry in the global offset table. Set it |
3133 |
up. */ |
up. */ |
3134 |
|
|
3135 |
sgot = bfd_get_section_by_name (dynobj, ".got"); |
sgot = htab->sgot; |
3136 |
srela = bfd_get_section_by_name (dynobj, ".rela.got"); |
srela = htab->srelgot; |
3137 |
BFD_ASSERT (sgot != NULL && srela != NULL); |
BFD_ASSERT (sgot != NULL && srela != NULL); |
3138 |
|
|
3139 |
rela.r_offset = (sgot->output_section->vma |
rela.r_offset = (sgot->output_section->vma |
3147 |
initialized in the relocate_section function. */ |
initialized in the relocate_section function. */ |
3148 |
if (info->shared |
if (info->shared |
3149 |
&& (info->symbolic || h->dynindx == -1) |
&& (info->symbolic || h->dynindx == -1) |
3150 |
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) |
&& h->def_regular) |
3151 |
rela.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE); |
{ |
3152 |
|
asection *sec = h->root.u.def.section; |
3153 |
|
rela.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE); |
3154 |
|
rela.r_addend = (h->root.u.def.value |
3155 |
|
+ sec->output_section->vma |
3156 |
|
+ sec->output_offset); |
3157 |
|
} |
3158 |
else |
else |
3159 |
{ |
{ |
|
bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset); |
|
3160 |
rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_GLOB_DAT); |
rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_GLOB_DAT); |
3161 |
|
rela.r_addend = 0; |
3162 |
} |
} |
3163 |
|
|
3164 |
rela.r_addend = 0; |
bfd_put_32 (output_bfd, (bfd_vma) 0, |
3165 |
bfd_elf32_swap_reloca_out (output_bfd, &rela, |
sgot->contents + (h->got.offset &~ (bfd_vma) 1)); |
3166 |
((Elf32_External_Rela *) srela->contents |
loc = srela->contents; |
3167 |
+ srela->reloc_count)); |
loc += srela->reloc_count++ * sizeof (Elf32_External_Rela); |
3168 |
++srela->reloc_count; |
bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); |
3169 |
} |
} |
3170 |
|
|
3171 |
if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0) |
if (h->needs_copy) |
3172 |
{ |
{ |
3173 |
asection *s; |
asection *s; |
3174 |
Elf_Internal_Rela rela; |
Elf_Internal_Rela rela; |
3175 |
|
bfd_byte *loc; |
3176 |
|
|
3177 |
/* This symbols needs a copy reloc. Set it up. */ |
/* This symbols needs a copy reloc. Set it up. */ |
3178 |
|
|
3187 |
+ h->root.u.def.section->output_offset); |
+ h->root.u.def.section->output_offset); |
3188 |
rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_COPY); |
rela.r_info = ELF32_R_INFO (h->dynindx, R_SPARC_COPY); |
3189 |
rela.r_addend = 0; |
rela.r_addend = 0; |
3190 |
bfd_elf32_swap_reloca_out (output_bfd, &rela, |
loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela); |
3191 |
((Elf32_External_Rela *) s->contents |
bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); |
|
+ s->reloc_count)); |
|
|
++s->reloc_count; |
|
3192 |
} |
} |
3193 |
|
|
3194 |
/* Mark some specially defined symbols as absolute. */ |
/* Mark some specially defined symbols as absolute. */ |
3197 |
|| strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0) |
|| strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0) |
3198 |
sym->st_shndx = SHN_ABS; |
sym->st_shndx = SHN_ABS; |
3199 |
|
|
3200 |
return true; |
return TRUE; |
3201 |
} |
} |
3202 |
|
|
3203 |
/* Finish up the dynamic sections. */ |
/* Finish up the dynamic sections. */ |
3204 |
|
|
3205 |
static boolean |
static bfd_boolean |
3206 |
elf32_sparc_finish_dynamic_sections (output_bfd, info) |
elf32_sparc_finish_dynamic_sections (output_bfd, info) |
3207 |
bfd *output_bfd; |
bfd *output_bfd; |
3208 |
struct bfd_link_info *info; |
struct bfd_link_info *info; |
3209 |
{ |
{ |
3210 |
bfd *dynobj; |
bfd *dynobj; |
3211 |
asection *sdyn; |
asection *sdyn; |
3212 |
asection *sgot; |
struct elf32_sparc_link_hash_table *htab; |
3213 |
|
|
3214 |
dynobj = elf_hash_table (info)->dynobj; |
htab = elf32_sparc_hash_table (info); |
3215 |
|
dynobj = htab->elf.dynobj; |
3216 |
|
|
3217 |
sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); |
sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); |
3218 |
|
|
3225 |
BFD_ASSERT (splt != NULL && sdyn != NULL); |
BFD_ASSERT (splt != NULL && sdyn != NULL); |
3226 |
|
|
3227 |
dyncon = (Elf32_External_Dyn *) sdyn->contents; |
dyncon = (Elf32_External_Dyn *) sdyn->contents; |
3228 |
dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); |
dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); |
3229 |
for (; dyncon < dynconend; dyncon++) |
for (; dyncon < dynconend; dyncon++) |
3230 |
{ |
{ |
3231 |
Elf_Internal_Dyn dyn; |
Elf_Internal_Dyn dyn; |
3232 |
const char *name; |
const char *name; |
3233 |
boolean size; |
bfd_boolean size; |
3234 |
|
|
3235 |
bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn); |
bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn); |
3236 |
|
|
3237 |
switch (dyn.d_tag) |
switch (dyn.d_tag) |
3238 |
{ |
{ |
3239 |
case DT_PLTGOT: name = ".plt"; size = false; break; |
case DT_PLTGOT: name = ".plt"; size = FALSE; break; |
3240 |
case DT_PLTRELSZ: name = ".rela.plt"; size = true; break; |
case DT_PLTRELSZ: name = ".rela.plt"; size = TRUE; break; |
3241 |
case DT_JMPREL: name = ".rela.plt"; size = false; break; |
case DT_JMPREL: name = ".rela.plt"; size = FALSE; break; |
3242 |
default: name = NULL; size = false; break; |
default: name = NULL; size = FALSE; break; |
3243 |
} |
} |
3244 |
|
|
3245 |
if (name != NULL) |
if (name != NULL) |
3254 |
if (! size) |
if (! size) |
3255 |
dyn.d_un.d_ptr = s->vma; |
dyn.d_un.d_ptr = s->vma; |
3256 |
else |
else |
3257 |
{ |
dyn.d_un.d_val = s->size; |
|
if (s->_cooked_size != 0) |
|
|
dyn.d_un.d_val = s->_cooked_size; |
|
|
else |
|
|
dyn.d_un.d_val = s->_raw_size; |
|
|
} |
|
3258 |
} |
} |
3259 |
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); |
bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); |
3260 |
} |
} |
3262 |
|
|
3263 |
/* Clear the first four entries in the procedure linkage table, |
/* Clear the first four entries in the procedure linkage table, |
3264 |
and put a nop in the last four bytes. */ |
and put a nop in the last four bytes. */ |
3265 |
if (splt->_raw_size > 0) |
if (splt->size > 0) |
3266 |
{ |
{ |
3267 |
memset (splt->contents, 0, 4 * PLT_ENTRY_SIZE); |
memset (splt->contents, 0, 4 * PLT_ENTRY_SIZE); |
3268 |
bfd_put_32 (output_bfd, (bfd_vma) SPARC_NOP, |
bfd_put_32 (output_bfd, (bfd_vma) SPARC_NOP, |
3269 |
splt->contents + splt->_raw_size - 4); |
splt->contents + splt->size - 4); |
3270 |
} |
} |
3271 |
|
|
3272 |
elf_section_data (splt->output_section)->this_hdr.sh_entsize = |
elf_section_data (splt->output_section)->this_hdr.sh_entsize = 0; |
|
PLT_ENTRY_SIZE; |
|
3273 |
} |
} |
3274 |
|
|
3275 |
/* Set the first entry in the global offset table to the address of |
/* Set the first entry in the global offset table to the address of |
3276 |
the dynamic section. */ |
the dynamic section. */ |
3277 |
sgot = bfd_get_section_by_name (dynobj, ".got"); |
if (htab->sgot && htab->sgot->size > 0) |
|
BFD_ASSERT (sgot != NULL); |
|
|
if (sgot->_raw_size > 0) |
|
3278 |
{ |
{ |
3279 |
if (sdyn == NULL) |
if (sdyn == NULL) |
3280 |
bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); |
bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgot->contents); |
3281 |
else |
else |
3282 |
bfd_put_32 (output_bfd, |
bfd_put_32 (output_bfd, |
3283 |
sdyn->output_section->vma + sdyn->output_offset, |
sdyn->output_section->vma + sdyn->output_offset, |
3284 |
sgot->contents); |
htab->sgot->contents); |
3285 |
} |
} |
3286 |
|
|
3287 |
elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4; |
if (htab->sgot) |
3288 |
|
elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize = 4; |
3289 |
|
|
3290 |
return true; |
return TRUE; |
3291 |
} |
} |
3292 |
|
|
3293 |
/* Functions for dealing with the e_flags field. |
/* Functions for dealing with the e_flags field. |
3300 |
/* Merge backend specific data from an object file to the output |
/* Merge backend specific data from an object file to the output |
3301 |
object file when linking. */ |
object file when linking. */ |
3302 |
|
|
3303 |
static boolean |
static bfd_boolean |
3304 |
elf32_sparc_merge_private_bfd_data (ibfd, obfd) |
elf32_sparc_merge_private_bfd_data (ibfd, obfd) |
3305 |
bfd *ibfd; |
bfd *ibfd; |
3306 |
bfd *obfd; |
bfd *obfd; |
3307 |
{ |
{ |
3308 |
boolean error; |
bfd_boolean error; |
3309 |
|
unsigned long ibfd_mach; |
3310 |
/* FIXME: This should not be static. */ |
/* FIXME: This should not be static. */ |
3311 |
static unsigned long previous_ibfd_e_flags = (unsigned long) -1; |
static unsigned long previous_ibfd_e_flags = (unsigned long) -1; |
3312 |
|
|
3313 |
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour |
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour |
3314 |
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour) |
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour) |
3315 |
return true; |
return TRUE; |
3316 |
|
|
3317 |
error = false; |
error = FALSE; |
3318 |
|
|
3319 |
if (bfd_get_mach (ibfd) >= bfd_mach_sparc_v9) |
ibfd_mach = bfd_get_mach (ibfd); |
3320 |
|
if (bfd_mach_sparc_64bit_p (ibfd_mach)) |
3321 |
{ |
{ |
3322 |
error = true; |
error = TRUE; |
3323 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
3324 |
(_("%s: compiled for a 64 bit system and target is 32 bit"), |
(_("%B: compiled for a 64 bit system and target is 32 bit"), ibfd); |
|
bfd_archive_filename (ibfd)); |
|
3325 |
} |
} |
3326 |
else if ((ibfd->flags & DYNAMIC) == 0) |
else if ((ibfd->flags & DYNAMIC) == 0) |
3327 |
{ |
{ |
3328 |
if (bfd_get_mach (obfd) < bfd_get_mach (ibfd)) |
if (bfd_get_mach (obfd) < ibfd_mach) |
3329 |
bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd)); |
bfd_set_arch_mach (obfd, bfd_arch_sparc, ibfd_mach); |
3330 |
} |
} |
3331 |
|
|
3332 |
if (((elf_elfheader (ibfd)->e_flags & EF_SPARC_LEDATA) |
if (((elf_elfheader (ibfd)->e_flags & EF_SPARC_LEDATA) |
3334 |
&& previous_ibfd_e_flags != (unsigned long) -1) |
&& previous_ibfd_e_flags != (unsigned long) -1) |
3335 |
{ |
{ |
3336 |
(*_bfd_error_handler) |
(*_bfd_error_handler) |
3337 |
(_("%s: linking little endian files with big endian files"), |
(_("%B: linking little endian files with big endian files"), ibfd); |
3338 |
bfd_archive_filename (ibfd)); |
error = TRUE; |
|
error = true; |
|
3339 |
} |
} |
3340 |
previous_ibfd_e_flags = elf_elfheader (ibfd)->e_flags & EF_SPARC_LEDATA; |
previous_ibfd_e_flags = elf_elfheader (ibfd)->e_flags & EF_SPARC_LEDATA; |
3341 |
|
|
3342 |
if (error) |
if (error) |
3343 |
{ |
{ |
3344 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
3345 |
return false; |
return FALSE; |
3346 |
} |
} |
3347 |
|
|
3348 |
return true; |
return TRUE; |
3349 |
} |
} |
3350 |
|
|
3351 |
/* Set the right machine number. */ |
/* Set the right machine number. */ |
3352 |
|
|
3353 |
static boolean |
static bfd_boolean |
3354 |
elf32_sparc_object_p (abfd) |
elf32_sparc_object_p (abfd) |
3355 |
bfd *abfd; |
bfd *abfd; |
3356 |
{ |
{ |
3366 |
return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, |
return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, |
3367 |
bfd_mach_sparc_v8plus); |
bfd_mach_sparc_v8plus); |
3368 |
else |
else |
3369 |
return false; |
return FALSE; |
3370 |
} |
} |
3371 |
else if (elf_elfheader (abfd)->e_flags & EF_SPARC_LEDATA) |
else if (elf_elfheader (abfd)->e_flags & EF_SPARC_LEDATA) |
3372 |
return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, |
return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, |
3381 |
static void |
static void |
3382 |
elf32_sparc_final_write_processing (abfd, linker) |
elf32_sparc_final_write_processing (abfd, linker) |
3383 |
bfd *abfd; |
bfd *abfd; |
3384 |
boolean linker ATTRIBUTE_UNUSED; |
bfd_boolean linker ATTRIBUTE_UNUSED; |
3385 |
{ |
{ |
3386 |
switch (bfd_get_mach (abfd)) |
switch (bfd_get_mach (abfd)) |
3387 |
{ |
{ |
3388 |
case bfd_mach_sparc : |
case bfd_mach_sparc : |
3389 |
|
case bfd_mach_sparc_sparclet : |
3390 |
|
case bfd_mach_sparc_sparclite : |
3391 |
break; /* nothing to do */ |
break; /* nothing to do */ |
3392 |
case bfd_mach_sparc_v8plus : |
case bfd_mach_sparc_v8plus : |
3393 |
elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS; |
elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS; |
3406 |
| EF_SPARC_SUN_US3; |
| EF_SPARC_SUN_US3; |
3407 |
break; |
break; |
3408 |
case bfd_mach_sparc_sparclite_le : |
case bfd_mach_sparc_sparclite_le : |
|
elf_elfheader (abfd)->e_machine = EM_SPARC; |
|
3409 |
elf_elfheader (abfd)->e_flags |= EF_SPARC_LEDATA; |
elf_elfheader (abfd)->e_flags |= EF_SPARC_LEDATA; |
3410 |
break; |
break; |
3411 |
default : |
default : |
3430 |
return reloc_class_normal; |
return reloc_class_normal; |
3431 |
} |
} |
3432 |
} |
} |
3433 |
|
|
3434 |
|
/* Return address for Ith PLT stub in section PLT, for relocation REL |
3435 |
|
or (bfd_vma) -1 if it should not be included. */ |
3436 |
|
|
3437 |
|
static bfd_vma |
3438 |
|
elf32_sparc_plt_sym_val (bfd_vma i ATTRIBUTE_UNUSED, |
3439 |
|
const asection *plt ATTRIBUTE_UNUSED, |
3440 |
|
const arelent *rel) |
3441 |
|
{ |
3442 |
|
return rel->address; |
3443 |
|
} |
3444 |
|
|
3445 |
#define TARGET_BIG_SYM bfd_elf32_sparc_vec |
#define TARGET_BIG_SYM bfd_elf32_sparc_vec |
3446 |
#define TARGET_BIG_NAME "elf32-sparc" |
#define TARGET_BIG_NAME "elf32-sparc" |
3450 |
#define ELF_MAXPAGESIZE 0x10000 |
#define ELF_MAXPAGESIZE 0x10000 |
3451 |
|
|
3452 |
#define bfd_elf32_bfd_reloc_type_lookup elf32_sparc_reloc_type_lookup |
#define bfd_elf32_bfd_reloc_type_lookup elf32_sparc_reloc_type_lookup |
3453 |
|
#define bfd_elf32_bfd_link_hash_table_create \ |
3454 |
|
elf32_sparc_link_hash_table_create |
3455 |
#define bfd_elf32_bfd_relax_section elf32_sparc_relax_section |
#define bfd_elf32_bfd_relax_section elf32_sparc_relax_section |
3456 |
|
#define bfd_elf32_new_section_hook elf32_sparc_new_section_hook |
3457 |
#define elf_info_to_howto elf32_sparc_info_to_howto |
#define elf_info_to_howto elf32_sparc_info_to_howto |
3458 |
|
#define elf_backend_copy_indirect_symbol \ |
3459 |
|
elf32_sparc_copy_indirect_symbol |
3460 |
#define elf_backend_create_dynamic_sections \ |
#define elf_backend_create_dynamic_sections \ |
3461 |
_bfd_elf_create_dynamic_sections |
elf32_sparc_create_dynamic_sections |
3462 |
#define elf_backend_check_relocs elf32_sparc_check_relocs |
#define elf_backend_check_relocs elf32_sparc_check_relocs |
3463 |
#define elf_backend_adjust_dynamic_symbol \ |
#define elf_backend_adjust_dynamic_symbol \ |
3464 |
elf32_sparc_adjust_dynamic_symbol |
elf32_sparc_adjust_dynamic_symbol |
3465 |
|
#define elf_backend_omit_section_dynsym elf32_sparc_omit_section_dynsym |
3466 |
#define elf_backend_size_dynamic_sections \ |
#define elf_backend_size_dynamic_sections \ |
3467 |
elf32_sparc_size_dynamic_sections |
elf32_sparc_size_dynamic_sections |
3468 |
#define elf_backend_relocate_section elf32_sparc_relocate_section |
#define elf_backend_relocate_section elf32_sparc_relocate_section |
3472 |
elf32_sparc_finish_dynamic_sections |
elf32_sparc_finish_dynamic_sections |
3473 |
#define bfd_elf32_bfd_merge_private_bfd_data \ |
#define bfd_elf32_bfd_merge_private_bfd_data \ |
3474 |
elf32_sparc_merge_private_bfd_data |
elf32_sparc_merge_private_bfd_data |
3475 |
|
#define bfd_elf32_mkobject elf32_sparc_mkobject |
3476 |
#define elf_backend_object_p elf32_sparc_object_p |
#define elf_backend_object_p elf32_sparc_object_p |
3477 |
#define elf_backend_final_write_processing \ |
#define elf_backend_final_write_processing \ |
3478 |
elf32_sparc_final_write_processing |
elf32_sparc_final_write_processing |
3479 |
#define elf_backend_gc_mark_hook elf32_sparc_gc_mark_hook |
#define elf_backend_gc_mark_hook elf32_sparc_gc_mark_hook |
3480 |
#define elf_backend_gc_sweep_hook elf32_sparc_gc_sweep_hook |
#define elf_backend_gc_sweep_hook elf32_sparc_gc_sweep_hook |
3481 |
|
#define elf_backend_grok_psinfo elf32_sparc_grok_psinfo |
3482 |
#define elf_backend_reloc_type_class elf32_sparc_reloc_type_class |
#define elf_backend_reloc_type_class elf32_sparc_reloc_type_class |
3483 |
|
#define elf_backend_plt_sym_val elf32_sparc_plt_sym_val |
3484 |
|
|
3485 |
#define elf_backend_can_gc_sections 1 |
#define elf_backend_can_gc_sections 1 |
3486 |
|
#define elf_backend_can_refcount 1 |
3487 |
#define elf_backend_want_got_plt 0 |
#define elf_backend_want_got_plt 0 |
3488 |
#define elf_backend_plt_readonly 0 |
#define elf_backend_plt_readonly 0 |
3489 |
#define elf_backend_want_plt_sym 1 |
#define elf_backend_want_plt_sym 1 |
3490 |
#define elf_backend_got_header_size 4 |
#define elf_backend_got_header_size 4 |
3491 |
#define elf_backend_plt_header_size (4*PLT_ENTRY_SIZE) |
#define elf_backend_rela_normal 1 |
3492 |
|
|
3493 |
#include "elf32-target.h" |
#include "elf32-target.h" |