1 /* Register names and numbers for ARM DWARF. 2 Copyright (C) 2009 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 <string.h> 34 #include <dwarf.h> 35 36 #define BACKEND arm_ 37 #include "libebl_CPU.h" 38 39 ssize_t 40 arm_register_info (Ebl *ebl __attribute__ ((unused)), 41 int regno, char *name, size_t namelen, 42 const char **prefix, const char **setname, 43 int *bits, int *type) 44 { 45 if (name == NULL) 46 return 320; 47 48 if (regno < 0 || regno > 320 || namelen < 5) 49 return -1; 50 51 *prefix = ""; 52 *bits = 32; 53 *type = DW_ATE_signed; 54 *setname = "integer"; 55 56 switch (regno) 57 { 58 case 0 ... 9: 59 name[0] = 'r'; 60 name[1] = regno + '0'; 61 namelen = 2; 62 break; 63 64 case 10 ... 12: 65 name[0] = 'r'; 66 name[1] = '1'; 67 name[2] = regno % 10 + '0'; 68 namelen = 3; 69 break; 70 71 case 13 ... 15: 72 *type = DW_ATE_address; 73 name[0] = "slp"[regno - 13]; 74 name[1] = "prc"[regno - 13]; 75 namelen = 2; 76 break; 77 78 case 16 + 0 ... 16 + 7: 79 regno += 96 - 16; 80 /* Fall through. */ 81 case 96 + 0 ... 96 + 7: 82 *setname = "FPA"; 83 *type = DW_ATE_float; 84 *bits = 96; 85 name[0] = 'f'; 86 name[1] = regno - 96 + '0'; 87 namelen = 2; 88 break; 89 90 case 128: 91 *type = DW_ATE_unsigned; 92 return stpcpy (name, "spsr") + 1 - name; 93 94 case 256 + 0 ... 256 + 9: 95 *setname = "VFP"; 96 *type = DW_ATE_float; 97 *bits = 64; 98 name[0] = 'd'; 99 name[1] = regno - 256 + '0'; 100 namelen = 2; 101 break; 102 103 case 256 + 10 ... 256 + 31: 104 *setname = "VFP"; 105 *type = DW_ATE_float; 106 *bits = 64; 107 name[0] = 'd'; 108 name[1] = (regno - 256) / 10 + '0'; 109 name[2] = (regno - 256) % 10 + '0'; 110 namelen = 3; 111 break; 112 113 default: 114 *setname = NULL; 115 return 0; 116 } 117 118 name[namelen++] = '\0'; 119 return namelen; 120 } 121