1a1ba9ba4Schristos /* AVR-specific support for 32-bit ELF. 2*184b2d41Schristos Copyright (C) 2006-2020 Free Software Foundation, Inc. 3a1ba9ba4Schristos 4a1ba9ba4Schristos Written by Bjoern Haase <bjoern.m.haase@web.de> 5a1ba9ba4Schristos 6a1ba9ba4Schristos This file is part of BFD, the Binary File Descriptor library. 7a1ba9ba4Schristos 8a1ba9ba4Schristos This program is free software; you can redistribute it and/or modify 9a1ba9ba4Schristos it under the terms of the GNU General Public License as published by 10a1ba9ba4Schristos the Free Software Foundation; either version 3 of the License, or 11a1ba9ba4Schristos (at your option) any later version. 12a1ba9ba4Schristos 13a1ba9ba4Schristos This program is distributed in the hope that it will be useful, 14a1ba9ba4Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 15a1ba9ba4Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16a1ba9ba4Schristos GNU General Public License for more details. 17a1ba9ba4Schristos 18a1ba9ba4Schristos You should have received a copy of the GNU General Public License 19a1ba9ba4Schristos along with this program; if not, write to the Free Software 20a1ba9ba4Schristos Foundation, Inc., 51 Franklin Street - Fifth Floor, 21a1ba9ba4Schristos Boston, MA 02110-1301, USA. */ 22a1ba9ba4Schristos 23a1ba9ba4Schristos 24a1ba9ba4Schristos /* These four functions will be called from the ld back-end. */ 25a1ba9ba4Schristos 26a1ba9ba4Schristos extern void 27a1ba9ba4Schristos elf32_avr_setup_params (struct bfd_link_info *, bfd *, asection *, 28a1ba9ba4Schristos bfd_boolean, bfd_boolean, bfd_boolean, 29a1ba9ba4Schristos bfd_vma, bfd_boolean); 30a1ba9ba4Schristos 31a1ba9ba4Schristos extern int 32a1ba9ba4Schristos elf32_avr_setup_section_lists (bfd *, struct bfd_link_info *); 33a1ba9ba4Schristos 34a1ba9ba4Schristos extern bfd_boolean 35a1ba9ba4Schristos elf32_avr_size_stubs (bfd *, struct bfd_link_info *, bfd_boolean); 36a1ba9ba4Schristos 37a1ba9ba4Schristos extern bfd_boolean 38a1ba9ba4Schristos elf32_avr_build_stubs (struct bfd_link_info *); 39a1ba9ba4Schristos 40a1ba9ba4Schristos /* The name of the section into which the property records are stored. */ 41a1ba9ba4Schristos #define AVR_PROPERTY_RECORD_SECTION_NAME ".avr.prop" 42a1ba9ba4Schristos 43a1ba9ba4Schristos /* The current version number for the format of the property records. */ 44a1ba9ba4Schristos #define AVR_PROPERTY_RECORDS_VERSION 1 45a1ba9ba4Schristos 46a1ba9ba4Schristos /* The size of the header that is written to the property record section 47a1ba9ba4Schristos before the property records are written out. */ 48a1ba9ba4Schristos #define AVR_PROPERTY_SECTION_HEADER_SIZE 4 49a1ba9ba4Schristos 50a1ba9ba4Schristos /* This holds a single property record in memory, the structure of this 51a1ba9ba4Schristos data when written out to the ELF section is more compressed. */ 52a1ba9ba4Schristos 53a1ba9ba4Schristos struct avr_property_record 54a1ba9ba4Schristos { 55a1ba9ba4Schristos /* The section and offset for this record. */ 56a1ba9ba4Schristos asection *section; 57a1ba9ba4Schristos bfd_vma offset; 58a1ba9ba4Schristos 59a1ba9ba4Schristos /* The type of this record. */ 60a1ba9ba4Schristos enum { 61a1ba9ba4Schristos RECORD_ORG = 0, 62a1ba9ba4Schristos RECORD_ORG_AND_FILL = 1, 63a1ba9ba4Schristos RECORD_ALIGN = 2, 64a1ba9ba4Schristos RECORD_ALIGN_AND_FILL = 3 65a1ba9ba4Schristos } type; 66a1ba9ba4Schristos 67a1ba9ba4Schristos /* Type specific data. */ 68a1ba9ba4Schristos union 69a1ba9ba4Schristos { 70a1ba9ba4Schristos /* RECORD_ORG and RECORD_ORG_AND_FILL. */ 71a1ba9ba4Schristos struct 72a1ba9ba4Schristos { 73a1ba9ba4Schristos unsigned long fill; 74a1ba9ba4Schristos } org; 75a1ba9ba4Schristos 76a1ba9ba4Schristos /* RECORD_ALIGN and RECORD_ALIGN_AND_FILL. */ 77a1ba9ba4Schristos struct 78a1ba9ba4Schristos { 79a1ba9ba4Schristos unsigned long bytes; 80a1ba9ba4Schristos unsigned long fill; 81a1ba9ba4Schristos 82a1ba9ba4Schristos /* This field is used during linker relaxation to track the number of 83a1ba9ba4Schristos bytes that have been opened up before this alignment directive. 84a1ba9ba4Schristos When we have enough bytes available it is possible to move the 85a1ba9ba4Schristos re-align this directive backwards while still maintaining the 86a1ba9ba4Schristos alignment requirement. */ 87a1ba9ba4Schristos unsigned long preceding_deleted; 88a1ba9ba4Schristos } align; 89a1ba9ba4Schristos } data; 90a1ba9ba4Schristos }; 91a1ba9ba4Schristos 92a1ba9ba4Schristos struct avr_property_record_list 93a1ba9ba4Schristos { 94a1ba9ba4Schristos /* The version number tells us the structure of the property record data 95a1ba9ba4Schristos within the section. See AVR_PROPERTY_RECORDS_VERSION. */ 96a1ba9ba4Schristos bfd_byte version; 97a1ba9ba4Schristos 98a1ba9ba4Schristos /* The flags field is currently unused. This should be set to 0. */ 99a1ba9ba4Schristos bfd_byte flags; 100a1ba9ba4Schristos 101a1ba9ba4Schristos /* The number of property records. This is stored as a 2-byte value in 102a1ba9ba4Schristos the section contents. */ 103a1ba9ba4Schristos unsigned long record_count; 104a1ba9ba4Schristos 105a1ba9ba4Schristos /* The section from which the property records were loaded. This is the 106a1ba9ba4Schristos actual section containing the records, not the section(s) to which the 107a1ba9ba4Schristos records apply. */ 108a1ba9ba4Schristos asection *section; 109a1ba9ba4Schristos 110a1ba9ba4Schristos /* The actual property records. */ 111a1ba9ba4Schristos struct avr_property_record *records; 112a1ba9ba4Schristos }; 113a1ba9ba4Schristos 114a1ba9ba4Schristos /* Load the property records from ABFD, return NULL if there are non 115a1ba9ba4Schristos found, otherwise return pointer to dynamically allocated memory. The 116a1ba9ba4Schristos memory for the header and all of the records are allocated in a single 117a1ba9ba4Schristos block, as such only the header needs to be freed. */ 118a1ba9ba4Schristos 119a1ba9ba4Schristos extern struct avr_property_record_list *avr_elf32_load_property_records (bfd *abfd); 120a1ba9ba4Schristos 121a1ba9ba4Schristos /* Return a string that is the name of the property record pointed to by REC. */ 122a1ba9ba4Schristos extern const char *avr_elf32_property_record_name (struct avr_property_record *rec); 123