/src/elfutils/libebl/eblcorenote.c
Line | Count | Source |
1 | | /* Describe known core note formats. |
2 | | Copyright (C) 2007, 2010 Red Hat, Inc. |
3 | | This file is part of elfutils. |
4 | | |
5 | | This file is free software; you can redistribute it and/or modify |
6 | | it under the terms of either |
7 | | |
8 | | * the GNU Lesser General Public License as published by the Free |
9 | | Software Foundation; either version 3 of the License, or (at |
10 | | your option) any later version |
11 | | |
12 | | or |
13 | | |
14 | | * the GNU General Public License as published by the Free |
15 | | Software Foundation; either version 2 of the License, or (at |
16 | | your option) any later version |
17 | | |
18 | | or both in parallel, as here. |
19 | | |
20 | | elfutils is distributed in the hope that it will be useful, but |
21 | | WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
23 | | General Public License for more details. |
24 | | |
25 | | You should have received copies of the GNU General Public License and |
26 | | the GNU Lesser General Public License along with this program. If |
27 | | not, see <http://www.gnu.org/licenses/>. */ |
28 | | |
29 | | #ifdef HAVE_CONFIG_H |
30 | | # include <config.h> |
31 | | #endif |
32 | | |
33 | | #include <assert.h> |
34 | | #include <byteswap.h> |
35 | | #include <endian.h> |
36 | | #include <inttypes.h> |
37 | | #include <stdio.h> |
38 | | #include <stddef.h> |
39 | | #include <string.h> |
40 | | #include <libeblP.h> |
41 | | |
42 | | |
43 | | int |
44 | | ebl_core_note (Ebl *ebl, const GElf_Nhdr *nhdr, const char *name, |
45 | | const char *desc, |
46 | | GElf_Word *regs_offset, size_t *nregloc, |
47 | | const Ebl_Register_Location **reglocs, size_t *nitems, |
48 | | const Ebl_Core_Item **items) |
49 | 148k | { |
50 | 148k | int result = ebl->core_note (nhdr, name, |
51 | 148k | regs_offset, nregloc, reglocs, nitems, items); |
52 | 148k | if (result == 0) |
53 | 146k | { |
54 | | /* The machine specific function did not know this type. */ |
55 | | |
56 | | /* NT_PLATFORM is kind of special since it needs a zero terminated |
57 | | string (other notes often have a fixed size string). */ |
58 | 146k | static const Ebl_Core_Item platform[] = |
59 | 146k | { |
60 | 146k | { |
61 | 146k | .name = "Platform", |
62 | 146k | .type = ELF_T_BYTE, .count = 0, .format = 's' |
63 | 146k | } |
64 | 146k | }; |
65 | | |
66 | 146k | if (nhdr->n_type == NT_PLATFORM |
67 | 2.47k | && memchr (desc, '\0', nhdr->n_descsz) != NULL) |
68 | 244 | { |
69 | 244 | *regs_offset = 0; |
70 | 244 | *nregloc = 0; |
71 | 244 | *reglocs = NULL; |
72 | 244 | *items = platform; |
73 | 244 | *nitems = 1; |
74 | 244 | result = 1; |
75 | 244 | } |
76 | 146k | } |
77 | | |
78 | 148k | return result; |
79 | 148k | } |