Changeset 609 for branches/GNU/src/binutils/bfd/elf32-avr.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/elf32-avr.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* AVR-specific support for 32-bit ELF 2 Copyright 1999, 2000 Free Software Foundation, Inc.2 Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. 3 3 Contributed by Denis Chertykov <denisc@overta.ru> 4 4 … … 28 28 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); 29 29 static void avr_info_to_howto_rela 30 PARAMS ((bfd *, arelent *, Elf 32_Internal_Rela *));30 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); 31 31 static asection *elf32_avr_gc_mark_hook 32 PARAMS (( bfd*, struct bfd_link_info *, Elf_Internal_Rela *,32 PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, 33 33 struct elf_link_hash_entry *, Elf_Internal_Sym *)); 34 static b oolean elf32_avr_gc_sweep_hook34 static bfd_boolean elf32_avr_gc_sweep_hook 35 35 PARAMS ((bfd *, struct bfd_link_info *, asection *, 36 36 const Elf_Internal_Rela *)); 37 static b oolean elf32_avr_check_relocs37 static bfd_boolean elf32_avr_check_relocs 38 38 PARAMS ((bfd *, struct bfd_link_info *, asection *, 39 39 const Elf_Internal_Rela *)); … … 41 41 PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, 42 42 Elf_Internal_Rela *, bfd_vma)); 43 static b oolean elf32_avr_relocate_section43 static bfd_boolean elf32_avr_relocate_section 44 44 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 45 45 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); 46 static void bfd_elf_avr_final_write_processing PARAMS ((bfd *, boolean)); 47 static boolean elf32_avr_object_p PARAMS ((bfd *)); 48 49 /* Use RELA instead of REL */ 50 #undef USE_REL 46 static void bfd_elf_avr_final_write_processing PARAMS ((bfd *, bfd_boolean)); 47 static bfd_boolean elf32_avr_object_p PARAMS ((bfd *)); 51 48 52 49 static reloc_howto_type elf_avr_howto_table[] = … … 56 53 2, /* size (0 = byte, 1 = short, 2 = long) */ 57 54 32, /* bitsize */ 58 false, /* pc_relative */55 FALSE, /* pc_relative */ 59 56 0, /* bitpos */ 60 57 complain_overflow_bitfield, /* complain_on_overflow */ 61 58 bfd_elf_generic_reloc, /* special_function */ 62 59 "R_AVR_NONE", /* name */ 63 false, /* partial_inplace */60 FALSE, /* partial_inplace */ 64 61 0, /* src_mask */ 65 62 0, /* dst_mask */ 66 false), /* pcrel_offset */63 FALSE), /* pcrel_offset */ 67 64 68 65 HOWTO (R_AVR_32, /* type */ … … 70 67 2, /* size (0 = byte, 1 = short, 2 = long) */ 71 68 32, /* bitsize */ 72 false, /* pc_relative */69 FALSE, /* pc_relative */ 73 70 0, /* bitpos */ 74 71 complain_overflow_bitfield, /* complain_on_overflow */ 75 72 bfd_elf_generic_reloc, /* special_function */ 76 73 "R_AVR_32", /* name */ 77 false, /* partial_inplace */74 FALSE, /* partial_inplace */ 78 75 0xffffffff, /* src_mask */ 79 76 0xffffffff, /* dst_mask */ 80 false), /* pcrel_offset */77 FALSE), /* pcrel_offset */ 81 78 82 79 /* A 7 bit PC relative relocation. */ … … 85 82 1, /* size (0 = byte, 1 = short, 2 = long) */ 86 83 7, /* bitsize */ 87 true, /* pc_relative */84 TRUE, /* pc_relative */ 88 85 3, /* bitpos */ 89 86 complain_overflow_bitfield, /* complain_on_overflow */ 90 87 bfd_elf_generic_reloc, /* special_function */ 91 88 "R_AVR_7_PCREL", /* name */ 92 false, /* partial_inplace */93 0xffff, /* src_mask */ 94 0xffff, /* dst_mask */ 95 true), /* pcrel_offset */89 FALSE, /* partial_inplace */ 90 0xffff, /* src_mask */ 91 0xffff, /* dst_mask */ 92 TRUE), /* pcrel_offset */ 96 93 97 94 /* A 13 bit PC relative relocation. */ … … 100 97 1, /* size (0 = byte, 1 = short, 2 = long) */ 101 98 13, /* bitsize */ 102 true, /* pc_relative */99 TRUE, /* pc_relative */ 103 100 0, /* bitpos */ 104 101 complain_overflow_bitfield, /* complain_on_overflow */ 105 102 bfd_elf_generic_reloc, /* special_function */ 106 103 "R_AVR_13_PCREL", /* name */ 107 false, /* partial_inplace */104 FALSE, /* partial_inplace */ 108 105 0xfff, /* src_mask */ 109 106 0xfff, /* dst_mask */ 110 true), /* pcrel_offset */107 TRUE), /* pcrel_offset */ 111 108 112 109 /* A 16 bit absolute relocation. */ … … 115 112 1, /* size (0 = byte, 1 = short, 2 = long) */ 116 113 16, /* bitsize */ 117 false, /* pc_relative */114 FALSE, /* pc_relative */ 118 115 0, /* bitpos */ 119 116 complain_overflow_dont, /* complain_on_overflow */ 120 117 bfd_elf_generic_reloc, /* special_function */ 121 118 "R_AVR_16", /* name */ 122 false, /* partial_inplace */123 0xffff, /* src_mask */ 124 0xffff, /* dst_mask */ 125 false), /* pcrel_offset */119 FALSE, /* partial_inplace */ 120 0xffff, /* src_mask */ 121 0xffff, /* dst_mask */ 122 FALSE), /* pcrel_offset */ 126 123 127 124 /* A 16 bit absolute relocation for command address. */ … … 130 127 1, /* size (0 = byte, 1 = short, 2 = long) */ 131 128 16, /* bitsize */ 132 false, /* pc_relative */129 FALSE, /* pc_relative */ 133 130 0, /* bitpos */ 134 131 complain_overflow_bitfield, /* complain_on_overflow */ 135 132 bfd_elf_generic_reloc, /* special_function */ 136 133 "R_AVR_16_PM", /* name */ 137 false, /* partial_inplace */138 0xffff, /* src_mask */ 139 0xffff, /* dst_mask */ 140 false), /* pcrel_offset */134 FALSE, /* partial_inplace */ 135 0xffff, /* src_mask */ 136 0xffff, /* dst_mask */ 137 FALSE), /* pcrel_offset */ 141 138 /* A low 8 bit absolute relocation of 16 bit address. 142 139 For LDI command. */ … … 145 142 1, /* size (0 = byte, 1 = short, 2 = long) */ 146 143 8, /* bitsize */ 147 false, /* pc_relative */144 FALSE, /* pc_relative */ 148 145 0, /* bitpos */ 149 146 complain_overflow_dont, /* complain_on_overflow */ 150 147 bfd_elf_generic_reloc, /* special_function */ 151 148 "R_AVR_LO8_LDI", /* name */ 152 false, /* partial_inplace */153 0xffff, /* src_mask */ 154 0xffff, /* dst_mask */ 155 false), /* pcrel_offset */149 FALSE, /* partial_inplace */ 150 0xffff, /* src_mask */ 151 0xffff, /* dst_mask */ 152 FALSE), /* pcrel_offset */ 156 153 /* A high 8 bit absolute relocation of 16 bit address. 157 154 For LDI command. */ … … 160 157 1, /* size (0 = byte, 1 = short, 2 = long) */ 161 158 8, /* bitsize */ 162 false, /* pc_relative */159 FALSE, /* pc_relative */ 163 160 0, /* bitpos */ 164 161 complain_overflow_dont, /* complain_on_overflow */ 165 162 bfd_elf_generic_reloc, /* special_function */ 166 163 "R_AVR_HI8_LDI", /* name */ 167 false, /* partial_inplace */168 0xffff, /* src_mask */ 169 0xffff, /* dst_mask */ 170 false), /* pcrel_offset */164 FALSE, /* partial_inplace */ 165 0xffff, /* src_mask */ 166 0xffff, /* dst_mask */ 167 FALSE), /* pcrel_offset */ 171 168 /* A high 6 bit absolute relocation of 22 bit address. 172 169 For LDI command. */ … … 175 172 1, /* size (0 = byte, 1 = short, 2 = long) */ 176 173 8, /* bitsize */ 177 false, /* pc_relative */174 FALSE, /* pc_relative */ 178 175 0, /* bitpos */ 179 176 complain_overflow_dont, /* complain_on_overflow */ 180 177 bfd_elf_generic_reloc, /* special_function */ 181 178 "R_AVR_HH8_LDI", /* name */ 182 false, /* partial_inplace */183 0xffff, /* src_mask */ 184 0xffff, /* dst_mask */ 185 false), /* pcrel_offset */179 FALSE, /* partial_inplace */ 180 0xffff, /* src_mask */ 181 0xffff, /* dst_mask */ 182 FALSE), /* pcrel_offset */ 186 183 /* A negative low 8 bit absolute relocation of 16 bit address. 187 184 For LDI command. */ … … 190 187 1, /* size (0 = byte, 1 = short, 2 = long) */ 191 188 8, /* bitsize */ 192 false, /* pc_relative */189 FALSE, /* pc_relative */ 193 190 0, /* bitpos */ 194 191 complain_overflow_dont, /* complain_on_overflow */ 195 192 bfd_elf_generic_reloc, /* special_function */ 196 193 "R_AVR_LO8_LDI_NEG", /* name */ 197 false, /* partial_inplace */198 0xffff, /* src_mask */ 199 0xffff, /* dst_mask */ 200 false), /* pcrel_offset */194 FALSE, /* partial_inplace */ 195 0xffff, /* src_mask */ 196 0xffff, /* dst_mask */ 197 FALSE), /* pcrel_offset */ 201 198 /* A hegative high 8 bit absolute relocation of 16 bit address. 202 199 For LDI command. */ … … 205 202 1, /* size (0 = byte, 1 = short, 2 = long) */ 206 203 8, /* bitsize */ 207 false, /* pc_relative */204 FALSE, /* pc_relative */ 208 205 0, /* bitpos */ 209 206 complain_overflow_dont, /* complain_on_overflow */ 210 207 bfd_elf_generic_reloc, /* special_function */ 211 208 "R_AVR_HI8_LDI_NEG", /* name */ 212 false, /* partial_inplace */213 0xffff, /* src_mask */ 214 0xffff, /* dst_mask */ 215 false), /* pcrel_offset */209 FALSE, /* partial_inplace */ 210 0xffff, /* src_mask */ 211 0xffff, /* dst_mask */ 212 FALSE), /* pcrel_offset */ 216 213 /* A hegative high 6 bit absolute relocation of 22 bit address. 217 214 For LDI command. */ … … 220 217 1, /* size (0 = byte, 1 = short, 2 = long) */ 221 218 8, /* bitsize */ 222 false, /* pc_relative */219 FALSE, /* pc_relative */ 223 220 0, /* bitpos */ 224 221 complain_overflow_dont, /* complain_on_overflow */ 225 222 bfd_elf_generic_reloc, /* special_function */ 226 223 "R_AVR_HH8_LDI_NEG", /* name */ 227 false, /* partial_inplace */228 0xffff, /* src_mask */ 229 0xffff, /* dst_mask */ 230 false), /* pcrel_offset */224 FALSE, /* partial_inplace */ 225 0xffff, /* src_mask */ 226 0xffff, /* dst_mask */ 227 FALSE), /* pcrel_offset */ 231 228 /* A low 8 bit absolute relocation of 24 bit program memory address. 232 229 For LDI command. */ … … 235 232 1, /* size (0 = byte, 1 = short, 2 = long) */ 236 233 8, /* bitsize */ 237 false, /* pc_relative */234 FALSE, /* pc_relative */ 238 235 0, /* bitpos */ 239 236 complain_overflow_dont, /* complain_on_overflow */ 240 237 bfd_elf_generic_reloc, /* special_function */ 241 238 "R_AVR_LO8_LDI_PM", /* name */ 242 false, /* partial_inplace */243 0xffff, /* src_mask */ 244 0xffff, /* dst_mask */ 245 false), /* pcrel_offset */239 FALSE, /* partial_inplace */ 240 0xffff, /* src_mask */ 241 0xffff, /* dst_mask */ 242 FALSE), /* pcrel_offset */ 246 243 /* A high 8 bit absolute relocation of 16 bit program memory address. 247 244 For LDI command. */ … … 250 247 1, /* size (0 = byte, 1 = short, 2 = long) */ 251 248 8, /* bitsize */ 252 false, /* pc_relative */249 FALSE, /* pc_relative */ 253 250 0, /* bitpos */ 254 251 complain_overflow_dont, /* complain_on_overflow */ 255 252 bfd_elf_generic_reloc, /* special_function */ 256 253 "R_AVR_HI8_LDI_PM", /* name */ 257 false, /* partial_inplace */258 0xffff, /* src_mask */ 259 0xffff, /* dst_mask */ 260 false), /* pcrel_offset */254 FALSE, /* partial_inplace */ 255 0xffff, /* src_mask */ 256 0xffff, /* dst_mask */ 257 FALSE), /* pcrel_offset */ 261 258 /* A high 8 bit absolute relocation of 24 bit program memory address. 262 259 For LDI command. */ … … 265 262 1, /* size (0 = byte, 1 = short, 2 = long) */ 266 263 8, /* bitsize */ 267 false, /* pc_relative */264 FALSE, /* pc_relative */ 268 265 0, /* bitpos */ 269 266 complain_overflow_dont, /* complain_on_overflow */ 270 267 bfd_elf_generic_reloc, /* special_function */ 271 268 "R_AVR_HH8_LDI_PM", /* name */ 272 false, /* partial_inplace */273 0xffff, /* src_mask */ 274 0xffff, /* dst_mask */ 275 false), /* pcrel_offset */269 FALSE, /* partial_inplace */ 270 0xffff, /* src_mask */ 271 0xffff, /* dst_mask */ 272 FALSE), /* pcrel_offset */ 276 273 /* A low 8 bit absolute relocation of a negative 24 bit 277 274 program memory address. For LDI command. */ … … 280 277 1, /* size (0 = byte, 1 = short, 2 = long) */ 281 278 8, /* bitsize */ 282 false, /* pc_relative */279 FALSE, /* pc_relative */ 283 280 0, /* bitpos */ 284 281 complain_overflow_dont, /* complain_on_overflow */ 285 282 bfd_elf_generic_reloc, /* special_function */ 286 283 "R_AVR_LO8_LDI_PM_NEG", /* name */ 287 false, /* partial_inplace */288 0xffff, /* src_mask */ 289 0xffff, /* dst_mask */ 290 false), /* pcrel_offset */284 FALSE, /* partial_inplace */ 285 0xffff, /* src_mask */ 286 0xffff, /* dst_mask */ 287 FALSE), /* pcrel_offset */ 291 288 /* A high 8 bit absolute relocation of a negative 16 bit 292 289 program memory address. For LDI command. */ … … 295 292 1, /* size (0 = byte, 1 = short, 2 = long) */ 296 293 8, /* bitsize */ 297 false, /* pc_relative */294 FALSE, /* pc_relative */ 298 295 0, /* bitpos */ 299 296 complain_overflow_dont, /* complain_on_overflow */ 300 297 bfd_elf_generic_reloc, /* special_function */ 301 298 "R_AVR_HI8_LDI_PM_NEG", /* name */ 302 false, /* partial_inplace */303 0xffff, /* src_mask */ 304 0xffff, /* dst_mask */ 305 false), /* pcrel_offset */299 FALSE, /* partial_inplace */ 300 0xffff, /* src_mask */ 301 0xffff, /* dst_mask */ 302 FALSE), /* pcrel_offset */ 306 303 /* A high 8 bit absolute relocation of a negative 24 bit 307 304 program memory address. For LDI command. */ … … 310 307 1, /* size (0 = byte, 1 = short, 2 = long) */ 311 308 8, /* bitsize */ 312 false, /* pc_relative */309 FALSE, /* pc_relative */ 313 310 0, /* bitpos */ 314 311 complain_overflow_dont, /* complain_on_overflow */ 315 312 bfd_elf_generic_reloc, /* special_function */ 316 313 "R_AVR_HH8_LDI_PM_NEG", /* name */ 317 false, /* partial_inplace */318 0xffff, /* src_mask */ 319 0xffff, /* dst_mask */ 320 false), /* pcrel_offset */314 FALSE, /* partial_inplace */ 315 0xffff, /* src_mask */ 316 0xffff, /* dst_mask */ 317 FALSE), /* pcrel_offset */ 321 318 /* Relocation for CALL command in ATmega. */ 322 319 HOWTO (R_AVR_CALL, /* type */ … … 324 321 2, /* size (0 = byte, 1 = short, 2 = long) */ 325 322 23, /* bitsize */ 326 false, /* pc_relative */323 FALSE, /* pc_relative */ 327 324 0, /* bitpos */ 328 325 complain_overflow_dont, /* complain_on_overflow */ 329 326 bfd_elf_generic_reloc, /* special_function */ 330 327 "R_AVR_CALL", /* name */ 331 false, /* partial_inplace */328 FALSE, /* partial_inplace */ 332 329 0xffffffff, /* src_mask */ 333 330 0xffffffff, /* dst_mask */ 334 false) /* pcrel_offset */331 FALSE) /* pcrel_offset */ 335 332 }; 336 333 … … 390 387 bfd *abfd ATTRIBUTE_UNUSED; 391 388 arelent *cache_ptr; 392 Elf 32_Internal_Rela *dst;389 Elf_Internal_Rela *dst; 393 390 { 394 391 unsigned int r_type; … … 400 397 401 398 static asection * 402 elf32_avr_gc_mark_hook ( abfd, info, rel, h, sym)403 bfd *abfd;399 elf32_avr_gc_mark_hook (sec, info, rel, h, sym) 400 asection *sec; 404 401 struct bfd_link_info *info ATTRIBUTE_UNUSED; 405 402 Elf_Internal_Rela *rel; … … 427 424 } 428 425 else 429 { 430 if (!(elf_bad_symtab (abfd) 431 && ELF_ST_BIND (sym->st_info) != STB_LOCAL) 432 && !((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE) 433 && sym->st_shndx != SHN_COMMON)) 434 { 435 return bfd_section_from_elf_index (abfd, sym->st_shndx); 436 } 437 } 426 return bfd_section_from_elf_index (sec->owner, sym->st_shndx); 427 438 428 return NULL; 439 429 } 440 430 441 static b oolean431 static bfd_boolean 442 432 elf32_avr_gc_sweep_hook (abfd, info, sec, relocs) 443 433 bfd *abfd ATTRIBUTE_UNUSED; … … 447 437 { 448 438 /* We don't use got and plt entries for avr. */ 449 return true;439 return TRUE; 450 440 } 451 441 … … 454 444 virtual table relocs for gc. */ 455 445 456 static b oolean446 static bfd_boolean 457 447 elf32_avr_check_relocs (abfd, info, sec, relocs) 458 448 bfd *abfd; … … 467 457 468 458 if (info->relocateable) 469 return true;459 return TRUE; 470 460 471 461 symtab_hdr = &elf_tdata (abfd)->symtab_hdr; … … 488 478 } 489 479 490 return true;480 return TRUE; 491 481 } 492 482 … … 700 690 x |= ((srel & 0x10000) | ((srel << 3) & 0x1f00000)) >> 16; 701 691 bfd_put_16 (input_bfd, x, contents); 702 bfd_put_16 (input_bfd, srel & 0xffff, contents+2);692 bfd_put_16 (input_bfd, (bfd_vma) srel & 0xffff, contents+2); 703 693 break; 704 694 … … 713 703 714 704 /* Relocate an AVR ELF section. */ 715 static b oolean705 static bfd_boolean 716 706 elf32_avr_relocate_section (output_bfd, info, input_bfd, input_section, 717 707 contents, relocs, local_syms, local_sections) … … 729 719 Elf_Internal_Rela * rel; 730 720 Elf_Internal_Rela * relend; 721 722 if (info->relocateable) 723 return TRUE; 731 724 732 725 symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr; … … 746 739 int r_type; 747 740 741 /* This is a final link. */ 748 742 r_type = ELF32_R_TYPE (rel->r_info); 749 743 r_symndx = ELF32_R_SYM (rel->r_info); 750 751 if (info->relocateable)752 {753 /* This is a relocateable link. We don't have to change754 anything, unless the reloc is against a section symbol,755 in which case we have to adjust according to where the756 section symbol winds up in the output section. */757 if (r_symndx < symtab_hdr->sh_info)758 {759 sym = local_syms + r_symndx;760 761 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)762 {763 sec = local_sections [r_symndx];764 rel->r_addend += sec->output_offset + sym->st_value;765 }766 }767 768 continue;769 }770 771 /* This is a final link. */772 744 howto = elf_avr_howto_table + ELF32_R_TYPE (rel->r_info); 773 745 h = NULL; … … 779 751 sym = local_syms + r_symndx; 780 752 sec = local_sections [r_symndx]; 781 relocation = (sec->output_section->vma 782 + sec->output_offset 783 + sym->st_value); 753 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); 784 754 785 755 name = bfd_elf_string_from_elf_section … … 813 783 if (! ((*info->callbacks->undefined_symbol) 814 784 (info, h->root.root.string, input_bfd, 815 input_section, rel->r_offset, true)))816 return false;785 input_section, rel->r_offset, TRUE))) 786 return FALSE; 817 787 relocation = 0; 818 788 } … … 836 806 case bfd_reloc_undefined: 837 807 r = info->callbacks->undefined_symbol 838 (info, name, input_bfd, input_section, rel->r_offset, true);808 (info, name, input_bfd, input_section, rel->r_offset, TRUE); 839 809 break; 840 810 … … 861 831 862 832 if (! r) 863 return false;833 return FALSE; 864 834 } 865 835 } 866 836 867 return true;837 return TRUE; 868 838 } 869 839 … … 875 845 bfd_elf_avr_final_write_processing (abfd, linker) 876 846 bfd *abfd; 877 b oolean linker ATTRIBUTE_UNUSED;847 bfd_boolean linker ATTRIBUTE_UNUSED; 878 848 { 879 849 unsigned long val; … … 910 880 /* Set the right machine number. */ 911 881 912 static b oolean882 static bfd_boolean 913 883 elf32_avr_object_p (abfd) 914 884 bfd *abfd; 915 885 { 916 int e_set = bfd_mach_avr2; 917 if (elf_elfheader (abfd)->e_machine == EM_AVR) 886 unsigned int e_set = bfd_mach_avr2; 887 if (elf_elfheader (abfd)->e_machine == EM_AVR 888 || elf_elfheader (abfd)->e_machine == EM_AVR_OLD) 918 889 { 919 890 int e_mach = elf_elfheader (abfd)->e_flags & EF_AVR_MACH; … … 948 919 #define ELF_ARCH bfd_arch_avr 949 920 #define ELF_MACHINE_CODE EM_AVR 921 #define ELF_MACHINE_ALT1 EM_AVR_OLD 950 922 #define ELF_MAXPAGESIZE 1 951 923 … … 960 932 #define elf_backend_check_relocs elf32_avr_check_relocs 961 933 #define elf_backend_can_gc_sections 1 934 #define elf_backend_rela_normal 1 962 935 #define elf_backend_final_write_processing \ 963 936 bfd_elf_avr_final_write_processing -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.