elf32-am33lin.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* Matsushita AM33/2.0 support for 32-bit GNU/Linux ELF
  2. Copyright (C) 2003-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 "elf-bfd.h"
  19. #include "elf/mn10300.h"
  20. #define elf_symbol_leading_char 0
  21. #define TARGET_LITTLE_SYM am33_elf32_linux_vec
  22. #define TARGET_LITTLE_NAME "elf32-am33lin"
  23. #define ELF_ARCH bfd_arch_mn10300
  24. #define ELF_MACHINE_CODE EM_MN10300
  25. #define ELF_MACHINE_ALT1 EM_CYGNUS_MN10300
  26. #define ELF_MAXPAGESIZE 0x1000
  27. /* Rename global functions. */
  28. #define _bfd_mn10300_elf_merge_private_bfd_data _bfd_am33_elf_merge_private_bfd_data
  29. #define _bfd_mn10300_elf_object_p _bfd_am33_elf_object_p
  30. #define _bfd_mn10300_elf_final_write_processing _bfd_am33_elf_final_write_processing
  31. /* Support for core dump NOTE sections. */
  32. static bool
  33. elf32_am33lin_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
  34. {
  35. int offset;
  36. unsigned int size;
  37. switch (note->descsz)
  38. {
  39. default:
  40. return false;
  41. case 184:
  42. case 188: /* Linux/am33 */
  43. /* pr_cursig */
  44. elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
  45. /* pr_pid */
  46. elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
  47. /* pr_reg */
  48. offset = 72;
  49. size = 112;
  50. break;
  51. }
  52. /* Make a ".reg/999" section. */
  53. return _bfd_elfcore_make_pseudosection (abfd, ".reg", size,
  54. note->descpos + offset);
  55. }
  56. static bool
  57. elf32_am33lin_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
  58. {
  59. switch (note->descsz)
  60. {
  61. default:
  62. return false;
  63. case 124: /* Linux/am33 elf_prpsinfo */
  64. elf_tdata (abfd)->core->program
  65. = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
  66. elf_tdata (abfd)->core->command
  67. = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
  68. }
  69. /* Note that for some reason, a spurious space is tacked
  70. onto the end of the args in some (at least one anyway)
  71. implementations, so strip it off if it exists. */
  72. {
  73. char *command = elf_tdata (abfd)->core->command;
  74. int n = strlen (command);
  75. if (0 < n && command[n - 1] == ' ')
  76. command[n - 1] = '\0';
  77. }
  78. return true;
  79. }
  80. #define elf_backend_grok_prstatus elf32_am33lin_grok_prstatus
  81. #define elf_backend_grok_psinfo elf32_am33lin_grok_psinfo
  82. #define elf_backend_linux_prpsinfo32_ugid16 true
  83. #include "elf-m10300.c"