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 184:
54 1.1 christos case 188: /* Linux/am33 */
55 1.1 christos /* pr_cursig */
56 1.1 christos elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
57 1.1 christos
58 1.1 christos /* pr_pid */
59 1.1 christos elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
60 1.1 christos
61 1.1 christos /* pr_reg */
62 1.1 christos offset = 72;
63 1.1 christos size = 112;
64 1.1 christos
65 1.1 christos break;
66 1.1 christos }
67 1.1 christos
68 1.1 christos /* Make a ".reg/999" section. */
69 1.1 christos return _bfd_elfcore_make_pseudosection (abfd, ".reg", size,
70 1.1 christos note->descpos + offset);
71 1.1 christos }
72 1.1 christos
73 1.1 christos static bfd_boolean
74 1.1 christos elf32_am33lin_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
75 1.1 christos {
76 1.1 christos switch (note->descsz)
77 1.1 christos {
78 1.1 christos default:
79 1.1 christos return FALSE;
80 1.1 christos
81 1.1 christos case 124: /* Linux/am33 elf_prpsinfo */
82 1.1 christos elf_tdata (abfd)->core->program
83 1.1 christos = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
84 1.1 christos elf_tdata (abfd)->core->command
85 1.1 christos = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
86 1.1 christos }
87 1.1 christos
88 1.1 christos /* Note that for some reason, a spurious space is tacked
89 1.1 christos onto the end of the args in some (at least one anyway)
90 1.1 christos implementations, so strip it off if it exists. */
91 1.1 christos
92 1.1 christos {
93 1.1 christos char *command = elf_tdata (abfd)->core->command;
94 1.1 christos int n = strlen (command);
95 1.1 christos
96 1.1 christos if (0 < n && command[n - 1] == ' ')
97 1.1 christos command[n - 1] = '\0';
98 1.1 christos }
99 1.1 christos
100 1.1 christos return TRUE;
101 1.1 christos }
102 1.1 christos
103 1.1 christos #define elf_backend_grok_prstatus elf32_am33lin_grok_prstatus
104 1.1 christos #define elf_backend_grok_psinfo elf32_am33lin_grok_psinfo
105 1.1 christos
106 1.1 christos #include "elf-m10300.c"
107