| Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame^] | 1 | /* Arm specific symbolic name handling. | 
 | 2 |    Copyright (C) 2002, 2005 Red Hat, Inc. | 
 | 3 |    Written by Ulrich Drepper <drepper@redhat.com>, 2002. | 
 | 4 |  | 
 | 5 |    This program is Open Source software; you can redistribute it and/or | 
 | 6 |    modify it under the terms of the Open Software License version 1.0 as | 
 | 7 |    published by the Open Source Initiative. | 
 | 8 |  | 
 | 9 |    You should have received a copy of the Open Software License along | 
 | 10 |    with this program; if not, you may obtain a copy of the Open Software | 
 | 11 |    License version 1.0 from http://www.opensource.org/licenses/osl.php or | 
 | 12 |    by writing the Open Source Initiative c/o Lawrence Rosen, Esq., | 
 | 13 |    3001 King Ranch Road, Ukiah, CA 95482.   */ | 
 | 14 |  | 
 | 15 | #ifdef HAVE_CONFIG_H | 
 | 16 | # include <config.h> | 
 | 17 | #endif | 
 | 18 |  | 
 | 19 | #include <elf.h> | 
 | 20 | #include <stddef.h> | 
 | 21 |  | 
 | 22 | #include <libebl_arm.h> | 
 | 23 |  | 
 | 24 |  | 
 | 25 | /* Return of the backend.  */ | 
 | 26 | const char * | 
 | 27 | arm_backend_name (void) | 
 | 28 | { | 
 | 29 |   return "arm"; | 
 | 30 | } | 
 | 31 |  | 
 | 32 |  | 
 | 33 | /* Relocation mapping table.  */ | 
 | 34 | static const char *reloc_map_table[] = | 
 | 35 |   { | 
 | 36 |     [R_ARM_NONE] = "R_ARM_NONE", | 
 | 37 |     [R_ARM_PC24] = "R_ARM_PC24", | 
 | 38 |     [R_ARM_ABS32] = "R_ARM_ABS32", | 
 | 39 |     [R_ARM_REL32] = "R_ARM_REL32", | 
 | 40 |     [R_ARM_PC13] = "R_ARM_PC13", | 
 | 41 |     [R_ARM_ABS16] = "R_ARM_ABS16", | 
 | 42 |     [R_ARM_ABS12] = "R_ARM_ABS12", | 
 | 43 |     [R_ARM_THM_ABS5] = "R_ARM_THM_ABS5", | 
 | 44 |     [R_ARM_ABS8] = "R_ARM_ABS8", | 
 | 45 |     [R_ARM_SBREL32] = "R_ARM_SBREL32", | 
 | 46 |     [R_ARM_THM_PC22] = "R_ARM_THM_PC22", | 
 | 47 |     [R_ARM_THM_PC8] = "R_ARM_THM_PC8", | 
 | 48 |     [R_ARM_AMP_VCALL9] = "R_ARM_AMP_VCALL9", | 
 | 49 |     [R_ARM_SWI24] = "R_ARM_SWI24", | 
 | 50 |     [R_ARM_THM_SWI8] = "R_ARM_THM_SWI8", | 
 | 51 |     [R_ARM_XPC25] = "R_ARM_XPC25", | 
 | 52 |     [R_ARM_THM_XPC22] = "R_ARM_THM_XPC22", | 
 | 53 |     [R_ARM_COPY] = "R_ARM_COPY", | 
 | 54 |     [R_ARM_GLOB_DAT] = "R_ARM_GLOB_DAT", | 
 | 55 |     [R_ARM_JUMP_SLOT] = "R_ARM_JUMP_SLOT", | 
 | 56 |     [R_ARM_RELATIVE] = "R_ARM_RELATIVE", | 
 | 57 |     [R_ARM_GOTOFF] = "R_ARM_GOTOFF", | 
 | 58 |     [R_ARM_GOTPC] = "R_ARM_GOTPC", | 
 | 59 |     [R_ARM_GOT32] = "R_ARM_GOT32", | 
 | 60 |     [R_ARM_PLT32] = "R_ARM_PLT32", | 
 | 61 |     [R_ARM_ALU_PCREL_7_0] = "R_ARM_ALU_PCREL_7_0", | 
 | 62 |     [R_ARM_ALU_PCREL_15_8] = "R_ARM_ALU_PCREL_15_8", | 
 | 63 |     [R_ARM_ALU_PCREL_23_15] = "R_ARM_ALU_PCREL_23_15", | 
 | 64 |     [R_ARM_LDR_SBREL_11_0] = "R_ARM_LDR_SBREL_11_0", | 
 | 65 |     [R_ARM_ALU_SBREL_19_12] = "R_ARM_ALU_SBREL_19_12", | 
 | 66 |     [R_ARM_ALU_SBREL_27_20] = "R_ARM_ALU_SBREL_27_20" | 
 | 67 |   }; | 
 | 68 |  | 
 | 69 | static const char *reloc_map_table2[] = | 
 | 70 |   { | 
 | 71 |     [R_ARM_GNU_VTENTRY] = "R_ARM_GNU_VTENTRY", | 
 | 72 |     [R_ARM_GNU_VTINHERIT] = "R_ARM_GNU_VTINHERIT", | 
 | 73 |     [R_ARM_THM_PC11] = "R_ARM_THM_PC11", | 
 | 74 |     [R_ARM_THM_PC9] = "R_ARM_THM_PC9" | 
 | 75 |   }; | 
 | 76 |  | 
 | 77 | static const char *reloc_map_table3[] = | 
 | 78 |   { | 
 | 79 |     [R_ARM_RXPC25] = "R_ARM_RXPC25", | 
 | 80 |     [R_ARM_RSBREL32] = "R_ARM_RSBREL32", | 
 | 81 |     [R_ARM_THM_RPC22] = "R_ARM_THM_RPC22", | 
 | 82 |     [R_ARM_RREL32] = "R_ARM_RREL32", | 
 | 83 |     [R_ARM_RABS22] = "R_ARM_RABS22", | 
 | 84 |     [R_ARM_RPC24] = "R_ARM_RPC24", | 
 | 85 |     [R_ARM_RBASE] = "R_ARM_RBASE" | 
 | 86 |   }; | 
 | 87 |  | 
 | 88 |  | 
 | 89 | /* Determine relocation type string for Alpha.  */ | 
 | 90 | const char * | 
 | 91 | arm_reloc_type_name (int type, char *buf __attribute__ ((unused)), | 
 | 92 | 		     size_t len __attribute__ ((unused))) | 
 | 93 | { | 
 | 94 |   if (type >= R_ARM_NONE && type <= R_ARM_ALU_SBREL_27_20) | 
 | 95 |     return reloc_map_table[type]; | 
 | 96 |  | 
 | 97 |   if (type >= R_ARM_GNU_VTENTRY && type <= R_ARM_THM_PC9) | 
 | 98 |     return reloc_map_table2[type - R_ARM_GNU_VTENTRY]; | 
 | 99 |  | 
 | 100 |   if (type >= R_ARM_RXPC25 && type <= R_ARM_RBASE) | 
 | 101 |     return reloc_map_table3[type - R_ARM_RXPC25]; | 
 | 102 |  | 
 | 103 |   return NULL; | 
 | 104 | } | 
 | 105 |  | 
 | 106 |  | 
 | 107 | /* Check for correct relocation type.  */ | 
 | 108 | bool | 
 | 109 | arm_reloc_type_check (int type) | 
 | 110 | { | 
 | 111 |   return ((type >= R_ARM_NONE && type <= R_ARM_ALU_SBREL_27_20) | 
 | 112 | 	  || (type >= R_ARM_GNU_VTENTRY && type <= R_ARM_THM_PC9) | 
 | 113 | 	  || (type >= R_ARM_RXPC25 && type <= R_ARM_RBASE)) ? true : false; | 
 | 114 | } | 
 | 115 |  | 
 | 116 | /* Check whether given relocation is a copy relocation.  */ | 
 | 117 | bool | 
 | 118 | arm_copy_reloc_p (int reloc) | 
 | 119 | { | 
 | 120 |   return reloc == R_ARM_COPY; | 
 | 121 | } |