elf32-gen.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* Generic support for 32-bit ELF
  2. Copyright (C) 1993-2015 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 void
  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. }
  43. static void
  44. elf_generic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
  45. arelent *bfd_reloc,
  46. Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED)
  47. {
  48. bfd_reloc->howto = &dummy;
  49. }
  50. static void
  51. check_for_relocs (bfd * abfd, asection * o, void * failed)
  52. {
  53. if ((o->flags & SEC_RELOC) != 0)
  54. {
  55. Elf_Internal_Ehdr *ehdrp;
  56. ehdrp = elf_elfheader (abfd);
  57. _bfd_error_handler (_("%B: Relocations in generic ELF (EM: %d)"),
  58. abfd, ehdrp->e_machine);
  59. bfd_set_error (bfd_error_wrong_format);
  60. * (bfd_boolean *) failed = TRUE;
  61. }
  62. }
  63. static bfd_boolean
  64. elf32_generic_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
  65. {
  66. bfd_boolean failed = FALSE;
  67. /* Check if there are any relocations. */
  68. bfd_map_over_sections (abfd, check_for_relocs, & failed);
  69. if (failed)
  70. return FALSE;
  71. return bfd_elf_link_add_symbols (abfd, info);
  72. }
  73. #define TARGET_LITTLE_SYM elf32_le_vec
  74. #define TARGET_LITTLE_NAME "elf32-little"
  75. #define TARGET_BIG_SYM elf32_be_vec
  76. #define TARGET_BIG_NAME "elf32-big"
  77. #define ELF_ARCH bfd_arch_unknown
  78. #define ELF_MACHINE_CODE EM_NONE
  79. #define ELF_MAXPAGESIZE 0x1
  80. #define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
  81. #define bfd_elf32_bfd_reloc_name_lookup _bfd_norelocs_bfd_reloc_name_lookup
  82. #define bfd_elf32_bfd_link_add_symbols elf32_generic_link_add_symbols
  83. #define elf_info_to_howto elf_generic_info_to_howto
  84. #define elf_info_to_howto_rel elf_generic_info_to_howto_rel
  85. #include "elf32-target.h"