/[gcl]/gcl/binutils/bfd/elf32-avr.c
ViewVC logotype

Diff of /gcl/binutils/bfd/elf32-avr.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by camm, Fri Aug 9 05:35:11 2002 UTC revision 1.1.1.1.20.1 by camm, Fri Sep 30 02:08:57 2005 UTC
# Line 1  Line 1 
1  /* AVR-specific support for 32-bit ELF  /* AVR-specific support for 32-bit ELF
2     Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.     Copyright 1999, 2000, 2001, 2002, 2003, 2004
3       Free Software Foundation, Inc.
4     Contributed by Denis Chertykov <denisc@overta.ru>     Contributed by Denis Chertykov <denisc@overta.ru>
5    
6  This file is part of BFD, the Binary File Descriptor library.     This file is part of BFD, the Binary File Descriptor library.
7    
8  This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
9  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
10  the Free Software Foundation; either version 2 of the License, or     the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.     (at your option) any later version.
12    
13  This program is distributed in the hope that it will be useful,     This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.     GNU General Public License for more details.
17    
18  You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software     along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
21    
22  #include "bfd.h"  #include "bfd.h"
23  #include "sysdep.h"  #include "sysdep.h"
# Line 27  Foundation, Inc., 59 Temple Place - Suit Line 28  Foundation, Inc., 59 Temple Place - Suit
28  static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup  static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
29    PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));    PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
30  static void avr_info_to_howto_rela  static void avr_info_to_howto_rela
31    PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));    PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
32  static asection *elf32_avr_gc_mark_hook  static asection *elf32_avr_gc_mark_hook
33    PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,    PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
34             struct elf_link_hash_entry *, Elf_Internal_Sym *));             struct elf_link_hash_entry *, Elf_Internal_Sym *));
35  static boolean elf32_avr_gc_sweep_hook  static bfd_boolean elf32_avr_gc_sweep_hook
36    PARAMS ((bfd *, struct bfd_link_info *, asection *,    PARAMS ((bfd *, struct bfd_link_info *, asection *,
37             const Elf_Internal_Rela *));             const Elf_Internal_Rela *));
38  static boolean elf32_avr_check_relocs  static bfd_boolean elf32_avr_check_relocs
39    PARAMS ((bfd *, struct bfd_link_info *, asection *,    PARAMS ((bfd *, struct bfd_link_info *, asection *,
40             const Elf_Internal_Rela *));             const Elf_Internal_Rela *));
41  static bfd_reloc_status_type avr_final_link_relocate  static bfd_reloc_status_type avr_final_link_relocate
42    PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,    PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
43             Elf_Internal_Rela *, bfd_vma));             Elf_Internal_Rela *, bfd_vma));
44  static boolean elf32_avr_relocate_section  static bfd_boolean elf32_avr_relocate_section
45    PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,    PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
46             Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));             Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
47  static void bfd_elf_avr_final_write_processing PARAMS ((bfd *, boolean));  static void bfd_elf_avr_final_write_processing PARAMS ((bfd *, bfd_boolean));
48  static boolean elf32_avr_object_p PARAMS ((bfd *));  static bfd_boolean elf32_avr_object_p PARAMS ((bfd *));
   
 /* Use RELA instead of REL */  
 #undef USE_REL  
49    
50  static reloc_howto_type elf_avr_howto_table[] =  static reloc_howto_type elf_avr_howto_table[] =
51  {  {
# Line 55  static reloc_howto_type elf_avr_howto_ta Line 53  static reloc_howto_type elf_avr_howto_ta
53           0,                     /* rightshift */           0,                     /* rightshift */
54           2,                     /* size (0 = byte, 1 = short, 2 = long) */           2,                     /* size (0 = byte, 1 = short, 2 = long) */
55           32,                    /* bitsize */           32,                    /* bitsize */
56           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
57           0,                     /* bitpos */           0,                     /* bitpos */
58           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
59           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
60           "R_AVR_NONE",          /* name */           "R_AVR_NONE",          /* name */
61           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
62           0,                     /* src_mask */           0,                     /* src_mask */
63           0,                     /* dst_mask */           0,                     /* dst_mask */
64           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
65    
66    HOWTO (R_AVR_32,              /* type */    HOWTO (R_AVR_32,              /* type */
67           0,                     /* rightshift */           0,                     /* rightshift */
68           2,                     /* size (0 = byte, 1 = short, 2 = long) */           2,                     /* size (0 = byte, 1 = short, 2 = long) */
69           32,                    /* bitsize */           32,                    /* bitsize */
70           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
71           0,                     /* bitpos */           0,                     /* bitpos */
72           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
73           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
74           "R_AVR_32",            /* name */           "R_AVR_32",            /* name */
75           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
76           0xffffffff,            /* src_mask */           0xffffffff,            /* src_mask */
77           0xffffffff,            /* dst_mask */           0xffffffff,            /* dst_mask */
78           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
79    
80    /* A 7 bit PC relative relocation.  */    /* A 7 bit PC relative relocation.  */
81    HOWTO (R_AVR_7_PCREL,         /* type */    HOWTO (R_AVR_7_PCREL,         /* type */
82           1,                     /* rightshift */           1,                     /* rightshift */
83           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
84           7,                     /* bitsize */           7,                     /* bitsize */
85           true,                  /* pc_relative */           TRUE,                  /* pc_relative */
86           3,                     /* bitpos */           3,                     /* bitpos */
87           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
88           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
89           "R_AVR_7_PCREL",       /* name */           "R_AVR_7_PCREL",       /* name */
90           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
91           0xffff,                /* src_mask */           0xffff,                /* src_mask */
92           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
93           true),                 /* pcrel_offset */           TRUE),                 /* pcrel_offset */
94    
95    /* A 13 bit PC relative relocation.  */    /* A 13 bit PC relative relocation.  */
96    HOWTO (R_AVR_13_PCREL,        /* type */    HOWTO (R_AVR_13_PCREL,        /* type */
97           1,                     /* rightshift */           1,                     /* rightshift */
98           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
99           13,                    /* bitsize */           13,                    /* bitsize */
100           true,                  /* pc_relative */           TRUE,                  /* pc_relative */
101           0,                     /* bitpos */           0,                     /* bitpos */
102           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
103           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
104           "R_AVR_13_PCREL",      /* name */           "R_AVR_13_PCREL",      /* name */
105           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
106           0xfff,                 /* src_mask */           0xfff,                 /* src_mask */
107           0xfff,                 /* dst_mask */           0xfff,                 /* dst_mask */
108           true),                 /* pcrel_offset */           TRUE),                 /* pcrel_offset */
109    
110    /* A 16 bit absolute relocation.  */    /* A 16 bit absolute relocation.  */
111    HOWTO (R_AVR_16,              /* type */    HOWTO (R_AVR_16,              /* type */
112           0,                     /* rightshift */           0,                     /* rightshift */
113           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
114           16,                    /* bitsize */           16,                    /* bitsize */
115           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
116           0,                     /* bitpos */           0,                     /* bitpos */
117           complain_overflow_dont, /* complain_on_overflow */           complain_overflow_dont, /* complain_on_overflow */
118           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
119           "R_AVR_16",            /* name */           "R_AVR_16",            /* name */
120           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
121           0xffff,                /* src_mask */           0xffff,                /* src_mask */
122           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
123           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
124    
125    /* A 16 bit absolute relocation for command address.  */    /* A 16 bit absolute relocation for command address.  */
126    HOWTO (R_AVR_16_PM,           /* type */    HOWTO (R_AVR_16_PM,           /* type */
127           1,                     /* rightshift */           1,                     /* rightshift */
128           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
129           16,                    /* bitsize */           16,                    /* bitsize */
130           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
131           0,                     /* bitpos */           0,                     /* bitpos */
132           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
133           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
134           "R_AVR_16_PM",         /* name */           "R_AVR_16_PM",         /* name */
135           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
136           0xffff,                /* src_mask */           0xffff,                /* src_mask */
137           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
138           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
139    /* A low 8 bit absolute relocation of 16 bit address.    /* A low 8 bit absolute relocation of 16 bit address.
140       For LDI command.  */       For LDI command.  */
141    HOWTO (R_AVR_LO8_LDI,         /* type */    HOWTO (R_AVR_LO8_LDI,         /* type */
142           0,                     /* rightshift */           0,                     /* rightshift */
143           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
144           8,                     /* bitsize */           8,                     /* bitsize */
145           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
146           0,                     /* bitpos */           0,                     /* bitpos */
147           complain_overflow_dont, /* complain_on_overflow */           complain_overflow_dont, /* complain_on_overflow */
148           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
149           "R_AVR_LO8_LDI",       /* name */           "R_AVR_LO8_LDI",       /* name */
150           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
151           0xffff,                /* src_mask */           0xffff,                /* src_mask */
152           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
153           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
154    /* A high 8 bit absolute relocation of 16 bit address.    /* A high 8 bit absolute relocation of 16 bit address.
155       For LDI command.  */       For LDI command.  */
156    HOWTO (R_AVR_HI8_LDI,         /* type */    HOWTO (R_AVR_HI8_LDI,         /* type */
157           8,                     /* rightshift */           8,                     /* rightshift */
158           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
159           8,                     /* bitsize */           8,                     /* bitsize */
160           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
161           0,                     /* bitpos */           0,                     /* bitpos */
162           complain_overflow_dont, /* complain_on_overflow */           complain_overflow_dont, /* complain_on_overflow */
163           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
164           "R_AVR_HI8_LDI",       /* name */           "R_AVR_HI8_LDI",       /* name */
165           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
166           0xffff,                /* src_mask */           0xffff,                /* src_mask */
167           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
168           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
169    /* A high 6 bit absolute relocation of 22 bit address.    /* A high 6 bit absolute relocation of 22 bit address.
170       For LDI command.  */       For LDI command.  */
171    HOWTO (R_AVR_HH8_LDI,         /* type */    HOWTO (R_AVR_HH8_LDI,         /* type */
172           16,                    /* rightshift */           16,                    /* rightshift */
173           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
174           8,                     /* bitsize */           8,                     /* bitsize */
175           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
176           0,                     /* bitpos */           0,                     /* bitpos */
177           complain_overflow_dont, /* complain_on_overflow */           complain_overflow_dont, /* complain_on_overflow */
178           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
179           "R_AVR_HH8_LDI",       /* name */           "R_AVR_HH8_LDI",       /* name */
180           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
181           0xffff,                /* src_mask */           0xffff,                /* src_mask */
182           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
183           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
184    /* A negative low 8 bit absolute relocation of 16 bit address.    /* A negative low 8 bit absolute relocation of 16 bit address.
185       For LDI command.  */       For LDI command.  */
186    HOWTO (R_AVR_LO8_LDI_NEG,     /* type */    HOWTO (R_AVR_LO8_LDI_NEG,     /* type */
187           0,                     /* rightshift */           0,                     /* rightshift */
188           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
189           8,                     /* bitsize */           8,                     /* bitsize */
190           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
191           0,                     /* bitpos */           0,                     /* bitpos */
192           complain_overflow_dont, /* complain_on_overflow */           complain_overflow_dont, /* complain_on_overflow */
193           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
194           "R_AVR_LO8_LDI_NEG",   /* name */           "R_AVR_LO8_LDI_NEG",   /* name */
195           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
196           0xffff,                /* src_mask */           0xffff,                /* src_mask */
197           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
198           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
199    /* A hegative high 8 bit absolute relocation of 16 bit address.    /* A hegative high 8 bit absolute relocation of 16 bit address.
200       For LDI command.  */       For LDI command.  */
201    HOWTO (R_AVR_HI8_LDI_NEG,     /* type */    HOWTO (R_AVR_HI8_LDI_NEG,     /* type */
202           8,                     /* rightshift */           8,                     /* rightshift */
203           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
204           8,                     /* bitsize */           8,                     /* bitsize */
205           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
206           0,                     /* bitpos */           0,                     /* bitpos */
207           complain_overflow_dont, /* complain_on_overflow */           complain_overflow_dont, /* complain_on_overflow */
208           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
209           "R_AVR_HI8_LDI_NEG",   /* name */           "R_AVR_HI8_LDI_NEG",   /* name */
210           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
211           0xffff,                /* src_mask */           0xffff,                /* src_mask */
212           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
213           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
214    /* A hegative high 6 bit absolute relocation of 22 bit address.    /* A hegative high 6 bit absolute relocation of 22 bit address.
215       For LDI command.  */       For LDI command.  */
216    HOWTO (R_AVR_HH8_LDI_NEG,     /* type */    HOWTO (R_AVR_HH8_LDI_NEG,     /* type */
217           16,                    /* rightshift */           16,                    /* rightshift */
218           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
219           8,                     /* bitsize */           8,                     /* bitsize */
220           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
221           0,                     /* bitpos */           0,                     /* bitpos */
222           complain_overflow_dont, /* complain_on_overflow */           complain_overflow_dont, /* complain_on_overflow */
223           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
224           "R_AVR_HH8_LDI_NEG",   /* name */           "R_AVR_HH8_LDI_NEG",   /* name */
225           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
226           0xffff,                /* src_mask */           0xffff,                /* src_mask */
227           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
228           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
229    /* A low 8 bit absolute relocation of 24 bit program memory address.    /* A low 8 bit absolute relocation of 24 bit program memory address.
230       For LDI command.  */       For LDI command.  */
231    HOWTO (R_AVR_LO8_LDI_PM,      /* type */    HOWTO (R_AVR_LO8_LDI_PM,      /* type */
232           1,                     /* rightshift */           1,                     /* rightshift */
233           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
234           8,                     /* bitsize */           8,                     /* bitsize */
235           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
236           0,                     /* bitpos */           0,                     /* bitpos */
237           complain_overflow_dont, /* complain_on_overflow */           complain_overflow_dont, /* complain_on_overflow */
238           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
239           "R_AVR_LO8_LDI_PM",    /* name */           "R_AVR_LO8_LDI_PM",    /* name */
240           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
241           0xffff,                /* src_mask */           0xffff,                /* src_mask */
242           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
243           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
244    /* A high 8 bit absolute relocation of 16 bit program memory address.    /* A high 8 bit absolute relocation of 16 bit program memory address.
245       For LDI command.  */       For LDI command.  */
246    HOWTO (R_AVR_HI8_LDI_PM,      /* type */    HOWTO (R_AVR_HI8_LDI_PM,      /* type */
247           9,                     /* rightshift */           9,                     /* rightshift */
248           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
249           8,                     /* bitsize */           8,                     /* bitsize */
250           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
251           0,                     /* bitpos */           0,                     /* bitpos */
252           complain_overflow_dont, /* complain_on_overflow */           complain_overflow_dont, /* complain_on_overflow */
253           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
254           "R_AVR_HI8_LDI_PM",    /* name */           "R_AVR_HI8_LDI_PM",    /* name */
255           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
256           0xffff,                /* src_mask */           0xffff,                /* src_mask */
257           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
258           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
259    /* A high 8 bit absolute relocation of 24 bit program memory address.    /* A high 8 bit absolute relocation of 24 bit program memory address.
260       For LDI command.  */       For LDI command.  */
261    HOWTO (R_AVR_HH8_LDI_PM,      /* type */    HOWTO (R_AVR_HH8_LDI_PM,      /* type */
262           17,                    /* rightshift */           17,                    /* rightshift */
263           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
264           8,                     /* bitsize */           8,                     /* bitsize */
265           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
266           0,                     /* bitpos */           0,                     /* bitpos */
267           complain_overflow_dont, /* complain_on_overflow */           complain_overflow_dont, /* complain_on_overflow */
268           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
269           "R_AVR_HH8_LDI_PM",    /* name */           "R_AVR_HH8_LDI_PM",    /* name */
270           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
271           0xffff,                /* src_mask */           0xffff,                /* src_mask */
272           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
273           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
274    /* A low 8 bit absolute relocation of a negative 24 bit    /* A low 8 bit absolute relocation of a negative 24 bit
275       program memory address.  For LDI command.  */       program memory address.  For LDI command.  */
276    HOWTO (R_AVR_LO8_LDI_PM_NEG,  /* type */    HOWTO (R_AVR_LO8_LDI_PM_NEG,  /* type */
277           1,                     /* rightshift */           1,                     /* rightshift */
278           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
279           8,                     /* bitsize */           8,                     /* bitsize */
280           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
281           0,                     /* bitpos */           0,                     /* bitpos */
282           complain_overflow_dont, /* complain_on_overflow */           complain_overflow_dont, /* complain_on_overflow */
283           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
284           "R_AVR_LO8_LDI_PM_NEG", /* name */           "R_AVR_LO8_LDI_PM_NEG", /* name */
285           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
286           0xffff,                /* src_mask */           0xffff,                /* src_mask */
287           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
288           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
289    /* A high 8 bit absolute relocation of a negative 16 bit    /* A high 8 bit absolute relocation of a negative 16 bit
290       program memory address.  For LDI command.  */       program memory address.  For LDI command.  */
291    HOWTO (R_AVR_HI8_LDI_PM_NEG,  /* type */    HOWTO (R_AVR_HI8_LDI_PM_NEG,  /* type */
292           9,                     /* rightshift */           9,                     /* rightshift */
293           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
294           8,                     /* bitsize */           8,                     /* bitsize */
295           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
296           0,                     /* bitpos */           0,                     /* bitpos */
297           complain_overflow_dont, /* complain_on_overflow */           complain_overflow_dont, /* complain_on_overflow */
298           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
299           "R_AVR_HI8_LDI_PM_NEG", /* name */           "R_AVR_HI8_LDI_PM_NEG", /* name */
300           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
301           0xffff,                /* src_mask */           0xffff,                /* src_mask */
302           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
303           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
304    /* A high 8 bit absolute relocation of a negative 24 bit    /* A high 8 bit absolute relocation of a negative 24 bit
305       program memory address.  For LDI command.  */       program memory address.  For LDI command.  */
306    HOWTO (R_AVR_HH8_LDI_PM_NEG,  /* type */    HOWTO (R_AVR_HH8_LDI_PM_NEG,  /* type */
307           17,                    /* rightshift */           17,                    /* rightshift */
308           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
309           8,                     /* bitsize */           8,                     /* bitsize */
310           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
311           0,                     /* bitpos */           0,                     /* bitpos */
312           complain_overflow_dont, /* complain_on_overflow */           complain_overflow_dont, /* complain_on_overflow */
313           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
314           "R_AVR_HH8_LDI_PM_NEG", /* name */           "R_AVR_HH8_LDI_PM_NEG", /* name */
315           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
316           0xffff,                /* src_mask */           0xffff,                /* src_mask */
317           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
318           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
319    /* Relocation for CALL command in ATmega.  */    /* Relocation for CALL command in ATmega.  */
320    HOWTO (R_AVR_CALL,            /* type */    HOWTO (R_AVR_CALL,            /* type */
321           1,                     /* rightshift */           1,                     /* rightshift */
322           2,                     /* size (0 = byte, 1 = short, 2 = long) */           2,                     /* size (0 = byte, 1 = short, 2 = long) */
323           23,                    /* bitsize */           23,                    /* bitsize */
324           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
325           0,                     /* bitpos */           0,                     /* bitpos */
326           complain_overflow_dont, /* complain_on_overflow */           complain_overflow_dont,/* complain_on_overflow */
327           bfd_elf_generic_reloc, /* special_function */           bfd_elf_generic_reloc, /* special_function */
328           "R_AVR_CALL",          /* name */           "R_AVR_CALL",          /* name */
329           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
330           0xffffffff,            /* src_mask */           0xffffffff,            /* src_mask */
331           0xffffffff,            /* dst_mask */           0xffffffff,            /* dst_mask */
332           false)                 /* pcrel_offset */           FALSE),                        /* pcrel_offset */
333      /* A 16 bit absolute relocation of 16 bit address.
334         For LDI command.  */
335      HOWTO (R_AVR_LDI,             /* type */
336             0,                     /* rightshift */
337             1,                     /* size (0 = byte, 1 = short, 2 = long) */
338             16,                    /* bitsize */
339             FALSE,                 /* pc_relative */
340             0,                     /* bitpos */
341             complain_overflow_dont,/* complain_on_overflow */
342             bfd_elf_generic_reloc, /* special_function */
343             "R_AVR_LDI",           /* name */
344             FALSE,                 /* partial_inplace */
345             0xffff,                /* src_mask */
346             0xffff,                /* dst_mask */
347             FALSE),                /* pcrel_offset */
348      /* A 6 bit absolute relocation of 6 bit offset.
349         For ldd/sdd command.  */
350      HOWTO (R_AVR_6,               /* type */
351             0,                     /* rightshift */
352             0,                     /* size (0 = byte, 1 = short, 2 = long) */
353             6,                     /* bitsize */
354             FALSE,                 /* pc_relative */
355             0,                     /* bitpos */
356             complain_overflow_dont,/* complain_on_overflow */
357             bfd_elf_generic_reloc, /* special_function */
358             "R_AVR_6",             /* name */
359             FALSE,                 /* partial_inplace */
360             0xffff,                /* src_mask */
361             0xffff,                /* dst_mask */
362             FALSE),                /* pcrel_offset */
363      /* A 6 bit absolute relocation of 6 bit offset.
364         For sbiw/adiw command.  */
365      HOWTO (R_AVR_6_ADIW,          /* type */
366             0,                     /* rightshift */
367             0,                     /* size (0 = byte, 1 = short, 2 = long) */
368             6,                     /* bitsize */
369             FALSE,                 /* pc_relative */
370             0,                     /* bitpos */
371             complain_overflow_dont,/* complain_on_overflow */
372             bfd_elf_generic_reloc, /* special_function */
373             "R_AVR_6_ADIW",        /* name */
374             FALSE,                 /* partial_inplace */
375             0xffff,                /* src_mask */
376             0xffff,                /* dst_mask */
377             FALSE)                 /* pcrel_offset */
378  };  };
379    
380  /* Map BFD reloc types to AVR ELF reloc types.  */  /* Map BFD reloc types to AVR ELF reloc types.  */
# Line 362  struct avr_reloc_map Line 405  struct avr_reloc_map
405    { BFD_RELOC_AVR_LO8_LDI_PM_NEG,   R_AVR_LO8_LDI_PM_NEG },    { BFD_RELOC_AVR_LO8_LDI_PM_NEG,   R_AVR_LO8_LDI_PM_NEG },
406    { BFD_RELOC_AVR_HI8_LDI_PM_NEG,   R_AVR_HI8_LDI_PM_NEG },    { BFD_RELOC_AVR_HI8_LDI_PM_NEG,   R_AVR_HI8_LDI_PM_NEG },
407    { BFD_RELOC_AVR_HH8_LDI_PM_NEG,   R_AVR_HH8_LDI_PM_NEG },    { BFD_RELOC_AVR_HH8_LDI_PM_NEG,   R_AVR_HH8_LDI_PM_NEG },
408    { BFD_RELOC_AVR_CALL,             R_AVR_CALL }    { BFD_RELOC_AVR_CALL,             R_AVR_CALL },
409      { BFD_RELOC_AVR_LDI,              R_AVR_LDI  },
410      { BFD_RELOC_AVR_6,                R_AVR_6    },
411      { BFD_RELOC_AVR_6_ADIW,           R_AVR_6_ADIW }
412  };  };
413    
414  static reloc_howto_type *  static reloc_howto_type *
# Line 389  static void Line 435  static void
435  avr_info_to_howto_rela (abfd, cache_ptr, dst)  avr_info_to_howto_rela (abfd, cache_ptr, dst)
436       bfd *abfd ATTRIBUTE_UNUSED;       bfd *abfd ATTRIBUTE_UNUSED;
437       arelent *cache_ptr;       arelent *cache_ptr;
438       Elf32_Internal_Rela *dst;       Elf_Internal_Rela *dst;
439  {  {
440    unsigned int r_type;    unsigned int r_type;
441    
# Line 431  elf32_avr_gc_mark_hook (sec, info, rel, Line 477  elf32_avr_gc_mark_hook (sec, info, rel,
477    return NULL;    return NULL;
478  }  }
479    
480  static boolean  static bfd_boolean
481  elf32_avr_gc_sweep_hook (abfd, info, sec, relocs)  elf32_avr_gc_sweep_hook (abfd, info, sec, relocs)
482       bfd *abfd ATTRIBUTE_UNUSED;       bfd *abfd ATTRIBUTE_UNUSED;
483       struct bfd_link_info *info ATTRIBUTE_UNUSED;       struct bfd_link_info *info ATTRIBUTE_UNUSED;
# Line 439  elf32_avr_gc_sweep_hook (abfd, info, sec Line 485  elf32_avr_gc_sweep_hook (abfd, info, sec
485       const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;       const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;
486  {  {
487    /* We don't use got and plt entries for avr.  */    /* We don't use got and plt entries for avr.  */
488    return true;    return TRUE;
489  }  }
490    
491  /* Look through the relocs for a section during the first phase.  /* Look through the relocs for a section during the first phase.
492     Since we don't do .gots or .plts, we just need to consider the     Since we don't do .gots or .plts, we just need to consider the
493     virtual table relocs for gc.  */     virtual table relocs for gc.  */
494    
495  static boolean  static bfd_boolean
496  elf32_avr_check_relocs (abfd, info, sec, relocs)  elf32_avr_check_relocs (abfd, info, sec, relocs)
497       bfd *abfd;       bfd *abfd;
498       struct bfd_link_info *info;       struct bfd_link_info *info;
# Line 458  elf32_avr_check_relocs (abfd, info, sec, Line 504  elf32_avr_check_relocs (abfd, info, sec,
504    const Elf_Internal_Rela *rel;    const Elf_Internal_Rela *rel;
505    const Elf_Internal_Rela *rel_end;    const Elf_Internal_Rela *rel_end;
506    
507    if (info->relocateable)    if (info->relocatable)
508      return true;      return TRUE;
509    
510    symtab_hdr = &elf_tdata (abfd)->symtab_hdr;    symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
511    sym_hashes = elf_sym_hashes (abfd);    sym_hashes = elf_sym_hashes (abfd);
# Line 480  elf32_avr_check_relocs (abfd, info, sec, Line 526  elf32_avr_check_relocs (abfd, info, sec,
526          h = sym_hashes[r_symndx - symtab_hdr->sh_info];          h = sym_hashes[r_symndx - symtab_hdr->sh_info];
527      }      }
528    
529    return true;    return TRUE;
530  }  }
531    
532  /* Perform a single relocation.  By default we use the standard BFD  /* Perform a single relocation.  By default we use the standard BFD
# Line 563  avr_final_link_relocate (howto, input_bf Line 609  avr_final_link_relocate (howto, input_bf
609        bfd_put_16 (input_bfd, x, contents);        bfd_put_16 (input_bfd, x, contents);
610        break;        break;
611    
612        case R_AVR_LDI:
613          contents += rel->r_offset;
614          srel = (bfd_signed_vma) relocation + rel->r_addend;
615          if ((srel & 0xffff) > 255)
616            /* Remove offset for data/eeprom section.  */
617            return bfd_reloc_overflow;
618          x = bfd_get_16 (input_bfd, contents);
619          x = (x & 0xf0f0) | (srel & 0xf) | ((srel << 4) & 0xf00);
620          bfd_put_16 (input_bfd, x, contents);
621          break;
622    
623        case R_AVR_6:
624          contents += rel->r_offset;
625          srel = (bfd_signed_vma) relocation + rel->r_addend;
626          if (((srel & 0xffff) > 63) || (srel < 0))
627            /* Remove offset for data/eeprom section.  */
628            return bfd_reloc_overflow;
629          x = bfd_get_16 (input_bfd, contents);
630          x = (x & 0xd3f8) | ((srel & 7) | ((srel & (3 << 3)) << 7) | ((srel & (1 << 5)) << 8));
631          bfd_put_16 (input_bfd, x, contents);
632          break;
633    
634        case R_AVR_6_ADIW:
635          contents += rel->r_offset;
636          srel = (bfd_signed_vma) relocation + rel->r_addend;
637          if (((srel & 0xffff) > 63) || (srel < 0))
638            /* Remove offset for data/eeprom section.  */
639            return bfd_reloc_overflow;
640          x = bfd_get_16 (input_bfd, contents);
641          x = (x & 0xff30) | (srel & 0xf) | ((srel & 0x30) << 2);
642          bfd_put_16 (input_bfd, x, contents);
643          break;
644    
645      case R_AVR_HI8_LDI:      case R_AVR_HI8_LDI:
646        contents += rel->r_offset;        contents += rel->r_offset;
647        srel = (bfd_signed_vma) relocation + rel->r_addend;        srel = (bfd_signed_vma) relocation + rel->r_addend;
# Line 705  avr_final_link_relocate (howto, input_bf Line 784  avr_final_link_relocate (howto, input_bf
784  }  }
785    
786  /* Relocate an AVR ELF section.  */  /* Relocate an AVR ELF section.  */
787  static boolean  static bfd_boolean
788  elf32_avr_relocate_section (output_bfd, info, input_bfd, input_section,  elf32_avr_relocate_section (output_bfd, info, input_bfd, input_section,
789                              contents, relocs, local_syms, local_sections)                              contents, relocs, local_syms, local_sections)
790       bfd *output_bfd ATTRIBUTE_UNUSED;       bfd *output_bfd ATTRIBUTE_UNUSED;
# Line 722  elf32_avr_relocate_section (output_bfd, Line 801  elf32_avr_relocate_section (output_bfd,
801    Elf_Internal_Rela *           rel;    Elf_Internal_Rela *           rel;
802    Elf_Internal_Rela *           relend;    Elf_Internal_Rela *           relend;
803    
804      if (info->relocatable)
805        return TRUE;
806    
807    symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;    symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
808    sym_hashes = elf_sym_hashes (input_bfd);    sym_hashes = elf_sym_hashes (input_bfd);
809    relend     = relocs + input_section->reloc_count;    relend     = relocs + input_section->reloc_count;
# Line 735  elf32_avr_relocate_section (output_bfd, Line 817  elf32_avr_relocate_section (output_bfd,
817        struct elf_link_hash_entry * h;        struct elf_link_hash_entry * h;
818        bfd_vma                      relocation;        bfd_vma                      relocation;
819        bfd_reloc_status_type        r;        bfd_reloc_status_type        r;
820        const char *                 name = NULL;        const char *                 name;
821        int                          r_type;        int                          r_type;
822    
823          /* This is a final link.  */
824        r_type = ELF32_R_TYPE (rel->r_info);        r_type = ELF32_R_TYPE (rel->r_info);
825        r_symndx = ELF32_R_SYM (rel->r_info);        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;  
         }  
   
       /* This is a final link.  */  
826        howto  = elf_avr_howto_table + ELF32_R_TYPE (rel->r_info);        howto  = elf_avr_howto_table + ELF32_R_TYPE (rel->r_info);
827        h      = NULL;        h      = NULL;
828        sym    = NULL;        sym    = NULL;
# Line 771  elf32_avr_relocate_section (output_bfd, Line 832  elf32_avr_relocate_section (output_bfd,
832          {          {
833            sym = local_syms + r_symndx;            sym = local_syms + r_symndx;
834            sec = local_sections [r_symndx];            sec = local_sections [r_symndx];
835            relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);            relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
836    
837            name = bfd_elf_string_from_elf_section            name = bfd_elf_string_from_elf_section
838              (input_bfd, symtab_hdr->sh_link, sym->st_name);              (input_bfd, symtab_hdr->sh_link, sym->st_name);
# Line 779  elf32_avr_relocate_section (output_bfd, Line 840  elf32_avr_relocate_section (output_bfd,
840          }          }
841        else        else
842          {          {
843            h = sym_hashes [r_symndx - symtab_hdr->sh_info];            bfd_boolean unresolved_reloc, warned;
844    
845            while (h->root.type == bfd_link_hash_indirect            RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
846                   || h->root.type == bfd_link_hash_warning)                                     r_symndx, symtab_hdr, sym_hashes,
847              h = (struct elf_link_hash_entry *) h->root.u.i.link;                                     h, sec, relocation,
848                                       unresolved_reloc, warned);
849    
850            name = h->root.root.string;            name = h->root.root.string;
   
           if (h->root.type == bfd_link_hash_defined  
               || h->root.type == bfd_link_hash_defweak)  
             {  
               sec = h->root.u.def.section;  
               relocation = (h->root.u.def.value  
                             + sec->output_section->vma  
                             + sec->output_offset);  
             }  
           else if (h->root.type == bfd_link_hash_undefweak)  
             {  
               relocation = 0;  
             }  
           else  
             {  
               if (! ((*info->callbacks->undefined_symbol)  
                      (info, h->root.root.string, input_bfd,  
                       input_section, rel->r_offset, true)))  
                 return false;  
               relocation = 0;  
             }  
851          }          }
852    
853        r = avr_final_link_relocate (howto, input_bfd, input_section,        r = avr_final_link_relocate (howto, input_bfd, input_section,
# Line 820  elf32_avr_relocate_section (output_bfd, Line 861  elf32_avr_relocate_section (output_bfd,
861              {              {
862              case bfd_reloc_overflow:              case bfd_reloc_overflow:
863                r = info->callbacks->reloc_overflow                r = info->callbacks->reloc_overflow
864                  (info, name, howto->name, (bfd_vma) 0,                  (info, (h ? &h->root : NULL),
865                     name, howto->name, (bfd_vma) 0,
866                   input_bfd, input_section, rel->r_offset);                   input_bfd, input_section, rel->r_offset);
867                break;                break;
868    
869              case bfd_reloc_undefined:              case bfd_reloc_undefined:
870                r = info->callbacks->undefined_symbol                r = info->callbacks->undefined_symbol
871                  (info, name, input_bfd, input_section, rel->r_offset, true);                  (info, name, input_bfd, input_section, rel->r_offset, TRUE);
872                break;                break;
873    
874              case bfd_reloc_outofrange:              case bfd_reloc_outofrange:
# Line 851  elf32_avr_relocate_section (output_bfd, Line 893  elf32_avr_relocate_section (output_bfd,
893                (info, msg, name, input_bfd, input_section, rel->r_offset);                (info, msg, name, input_bfd, input_section, rel->r_offset);
894    
895            if (! r)            if (! r)
896              return false;              return FALSE;
897          }          }
898      }      }
899    
900    return true;    return TRUE;
901  }  }
902    
903  /* The final processing done just before writing out a AVR ELF object  /* The final processing done just before writing out a AVR ELF object
# Line 865  elf32_avr_relocate_section (output_bfd, Line 907  elf32_avr_relocate_section (output_bfd,
907  static void  static void
908  bfd_elf_avr_final_write_processing (abfd, linker)  bfd_elf_avr_final_write_processing (abfd, linker)
909       bfd *abfd;       bfd *abfd;
910       boolean linker ATTRIBUTE_UNUSED;       bfd_boolean linker ATTRIBUTE_UNUSED;
911  {  {
912    unsigned long val;    unsigned long val;
913    
# Line 900  bfd_elf_avr_final_write_processing (abfd Line 942  bfd_elf_avr_final_write_processing (abfd
942    
943  /* Set the right machine number.  */  /* Set the right machine number.  */
944    
945  static boolean  static bfd_boolean
946  elf32_avr_object_p (abfd)  elf32_avr_object_p (abfd)
947       bfd *abfd;       bfd *abfd;
948  {  {
# Line 952  elf32_avr_object_p (abfd) Line 994  elf32_avr_object_p (abfd)
994  #define elf_backend_gc_sweep_hook            elf32_avr_gc_sweep_hook  #define elf_backend_gc_sweep_hook            elf32_avr_gc_sweep_hook
995  #define elf_backend_check_relocs             elf32_avr_check_relocs  #define elf_backend_check_relocs             elf32_avr_check_relocs
996  #define elf_backend_can_gc_sections          1  #define elf_backend_can_gc_sections          1
997    #define elf_backend_rela_normal              1
998  #define elf_backend_final_write_processing \  #define elf_backend_final_write_processing \
999                                          bfd_elf_avr_final_write_processing                                          bfd_elf_avr_final_write_processing
1000  #define elf_backend_object_p            elf32_avr_object_p  #define elf_backend_object_p            elf32_avr_object_p

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.1.20.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26