Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame^] | 1 | /* SH specific relocation handling. |
| 2 | Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. |
| 3 | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| 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_sh.h> |
| 23 | |
| 24 | |
| 25 | /* Return of the backend. */ |
| 26 | const char * |
| 27 | sh_backend_name (void) |
| 28 | { |
| 29 | return "sh"; |
| 30 | } |
| 31 | |
| 32 | |
| 33 | /* Determine relocation type string for SH. */ |
| 34 | const char * |
| 35 | sh_reloc_type_name (int type, char *buf __attribute__ ((unused)), |
| 36 | size_t len __attribute__ ((unused))) |
| 37 | { |
| 38 | static const char *map_table1[] = |
| 39 | { |
| 40 | [R_SH_NONE] = "R_SH_NONE", |
| 41 | [R_SH_DIR32] = "R_SH_DIR32", |
| 42 | [R_SH_REL32] = "R_SH_REL32", |
| 43 | [R_SH_DIR8WPN] = "R_SH_DIR8WPN", |
| 44 | [R_SH_IND12W] = "R_SH_IND12W", |
| 45 | [R_SH_DIR8WPL] = "R_SH_DIR8WPL", |
| 46 | [R_SH_DIR8WPZ] = "R_SH_DIR8WPZ", |
| 47 | [R_SH_DIR8BP] = "R_SH_DIR8BP", |
| 48 | [R_SH_DIR8W] = "R_SH_DIR8W", |
| 49 | [R_SH_DIR8L] = "R_SH_DIR8L", |
| 50 | [R_SH_SWITCH16] = "R_SH_SWITCH16", |
| 51 | [R_SH_SWITCH32] = "R_SH_SWITCH32", |
| 52 | [R_SH_USES] = "R_SH_USES", |
| 53 | [R_SH_COUNT] = "R_SH_COUNT", |
| 54 | [R_SH_ALIGN] = "R_SH_ALIGN", |
| 55 | [R_SH_CODE] = "R_SH_CODE", |
| 56 | [R_SH_DATA] = "R_SH_DATA", |
| 57 | [R_SH_LABEL] = "R_SH_LABEL", |
| 58 | [R_SH_SWITCH8] = "R_SH_SWITCH8", |
| 59 | [R_SH_GNU_VTINHERIT] ="R_SH_GNU_VTINHERIT", |
| 60 | [R_SH_GNU_VTENTRY] = "R_SH_GNU_VTENTRY" |
| 61 | }; |
| 62 | static const char *map_table2[] = |
| 63 | { |
| 64 | [R_SH_TLS_GD_32] = "R_SH_TLS_GD_32", |
| 65 | [R_SH_TLS_LD_32] = "R_SH_TLS_LD_32", |
| 66 | [R_SH_TLS_LDO_32] = "R_SH_TLS_LDO_32", |
| 67 | [R_SH_TLS_IE_32] = "R_SH_TLS_IE_32", |
| 68 | [R_SH_TLS_LE_32] = "R_SH_TLS_LE_32", |
| 69 | [R_SH_TLS_DTPMOD32] = "R_SH_TLS_DTPMOD32", |
| 70 | [R_SH_TLS_DTPOFF32] = "R_SH_TLS_DTPOFF32", |
| 71 | [R_SH_TLS_TPOFF32] = "R_SH_TLS_TPOFF32", |
| 72 | [R_SH_GOT32 - R_SH_GOT32] = "R_SH_GOT32", |
| 73 | [R_SH_PLT32 - R_SH_GOT32] = "R_SH_PLT32", |
| 74 | [R_SH_COPY - R_SH_GOT32] = "R_SH_COPY", |
| 75 | [R_SH_GLOB_DAT - R_SH_GOT32] = "R_SH_GLOB_DAT", |
| 76 | [R_SH_JMP_SLOT - R_SH_GOT32] = "R_SH_JMP_SLOT", |
| 77 | [R_SH_RELATIVE - R_SH_GOT32] = "R_SH_RELATIVE", |
| 78 | [R_SH_GOTOFF - R_SH_GOT32] = "R_SH_GOTOFF", |
| 79 | [R_SH_GOTPC - R_SH_GOT32] = "R_SH_GOTPC" |
| 80 | }; |
| 81 | |
| 82 | if (type >= 0 |
| 83 | && (size_t) type < sizeof (map_table1) / sizeof (map_table1[0])) |
| 84 | return map_table1[type]; |
| 85 | |
| 86 | if ((type - R_SH_TLS_GD_32) >= 0 |
| 87 | && ((size_t) (type - R_SH_TLS_GD_32) |
| 88 | < sizeof (map_table2) / sizeof (map_table2[0]))) |
| 89 | return map_table2[type - R_SH_TLS_GD_32]; |
| 90 | |
| 91 | return NULL; |
| 92 | } |
| 93 | |
| 94 | /* Check whether given relocation is a copy relocation. */ |
| 95 | bool |
| 96 | sh_copy_reloc_p (int reloc) |
| 97 | { |
| 98 | return reloc == R_SH_COPY; |
| 99 | } |