elf32-nds32.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* NDS32-specific support for 32-bit ELF.
  2. Copyright (C) 2012-2015 Free Software Foundation, Inc.
  3. Contributed by Andes Technology Corporation.
  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, Boston, MA
  16. 02110-1301, USA.*/
  17. #ifndef ELF32_NDS32_H
  18. #define ELF32_NDS32_H
  19. /* Relocation flags encoded in r_addend. */
  20. /* Relocation flags for R_NDS32_ERLAX_ENTRY. */
  21. /* Set if relax on this section is done or disabled. */
  22. #define R_NDS32_RELAX_ENTRY_DISABLE_RELAX_FLAG (1 << 31)
  23. /* Optimize for performance. */
  24. #define R_NDS32_RELAX_ENTRY_OPTIMIZE_FLAG (1 << 30)
  25. /* Optimize for size. Branch destination 4-byte adjustment
  26. may be disabled. */
  27. #define R_NDS32_RELAX_ENTRY_OPTIMIZE_FOR_SPACE_FLAG (1 << 29)
  28. /* To distinguish the assembly code generated by compiler
  29. or written manually. */
  30. #define R_NDS32_RELAX_ENTRY_VERBATIM_FLAG (1 << 28)
  31. /* EX9 and link-time IFC must be explicitly enabled, so we
  32. won't mess up handcraft assembly code. */
  33. /* Enable EX9 optimization for this section. */
  34. #define R_NDS32_RELAX_ENTRY_EX9_FLAG (1 << 2)
  35. /* Enable IFC optimization for this section. */
  36. #define R_NDS32_RELAX_ENTRY_IFC_FLAG (1 << 3)
  37. /* Relocation flags for R_NDS32_INSN16. */
  38. /* Tag the nop16 can be removed. */
  39. #define R_NDS32_INSN16_CONVERT_FLAG (1 << 0)
  40. /* Convert a gp-relative access (e.g., lwi.gp)
  41. to fp-as-gp access (lwi37.fp).
  42. This value is used by linker internally only.
  43. It's fine to change the vlaue. */
  44. #define R_NDS32_INSN16_FP7U2_FLAG (1 << 1)
  45. /* Relocation flags for R_NDS32_RELAX_REGION_OMIT_FP_START/END. */
  46. /* OMIT_FP_FLAG marks the region for applying fp-as-gp
  47. optimization. */
  48. #define R_NDS32_RELAX_REGION_OMIT_FP_FLAG (1 << 0)
  49. /* NOT_OMIT_FP_FLAG is set if this region is not worth
  50. for fp-as-gp. */
  51. #define R_NDS32_RELAX_REGION_NOT_OMIT_FP_FLAG (1 << 1)
  52. /* Suppress EX9 optimization in the region. */
  53. #define R_NDS32_RELAX_REGION_NO_EX9_FLAG (1 << 2)
  54. /* A Innermost loop region. Some optimizations is suppressed
  55. in this region due to performance drop. */
  56. #define R_NDS32_RELAX_REGION_INNERMOST_LOOP_FLAG (1 << 4)
  57. /* Tag range for LOADSTORE relocation. */
  58. enum
  59. {
  60. NDS32_LOADSTORE_NONE = 0x0,
  61. NDS32_LOADSTORE_BYTE = 0x1,
  62. NDS32_LOADSTORE_HALF = 0x2,
  63. NDS32_LOADSTORE_WORD = 0x4,
  64. NDS32_LOADSTORE_FLOAT_S = 0x8,
  65. NDS32_LOADSTORE_FLOAT_D = 0x10,
  66. NDS32_LOADSTORE_IMM = 0x20
  67. };
  68. /* Relax tag for nds32_elf_relax_section, we have to specify which
  69. optimization do in this round. */
  70. enum
  71. {
  72. NDS32_RELAX_NONE_ROUND = 0,
  73. NDS32_RELAX_NORMAL_ROUND,
  74. NDS32_RELAX_JUMP_IFC_ROUND,
  75. NDS32_RELAX_EX9_BUILD_ROUND,
  76. NDS32_RELAX_EX9_REPLACE_ROUND,
  77. NDS32_RELAX_EMPTY_ROUND
  78. };
  79. /* Optimization status mask. */
  80. #define NDS32_RELAX_JUMP_IFC_DONE (1 << 0)
  81. #define NDS32_RELAX_EX9_DONE (1 << 1)
  82. /* Optimization turn on mask. */
  83. #define NDS32_RELAX_JUMP_IFC_ON (1 << 0)
  84. #define NDS32_RELAX_EX9_ON (1 << 1)
  85. extern void nds32_insertion_sort
  86. (void *, size_t, size_t, int (*) (const void *, const void *));
  87. extern int nds32_elf_ex9_init (void);
  88. extern int nds32_convert_32_to_16 (bfd *, uint32_t, uint16_t *, int *);
  89. extern int nds32_convert_16_to_32 (bfd *, uint16_t, uint32_t *);
  90. extern void bfd_elf32_nds32_set_target_option (struct bfd_link_info *,
  91. int, int, FILE *, int,
  92. int, int, int, FILE *,
  93. FILE *, int, int,
  94. bfd_boolean, bfd_boolean);
  95. #define nds32_elf_hash_table(info) \
  96. (elf_hash_table_id ((struct elf_link_hash_table *) ((info)->hash)) \
  97. == NDS32_ELF_DATA ? \
  98. ((struct elf_nds32_link_hash_table *) ((info)->hash)) : NULL)
  99. /* Hash table structure for target nds32. There are some members to
  100. save target options passed from nds32elf.em to bfd. */
  101. struct elf_nds32_link_hash_table
  102. {
  103. struct elf_link_hash_table root;
  104. /* Short-cuts to get to dynamic linker sections. */
  105. asection *sgot;
  106. asection *sgotplt;
  107. asection *srelgot;
  108. asection *splt;
  109. asection *srelplt;
  110. asection *sdynbss;
  111. asection *srelbss;
  112. /* Small local sym to section mapping cache. */
  113. struct sym_cache sym_cache;
  114. /* Target dependent options. */
  115. int relax_fp_as_gp; /* --mrelax-omit-fp */
  116. int eliminate_gc_relocs; /* --meliminate-gc-relocs */
  117. FILE *sym_ld_script; /* --mgen-symbol-ld-script=<file> */
  118. /* Disable if linking a dynamically linked executable. */
  119. int load_store_relax;
  120. int target_optimize; /* Switch optimization. */
  121. int relax_status; /* Finished optimization. */
  122. int relax_round; /* Going optimization. */
  123. FILE *ex9_export_file; /* --mexport-ex9=<file> */
  124. FILE *ex9_import_file; /* --mimport-ex9=<file> */
  125. int update_ex9_table; /* --mupdate-ex9. */
  126. int ex9_limit;
  127. bfd_boolean ex9_loop_aware; /* Ignore ex9 if inside a loop. */
  128. bfd_boolean ifc_loop_aware; /* Ignore ifc if inside a loop. */
  129. };
  130. #endif