Commit | Line | Data |
---|---|---|
73c3cd1c | 1 | /* Matsushita AM33/2.0 support for 32-bit GNU/Linux ELF |
6f2750fe | 2 | Copyright (C) 2003-2016 Free Software Foundation, Inc. |
73c3cd1c AO |
3 | |
4 | This file is part of BFD, the Binary File Descriptor library. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
cd123cb7 | 8 | the Free Software Foundation; either version 3 of the License, or |
73c3cd1c AO |
9 | (at your option) any later version. |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
cd123cb7 NC |
18 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
19 | MA 02110-1301, USA. */ | |
73c3cd1c | 20 | |
6cfda947 | 21 | #include "sysdep.h" |
3db64b00 | 22 | #include "bfd.h" |
6cfda947 KB |
23 | #include "elf-bfd.h" |
24 | #include "elf/mn10300.h" | |
25 | ||
73c3cd1c AO |
26 | #define elf_symbol_leading_char 0 |
27 | ||
6d00b590 | 28 | #define TARGET_LITTLE_SYM am33_elf32_linux_vec |
73c3cd1c AO |
29 | #define TARGET_LITTLE_NAME "elf32-am33lin" |
30 | #define ELF_ARCH bfd_arch_mn10300 | |
31 | #define ELF_MACHINE_CODE EM_MN10300 | |
32 | #define ELF_MACHINE_ALT1 EM_CYGNUS_MN10300 | |
33 | #define ELF_MAXPAGESIZE 0x1000 | |
34 | ||
35 | /* Rename global functions. */ | |
36 | #define _bfd_mn10300_elf_merge_private_bfd_data _bfd_am33_elf_merge_private_bfd_data | |
37 | #define _bfd_mn10300_elf_object_p _bfd_am33_elf_object_p | |
38 | #define _bfd_mn10300_elf_final_write_processing _bfd_am33_elf_final_write_processing | |
39 | ||
6cfda947 KB |
40 | /* Support for core dump NOTE sections. */ |
41 | static bfd_boolean | |
42 | elf32_am33lin_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) | |
43 | { | |
44 | int offset; | |
45 | unsigned int size; | |
46 | ||
47 | switch (note->descsz) | |
48 | { | |
49 | default: | |
50 | return FALSE; | |
51 | ||
083a5534 | 52 | case 184: |
6cfda947 KB |
53 | case 188: /* Linux/am33 */ |
54 | /* pr_cursig */ | |
228e534f | 55 | elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12); |
6cfda947 KB |
56 | |
57 | /* pr_pid */ | |
228e534f | 58 | elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24); |
6cfda947 KB |
59 | |
60 | /* pr_reg */ | |
61 | offset = 72; | |
62 | size = 112; | |
63 | ||
64 | break; | |
65 | } | |
66 | ||
67 | /* Make a ".reg/999" section. */ | |
68 | return _bfd_elfcore_make_pseudosection (abfd, ".reg", size, | |
69 | note->descpos + offset); | |
70 | } | |
71 | ||
72 | static bfd_boolean | |
73 | elf32_am33lin_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) | |
74 | { | |
75 | switch (note->descsz) | |
76 | { | |
77 | default: | |
78 | return FALSE; | |
79 | ||
80 | case 124: /* Linux/am33 elf_prpsinfo */ | |
228e534f | 81 | elf_tdata (abfd)->core->program |
6cfda947 | 82 | = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16); |
228e534f | 83 | elf_tdata (abfd)->core->command |
6cfda947 KB |
84 | = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80); |
85 | } | |
86 | ||
87 | /* Note that for some reason, a spurious space is tacked | |
88 | onto the end of the args in some (at least one anyway) | |
89 | implementations, so strip it off if it exists. */ | |
90 | ||
91 | { | |
228e534f | 92 | char *command = elf_tdata (abfd)->core->command; |
6cfda947 KB |
93 | int n = strlen (command); |
94 | ||
95 | if (0 < n && command[n - 1] == ' ') | |
96 | command[n - 1] = '\0'; | |
97 | } | |
98 | ||
99 | return TRUE; | |
100 | } | |
101 | ||
102 | #define elf_backend_grok_prstatus elf32_am33lin_grok_prstatus | |
103 | #define elf_backend_grok_psinfo elf32_am33lin_grok_psinfo | |
104 | ||
73c3cd1c | 105 | #include "elf-m10300.c" |