elf64-gen.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* Generic support for 64-bit ELF
  2. Copyright (C) 1993-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. /* This does not include any relocation information, but should be
  21. good enough for GDB or objdump to read the file. */
  22. static reloc_howto_type dummy =
  23. HOWTO (0, /* type */
  24. 0, /* rightshift */
  25. 0, /* size (0 = byte, 1 = short, 2 = long) */
  26. 0, /* bitsize */
  27. false, /* pc_relative */
  28. 0, /* bitpos */
  29. complain_overflow_dont, /* complain_on_overflow */
  30. NULL, /* special_function */
  31. "UNKNOWN", /* name */
  32. false, /* partial_inplace */
  33. 0, /* src_mask */
  34. 0, /* dst_mask */
  35. false); /* pcrel_offset */
  36. static bool
  37. elf_generic_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
  38. arelent *bfd_reloc,
  39. Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
  40. {
  41. bfd_reloc->howto = &dummy;
  42. return true;
  43. }
  44. static bool
  45. elf_generic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
  46. arelent *bfd_reloc,
  47. Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
  48. {
  49. bfd_reloc->howto = &dummy;
  50. return true;
  51. }
  52. static void
  53. check_for_relocs (bfd * abfd, asection * o, void * failed)
  54. {
  55. if ((o->flags & SEC_RELOC) != 0)
  56. {
  57. Elf_Internal_Ehdr *ehdrp;
  58. ehdrp = elf_elfheader (abfd);
  59. /* xgettext:c-format */
  60. _bfd_error_handler (_("%pB: Relocations in generic ELF (EM: %d)"),
  61. abfd, ehdrp->e_machine);
  62. bfd_set_error (bfd_error_wrong_format);
  63. * (bool *) failed = true;
  64. }
  65. }
  66. static bool
  67. elf64_generic_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
  68. {
  69. bool failed = false;
  70. /* Check if there are any relocations. */
  71. bfd_map_over_sections (abfd, check_for_relocs, & failed);
  72. if (failed)
  73. return false;
  74. return bfd_elf_link_add_symbols (abfd, info);
  75. }
  76. #define TARGET_LITTLE_SYM elf64_le_vec
  77. #define TARGET_LITTLE_NAME "elf64-little"
  78. #define TARGET_BIG_SYM elf64_be_vec
  79. #define TARGET_BIG_NAME "elf64-big"
  80. #define ELF_ARCH bfd_arch_unknown
  81. #define ELF_MACHINE_CODE EM_NONE
  82. #define ELF_MAXPAGESIZE 0x1
  83. #define bfd_elf64_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
  84. #define bfd_elf64_bfd_reloc_name_lookup _bfd_norelocs_bfd_reloc_name_lookup
  85. #define bfd_elf64_bfd_link_add_symbols elf64_generic_link_add_symbols
  86. #define elf_info_to_howto elf_generic_info_to_howto
  87. #define elf_info_to_howto_rel elf_generic_info_to_howto_rel
  88. #include "elf64-target.h"