elf.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* Definitions of target machine for GNU compiler, for DEC Alpha w/ELF.
  2. Copyright (C) 1996-2015 Free Software Foundation, Inc.
  3. Contributed by Richard Henderson (rth@tamu.edu).
  4. This file is part of GCC.
  5. GCC 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, or (at your option)
  8. any later version.
  9. GCC 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 GCC; see the file COPYING3. If not see
  15. <http://www.gnu.org/licenses/>. */
  16. #undef CC1_SPEC
  17. #define CC1_SPEC "%{G*}"
  18. #undef ASM_SPEC
  19. #define ASM_SPEC "%{G*} %{relax:-relax} %{!gstabs*:-no-mdebug}%{gstabs*:-mdebug}"
  20. /* Do not output a .file directive at the beginning of the input file. */
  21. #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
  22. #define TARGET_ASM_FILE_START_FILE_DIRECTIVE false
  23. /* This is how to output an assembler line
  24. that says to advance the location counter
  25. to a multiple of 2**LOG bytes. */
  26. #define ASM_OUTPUT_ALIGN(FILE,LOG) \
  27. if ((LOG) != 0) \
  28. fprintf (FILE, "\t.align %d\n", LOG);
  29. /* This says how to output assembler code to declare an
  30. uninitialized internal linkage data object. Under SVR4,
  31. the linker seems to want the alignment of data objects
  32. to depend on their types. We do exactly that here. */
  33. #undef ASM_OUTPUT_ALIGNED_LOCAL
  34. #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
  35. do { \
  36. if ((SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value) \
  37. switch_to_section (sbss_section); \
  38. else \
  39. switch_to_section (bss_section); \
  40. ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
  41. if (!flag_inhibit_size_directive) \
  42. ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \
  43. ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \
  44. ASM_OUTPUT_LABEL(FILE, NAME); \
  45. ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \
  46. } while (0)
  47. /* This says how to output assembler code to declare an
  48. uninitialized external linkage data object. */
  49. #undef ASM_OUTPUT_ALIGNED_BSS
  50. #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
  51. do { \
  52. ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN); \
  53. } while (0)
  54. #undef BSS_SECTION_ASM_OP
  55. #define BSS_SECTION_ASM_OP "\t.section\t.bss"
  56. #undef SBSS_SECTION_ASM_OP
  57. #define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\""
  58. #undef SDATA_SECTION_ASM_OP
  59. #define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\""
  60. /* This is how we tell the assembler that two symbols have the same value. */
  61. #undef ASM_OUTPUT_DEF
  62. #define ASM_OUTPUT_DEF(FILE, ALIAS, NAME) \
  63. do { \
  64. assemble_name(FILE, ALIAS); \
  65. fputs(" = ", FILE); \
  66. assemble_name(FILE, NAME); \
  67. fputc('\n', FILE); \
  68. } while (0)
  69. #undef ASM_OUTPUT_DEF_FROM_DECLS
  70. #define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL, TARGET) \
  71. do { \
  72. const char *alias = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
  73. const char *name = IDENTIFIER_POINTER (TARGET); \
  74. if (TREE_CODE (DECL) == FUNCTION_DECL) \
  75. { \
  76. fputc ('$', FILE); \
  77. assemble_name (FILE, alias); \
  78. fputs ("..ng = $", FILE); \
  79. assemble_name (FILE, name); \
  80. fputs ("..ng\n", FILE); \
  81. } \
  82. ASM_OUTPUT_DEF (FILE, alias, name); \
  83. } while (0)
  84. /* Provide a STARTFILE_SPEC appropriate for ELF. Here we add the
  85. (even more) magical crtbegin.o file which provides part of the
  86. support for getting C++ file-scope static object constructed
  87. before entering `main'. */
  88. #undef STARTFILE_SPEC
  89. #ifdef HAVE_LD_PIE
  90. #define STARTFILE_SPEC \
  91. "%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
  92. crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
  93. #else
  94. #define STARTFILE_SPEC \
  95. "%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\
  96. crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
  97. #endif
  98. /* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the
  99. magical crtend.o file which provides part of the support for
  100. getting C++ file-scope static object constructed before entering
  101. `main', followed by a normal ELF "finalizer" file, `crtn.o'. */
  102. #undef ENDFILE_SPEC
  103. #define ENDFILE_SPEC \
  104. "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
  105. %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
  106. /* This variable should be set to 'true' if the target ABI requires
  107. unwinding tables even when exceptions are not used. */
  108. #define TARGET_UNWIND_TABLES_DEFAULT true
  109. /* Select a format to encode pointers in exception handling data. CODE
  110. is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
  111. true if the symbol may be affected by dynamic relocations.
  112. Since application size is already constrained to <2GB by the form of
  113. the ldgp relocation, we can use a 32-bit pc-relative relocation to
  114. static data. Dynamic data is accessed indirectly to allow for read
  115. only EH sections. */
  116. #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
  117. (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4)
  118. /* If defined, a C statement to be executed just prior to the output of
  119. assembler code for INSN. */
  120. #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
  121. (alpha_this_literal_sequence_number = 0, \
  122. alpha_this_gpdisp_sequence_number = 0)
  123. extern int alpha_this_literal_sequence_number;
  124. extern int alpha_this_gpdisp_sequence_number;
  125. /* Since the bits of the _init and _fini function is spread across
  126. many object files, each potentially with its own GP, we must assume
  127. we need to load our GP. Further, the .init/.fini section can
  128. easily be more than 4MB away from the function to call so we can't
  129. use bsr. */
  130. #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
  131. asm (SECTION_OP "\n" \
  132. " br $29,1f\n" \
  133. "1: ldgp $29,0($29)\n" \
  134. " unop\n" \
  135. " jsr $26," USER_LABEL_PREFIX #FUNC "\n" \
  136. " .align 3\n" \
  137. " .previous");
  138. /* If we have the capability create headers for efficient EH lookup.
  139. As of Jan 2002, only glibc 2.2.4 can actually make use of this, but
  140. I imagine that other systems will catch up. In the meantime, it
  141. doesn't harm to make sure that the data exists to be used later. */
  142. #if defined(HAVE_LD_EH_FRAME_HDR)
  143. #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
  144. #endif