elf64-tilegx.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* TILE-Gx-specific support for 64-bit ELF.
  2. Copyright (C) 2011-2022 Free Software Foundation, Inc.
  3. This file is part of BFD, the Binary File Descriptor library.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  15. MA 02110-1301, USA. */
  16. #include "sysdep.h"
  17. #include "bfd.h"
  18. #include "libbfd.h"
  19. #include "elf-bfd.h"
  20. #include "elfxx-tilegx.h"
  21. #include "elf64-tilegx.h"
  22. /* Support for core dump NOTE sections. */
  23. static bool
  24. tilegx_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
  25. {
  26. int offset;
  27. size_t size;
  28. if (note->descsz != TILEGX_PRSTATUS_SIZEOF)
  29. return false;
  30. /* pr_cursig */
  31. elf_tdata (abfd)->core->signal =
  32. bfd_get_16 (abfd, note->descdata + TILEGX_PRSTATUS_OFFSET_PR_CURSIG);
  33. /* pr_pid */
  34. elf_tdata (abfd)->core->pid =
  35. bfd_get_32 (abfd, note->descdata + TILEGX_PRSTATUS_OFFSET_PR_PID);
  36. /* pr_reg */
  37. offset = TILEGX_PRSTATUS_OFFSET_PR_REG;
  38. size = TILEGX_GREGSET_T_SIZE;
  39. /* Make a ".reg/999" section. */
  40. return _bfd_elfcore_make_pseudosection (abfd, ".reg",
  41. size, note->descpos + offset);
  42. }
  43. static bool
  44. tilegx_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
  45. {
  46. if (note->descsz != TILEGX_PRPSINFO_SIZEOF)
  47. return false;
  48. elf_tdata (abfd)->core->program
  49. = _bfd_elfcore_strndup (abfd, note->descdata + TILEGX_PRPSINFO_OFFSET_PR_FNAME, 16);
  50. elf_tdata (abfd)->core->command
  51. = _bfd_elfcore_strndup (abfd, note->descdata + TILEGX_PRPSINFO_OFFSET_PR_PSARGS, ELF_PR_PSARGS_SIZE);
  52. /* Note that for some reason, a spurious space is tacked
  53. onto the end of the args in some (at least one anyway)
  54. implementations, so strip it off if it exists. */
  55. {
  56. char *command = elf_tdata (abfd)->core->command;
  57. int n = strlen (command);
  58. if (0 < n && command[n - 1] == ' ')
  59. command[n - 1] = '\0';
  60. }
  61. return true;
  62. }
  63. #define ELF_ARCH bfd_arch_tilegx
  64. #define ELF_TARGET_ID TILEGX_ELF_DATA
  65. #define ELF_MACHINE_CODE EM_TILEGX
  66. #define ELF_MAXPAGESIZE 0x10000
  67. #define ELF_COMMONPAGESIZE 0x10000
  68. #define TARGET_BIG_SYM tilegx_elf64_be_vec
  69. #define TARGET_BIG_NAME "elf64-tilegx-be"
  70. #define TARGET_LITTLE_SYM tilegx_elf64_le_vec
  71. #define TARGET_LITTLE_NAME "elf64-tilegx-le"
  72. #define elf_backend_reloc_type_class tilegx_reloc_type_class
  73. #define bfd_elf64_bfd_reloc_name_lookup tilegx_reloc_name_lookup
  74. #define bfd_elf64_bfd_link_hash_table_create tilegx_elf_link_hash_table_create
  75. #define bfd_elf64_bfd_reloc_type_lookup tilegx_reloc_type_lookup
  76. #define bfd_elf64_bfd_merge_private_bfd_data \
  77. _bfd_tilegx_elf_merge_private_bfd_data
  78. #define elf_backend_copy_indirect_symbol tilegx_elf_copy_indirect_symbol
  79. #define elf_backend_create_dynamic_sections tilegx_elf_create_dynamic_sections
  80. #define elf_backend_check_relocs tilegx_elf_check_relocs
  81. #define elf_backend_adjust_dynamic_symbol tilegx_elf_adjust_dynamic_symbol
  82. #define elf_backend_omit_section_dynsym tilegx_elf_omit_section_dynsym
  83. #define elf_backend_size_dynamic_sections tilegx_elf_size_dynamic_sections
  84. #define elf_backend_relocate_section tilegx_elf_relocate_section
  85. #define elf_backend_finish_dynamic_symbol tilegx_elf_finish_dynamic_symbol
  86. #define elf_backend_finish_dynamic_sections tilegx_elf_finish_dynamic_sections
  87. #define elf_backend_gc_mark_hook tilegx_elf_gc_mark_hook
  88. #define elf_backend_plt_sym_val tilegx_elf_plt_sym_val
  89. #define elf_info_to_howto_rel NULL
  90. #define elf_info_to_howto tilegx_info_to_howto_rela
  91. #define elf_backend_grok_prstatus tilegx_elf_grok_prstatus
  92. #define elf_backend_grok_psinfo tilegx_elf_grok_psinfo
  93. #define elf_backend_additional_program_headers tilegx_additional_program_headers
  94. #define elf_backend_init_index_section _bfd_elf_init_1_index_section
  95. #define elf_backend_can_gc_sections 1
  96. #define elf_backend_can_refcount 1
  97. #define elf_backend_want_got_plt 1
  98. #define elf_backend_plt_readonly 1
  99. /* Align PLT mod 64 byte L2 line size. */
  100. #define elf_backend_plt_alignment 6
  101. #define elf_backend_want_plt_sym 1
  102. #define elf_backend_got_header_size 8
  103. #define elf_backend_want_dynrelro 1
  104. #define elf_backend_rela_normal 1
  105. #define elf_backend_default_execstack 0
  106. #include "elf64-target.h"