1 /* SPARC-specific support for 32-bit ELF
2 Copyright (C) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 #include "elf/sparc.h"
27 static reloc_howto_type
*elf32_sparc_reloc_type_lookup
28 PARAMS ((bfd
*, bfd_reloc_code_real_type
));
29 static void elf32_sparc_info_to_howto
30 PARAMS ((bfd
*, arelent
*, Elf_Internal_Rela
*));
31 static boolean elf32_sparc_check_relocs
32 PARAMS ((bfd
*, struct bfd_link_info
*, asection
*,
33 const Elf_Internal_Rela
*));
34 static boolean elf32_sparc_adjust_dynamic_symbol
35 PARAMS ((struct bfd_link_info
*, struct elf_link_hash_entry
*));
36 static boolean elf32_sparc_size_dynamic_sections
37 PARAMS ((bfd
*, struct bfd_link_info
*));
38 static boolean elf32_sparc_relocate_section
39 PARAMS ((bfd
*, struct bfd_link_info
*, bfd
*, asection
*, bfd_byte
*,
40 Elf_Internal_Rela
*, Elf_Internal_Sym
*, asection
**));
41 static boolean elf32_sparc_finish_dynamic_symbol
42 PARAMS ((bfd
*, struct bfd_link_info
*, struct elf_link_hash_entry
*,
44 static boolean elf32_sparc_finish_dynamic_sections
45 PARAMS ((bfd
*, struct bfd_link_info
*));
46 static boolean elf32_sparc_merge_private_bfd_data
PARAMS ((bfd
*, bfd
*));
47 static boolean elf32_sparc_object_p
49 static void elf32_sparc_final_write_processing
50 PARAMS ((bfd
*, boolean
));
52 /* The relocation "howto" table. */
54 static bfd_reloc_status_type sparc_elf_notsupported_reloc
55 PARAMS ((bfd
*, arelent
*, asymbol
*, PTR
, asection
*, bfd
*, char **));
56 static bfd_reloc_status_type sparc_elf_wdisp16_reloc
57 PARAMS ((bfd
*, arelent
*, asymbol
*, PTR
, asection
*, bfd
*, char **));
59 reloc_howto_type _bfd_sparc_elf_howto_table
[] =
61 HOWTO(R_SPARC_NONE
, 0,0, 0,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_NONE", false,0,0x00000000,true),
62 HOWTO(R_SPARC_8
, 0,0, 8,false,0,complain_overflow_bitfield
,bfd_elf_generic_reloc
, "R_SPARC_8", false,0,0x000000ff,true),
63 HOWTO(R_SPARC_16
, 0,1,16,false,0,complain_overflow_bitfield
,bfd_elf_generic_reloc
, "R_SPARC_16", false,0,0x0000ffff,true),
64 HOWTO(R_SPARC_32
, 0,2,32,false,0,complain_overflow_bitfield
,bfd_elf_generic_reloc
, "R_SPARC_32", false,0,0xffffffff,true),
65 HOWTO(R_SPARC_DISP8
, 0,0, 8,true, 0,complain_overflow_signed
, bfd_elf_generic_reloc
, "R_SPARC_DISP8", false,0,0x000000ff,true),
66 HOWTO(R_SPARC_DISP16
, 0,1,16,true, 0,complain_overflow_signed
, bfd_elf_generic_reloc
, "R_SPARC_DISP16", false,0,0x0000ffff,true),
67 HOWTO(R_SPARC_DISP32
, 0,2,32,true, 0,complain_overflow_signed
, bfd_elf_generic_reloc
, "R_SPARC_DISP32", false,0,0x00ffffff,true),
68 HOWTO(R_SPARC_WDISP30
, 2,2,30,true, 0,complain_overflow_signed
, bfd_elf_generic_reloc
, "R_SPARC_WDISP30", false,0,0x3fffffff,true),
69 HOWTO(R_SPARC_WDISP22
, 2,2,22,true, 0,complain_overflow_signed
, bfd_elf_generic_reloc
, "R_SPARC_WDISP22", false,0,0x003fffff,true),
70 HOWTO(R_SPARC_HI22
, 10,2,22,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_HI22", false,0,0x003fffff,true),
71 HOWTO(R_SPARC_22
, 0,2,22,false,0,complain_overflow_bitfield
,bfd_elf_generic_reloc
, "R_SPARC_22", false,0,0x003fffff,true),
72 HOWTO(R_SPARC_13
, 0,2,13,false,0,complain_overflow_bitfield
,bfd_elf_generic_reloc
, "R_SPARC_13", false,0,0x00001fff,true),
73 HOWTO(R_SPARC_LO10
, 0,2,10,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_LO10", false,0,0x000003ff,true),
74 HOWTO(R_SPARC_GOT10
, 0,2,10,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_GOT10", false,0,0x000003ff,true),
75 HOWTO(R_SPARC_GOT13
, 0,2,13,false,0,complain_overflow_signed
, bfd_elf_generic_reloc
, "R_SPARC_GOT13", false,0,0x00001fff,true),
76 HOWTO(R_SPARC_GOT22
, 10,2,22,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_GOT22", false,0,0x003fffff,true),
77 HOWTO(R_SPARC_PC10
, 0,2,10,true, 0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_PC10", false,0,0x000003ff,true),
78 HOWTO(R_SPARC_PC22
, 10,2,22,true, 0,complain_overflow_bitfield
,bfd_elf_generic_reloc
, "R_SPARC_PC22", false,0,0x003fffff,true),
79 HOWTO(R_SPARC_WPLT30
, 2,2,30,true, 0,complain_overflow_signed
, bfd_elf_generic_reloc
, "R_SPARC_WPLT30", false,0,0x3fffffff,true),
80 HOWTO(R_SPARC_COPY
, 0,0,00,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_COPY", false,0,0x00000000,true),
81 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),
82 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),
83 HOWTO(R_SPARC_RELATIVE
, 0,0,00,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_RELATIVE",false,0,0x00000000,true),
84 HOWTO(R_SPARC_UA32
, 0,0,00,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_UA32", false,0,0x00000000,true),
85 HOWTO(R_SPARC_PLT32
, 0,0,00,false,0,complain_overflow_dont
, sparc_elf_notsupported_reloc
, "R_SPARC_PLT32", false,0,0x00000000,true),
86 HOWTO(R_SPARC_HIPLT22
, 0,0,00,false,0,complain_overflow_dont
, sparc_elf_notsupported_reloc
, "R_SPARC_HIPLT22", false,0,0x00000000,true),
87 HOWTO(R_SPARC_LOPLT10
, 0,0,00,false,0,complain_overflow_dont
, sparc_elf_notsupported_reloc
, "R_SPARC_LOPLT10", false,0,0x00000000,true),
88 HOWTO(R_SPARC_PCPLT32
, 0,0,00,false,0,complain_overflow_dont
, sparc_elf_notsupported_reloc
, "R_SPARC_PCPLT32", false,0,0x00000000,true),
89 HOWTO(R_SPARC_PCPLT22
, 0,0,00,false,0,complain_overflow_dont
, sparc_elf_notsupported_reloc
, "R_SPARC_PCPLT22", false,0,0x00000000,true),
90 HOWTO(R_SPARC_PCPLT10
, 0,0,00,false,0,complain_overflow_dont
, sparc_elf_notsupported_reloc
, "R_SPARC_PCPLT10", false,0,0x00000000,true),
91 HOWTO(R_SPARC_10
, 0,2,10,false,0,complain_overflow_bitfield
,bfd_elf_generic_reloc
, "R_SPARC_10", false,0,0x000003ff,true),
92 HOWTO(R_SPARC_11
, 0,2,11,false,0,complain_overflow_bitfield
,bfd_elf_generic_reloc
, "R_SPARC_11", false,0,0x000007ff,true),
93 /* These are for sparc64 in a 64 bit environment.
94 Values need to be here because the table is indexed by reloc number. */
95 HOWTO(R_SPARC_64
, 0,0,00,false,0,complain_overflow_dont
, sparc_elf_notsupported_reloc
, "R_SPARC_64", false,0,0x00000000,true),
96 HOWTO(R_SPARC_OLO10
, 0,0,00,false,0,complain_overflow_dont
, sparc_elf_notsupported_reloc
, "R_SPARC_OLO10", false,0,0x00000000,true),
97 HOWTO(R_SPARC_HH22
, 0,0,00,false,0,complain_overflow_dont
, sparc_elf_notsupported_reloc
, "R_SPARC_HH22", false,0,0x00000000,true),
98 HOWTO(R_SPARC_HM10
, 0,0,00,false,0,complain_overflow_dont
, sparc_elf_notsupported_reloc
, "R_SPARC_HM10", false,0,0x00000000,true),
99 HOWTO(R_SPARC_LM22
, 0,0,00,false,0,complain_overflow_dont
, sparc_elf_notsupported_reloc
, "R_SPARC_LM22", false,0,0x00000000,true),
100 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),
101 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),
102 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),
103 /* End sparc64 in 64 bit environment values.
104 The following are for sparc64 in a 32 bit environment. */
105 HOWTO(R_SPARC_WDISP16
, 2,2,16,true, 0,complain_overflow_signed
, sparc_elf_wdisp16_reloc
,"R_SPARC_WDISP16", false,0,0x00000000,true),
106 HOWTO(R_SPARC_WDISP19
, 2,2,19,true, 0,complain_overflow_signed
, bfd_elf_generic_reloc
, "R_SPARC_WDISP19", false,0,0x0007ffff,true),
107 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),
108 HOWTO(R_SPARC_7
, 0,2, 7,false,0,complain_overflow_bitfield
,bfd_elf_generic_reloc
, "R_SPARC_7", false,0,0x0000007f,true),
109 HOWTO(R_SPARC_5
, 0,2, 5,false,0,complain_overflow_bitfield
,bfd_elf_generic_reloc
, "R_SPARC_5", false,0,0x0000001f,true),
110 HOWTO(R_SPARC_6
, 0,2, 6,false,0,complain_overflow_bitfield
,bfd_elf_generic_reloc
, "R_SPARC_6", false,0,0x0000003f,true),
111 HOWTO(R_SPARC_NONE
, 0,0, 0,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_NONE", false,0,0x00000000,true),
112 HOWTO(R_SPARC_NONE
, 0,0, 0,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_NONE", false,0,0x00000000,true),
113 HOWTO(R_SPARC_NONE
, 0,0, 0,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_NONE", false,0,0x00000000,true),
114 HOWTO(R_SPARC_NONE
, 0,0, 0,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_NONE", false,0,0x00000000,true),
115 HOWTO(R_SPARC_NONE
, 0,0, 0,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_NONE", false,0,0x00000000,true),
116 HOWTO(R_SPARC_NONE
, 0,0, 0,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_NONE", false,0,0x00000000,true),
117 HOWTO(R_SPARC_NONE
, 0,0, 0,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_NONE", false,0,0x00000000,true),
118 HOWTO(R_SPARC_NONE
, 0,0, 0,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_NONE", false,0,0x00000000,true),
119 HOWTO(R_SPARC_NONE
, 0,0, 0,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_NONE", false,0,0x00000000,true),
120 HOWTO(R_SPARC_NONE
, 0,0, 0,false,0,complain_overflow_dont
, bfd_elf_generic_reloc
, "R_SPARC_NONE", false,0,0x00000000,true),
121 HOWTO(R_SPARC_REV32
, 0,2,32,false,0,complain_overflow_bitfield
,bfd_elf_generic_reloc
, "R_SPARC_REV32", false,0,0xffffffff,true),
123 static reloc_howto_type elf32_sparc_vtinherit_howto
=
124 HOWTO (R_SPARC_GNU_VTINHERIT
, 0,2,0,false,0,complain_overflow_dont
, NULL
, "R_SPARC_GNU_VTINHERIT", false,0, 0, false);
125 static reloc_howto_type elf32_sparc_vtentry_howto
=
126 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);
129 struct elf_reloc_map
{
130 bfd_reloc_code_real_type bfd_reloc_val
;
131 unsigned char elf_reloc_val
;
134 static CONST
struct elf_reloc_map sparc_reloc_map
[] =
136 { BFD_RELOC_NONE
, R_SPARC_NONE
, },
137 { BFD_RELOC_16
, R_SPARC_16
, },
138 { BFD_RELOC_8
, R_SPARC_8
},
139 { BFD_RELOC_8_PCREL
, R_SPARC_DISP8
},
140 { BFD_RELOC_CTOR
, R_SPARC_32
},
141 { BFD_RELOC_32
, R_SPARC_32
},
142 { BFD_RELOC_32_PCREL
, R_SPARC_DISP32
},
143 { BFD_RELOC_HI22
, R_SPARC_HI22
},
144 { BFD_RELOC_LO10
, R_SPARC_LO10
, },
145 { BFD_RELOC_32_PCREL_S2
, R_SPARC_WDISP30
},
146 { BFD_RELOC_SPARC22
, R_SPARC_22
},
147 { BFD_RELOC_SPARC13
, R_SPARC_13
},
148 { BFD_RELOC_SPARC_GOT10
, R_SPARC_GOT10
},
149 { BFD_RELOC_SPARC_GOT13
, R_SPARC_GOT13
},
150 { BFD_RELOC_SPARC_GOT22
, R_SPARC_GOT22
},
151 { BFD_RELOC_SPARC_PC10
, R_SPARC_PC10
},
152 { BFD_RELOC_SPARC_PC22
, R_SPARC_PC22
},
153 { BFD_RELOC_SPARC_WPLT30
, R_SPARC_WPLT30
},
154 { BFD_RELOC_SPARC_COPY
, R_SPARC_COPY
},
155 { BFD_RELOC_SPARC_GLOB_DAT
, R_SPARC_GLOB_DAT
},
156 { BFD_RELOC_SPARC_JMP_SLOT
, R_SPARC_JMP_SLOT
},
157 { BFD_RELOC_SPARC_RELATIVE
, R_SPARC_RELATIVE
},
158 { BFD_RELOC_SPARC_WDISP22
, R_SPARC_WDISP22
},
159 /* ??? Doesn't dwarf use this? */
160 /*{ BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
161 {BFD_RELOC_SPARC_10
, R_SPARC_10
},
162 {BFD_RELOC_SPARC_11
, R_SPARC_11
},
163 {BFD_RELOC_SPARC_64
, R_SPARC_64
},
164 {BFD_RELOC_SPARC_OLO10
, R_SPARC_OLO10
},
165 {BFD_RELOC_SPARC_HH22
, R_SPARC_HH22
},
166 {BFD_RELOC_SPARC_HM10
, R_SPARC_HM10
},
167 {BFD_RELOC_SPARC_LM22
, R_SPARC_LM22
},
168 {BFD_RELOC_SPARC_PC_HH22
, R_SPARC_PC_HH22
},
169 {BFD_RELOC_SPARC_PC_HM10
, R_SPARC_PC_HM10
},
170 {BFD_RELOC_SPARC_PC_LM22
, R_SPARC_PC_LM22
},
171 {BFD_RELOC_SPARC_WDISP16
, R_SPARC_WDISP16
},
172 {BFD_RELOC_SPARC_WDISP19
, R_SPARC_WDISP19
},
173 {BFD_RELOC_SPARC_7
, R_SPARC_7
},
174 {BFD_RELOC_SPARC_5
, R_SPARC_5
},
175 {BFD_RELOC_SPARC_6
, R_SPARC_6
},
176 {BFD_RELOC_SPARC_REV32
, R_SPARC_REV32
},
177 {BFD_RELOC_VTABLE_INHERIT
, R_SPARC_GNU_VTINHERIT
},
178 {BFD_RELOC_VTABLE_ENTRY
, R_SPARC_GNU_VTENTRY
},
181 static reloc_howto_type
*
182 elf32_sparc_reloc_type_lookup (abfd
, code
)
183 bfd
*abfd ATTRIBUTE_UNUSED
;
184 bfd_reloc_code_real_type code
;
190 case BFD_RELOC_VTABLE_INHERIT
:
191 return &elf32_sparc_vtinherit_howto
;
193 case BFD_RELOC_VTABLE_ENTRY
:
194 return &elf32_sparc_vtentry_howto
;
197 for (i
= 0; i
< sizeof (sparc_reloc_map
) / sizeof (struct elf_reloc_map
); i
++)
199 if (sparc_reloc_map
[i
].bfd_reloc_val
== code
)
200 return &_bfd_sparc_elf_howto_table
[(int) sparc_reloc_map
[i
].elf_reloc_val
];
203 bfd_set_error (bfd_error_bad_value
);
207 /* We need to use ELF32_R_TYPE so we have our own copy of this function,
208 and elf64-sparc.c has its own copy. */
211 elf32_sparc_info_to_howto (abfd
, cache_ptr
, dst
)
212 bfd
*abfd ATTRIBUTE_UNUSED
;
214 Elf_Internal_Rela
*dst
;
216 switch (ELF32_R_TYPE(dst
->r_info
))
218 case R_SPARC_GNU_VTINHERIT
:
219 cache_ptr
->howto
= &elf32_sparc_vtinherit_howto
;
222 case R_SPARC_GNU_VTENTRY
:
223 cache_ptr
->howto
= &elf32_sparc_vtentry_howto
;
227 BFD_ASSERT (ELF32_R_TYPE(dst
->r_info
) < (unsigned int) R_SPARC_max_std
);
228 cache_ptr
->howto
= &_bfd_sparc_elf_howto_table
[ELF32_R_TYPE(dst
->r_info
)];
232 /* For unsupported relocs. */
234 static bfd_reloc_status_type
235 sparc_elf_notsupported_reloc (abfd
,
242 bfd
*abfd ATTRIBUTE_UNUSED
;
243 arelent
*reloc_entry ATTRIBUTE_UNUSED
;
244 asymbol
*symbol ATTRIBUTE_UNUSED
;
245 PTR data ATTRIBUTE_UNUSED
;
246 asection
*input_section ATTRIBUTE_UNUSED
;
247 bfd
*output_bfd ATTRIBUTE_UNUSED
;
248 char **error_message ATTRIBUTE_UNUSED
;
250 return bfd_reloc_notsupported
;
253 /* Handle the WDISP16 reloc. */
255 static bfd_reloc_status_type
256 sparc_elf_wdisp16_reloc (abfd
,
264 arelent
*reloc_entry
;
267 asection
*input_section
;
269 char **error_message ATTRIBUTE_UNUSED
;
274 if (output_bfd
!= (bfd
*) NULL
275 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
276 && (! reloc_entry
->howto
->partial_inplace
277 || reloc_entry
->addend
== 0))
279 reloc_entry
->address
+= input_section
->output_offset
;
283 if (output_bfd
!= NULL
)
284 return bfd_reloc_continue
;
286 if (reloc_entry
->address
> input_section
->_cooked_size
)
287 return bfd_reloc_outofrange
;
289 relocation
= (symbol
->value
290 + symbol
->section
->output_section
->vma
291 + symbol
->section
->output_offset
);
292 relocation
+= reloc_entry
->addend
;
293 relocation
-= (input_section
->output_section
->vma
294 + input_section
->output_offset
);
295 relocation
-= reloc_entry
->address
;
297 x
= bfd_get_32 (abfd
, (bfd_byte
*) data
+ reloc_entry
->address
);
298 x
|= ((((relocation
>> 2) & 0xc000) << 6)
299 | ((relocation
>> 2) & 0x3fff));
300 bfd_put_32 (abfd
, x
, (bfd_byte
*) data
+ reloc_entry
->address
);
302 if ((bfd_signed_vma
) relocation
< - 0x40000
303 || (bfd_signed_vma
) relocation
> 0x3ffff)
304 return bfd_reloc_overflow
;
309 /* Functions for the SPARC ELF linker. */
311 /* The name of the dynamic interpreter. This is put in the .interp
314 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
316 /* The nop opcode we use. */
318 #define SPARC_NOP 0x01000000
320 /* The size in bytes of an entry in the procedure linkage table. */
322 #define PLT_ENTRY_SIZE 12
324 /* The first four entries in a procedure linkage table are reserved,
325 and the initial contents are unimportant (we zero them out).
326 Subsequent entries look like this. See the SVR4 ABI SPARC
327 supplement to see how this works. */
329 /* sethi %hi(.-.plt0),%g1. We fill in the address later. */
330 #define PLT_ENTRY_WORD0 0x03000000
331 /* b,a .plt0. We fill in the offset later. */
332 #define PLT_ENTRY_WORD1 0x30800000
334 #define PLT_ENTRY_WORD2 SPARC_NOP
336 /* Look through the relocs for a section during the first phase, and
337 allocate space in the global offset table or procedure linkage
341 elf32_sparc_check_relocs (abfd
, info
, sec
, relocs
)
343 struct bfd_link_info
*info
;
345 const Elf_Internal_Rela
*relocs
;
348 Elf_Internal_Shdr
*symtab_hdr
;
349 struct elf_link_hash_entry
**sym_hashes
;
350 bfd_vma
*local_got_offsets
;
351 const Elf_Internal_Rela
*rel
;
352 const Elf_Internal_Rela
*rel_end
;
357 if (info
->relocateable
)
360 dynobj
= elf_hash_table (info
)->dynobj
;
361 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
362 sym_hashes
= elf_sym_hashes (abfd
);
363 local_got_offsets
= elf_local_got_offsets (abfd
);
369 rel_end
= relocs
+ sec
->reloc_count
;
370 for (rel
= relocs
; rel
< rel_end
; rel
++)
372 unsigned long r_symndx
;
373 struct elf_link_hash_entry
*h
;
375 r_symndx
= ELF32_R_SYM (rel
->r_info
);
376 if (r_symndx
< symtab_hdr
->sh_info
)
379 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
381 switch (ELF32_R_TYPE (rel
->r_info
))
386 /* This symbol requires a global offset table entry. */
390 /* Create the .got section. */
391 elf_hash_table (info
)->dynobj
= dynobj
= abfd
;
392 if (! _bfd_elf_create_got_section (dynobj
, info
))
398 sgot
= bfd_get_section_by_name (dynobj
, ".got");
399 BFD_ASSERT (sgot
!= NULL
);
403 && (h
!= NULL
|| info
->shared
))
405 srelgot
= bfd_get_section_by_name (dynobj
, ".rela.got");
408 srelgot
= bfd_make_section (dynobj
, ".rela.got");
410 || ! bfd_set_section_flags (dynobj
, srelgot
,
417 || ! bfd_set_section_alignment (dynobj
, srelgot
, 2))
424 if (h
->got
.offset
!= (bfd_vma
) -1)
426 /* We have already allocated space in the .got. */
429 h
->got
.offset
= sgot
->_raw_size
;
431 /* Make sure this symbol is output as a dynamic symbol. */
432 if (h
->dynindx
== -1)
434 if (! bfd_elf32_link_record_dynamic_symbol (info
, h
))
438 srelgot
->_raw_size
+= sizeof (Elf32_External_Rela
);
442 /* This is a global offset table entry for a local
444 if (local_got_offsets
== NULL
)
447 register unsigned int i
;
449 size
= symtab_hdr
->sh_info
* sizeof (bfd_vma
);
450 local_got_offsets
= (bfd_vma
*) bfd_alloc (abfd
, size
);
451 if (local_got_offsets
== NULL
)
453 elf_local_got_offsets (abfd
) = local_got_offsets
;
454 for (i
= 0; i
< symtab_hdr
->sh_info
; i
++)
455 local_got_offsets
[i
] = (bfd_vma
) -1;
457 if (local_got_offsets
[r_symndx
] != (bfd_vma
) -1)
459 /* We have already allocated space in the .got. */
462 local_got_offsets
[r_symndx
] = sgot
->_raw_size
;
466 /* If we are generating a shared object, we need to
467 output a R_SPARC_RELATIVE reloc so that the
468 dynamic linker can adjust this GOT entry. */
469 srelgot
->_raw_size
+= sizeof (Elf32_External_Rela
);
473 sgot
->_raw_size
+= 4;
475 /* If the .got section is more than 0x1000 bytes, we add
476 0x1000 to the value of _GLOBAL_OFFSET_TABLE_, so that 13
477 bit relocations have a greater chance of working. */
478 if (sgot
->_raw_size
>= 0x1000
479 && elf_hash_table (info
)->hgot
->root
.u
.def
.value
== 0)
480 elf_hash_table (info
)->hgot
->root
.u
.def
.value
= 0x1000;
485 /* This symbol requires a procedure linkage table entry. We
486 actually build the entry in adjust_dynamic_symbol,
487 because this might be a case of linking PIC code without
488 linking in any dynamic objects, in which case we don't
489 need to generate a procedure linkage table after all. */
493 /* The Solaris native assembler will generate a WPLT30
494 reloc for a local symbol if you assemble a call from
495 one section to another when using -K pic. We treat
500 /* Make sure this symbol is output as a dynamic symbol. */
501 if (h
->dynindx
== -1)
503 if (! bfd_elf32_link_record_dynamic_symbol (info
, h
))
507 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
514 h
->elf_link_hash_flags
|= ELF_LINK_NON_GOT_REF
;
517 && strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0)
523 case R_SPARC_WDISP30
:
524 case R_SPARC_WDISP22
:
525 case R_SPARC_WDISP19
:
526 case R_SPARC_WDISP16
:
528 h
->elf_link_hash_flags
|= ELF_LINK_NON_GOT_REF
;
530 /* If we are linking with -Bsymbolic, we do not need to copy
531 a PC relative reloc against a global symbol which is
532 defined in an object we are including in the link (i.e.,
533 DEF_REGULAR is set). FIXME: At this point we have not
534 seen all the input files, so it is possible that
535 DEF_REGULAR is not set now but will be set later (it is
536 never cleared). This needs to be handled as in
540 && (h
->elf_link_hash_flags
541 & ELF_LINK_HASH_DEF_REGULAR
) != 0))
553 h
->elf_link_hash_flags
|= ELF_LINK_NON_GOT_REF
;
557 /* When creating a shared object, we must copy these
558 relocs into the output file. We create a reloc
559 section in dynobj and make room for the reloc. */
564 name
= (bfd_elf_string_from_elf_section
566 elf_elfheader (abfd
)->e_shstrndx
,
567 elf_section_data (sec
)->rel_hdr
.sh_name
));
571 BFD_ASSERT (strncmp (name
, ".rela", 5) == 0
572 && strcmp (bfd_get_section_name (abfd
, sec
),
575 sreloc
= bfd_get_section_by_name (dynobj
, name
);
580 sreloc
= bfd_make_section (dynobj
, name
);
581 flags
= (SEC_HAS_CONTENTS
| SEC_READONLY
582 | SEC_IN_MEMORY
| SEC_LINKER_CREATED
);
583 if ((sec
->flags
& SEC_ALLOC
) != 0)
584 flags
|= SEC_ALLOC
| SEC_LOAD
;
586 || ! bfd_set_section_flags (dynobj
, sreloc
, flags
)
587 || ! bfd_set_section_alignment (dynobj
, sreloc
, 2))
592 sreloc
->_raw_size
+= sizeof (Elf32_External_Rela
);
597 case R_SPARC_GNU_VTINHERIT
:
598 if (!_bfd_elf32_gc_record_vtinherit (abfd
, sec
, h
, rel
->r_offset
))
602 case R_SPARC_GNU_VTENTRY
:
603 if (!_bfd_elf32_gc_record_vtentry (abfd
, sec
, h
, rel
->r_addend
))
616 elf32_sparc_gc_mark_hook (abfd
, info
, rel
, h
, sym
)
618 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
619 Elf_Internal_Rela
*rel
;
620 struct elf_link_hash_entry
*h
;
621 Elf_Internal_Sym
*sym
;
626 switch (ELF32_R_TYPE (rel
->r_info
))
628 case R_SPARC_GNU_VTINHERIT
:
629 case R_SPARC_GNU_VTENTRY
:
633 switch (h
->root
.type
)
635 case bfd_link_hash_defined
:
636 case bfd_link_hash_defweak
:
637 return h
->root
.u
.def
.section
;
639 case bfd_link_hash_common
:
640 return h
->root
.u
.c
.p
->section
;
649 if (!(elf_bad_symtab (abfd
)
650 && ELF_ST_BIND (sym
->st_info
) != STB_LOCAL
)
651 && ! ((sym
->st_shndx
<= 0 || sym
->st_shndx
>= SHN_LORESERVE
)
652 && sym
->st_shndx
!= SHN_COMMON
))
654 return bfd_section_from_elf_index (abfd
, sym
->st_shndx
);
661 /* Update the got entry reference counts for the section being removed. */
663 elf32_sparc_gc_sweep_hook (abfd
, info
, sec
, relocs
)
665 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
667 const Elf_Internal_Rela
*relocs
;
670 Elf_Internal_Shdr
*symtab_hdr
;
671 struct elf_link_hash_entry
**sym_hashes
;
672 bfd_signed_vma
*local_got_refcounts
;
673 const Elf_Internal_Rela
*rel
, *relend
;
674 unsigned long r_symndx
;
675 struct elf_link_hash_entry
*h
;
677 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
678 sym_hashes
= elf_sym_hashes (abfd
);
679 local_got_refcounts
= elf_local_got_refcounts (abfd
);
681 relend
= relocs
+ sec
->reloc_count
;
682 for (rel
= relocs
; rel
< relend
; rel
++)
683 switch (ELF32_R_TYPE (rel
->r_info
))
688 r_symndx
= ELF32_R_SYM (rel
->r_info
);
689 if (r_symndx
>= symtab_hdr
->sh_info
)
691 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
692 if (h
->got
.refcount
> 0)
697 if (local_got_refcounts
[r_symndx
] > 0)
698 local_got_refcounts
[r_symndx
]--;
703 case R_SPARC_HIPLT22
:
704 case R_SPARC_LOPLT10
:
705 case R_SPARC_PCPLT32
:
706 case R_SPARC_PCPLT10
:
707 r_symndx
= ELF32_R_SYM (rel
->r_info
);
708 if (r_symndx
>= symtab_hdr
->sh_info
)
710 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
711 if (h
->plt
.refcount
> 0)
723 /* Adjust a symbol defined by a dynamic object and referenced by a
724 regular object. The current definition is in some section of the
725 dynamic object, but we're not including those sections. We have to
726 change the definition to something the rest of the link can
730 elf32_sparc_adjust_dynamic_symbol (info
, h
)
731 struct bfd_link_info
*info
;
732 struct elf_link_hash_entry
*h
;
736 unsigned int power_of_two
;
738 dynobj
= elf_hash_table (info
)->dynobj
;
740 /* Make sure we know what is going on here. */
741 BFD_ASSERT (dynobj
!= NULL
742 && ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
)
743 || h
->weakdef
!= NULL
744 || ((h
->elf_link_hash_flags
745 & ELF_LINK_HASH_DEF_DYNAMIC
) != 0
746 && (h
->elf_link_hash_flags
747 & ELF_LINK_HASH_REF_REGULAR
) != 0
748 && (h
->elf_link_hash_flags
749 & ELF_LINK_HASH_DEF_REGULAR
) == 0)));
751 /* If this is a function, put it in the procedure linkage table. We
752 will fill in the contents of the procedure linkage table later
753 (although we could actually do it here). The STT_NOTYPE
754 condition is a hack specifically for the Oracle libraries
755 delivered for Solaris; for some inexplicable reason, they define
756 some of their functions as STT_NOTYPE when they really should be
758 if (h
->type
== STT_FUNC
759 || (h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_PLT
) != 0
760 || (h
->type
== STT_NOTYPE
761 && (h
->root
.type
== bfd_link_hash_defined
762 || h
->root
.type
== bfd_link_hash_defweak
)
763 && (h
->root
.u
.def
.section
->flags
& SEC_CODE
) != 0))
765 if (! elf_hash_table (info
)->dynamic_sections_created
766 || ((!info
->shared
|| info
->symbolic
|| h
->dynindx
== -1)
767 && (h
->elf_link_hash_flags
768 & ELF_LINK_HASH_DEF_REGULAR
) != 0))
770 /* This case can occur if we saw a WPLT30 reloc in an input
771 file, but none of the input files were dynamic objects.
772 Or, when linking the main application or a -Bsymbolic
773 shared library against PIC code. Or when a global symbol
774 has been made private, e.g. via versioning.
776 In these cases we know what value the symbol will resolve
777 to, so we don't actually need to build a procedure linkage
778 table, and we can just do a WDISP30 reloc instead. */
780 h
->elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
784 s
= bfd_get_section_by_name (dynobj
, ".plt");
785 BFD_ASSERT (s
!= NULL
);
787 /* The first four entries in .plt are reserved. */
788 if (s
->_raw_size
== 0)
789 s
->_raw_size
= 4 * PLT_ENTRY_SIZE
;
791 /* The procedure linkage table has a maximum size. */
792 if (s
->_raw_size
>= 0x400000)
794 bfd_set_error (bfd_error_bad_value
);
798 /* If this symbol is not defined in a regular file, and we are
799 not generating a shared library, then set the symbol to this
800 location in the .plt. This is required to make function
801 pointers compare as equal between the normal executable and
802 the shared library. */
804 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
806 h
->root
.u
.def
.section
= s
;
807 h
->root
.u
.def
.value
= s
->_raw_size
;
810 h
->plt
.offset
= s
->_raw_size
;
812 /* Make room for this entry. */
813 s
->_raw_size
+= PLT_ENTRY_SIZE
;
815 /* We also need to make an entry in the .rela.plt section. */
817 s
= bfd_get_section_by_name (dynobj
, ".rela.plt");
818 BFD_ASSERT (s
!= NULL
);
819 s
->_raw_size
+= sizeof (Elf32_External_Rela
);
824 /* If this is a weak symbol, and there is a real definition, the
825 processor independent code will have arranged for us to see the
826 real definition first, and we can just use the same value. */
827 if (h
->weakdef
!= NULL
)
829 BFD_ASSERT (h
->weakdef
->root
.type
== bfd_link_hash_defined
830 || h
->weakdef
->root
.type
== bfd_link_hash_defweak
);
831 h
->root
.u
.def
.section
= h
->weakdef
->root
.u
.def
.section
;
832 h
->root
.u
.def
.value
= h
->weakdef
->root
.u
.def
.value
;
836 /* This is a reference to a symbol defined by a dynamic object which
837 is not a function. */
839 /* If we are creating a shared library, we must presume that the
840 only references to the symbol are via the global offset table.
841 For such cases we need not do anything here; the relocations will
842 be handled correctly by relocate_section. */
846 /* If there are no references to this symbol that do not use the
847 GOT, we don't need to generate a copy reloc. */
848 if ((h
->elf_link_hash_flags
& ELF_LINK_NON_GOT_REF
) == 0)
851 /* We must allocate the symbol in our .dynbss section, which will
852 become part of the .bss section of the executable. There will be
853 an entry for this symbol in the .dynsym section. The dynamic
854 object will contain position independent code, so all references
855 from the dynamic object to this symbol will go through the global
856 offset table. The dynamic linker will use the .dynsym entry to
857 determine the address it must put in the global offset table, so
858 both the dynamic object and the regular object will refer to the
859 same memory location for the variable. */
861 s
= bfd_get_section_by_name (dynobj
, ".dynbss");
862 BFD_ASSERT (s
!= NULL
);
864 /* We must generate a R_SPARC_COPY reloc to tell the dynamic linker
865 to copy the initial value out of the dynamic object and into the
866 runtime process image. We need to remember the offset into the
867 .rel.bss section we are going to use. */
868 if ((h
->root
.u
.def
.section
->flags
& SEC_ALLOC
) != 0)
872 srel
= bfd_get_section_by_name (dynobj
, ".rela.bss");
873 BFD_ASSERT (srel
!= NULL
);
874 srel
->_raw_size
+= sizeof (Elf32_External_Rela
);
875 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_COPY
;
878 /* We need to figure out the alignment required for this symbol. I
879 have no idea how ELF linkers handle this. */
880 power_of_two
= bfd_log2 (h
->size
);
881 if (power_of_two
> 3)
884 /* Apply the required alignment. */
885 s
->_raw_size
= BFD_ALIGN (s
->_raw_size
,
886 (bfd_size_type
) (1 << power_of_two
));
887 if (power_of_two
> bfd_get_section_alignment (dynobj
, s
))
889 if (! bfd_set_section_alignment (dynobj
, s
, power_of_two
))
893 /* Define the symbol as being at this point in the section. */
894 h
->root
.u
.def
.section
= s
;
895 h
->root
.u
.def
.value
= s
->_raw_size
;
897 /* Increment the section size to make room for the symbol. */
898 s
->_raw_size
+= h
->size
;
903 /* Set the sizes of the dynamic sections. */
906 elf32_sparc_size_dynamic_sections (output_bfd
, info
)
908 struct bfd_link_info
*info
;
915 dynobj
= elf_hash_table (info
)->dynobj
;
916 BFD_ASSERT (dynobj
!= NULL
);
918 if (elf_hash_table (info
)->dynamic_sections_created
)
920 /* Set the contents of the .interp section to the interpreter. */
923 s
= bfd_get_section_by_name (dynobj
, ".interp");
924 BFD_ASSERT (s
!= NULL
);
925 s
->_raw_size
= sizeof ELF_DYNAMIC_INTERPRETER
;
926 s
->contents
= (unsigned char *) ELF_DYNAMIC_INTERPRETER
;
929 /* Make space for the trailing nop in .plt. */
930 s
= bfd_get_section_by_name (dynobj
, ".plt");
931 BFD_ASSERT (s
!= NULL
);
932 if (s
->_raw_size
> 0)
937 /* We may have created entries in the .rela.got section.
938 However, if we are not creating the dynamic sections, we will
939 not actually use these entries. Reset the size of .rela.got,
940 which will cause it to get stripped from the output file
942 s
= bfd_get_section_by_name (dynobj
, ".rela.got");
947 /* The check_relocs and adjust_dynamic_symbol entry points have
948 determined the sizes of the various dynamic sections. Allocate
952 for (s
= dynobj
->sections
; s
!= NULL
; s
= s
->next
)
957 if ((s
->flags
& SEC_LINKER_CREATED
) == 0)
960 /* It's OK to base decisions on the section name, because none
961 of the dynobj section names depend upon the input files. */
962 name
= bfd_get_section_name (dynobj
, s
);
966 if (strncmp (name
, ".rela", 5) == 0)
968 if (s
->_raw_size
== 0)
970 /* If we don't need this section, strip it from the
971 output file. This is to handle .rela.bss and
972 .rel.plt. We must create it in
973 create_dynamic_sections, because it must be created
974 before the linker maps input sections to output
975 sections. The linker does that before
976 adjust_dynamic_symbol is called, and it is that
977 function which decides whether anything needs to go
978 into these sections. */
986 /* If this relocation section applies to a read only
987 section, then we probably need a DT_TEXTREL entry. */
988 outname
= bfd_get_section_name (output_bfd
,
990 target
= bfd_get_section_by_name (output_bfd
, outname
+ 5);
992 && (target
->flags
& SEC_READONLY
) != 0
993 && (target
->flags
& SEC_ALLOC
) != 0)
996 if (strcmp (name
, ".rela.plt") == 0)
999 /* We use the reloc_count field as a counter if we need
1000 to copy relocs into the output file. */
1004 else if (strcmp (name
, ".plt") != 0
1005 && strcmp (name
, ".got") != 0)
1007 /* It's not one of our sections, so don't allocate space. */
1013 _bfd_strip_section_from_output (s
);
1017 /* Allocate memory for the section contents. */
1018 s
->contents
= (bfd_byte
*) bfd_alloc (dynobj
, s
->_raw_size
);
1019 if (s
->contents
== NULL
&& s
->_raw_size
!= 0)
1023 if (elf_hash_table (info
)->dynamic_sections_created
)
1025 /* Add some entries to the .dynamic section. We fill in the
1026 values later, in elf32_sparc_finish_dynamic_sections, but we
1027 must add the entries now so that we get the correct size for
1028 the .dynamic section. The DT_DEBUG entry is filled in by the
1029 dynamic linker and used by the debugger. */
1032 if (! bfd_elf32_add_dynamic_entry (info
, DT_DEBUG
, 0))
1038 if (! bfd_elf32_add_dynamic_entry (info
, DT_PLTGOT
, 0)
1039 || ! bfd_elf32_add_dynamic_entry (info
, DT_PLTRELSZ
, 0)
1040 || ! bfd_elf32_add_dynamic_entry (info
, DT_PLTREL
, DT_RELA
)
1041 || ! bfd_elf32_add_dynamic_entry (info
, DT_JMPREL
, 0))
1045 if (! bfd_elf32_add_dynamic_entry (info
, DT_RELA
, 0)
1046 || ! bfd_elf32_add_dynamic_entry (info
, DT_RELASZ
, 0)
1047 || ! bfd_elf32_add_dynamic_entry (info
, DT_RELAENT
,
1048 sizeof (Elf32_External_Rela
)))
1053 if (! bfd_elf32_add_dynamic_entry (info
, DT_TEXTREL
, 0))
1061 /* Relocate a SPARC ELF section. */
1064 elf32_sparc_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
1065 contents
, relocs
, local_syms
, local_sections
)
1067 struct bfd_link_info
*info
;
1069 asection
*input_section
;
1071 Elf_Internal_Rela
*relocs
;
1072 Elf_Internal_Sym
*local_syms
;
1073 asection
**local_sections
;
1076 Elf_Internal_Shdr
*symtab_hdr
;
1077 struct elf_link_hash_entry
**sym_hashes
;
1078 bfd_vma
*local_got_offsets
;
1083 Elf_Internal_Rela
*rel
;
1084 Elf_Internal_Rela
*relend
;
1086 dynobj
= elf_hash_table (info
)->dynobj
;
1087 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
1088 sym_hashes
= elf_sym_hashes (input_bfd
);
1089 local_got_offsets
= elf_local_got_offsets (input_bfd
);
1091 if (elf_hash_table (info
)->hgot
== NULL
)
1094 got_base
= elf_hash_table (info
)->hgot
->root
.u
.def
.value
;
1101 relend
= relocs
+ input_section
->reloc_count
;
1102 for (; rel
< relend
; rel
++)
1105 reloc_howto_type
*howto
;
1106 unsigned long r_symndx
;
1107 struct elf_link_hash_entry
*h
;
1108 Elf_Internal_Sym
*sym
;
1111 bfd_reloc_status_type r
;
1113 r_type
= ELF32_R_TYPE (rel
->r_info
);
1115 if (r_type
== R_SPARC_GNU_VTINHERIT
1116 || r_type
== R_SPARC_GNU_VTENTRY
)
1119 if (r_type
< 0 || r_type
>= (int) R_SPARC_max_std
)
1121 bfd_set_error (bfd_error_bad_value
);
1124 howto
= _bfd_sparc_elf_howto_table
+ r_type
;
1126 r_symndx
= ELF32_R_SYM (rel
->r_info
);
1128 if (info
->relocateable
)
1130 /* This is a relocateable link. We don't have to change
1131 anything, unless the reloc is against a section symbol,
1132 in which case we have to adjust according to where the
1133 section symbol winds up in the output section. */
1134 if (r_symndx
< symtab_hdr
->sh_info
)
1136 sym
= local_syms
+ r_symndx
;
1137 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
1139 sec
= local_sections
[r_symndx
];
1140 rel
->r_addend
+= sec
->output_offset
+ sym
->st_value
;
1147 /* This is a final link. */
1151 if (r_symndx
< symtab_hdr
->sh_info
)
1153 sym
= local_syms
+ r_symndx
;
1154 sec
= local_sections
[r_symndx
];
1155 relocation
= (sec
->output_section
->vma
1156 + sec
->output_offset
1161 h
= sym_hashes
[r_symndx
- symtab_hdr
->sh_info
];
1162 while (h
->root
.type
== bfd_link_hash_indirect
1163 || h
->root
.type
== bfd_link_hash_warning
)
1164 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
1165 if (h
->root
.type
== bfd_link_hash_defined
1166 || h
->root
.type
== bfd_link_hash_defweak
)
1168 sec
= h
->root
.u
.def
.section
;
1169 if ((r_type
== R_SPARC_WPLT30
1170 && h
->plt
.offset
!= (bfd_vma
) -1)
1171 || ((r_type
== R_SPARC_GOT10
1172 || r_type
== R_SPARC_GOT13
1173 || r_type
== R_SPARC_GOT22
)
1174 && elf_hash_table (info
)->dynamic_sections_created
1176 || (! info
->symbolic
&& h
->dynindx
!= -1)
1177 || (h
->elf_link_hash_flags
1178 & ELF_LINK_HASH_DEF_REGULAR
) == 0))
1180 && ((! info
->symbolic
&& h
->dynindx
!= -1)
1181 || (h
->elf_link_hash_flags
1182 & ELF_LINK_HASH_DEF_REGULAR
) == 0)
1183 && (r_type
== R_SPARC_8
1184 || r_type
== R_SPARC_16
1185 || r_type
== R_SPARC_32
1186 || r_type
== R_SPARC_DISP8
1187 || r_type
== R_SPARC_DISP16
1188 || r_type
== R_SPARC_DISP32
1189 || r_type
== R_SPARC_WDISP30
1190 || r_type
== R_SPARC_WDISP22
1191 || r_type
== R_SPARC_WDISP19
1192 || r_type
== R_SPARC_WDISP16
1193 || r_type
== R_SPARC_HI22
1194 || r_type
== R_SPARC_22
1195 || r_type
== R_SPARC_13
1196 || r_type
== R_SPARC_LO10
1197 || r_type
== R_SPARC_UA32
1198 || ((r_type
== R_SPARC_PC10
1199 || r_type
== R_SPARC_PC22
)
1200 && strcmp (h
->root
.root
.string
,
1201 "_GLOBAL_OFFSET_TABLE_") != 0))))
1203 /* In these cases, we don't need the relocation
1204 value. We check specially because in some
1205 obscure cases sec->output_section will be NULL. */
1209 relocation
= (h
->root
.u
.def
.value
1210 + sec
->output_section
->vma
1211 + sec
->output_offset
);
1213 else if (h
->root
.type
== bfd_link_hash_undefweak
)
1215 else if (info
->shared
&& !info
->symbolic
&& !info
->no_undefined
)
1219 if (! ((*info
->callbacks
->undefined_symbol
)
1220 (info
, h
->root
.root
.string
, input_bfd
,
1221 input_section
, rel
->r_offset
)))
1232 /* Relocation is to the entry for this symbol in the global
1236 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1237 BFD_ASSERT (sgot
!= NULL
);
1244 off
= h
->got
.offset
;
1245 BFD_ASSERT (off
!= (bfd_vma
) -1);
1247 if (! elf_hash_table (info
)->dynamic_sections_created
1249 && (info
->symbolic
|| h
->dynindx
== -1)
1250 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
)))
1252 /* This is actually a static link, or it is a
1253 -Bsymbolic link and the symbol is defined
1254 locally, or the symbol was forced to be local
1255 because of a version file. We must initialize
1256 this entry in the global offset table. Since the
1257 offset must always be a multiple of 4, we use the
1258 least significant bit to record whether we have
1259 initialized it already.
1261 When doing a dynamic link, we create a .rela.got
1262 relocation entry to initialize the value. This
1263 is done in the finish_dynamic_symbol routine. */
1268 bfd_put_32 (output_bfd
, relocation
,
1269 sgot
->contents
+ off
);
1274 relocation
= sgot
->output_offset
+ off
- got_base
;
1280 BFD_ASSERT (local_got_offsets
!= NULL
1281 && local_got_offsets
[r_symndx
] != (bfd_vma
) -1);
1283 off
= local_got_offsets
[r_symndx
];
1285 /* The offset must always be a multiple of 4. We use
1286 the least significant bit to record whether we have
1287 already processed this entry. */
1292 bfd_put_32 (output_bfd
, relocation
, sgot
->contents
+ off
);
1297 Elf_Internal_Rela outrel
;
1299 /* We need to generate a R_SPARC_RELATIVE reloc
1300 for the dynamic linker. */
1301 srelgot
= bfd_get_section_by_name (dynobj
, ".rela.got");
1302 BFD_ASSERT (srelgot
!= NULL
);
1304 outrel
.r_offset
= (sgot
->output_section
->vma
1305 + sgot
->output_offset
1307 outrel
.r_info
= ELF32_R_INFO (0, R_SPARC_RELATIVE
);
1308 outrel
.r_addend
= 0;
1309 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
,
1310 (((Elf32_External_Rela
*)
1312 + srelgot
->reloc_count
));
1313 ++srelgot
->reloc_count
;
1316 local_got_offsets
[r_symndx
] |= 1;
1319 relocation
= sgot
->output_offset
+ off
- got_base
;
1324 case R_SPARC_WPLT30
:
1325 /* Relocation is to the entry for this symbol in the
1326 procedure linkage table. */
1328 /* The Solaris native assembler will generate a WPLT30 reloc
1329 for a local symbol if you assemble a call from one
1330 section to another when using -K pic. We treat it as
1335 if (h
->plt
.offset
== (bfd_vma
) -1)
1337 /* We didn't make a PLT entry for this symbol. This
1338 happens when statically linking PIC code, or when
1339 using -Bsymbolic. */
1345 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1346 BFD_ASSERT (splt
!= NULL
);
1349 relocation
= (splt
->output_section
->vma
1350 + splt
->output_offset
1357 && strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0)
1361 case R_SPARC_DISP16
:
1362 case R_SPARC_DISP32
:
1363 case R_SPARC_WDISP30
:
1364 case R_SPARC_WDISP22
:
1365 case R_SPARC_WDISP19
:
1366 case R_SPARC_WDISP16
:
1369 && (h
->elf_link_hash_flags
1370 & ELF_LINK_HASH_DEF_REGULAR
) != 0))
1383 Elf_Internal_Rela outrel
;
1386 /* When generating a shared object, these relocations
1387 are copied into the output file to be resolved at run
1394 name
= (bfd_elf_string_from_elf_section
1396 elf_elfheader (input_bfd
)->e_shstrndx
,
1397 elf_section_data (input_section
)->rel_hdr
.sh_name
));
1401 BFD_ASSERT (strncmp (name
, ".rela", 5) == 0
1402 && strcmp (bfd_get_section_name (input_bfd
,
1406 sreloc
= bfd_get_section_by_name (dynobj
, name
);
1407 BFD_ASSERT (sreloc
!= NULL
);
1412 if (elf_section_data (input_section
)->stab_info
== NULL
)
1413 outrel
.r_offset
= rel
->r_offset
;
1418 off
= (_bfd_stab_section_offset
1419 (output_bfd
, &elf_hash_table (info
)->stab_info
,
1421 &elf_section_data (input_section
)->stab_info
,
1423 if (off
== (bfd_vma
) -1)
1425 outrel
.r_offset
= off
;
1428 outrel
.r_offset
+= (input_section
->output_section
->vma
1429 + input_section
->output_offset
);
1432 memset (&outrel
, 0, sizeof outrel
);
1433 /* h->dynindx may be -1 if the symbol was marked to
1436 && ((! info
->symbolic
&& h
->dynindx
!= -1)
1437 || (h
->elf_link_hash_flags
1438 & ELF_LINK_HASH_DEF_REGULAR
) == 0))
1440 BFD_ASSERT (h
->dynindx
!= -1);
1441 outrel
.r_info
= ELF32_R_INFO (h
->dynindx
, r_type
);
1442 outrel
.r_addend
= rel
->r_addend
;
1446 if (r_type
== R_SPARC_32
)
1448 outrel
.r_info
= ELF32_R_INFO (0, R_SPARC_RELATIVE
);
1449 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1456 sec
= local_sections
[r_symndx
];
1459 BFD_ASSERT (h
->root
.type
== bfd_link_hash_defined
1461 == bfd_link_hash_defweak
));
1462 sec
= h
->root
.u
.def
.section
;
1464 if (sec
!= NULL
&& bfd_is_abs_section (sec
))
1466 else if (sec
== NULL
|| sec
->owner
== NULL
)
1468 bfd_set_error (bfd_error_bad_value
);
1475 osec
= sec
->output_section
;
1476 indx
= elf_section_data (osec
)->dynindx
;
1478 /* FIXME: we really should be able to link non-pic
1479 shared libraries. */
1483 (*_bfd_error_handler
)
1484 (_("%s: probably compiled without -fPIC?"),
1485 bfd_get_filename (input_bfd
));
1486 bfd_set_error (bfd_error_bad_value
);
1491 outrel
.r_info
= ELF32_R_INFO (indx
, r_type
);
1492 outrel
.r_addend
= relocation
+ rel
->r_addend
;
1496 bfd_elf32_swap_reloca_out (output_bfd
, &outrel
,
1497 (((Elf32_External_Rela
*)
1499 + sreloc
->reloc_count
));
1500 ++sreloc
->reloc_count
;
1502 /* This reloc will be computed at runtime, so there's no
1503 need to do anything now, unless this is a RELATIVE
1504 reloc in an unallocated section. */
1506 || (input_section
->flags
& SEC_ALLOC
) != 0
1507 || ELF32_R_TYPE (outrel
.r_info
) != R_SPARC_RELATIVE
)
1516 if (r_type
== R_SPARC_WDISP16
)
1520 relocation
+= rel
->r_addend
;
1521 relocation
-= (input_section
->output_section
->vma
1522 + input_section
->output_offset
);
1523 relocation
-= rel
->r_offset
;
1525 x
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
1526 x
|= ((((relocation
>> 2) & 0xc000) << 6)
1527 | ((relocation
>> 2) & 0x3fff));
1528 bfd_put_32 (input_bfd
, x
, contents
+ rel
->r_offset
);
1530 if ((bfd_signed_vma
) relocation
< - 0x40000
1531 || (bfd_signed_vma
) relocation
> 0x3ffff)
1532 r
= bfd_reloc_overflow
;
1536 else if (r_type
== R_SPARC_REV32
)
1540 relocation
= relocation
+ rel
->r_addend
;
1542 x
= bfd_get_32 (input_bfd
, contents
+ rel
->r_offset
);
1544 bfd_putl32 (/*input_bfd,*/ x
, contents
+ rel
->r_offset
);
1548 r
= _bfd_final_link_relocate (howto
, input_bfd
, input_section
,
1549 contents
, rel
->r_offset
,
1550 relocation
, rel
->r_addend
);
1553 if (r
!= bfd_reloc_ok
)
1558 case bfd_reloc_outofrange
:
1560 case bfd_reloc_overflow
:
1565 name
= h
->root
.root
.string
;
1568 name
= bfd_elf_string_from_elf_section (input_bfd
,
1569 symtab_hdr
->sh_link
,
1574 name
= bfd_section_name (input_bfd
, sec
);
1576 if (! ((*info
->callbacks
->reloc_overflow
)
1577 (info
, name
, howto
->name
, (bfd_vma
) 0,
1578 input_bfd
, input_section
, rel
->r_offset
)))
1589 /* Finish up dynamic symbol handling. We set the contents of various
1590 dynamic sections here. */
1593 elf32_sparc_finish_dynamic_symbol (output_bfd
, info
, h
, sym
)
1595 struct bfd_link_info
*info
;
1596 struct elf_link_hash_entry
*h
;
1597 Elf_Internal_Sym
*sym
;
1601 dynobj
= elf_hash_table (info
)->dynobj
;
1603 if (h
->plt
.offset
!= (bfd_vma
) -1)
1607 Elf_Internal_Rela rela
;
1609 /* This symbol has an entry in the procedure linkage table. Set
1612 BFD_ASSERT (h
->dynindx
!= -1);
1614 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1615 srela
= bfd_get_section_by_name (dynobj
, ".rela.plt");
1616 BFD_ASSERT (splt
!= NULL
&& srela
!= NULL
);
1618 /* Fill in the entry in the procedure linkage table. */
1619 bfd_put_32 (output_bfd
,
1620 PLT_ENTRY_WORD0
+ h
->plt
.offset
,
1621 splt
->contents
+ h
->plt
.offset
);
1622 bfd_put_32 (output_bfd
,
1624 + (((- (h
->plt
.offset
+ 4)) >> 2) & 0x3fffff)),
1625 splt
->contents
+ h
->plt
.offset
+ 4);
1626 bfd_put_32 (output_bfd
, PLT_ENTRY_WORD2
,
1627 splt
->contents
+ h
->plt
.offset
+ 8);
1629 /* Fill in the entry in the .rela.plt section. */
1630 rela
.r_offset
= (splt
->output_section
->vma
1631 + splt
->output_offset
1633 rela
.r_info
= ELF32_R_INFO (h
->dynindx
, R_SPARC_JMP_SLOT
);
1635 bfd_elf32_swap_reloca_out (output_bfd
, &rela
,
1636 ((Elf32_External_Rela
*) srela
->contents
1637 + h
->plt
.offset
/ PLT_ENTRY_SIZE
- 4));
1639 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
1641 /* Mark the symbol as undefined, rather than as defined in
1642 the .plt section. Leave the value alone. */
1643 sym
->st_shndx
= SHN_UNDEF
;
1647 if (h
->got
.offset
!= (bfd_vma
) -1)
1651 Elf_Internal_Rela rela
;
1653 /* This symbol has an entry in the global offset table. Set it
1656 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1657 srela
= bfd_get_section_by_name (dynobj
, ".rela.got");
1658 BFD_ASSERT (sgot
!= NULL
&& srela
!= NULL
);
1660 rela
.r_offset
= (sgot
->output_section
->vma
1661 + sgot
->output_offset
1662 + (h
->got
.offset
&~ 1));
1664 /* If this is a -Bsymbolic link, and the symbol is defined
1665 locally, we just want to emit a RELATIVE reloc. Likewise if
1666 the symbol was forced to be local because of a version file.
1667 The entry in the global offset table will already have been
1668 initialized in the relocate_section function. */
1670 && (info
->symbolic
|| h
->dynindx
== -1)
1671 && (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
))
1672 rela
.r_info
= ELF32_R_INFO (0, R_SPARC_RELATIVE
);
1675 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
+ h
->got
.offset
);
1676 rela
.r_info
= ELF32_R_INFO (h
->dynindx
, R_SPARC_GLOB_DAT
);
1680 bfd_elf32_swap_reloca_out (output_bfd
, &rela
,
1681 ((Elf32_External_Rela
*) srela
->contents
1682 + srela
->reloc_count
));
1683 ++srela
->reloc_count
;
1686 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_NEEDS_COPY
) != 0)
1689 Elf_Internal_Rela rela
;
1691 /* This symbols needs a copy reloc. Set it up. */
1693 BFD_ASSERT (h
->dynindx
!= -1);
1695 s
= bfd_get_section_by_name (h
->root
.u
.def
.section
->owner
,
1697 BFD_ASSERT (s
!= NULL
);
1699 rela
.r_offset
= (h
->root
.u
.def
.value
1700 + h
->root
.u
.def
.section
->output_section
->vma
1701 + h
->root
.u
.def
.section
->output_offset
);
1702 rela
.r_info
= ELF32_R_INFO (h
->dynindx
, R_SPARC_COPY
);
1704 bfd_elf32_swap_reloca_out (output_bfd
, &rela
,
1705 ((Elf32_External_Rela
*) s
->contents
1710 /* Mark some specially defined symbols as absolute. */
1711 if (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
1712 || strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0
1713 || strcmp (h
->root
.root
.string
, "_PROCEDURE_LINKAGE_TABLE_") == 0)
1714 sym
->st_shndx
= SHN_ABS
;
1719 /* Finish up the dynamic sections. */
1722 elf32_sparc_finish_dynamic_sections (output_bfd
, info
)
1724 struct bfd_link_info
*info
;
1730 dynobj
= elf_hash_table (info
)->dynobj
;
1732 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
1734 if (elf_hash_table (info
)->dynamic_sections_created
)
1737 Elf32_External_Dyn
*dyncon
, *dynconend
;
1739 splt
= bfd_get_section_by_name (dynobj
, ".plt");
1740 BFD_ASSERT (splt
!= NULL
&& sdyn
!= NULL
);
1742 dyncon
= (Elf32_External_Dyn
*) sdyn
->contents
;
1743 dynconend
= (Elf32_External_Dyn
*) (sdyn
->contents
+ sdyn
->_raw_size
);
1744 for (; dyncon
< dynconend
; dyncon
++)
1746 Elf_Internal_Dyn dyn
;
1750 bfd_elf32_swap_dyn_in (dynobj
, dyncon
, &dyn
);
1754 case DT_PLTGOT
: name
= ".plt"; size
= false; break;
1755 case DT_PLTRELSZ
: name
= ".rela.plt"; size
= true; break;
1756 case DT_JMPREL
: name
= ".rela.plt"; size
= false; break;
1757 default: name
= NULL
; size
= false; break;
1764 s
= bfd_get_section_by_name (output_bfd
, name
);
1770 dyn
.d_un
.d_ptr
= s
->vma
;
1773 if (s
->_cooked_size
!= 0)
1774 dyn
.d_un
.d_val
= s
->_cooked_size
;
1776 dyn
.d_un
.d_val
= s
->_raw_size
;
1779 bfd_elf32_swap_dyn_out (output_bfd
, &dyn
, dyncon
);
1783 /* Clear the first four entries in the procedure linkage table,
1784 and put a nop in the last four bytes. */
1785 if (splt
->_raw_size
> 0)
1787 memset (splt
->contents
, 0, 4 * PLT_ENTRY_SIZE
);
1788 bfd_put_32 (output_bfd
, SPARC_NOP
,
1789 splt
->contents
+ splt
->_raw_size
- 4);
1792 elf_section_data (splt
->output_section
)->this_hdr
.sh_entsize
=
1796 /* Set the first entry in the global offset table to the address of
1797 the dynamic section. */
1798 sgot
= bfd_get_section_by_name (dynobj
, ".got");
1799 BFD_ASSERT (sgot
!= NULL
);
1800 if (sgot
->_raw_size
> 0)
1803 bfd_put_32 (output_bfd
, (bfd_vma
) 0, sgot
->contents
);
1805 bfd_put_32 (output_bfd
,
1806 sdyn
->output_section
->vma
+ sdyn
->output_offset
,
1810 elf_section_data (sgot
->output_section
)->this_hdr
.sh_entsize
= 4;
1815 /* Functions for dealing with the e_flags field.
1817 We don't define set_private_flags or copy_private_bfd_data because
1818 the only currently defined values are based on the bfd mach number,
1819 so we use the latter instead and defer setting e_flags until the
1820 file is written out. */
1822 /* Merge backend specific data from an object file to the output
1823 object file when linking. */
1826 elf32_sparc_merge_private_bfd_data (ibfd
, obfd
)
1831 /* FIXME: This should not be static. */
1832 static unsigned long previous_ibfd_e_flags
= (unsigned long) -1;
1834 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
1835 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
1841 /* ??? The native linker doesn't do this so we can't (otherwise gcc would
1842 have to know which linker is being used). Instead, the native linker
1843 bumps up the architecture level when it has to. However, I still think
1844 warnings like these are good, so it would be nice to have them turned on
1847 /* If the output machine is normal sparc, we can't allow v9 input files. */
1848 if (bfd_get_mach (obfd
) == bfd_mach_sparc
1849 && (bfd_get_mach (ibfd
) == bfd_mach_sparc_v8plus
1850 || bfd_get_mach (ibfd
) == bfd_mach_sparc_v8plusa
))
1853 (*_bfd_error_handler
)
1854 (_("%s: compiled for a v8plus system and target is v8"),
1855 bfd_get_filename (ibfd
));
1857 /* If the output machine is v9, we can't allow v9+vis input files. */
1858 if (bfd_get_mach (obfd
) == bfd_mach_sparc_v8plus
1859 && bfd_get_mach (ibfd
) == bfd_mach_sparc_v8plusa
)
1862 (*_bfd_error_handler
)
1863 (_("%s: compiled for a v8plusa system and target is v8plus"),
1864 bfd_get_filename (ibfd
));
1867 if (bfd_get_mach (ibfd
) >= bfd_mach_sparc_v9
)
1870 (*_bfd_error_handler
)
1871 (_("%s: compiled for a 64 bit system and target is 32 bit"),
1872 bfd_get_filename (ibfd
));
1874 else if (bfd_get_mach (obfd
) < bfd_get_mach (ibfd
))
1875 bfd_set_arch_mach (obfd
, bfd_arch_sparc
, bfd_get_mach (ibfd
));
1878 if (((elf_elfheader (ibfd
)->e_flags
& EF_SPARC_LEDATA
)
1879 != previous_ibfd_e_flags
)
1880 && previous_ibfd_e_flags
!= (unsigned long) -1)
1882 (*_bfd_error_handler
)
1883 (_("%s: linking little endian files with big endian files"),
1884 bfd_get_filename (ibfd
));
1887 previous_ibfd_e_flags
= elf_elfheader (ibfd
)->e_flags
& EF_SPARC_LEDATA
;
1891 bfd_set_error (bfd_error_bad_value
);
1898 /* Set the right machine number. */
1901 elf32_sparc_object_p (abfd
)
1904 if (elf_elfheader (abfd
)->e_machine
== EM_SPARC32PLUS
)
1906 if (elf_elfheader (abfd
)->e_flags
& EF_SPARC_SUN_US1
)
1907 return bfd_default_set_arch_mach (abfd
, bfd_arch_sparc
,
1908 bfd_mach_sparc_v8plusa
);
1909 else if (elf_elfheader (abfd
)->e_flags
& EF_SPARC_32PLUS
)
1910 return bfd_default_set_arch_mach (abfd
, bfd_arch_sparc
,
1911 bfd_mach_sparc_v8plus
);
1915 else if (elf_elfheader (abfd
)->e_flags
& EF_SPARC_LEDATA
)
1916 return bfd_default_set_arch_mach (abfd
, bfd_arch_sparc
,
1917 bfd_mach_sparc_sparclite_le
);
1919 return bfd_default_set_arch_mach (abfd
, bfd_arch_sparc
, bfd_mach_sparc
);
1922 /* The final processing done just before writing out the object file.
1923 We need to set the e_machine field appropriately. */
1926 elf32_sparc_final_write_processing (abfd
, linker
)
1928 boolean linker ATTRIBUTE_UNUSED
;
1930 switch (bfd_get_mach (abfd
))
1932 case bfd_mach_sparc
:
1933 break; /* nothing to do */
1934 case bfd_mach_sparc_v8plus
:
1935 elf_elfheader (abfd
)->e_machine
= EM_SPARC32PLUS
;
1936 elf_elfheader (abfd
)->e_flags
&=~ EF_SPARC_32PLUS_MASK
;
1937 elf_elfheader (abfd
)->e_flags
|= EF_SPARC_32PLUS
;
1939 case bfd_mach_sparc_v8plusa
:
1940 elf_elfheader (abfd
)->e_machine
= EM_SPARC32PLUS
;
1941 elf_elfheader (abfd
)->e_flags
&=~ EF_SPARC_32PLUS_MASK
;
1942 elf_elfheader (abfd
)->e_flags
|= EF_SPARC_32PLUS
| EF_SPARC_SUN_US1
;
1944 case bfd_mach_sparc_sparclite_le
:
1945 elf_elfheader (abfd
)->e_machine
= EM_SPARC
;
1946 elf_elfheader (abfd
)->e_flags
|= EF_SPARC_LEDATA
;
1954 #define TARGET_BIG_SYM bfd_elf32_sparc_vec
1955 #define TARGET_BIG_NAME "elf32-sparc"
1956 #define ELF_ARCH bfd_arch_sparc
1957 #define ELF_MACHINE_CODE EM_SPARC
1958 #define ELF_MACHINE_ALT1 EM_SPARC32PLUS
1959 #define ELF_MAXPAGESIZE 0x10000
1961 #define bfd_elf32_bfd_reloc_type_lookup elf32_sparc_reloc_type_lookup
1962 #define elf_info_to_howto elf32_sparc_info_to_howto
1963 #define elf_backend_create_dynamic_sections \
1964 _bfd_elf_create_dynamic_sections
1965 #define elf_backend_check_relocs elf32_sparc_check_relocs
1966 #define elf_backend_adjust_dynamic_symbol \
1967 elf32_sparc_adjust_dynamic_symbol
1968 #define elf_backend_size_dynamic_sections \
1969 elf32_sparc_size_dynamic_sections
1970 #define elf_backend_relocate_section elf32_sparc_relocate_section
1971 #define elf_backend_finish_dynamic_symbol \
1972 elf32_sparc_finish_dynamic_symbol
1973 #define elf_backend_finish_dynamic_sections \
1974 elf32_sparc_finish_dynamic_sections
1975 #define bfd_elf32_bfd_merge_private_bfd_data \
1976 elf32_sparc_merge_private_bfd_data
1977 #define elf_backend_object_p elf32_sparc_object_p
1978 #define elf_backend_final_write_processing \
1979 elf32_sparc_final_write_processing
1980 #define elf_backend_gc_mark_hook elf32_sparc_gc_mark_hook
1981 #define elf_backend_gc_sweep_hook elf32_sparc_gc_sweep_hook
1983 #define elf_backend_can_gc_sections 1
1984 #define elf_backend_want_got_plt 0
1985 #define elf_backend_plt_readonly 0
1986 #define elf_backend_want_plt_sym 1
1987 #define elf_backend_got_header_size 4
1988 #define elf_backend_plt_header_size (4*PLT_ENTRY_SIZE)
1990 #include "elf32-target.h"