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. |
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 | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| 5 | |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 6 | This file is free software; you can redistribute it and/or modify |
| 7 | it under the terms of either |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 8 | |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 9 | * the GNU Lesser General Public License as published by the Free |
| 10 | Software Foundation; either version 3 of the License, or (at |
| 11 | your option) any later version |
| 12 | |
| 13 | or |
| 14 | |
| 15 | * the GNU General Public License as published by the Free |
| 16 | Software Foundation; either version 2 of the License, or (at |
| 17 | your option) any later version |
| 18 | |
| 19 | or both in parallel, as here. |
| 20 | |
| 21 | elfutils is distributed in the hope that it will be useful, but |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 22 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 24 | General Public License for more details. |
| 25 | |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 26 | You should have received copies of the GNU General Public License and |
| 27 | the GNU Lesser General Public License along with this program. If |
| 28 | not, see <http://www.gnu.org/licenses/>. */ |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 29 | |
| 30 | #ifdef HAVE_CONFIG_H |
| 31 | # include <config.h> |
| 32 | #endif |
| 33 | |
| 34 | #include <elf.h> |
| 35 | #include <stddef.h> |
| 36 | |
Roland McGrath | cd60ea8 | 2005-11-16 01:57:40 +0000 | [diff] [blame] | 37 | #define BACKEND sh_ |
| 38 | #include "libebl_CPU.h" |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 39 | |
| 40 | |
Roland McGrath | cd60ea8 | 2005-11-16 01:57:40 +0000 | [diff] [blame] | 41 | /* Return true if the symbol type is that referencing the GOT. */ |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 42 | bool |
Roland McGrath | cd60ea8 | 2005-11-16 01:57:40 +0000 | [diff] [blame] | 43 | sh_gotpc_reloc_check (Elf *elf __attribute__ ((unused)), int type) |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 44 | { |
Roland McGrath | cd60ea8 | 2005-11-16 01:57:40 +0000 | [diff] [blame] | 45 | return type == R_SH_GOTPC; |
| 46 | } |
| 47 | |
| 48 | /* Check for the simple reloc types. */ |
| 49 | Elf_Type |
| 50 | sh_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) |
| 51 | { |
| 52 | switch (type) |
| 53 | { |
| 54 | case R_SH_DIR32: |
| 55 | return ELF_T_WORD; |
| 56 | default: |
| 57 | return ELF_T_NUM; |
| 58 | } |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 59 | } |
Matt Fleming | d80f0b2 | 2010-04-10 19:13:37 -0700 | [diff] [blame] | 60 | |
| 61 | /* Check whether machine flags are valid. */ |
| 62 | bool |
| 63 | sh_machine_flag_check (GElf_Word flags) |
| 64 | { |
| 65 | switch (flags & EF_SH_MACH_MASK) |
| 66 | { |
| 67 | case EF_SH_UNKNOWN: |
| 68 | case EF_SH1: |
| 69 | case EF_SH2: |
| 70 | case EF_SH3: |
| 71 | case EF_SH_DSP: |
| 72 | case EF_SH3_DSP: |
| 73 | case EF_SH4AL_DSP: |
| 74 | case EF_SH3E: |
| 75 | case EF_SH4: |
| 76 | case EF_SH2E: |
| 77 | case EF_SH4A: |
| 78 | case EF_SH2A: |
| 79 | case EF_SH4_NOFPU: |
| 80 | case EF_SH4A_NOFPU: |
| 81 | case EF_SH4_NOMMU_NOFPU: |
| 82 | case EF_SH2A_NOFPU: |
| 83 | case EF_SH3_NOMMU: |
| 84 | case EF_SH2A_SH4_NOFPU: |
| 85 | case EF_SH2A_SH3_NOFPU: |
| 86 | case EF_SH2A_SH4: |
| 87 | case EF_SH2A_SH3E: |
| 88 | break; |
| 89 | default: |
| 90 | return false; |
| 91 | } |
| 92 | |
| 93 | return ((flags &~ (EF_SH_MACH_MASK)) == 0); |
| 94 | } |