elf32-avr.h 3.9 KB

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