Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 1 | /* Describe known core note formats. |
Roland McGrath | 0ccbbcd | 2010-01-04 21:59:07 -0800 | [diff] [blame] | 2 | Copyright (C) 2007, 2010 Red Hat, Inc. |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 3 | This file is part of elfutils. |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 4 | |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 5 | This file is free software; you can redistribute it and/or modify |
| 6 | it under the terms of either |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 7 | |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 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 |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 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 | |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 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/>. */ |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 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 <libeblP.h> |
| 40 | |
| 41 | |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 42 | int |
Mark Wielaard | 1ccdfb6 | 2015-09-22 22:27:01 +0200 | [diff] [blame] | 43 | ebl_core_note (Ebl *ebl, const GElf_Nhdr *nhdr, const char *name, |
| 44 | GElf_Word *regs_offset, size_t *nregloc, |
| 45 | const Ebl_Register_Location **reglocs, size_t *nitems, |
| 46 | const Ebl_Core_Item **items) |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 47 | { |
Roland McGrath | 0ccbbcd | 2010-01-04 21:59:07 -0800 | [diff] [blame] | 48 | int result = ebl->core_note (nhdr, name, |
| 49 | regs_offset, nregloc, reglocs, nitems, items); |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 50 | if (result == 0) |
| 51 | { |
| 52 | /* The machine specific function did not know this type. */ |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 53 | |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 54 | *regs_offset = 0; |
| 55 | *nregloc = 0; |
| 56 | *reglocs = NULL; |
Roland McGrath | 0ccbbcd | 2010-01-04 21:59:07 -0800 | [diff] [blame] | 57 | switch (nhdr->n_type) |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 58 | { |
| 59 | #define ITEMS(type, table) \ |
| 60 | case type: \ |
| 61 | *items = table; \ |
| 62 | *nitems = sizeof table / sizeof table[0]; \ |
| 63 | result = 1; \ |
| 64 | break |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 65 | |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 66 | static const Ebl_Core_Item platform[] = |
| 67 | { |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 68 | { |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 69 | .name = "Platform", |
| 70 | .type = ELF_T_BYTE, .count = 0, .format = 's' |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 71 | } |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 72 | }; |
| 73 | ITEMS (NT_PLATFORM, platform); |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 74 | |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 75 | #undef ITEMS |
| 76 | } |
| 77 | } |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 78 | |
Roland McGrath | cb6d865 | 2007-08-23 08:10:54 +0000 | [diff] [blame] | 79 | return result; |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 80 | } |