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