summaryrefslogtreecommitdiff
path: root/libexec/ld.so/sh/rtld_machine.c
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2006-11-10 21:19:55 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2006-11-10 21:19:55 +0000
commitce8c5f1f3c6b816cb7f5f996cbdf1f1d950a7792 (patch)
treef17583ed8b27f2ed50079e45cad6c3254c4bd25e /libexec/ld.so/sh/rtld_machine.c
parentad1e175683d1623277294c81bb4c147ba30a6e82 (diff)
Getting much closer.
Diffstat (limited to 'libexec/ld.so/sh/rtld_machine.c')
-rw-r--r--libexec/ld.so/sh/rtld_machine.c543
1 files changed, 487 insertions, 56 deletions
diff --git a/libexec/ld.so/sh/rtld_machine.c b/libexec/ld.so/sh/rtld_machine.c
index 5922ddd73fd..fed80751f66 100644
--- a/libexec/ld.so/sh/rtld_machine.c
+++ b/libexec/ld.so/sh/rtld_machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtld_machine.c,v 1.1 2006/11/10 07:44:58 drahn Exp $ */
+/* $OpenBSD: rtld_machine.c,v 1.2 2006/11/10 21:19:54 drahn Exp $ */
/*
* Copyright (c) 2004 Dale Rahn
@@ -27,6 +27,7 @@
*/
#define _DYN_LOADER
+#define LDSO_ARCH_IS_RELA_
#include <sys/types.h>
#include <sys/mman.h>
@@ -51,6 +52,7 @@ Elf_Addr _dl_bind(elf_object_t *object, int reloff);
#define _RF_SZ(s) (((s) & 0xff) << 8) /* memory target size */
#define _RF_RS(s) ((s) & 0xff) /* right shift */
static int reloc_target_flags[] = {
+#if 0
0, /* 0 NONE */
_RF_S|_RF_P|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 1 PC24 */
_RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 2 ABS32 */
@@ -94,6 +96,267 @@ static int reloc_target_flags[] = {
_RF_E, /* 40 V4BX */
_RF_E, /* 41 STKCHK */
_RF_E /* 42 TSTKCHK */
+
+#endif
+ 0, /* 0 R_SH_NONE */
+ _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 1 R_SH_DIR32 */
+ _RF_S|_RF_P|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 2 REL32 */
+ _RF_E, /* 3 R_SH_DIR8WPN */
+ _RF_E, /* 4 R_SH_IND12W */
+ _RF_E, /* 5 R_SH_DIR8WPL */
+ _RF_E, /* 6 R_SH_DIR8WPZ */
+ _RF_E, /* 7 R_SH_DIR8BP */
+ _RF_E, /* 8 R_SH_DIR8W */
+ _RF_E, /* 9 R_SH_DIR8L */
+ _RF_E, /* 10 R_SH_LOOP_START */
+ _RF_E, /* 11 R_SH_LOOP_END */
+ _RF_E, /* 12 Unused */
+ _RF_E, /* 13 Unused */
+ _RF_E, /* 14 Unused */
+ _RF_E, /* 15 Unused */
+ _RF_E, /* 16 Unused */
+ _RF_E, /* 17 Unused */
+ _RF_E, /* 18 Unused */
+ _RF_E, /* 19 Unused */
+ _RF_E, /* 20 Unused */
+ _RF_E, /* 21 Unused */
+ _RF_E, /* 22 R_SH_GNU_VTINHERIT */
+ _RF_E, /* 23 R_SH_GNU_VTENTRY */
+ _RF_E, /* 24 R_SH_SWITCH8 */
+ _RF_E, /* 25 R_SH_SWITCH16 */
+ _RF_E, /* 26 R_SH_SWITCH32 */
+ _RF_E, /* 27 R_SH_USES */
+ _RF_E, /* 28 R_SH_COUNT */
+ _RF_E, /* 29 R_SH_ALIGN */
+ _RF_E, /* 30 R_SH_CODE */
+ _RF_E, /* 31 R_SH_DATA */
+ _RF_E, /* 32 R_SH_LABEL */
+ _RF_E, /* 33 R_SH_DIR16 */
+ _RF_E, /* 34 R_SH_DIR8 */
+ _RF_E, /* 35 R_SH_DIR8UL */
+ _RF_E, /* 36 R_SH_DIR8UW */
+ _RF_E, /* 37 R_SH_DIR8U */
+ _RF_E, /* 38 R_SH_DIR8SW */
+ _RF_E, /* 39 R_SH_DIR8S */
+ _RF_E, /* 40 R_SH_DIR4UL */
+ _RF_E, /* 41 R_SH_DIR4UW */
+ _RF_E, /* 42 R_SH_DIR4U */
+ _RF_E, /* 43 R_SH_PSHA */
+ _RF_E, /* 44 R_SH_PSHL */
+ _RF_E, /* 45 R_SH_DIR5U */
+ _RF_E, /* 46 R_SH_DIR6U */
+ _RF_E, /* 47 R_SH_DIR6S */
+ _RF_E, /* 48 R_SH_DIR10S */
+ _RF_E, /* 49 R_SH_DIR10SW */
+ _RF_E, /* 50 R_SH_DIR10SL */
+ _RF_E, /* 51 R_SH_DIR10SQ */
+ _RF_E, /* 52 XXXX */
+ _RF_E, /* 53 R_SH_DIR16S */
+ _RF_E, /* 54 Unused */
+ _RF_E, /* 55 Unused */
+ _RF_E, /* 56 Unused */
+ _RF_E, /* 57 Unused */
+ _RF_E, /* 58 Unused */
+ _RF_E, /* 59 Unused */
+ _RF_E, /* 60 Unused */
+ _RF_E, /* 61 Unused */
+ _RF_E, /* 62 Unused */
+ _RF_E, /* 63 Unused */
+ _RF_E, /* 64 Unused */
+ _RF_E, /* 65 Unused */
+ _RF_E, /* 66 Unused */
+ _RF_E, /* 67 Unused */
+ _RF_E, /* 68 Unused */
+ _RF_E, /* 69 Unused */
+ _RF_E, /* 70 Unused */
+ _RF_E, /* 71 Unused */
+ _RF_E, /* 72 Unused */
+ _RF_E, /* 73 Unused */
+ _RF_E, /* 74 Unused */
+ _RF_E, /* 75 Unused */
+ _RF_E, /* 76 Unused */
+ _RF_E, /* 77 Unused */
+ _RF_E, /* 78 Unused */
+ _RF_E, /* 79 Unused */
+ _RF_E, /* 80 Unused */
+ _RF_E, /* 81 Unused */
+ _RF_E, /* 82 Unused */
+ _RF_E, /* 83 Unused */
+ _RF_E, /* 84 Unused */
+ _RF_E, /* 85 Unused */
+ _RF_E, /* 86 Unused */
+ _RF_E, /* 87 Unused */
+ _RF_E, /* 88 Unused */
+ _RF_E, /* 89 Unused */
+ _RF_E, /* 90 Unused */
+ _RF_E, /* 91 Unused */
+ _RF_E, /* 92 Unused */
+ _RF_E, /* 93 Unused */
+ _RF_E, /* 94 Unused */
+ _RF_E, /* 95 Unused */
+ _RF_E, /* 96 Unused */
+ _RF_E, /* 97 Unused */
+ _RF_E, /* 98 Unused */
+ _RF_E, /* 99 Unused */
+ _RF_E, /* 100 Unused */
+ _RF_E, /* 101 Unused */
+ _RF_E, /* 102 Unused */
+ _RF_E, /* 103 Unused */
+ _RF_E, /* 104 Unused */
+ _RF_E, /* 105 Unused */
+ _RF_E, /* 106 Unused */
+ _RF_E, /* 107 Unused */
+ _RF_E, /* 108 Unused */
+ _RF_E, /* 109 Unused */
+ _RF_E, /* 110 Unused */
+ _RF_E, /* 111 Unused */
+ _RF_E, /* 112 Unused */
+ _RF_E, /* 113 Unused */
+ _RF_E, /* 114 Unused */
+ _RF_E, /* 115 Unused */
+ _RF_E, /* 116 Unused */
+ _RF_E, /* 117 Unused */
+ _RF_E, /* 118 Unused */
+ _RF_E, /* 119 Unused */
+ _RF_E, /* 120 Unused */
+ _RF_E, /* 121 Unused */
+ _RF_E, /* 122 Unused */
+ _RF_E, /* 123 Unused */
+ _RF_E, /* 124 Unused */
+ _RF_E, /* 125 Unused */
+ _RF_E, /* 126 Unused */
+ _RF_E, /* 127 Unused */
+ _RF_E, /* 128 Unused */
+ _RF_E, /* 129 Unused */
+ _RF_E, /* 130 Unused */
+ _RF_E, /* 131 Unused */
+ _RF_E, /* 132 Unused */
+ _RF_E, /* 133 Unused */
+ _RF_E, /* 134 Unused */
+ _RF_E, /* 135 Unused */
+ _RF_E, /* 136 Unused */
+ _RF_E, /* 137 Unused */
+ _RF_E, /* 138 Unused */
+ _RF_E, /* 139 Unused */
+ _RF_E, /* 140 Unused */
+ _RF_E, /* 141 Unused */
+ _RF_E, /* 142 Unused */
+ _RF_E, /* 143 Unused */
+ _RF_E, /* 144 R_SH_TLS_GD_32 */
+ _RF_E, /* 145 R_SH_TLS_LD_32 */
+ _RF_E, /* 146 R_SH_TLS_LDO_32 */
+ _RF_E, /* 147 R_SH_TLS_IE_32 */
+ _RF_E, /* 148 R_SH_TLS_LE_32 */
+ _RF_E, /* 149 R_SH_TLS_DTPMOD32 */
+ _RF_E, /* 150 R_SH_TLS_DTPOFF32 */
+ _RF_E, /* 151 R_SH_TLS_TPOFF32 */
+ _RF_E, /* 152 Unused */
+ _RF_E, /* 153 Unused */
+ _RF_E, /* 154 Unused */
+ _RF_E, /* 155 Unused */
+ _RF_E, /* 156 Unused */
+ _RF_E, /* 157 Unused */
+ _RF_E, /* 158 Unused */
+ _RF_E, /* 159 Unused */
+ _RF_E, /* 160 R_SH_GOT32 */
+ _RF_E, /* 161 R_SH_PLT32 */
+ _RF_S| _RF_SZ(32) | _RF_RS(0), /* 162 COPY */
+ _RF_S|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 163 GLOB_DAT */
+ _RF_S| _RF_SZ(32) | _RF_RS(0), /* 164 JMP_SLOT */
+ _RF_P|_RF_A| _RF_SZ(32) | _RF_RS(0), /* 165 REL32 */
+ _RF_E, /* 166 R_SH_GOTOFF */
+ _RF_E, /* 167 R_SH_GOTPC */
+ _RF_E, /* 168 R_SH_GOTPLT32 */
+ _RF_E, /* 169 R_SH_GOT_LOW16 */
+ _RF_E, /* 170 R_SH_GOT_MEDLOW16 */
+ _RF_E, /* 171 R_SH_GOT_MEDHI16 */
+ _RF_E, /* 172 R_SH_GOT_HI16 */
+ _RF_E, /* 173 R_SH_GOTPLT_LOW16 */
+ _RF_E, /* 174 R_SH_GOTPLT_MEDLOW16 */
+ _RF_E, /* 175 R_SH_GOTPLT_MEDHI16 */
+ _RF_E, /* 176 R_SH_GOTPLT_HI16 */
+ _RF_E, /* 177 R_SH_PLT_LOW16 */
+ _RF_E, /* 178 R_SH_PLT_MEDLOW16 */
+ _RF_E, /* 179 R_SH_PLT_MEDHI16 */
+ _RF_E, /* 180 R_SH_PLT_HI16 */
+ _RF_E, /* 181 R_SH_GOTOFF_LOW16 */
+ _RF_E, /* 182 R_SH_GOTOFF_MEDLOW16 */
+ _RF_E, /* 183 R_SH_GOTOFF_MEDHI16 */
+ _RF_E, /* 184 R_SH_GOTOFF_HI16 */
+ _RF_E, /* 185 R_SH_GOTPC_LOW16 */
+ _RF_E, /* 186 R_SH_GOTPC_MEDLOW16 */
+ _RF_E, /* 187 R_SH_GOTPC_MEDHI16 */
+ _RF_E, /* 188 R_SH_GOTPC_HI16 */
+ _RF_E, /* 189 R_SH_GOT10BY4 */
+ _RF_E, /* 190 R_SH_GOTPLT10BY4 */
+ _RF_E, /* 191 R_SH_GOT10BY8 */
+ _RF_E, /* 192 R_SH_GOTPLT10BY8 */
+#ifdef SH_SUPPORT_64_BIT
+ _RF_E, /* 193 R_SH_COPY64 */
+ _RF_E, /* 194 R_SH_GLOB_DAT64 */
+ _RF_E, /* 195 R_SH_JMP_SLOT64 */
+ _RF_E, /* 196 R_SH_RELATIVE64 */
+ _RF_E, /* 197 Unused */
+ _RF_E, /* 198 Unused */
+ _RF_E, /* 199 Unused */
+ _RF_E, /* 200 Unused */
+ _RF_E, /* 201 Unused */
+ _RF_E, /* 202 Unused */
+ _RF_E, /* 203 Unused */
+ _RF_E, /* 204 Unused */
+ _RF_E, /* 205 Unused */
+ _RF_E, /* 206 Unused */
+ _RF_E, /* 207 Unused */
+ _RF_E, /* 208 Unused */
+ _RF_E, /* 209 Unused */
+ _RF_E, /* 210 Unused */
+ _RF_E, /* 211 Unused */
+ _RF_E, /* 212 Unused */
+ _RF_E, /* 213 Unused */
+ _RF_E, /* 214 Unused */
+ _RF_E, /* 215 Unused */
+ _RF_E, /* 216 Unused */
+ _RF_E, /* 217 Unused */
+ _RF_E, /* 218 Unused */
+ _RF_E, /* 219 Unused */
+ _RF_E, /* 220 Unused */
+ _RF_E, /* 221 Unused */
+ _RF_E, /* 222 Unused */
+ _RF_E, /* 223 Unused */
+ _RF_E, /* 224 Unused */
+ _RF_E, /* 225 Unused */
+ _RF_E, /* 226 Unused */
+ _RF_E, /* 227 Unused */
+ _RF_E, /* 228 Unused */
+ _RF_E, /* 229 Unused */
+ _RF_E, /* 230 Unused */
+ _RF_E, /* 231 Unused */
+ _RF_E, /* 232 Unused */
+ _RF_E, /* 233 Unused */
+ _RF_E, /* 234 Unused */
+ _RF_E, /* 235 Unused */
+ _RF_E, /* 236 Unused */
+ _RF_E, /* 237 Unused */
+ _RF_E, /* 238 Unused */
+ _RF_E, /* 239 Unused */
+ _RF_E, /* 240 Unused */
+ _RF_E, /* 241 Unused */
+ _RF_E, /* 242 R_SH_SHMEDIA_CODE */
+ _RF_E, /* 243 R_SH_PT_16 */
+ _RF_E, /* 244 R_SH_IMMS16 */
+ _RF_E, /* 245 R_SH_IMMU16 */
+ _RF_E, /* 246 R_SH_IMM_LOW16 */
+ _RF_E, /* 247 R_SH_IMM_LOW16_PCREL */
+ _RF_E, /* 248 R_SH_IMM_MEDLOW16 */
+ _RF_E, /* 249 R_SH_IMM_MEDLOW16_PCREL */
+ _RF_E, /* 250 R_SH_IMM_MEDHI16 */
+ _RF_E, /* 251 R_SH_IMM_MEDHI16_PCREL */
+ _RF_E, /* 252 R_SH_IMM_HI16 */
+ _RF_E, /* 253 R_SH_IMM_HI16_PCREL */
+ _RF_E, /* 254 R_SH_64 */
+ _RF_E, /* 255 R_SH_64_PCREL */
+ 0
+#endif
};
#define RELOC_RESOLVE_SYMBOL(t) ((reloc_target_flags[t] & _RF_S) != 0)
@@ -105,70 +368,237 @@ static int reloc_target_flags[] = {
#define RELOC_VALUE_RIGHTSHIFT(t) (reloc_target_flags[t] & 0xff)
static int reloc_target_bitmask[] = {
#define _BM(x) (x == 32? ~0 : ~(-(1UL << (x))))
- _BM(0), /* 0 NONE */
- _BM(24), /* 1 PC24 */
- _BM(32), /* 2 ABS32 */
- _BM(32), /* 3 REL32 */
- _BM(0), /* 4 REL13 */
- _BM(0), /* 5 ABS16 */
- _BM(0), /* 6 ABS12 */
- _BM(0), /* 7 T_ABS5 */
- _BM(0), /* 8 ABS8 */
- _BM(32), /* 9 SBREL32 */
- _BM(0), /* 10 T_PC22 */
- _BM(0), /* 11 T_PC8 */
- _BM(0), /* 12 Reserved */
- _BM(0), /* 13 SWI24 */
- _BM(0), /* 14 T_SWI8 */
- _BM(0), /* 15 OBSL */
- _BM(0), /* 16 OBSL */
- _BM(0), /* 17 UNUSED */
- _BM(0), /* 18 UNUSED */
- _BM(0), /* 19 UNUSED */
- _BM(32), /* 20 COPY */
- _BM(32), /* 21 GLOB_DAT */
- _BM(32), /* 22 JMP_SLOT */
- _BM(32), /* 23 RELATIVE */
- _BM(0), /* 24 GOTOFF */
- _BM(0), /* 25 GOTPC */
- _BM(0), /* 26 GOT32 */
- _BM(0), /* 27 PLT32 */
- _BM(0), /* 28 UNUSED */
- _BM(0), /* 29 UNUSED */
- _BM(0), /* 30 UNUSED */
- _BM(0), /* 31 UNUSED */
- _BM(0), /* 32 A_PCR 0 */
- _BM(0), /* 33 A_PCR 8 */
- _BM(0), /* 34 A_PCR 16 */
- _BM(0), /* 35 B_PCR 0 */
- _BM(0), /* 36 B_PCR 12 */
- _BM(0), /* 37 B_PCR 20 */
- _BM(0), /* 38 RELAB32 */
- _BM(0), /* 39 ROSGREL32 */
- _BM(0), /* 40 V4BX */
- _BM(0), /* 41 STKCHK */
- _BM(0) /* 42 TSTKCHK */
+ _BM(0), /* 0 R_SH_NONE */
+ _BM(32), /* 1 R_SH_DIR32 */
+ _BM(32), /* 2 R_SH_REL32 */
+ _BM(8), /* 3 R_SH_DIR8WPN */
+ _BM(12), /* 4 R_SH_IND12W */
+ _BM(8), /* 5 R_SH_DIR8WPL */
+ _BM(8), /* 6 R_SH_DIR8WPZ */
+ _BM(8), /* 7 R_SH_DIR8BP */
+ _BM(8), /* 8 R_SH_DIR8W */
+ _BM(8), /* 9 R_SH_DIR8L */
+ _BM(0), /* 10 R_SH_LOOP_START */
+ _BM(0), /* 11 R_SH_LOOP_END */
+ _BM(0), /* 12 Unused */
+ _BM(0), /* 13 Unused */
+ _BM(0), /* 14 Unused */
+ _BM(0), /* 14 Unused */
+ _BM(0), /* 16 Unused */
+ _BM(0), /* 17 Unused */
+ _BM(0), /* 18 Unused */
+ _BM(0), /* 19 Unused */
+ _BM(0), /* 20 Unused */
+ _BM(0), /* 21 Unused */
+ _BM(0), /* 22 R_SH_GNU_VTINHERIT */
+ _BM(0), /* 23 R_SH_GNU_VTENTRY */
+ _BM(0), /* 24 R_SH_SWITCH8 */
+ _BM(0), /* 25 R_SH_SWITCH16 */
+ _BM(0), /* 26 R_SH_SWITCH32 */
+ _BM(0), /* 27 R_SH_USES */
+ _BM(0), /* 28 R_SH_COUNT */
+ _BM(0), /* 29 R_SH_ALIGN */
+ _BM(0), /* 30 R_SH_CODE */
+ _BM(0), /* 31 R_SH_DATA */
+ _BM(0), /* 32 R_SH_LABEL */
+ _BM(0), /* 33 R_SH_DIR16 */
+ _BM(0), /* 34 R_SH_DIR8 */
+ _BM(0), /* 35 R_SH_DIR8UL */
+ _BM(0), /* 36 R_SH_DIR8UW */
+ _BM(0), /* 37 R_SH_DIR8U */
+ _BM(0), /* 38 R_SH_DIR8SW */
+ _BM(0), /* 39 R_SH_DIR8S */
+ _BM(0), /* 40 R_SH_DIR4UL */
+ _BM(0), /* 41 R_SH_DIR4UW */
+ _BM(0), /* 42 R_SH_DIR4U */
+ _BM(0), /* 43 R_SH_PSHA */
+ _BM(0), /* 44 R_SH_PSHL */
+ _BM(0), /* 45 R_SH_DIR5U */
+ _BM(0), /* 46 R_SH_DIR6U */
+ _BM(0), /* 47 R_SH_DIR6S */
+ _BM(0), /* 48 R_SH_DIR10S */
+ _BM(0), /* 49 R_SH_DIR10SW */
+ _BM(0), /* 50 R_SH_DIR10SL */
+ _BM(0), /* 51 R_SH_DIR10SQ */
+ _BM(0), /* 53 R_SH_DIR16S */
+ _BM(0), /* 54 Unused */
+ _BM(0), /* 55 Unused */
+ _BM(0), /* 56 Unused */
+ _BM(0), /* 57 Unused */
+ _BM(0), /* 58 Unused */
+ _BM(0), /* 59 Unused */
+ _BM(0), /* 60 Unused */
+ _BM(0), /* 61 Unused */
+ _BM(0), /* 62 Unused */
+ _BM(0), /* 63 Unused */
+ _BM(0), /* 64 Unused */
+ _BM(0), /* 65 Unused */
+ _BM(0), /* 66 Unused */
+ _BM(0), /* 67 Unused */
+ _BM(0), /* 68 Unused */
+ _BM(0), /* 69 Unused */
+ _BM(0), /* 70 Unused */
+ _BM(0), /* 71 Unused */
+ _BM(0), /* 72 Unused */
+ _BM(0), /* 73 Unused */
+ _BM(0), /* 74 Unused */
+ _BM(0), /* 75 Unused */
+ _BM(0), /* 76 Unused */
+ _BM(0), /* 77 Unused */
+ _BM(0), /* 78 Unused */
+ _BM(0), /* 79 Unused */
+ _BM(0), /* 80 Unused */
+ _BM(0), /* 81 Unused */
+ _BM(0), /* 82 Unused */
+ _BM(0), /* 83 Unused */
+ _BM(0), /* 84 Unused */
+ _BM(0), /* 85 Unused */
+ _BM(0), /* 86 Unused */
+ _BM(0), /* 87 Unused */
+ _BM(0), /* 88 Unused */
+ _BM(0), /* 89 Unused */
+ _BM(0), /* 90 Unused */
+ _BM(0), /* 91 Unused */
+ _BM(0), /* 92 Unused */
+ _BM(0), /* 93 Unused */
+ _BM(0), /* 94 Unused */
+ _BM(0), /* 95 Unused */
+ _BM(0), /* 96 Unused */
+ _BM(0), /* 97 Unused */
+ _BM(0), /* 98 Unused */
+ _BM(0), /* 99 Unused */
+ _BM(0), /* 100 Unused */
+ _BM(0), /* 101 Unused */
+ _BM(0), /* 102 Unused */
+ _BM(0), /* 103 Unused */
+ _BM(0), /* 104 Unused */
+ _BM(0), /* 105 Unused */
+ _BM(0), /* 106 Unused */
+ _BM(0), /* 107 Unused */
+ _BM(0), /* 108 Unused */
+ _BM(0), /* 109 Unused */
+ _BM(0), /* 110 Unused */
+ _BM(0), /* 111 Unused */
+ _BM(0), /* 112 Unused */
+ _BM(0), /* 113 Unused */
+ _BM(0), /* 114 Unused */
+ _BM(0), /* 115 Unused */
+ _BM(0), /* 116 Unused */
+ _BM(0), /* 117 Unused */
+ _BM(0), /* 118 Unused */
+ _BM(0), /* 119 Unused */
+ _BM(0), /* 120 Unused */
+ _BM(0), /* 121 Unused */
+ _BM(0), /* 122 Unused */
+ _BM(0), /* 123 Unused */
+ _BM(0), /* 124 Unused */
+ _BM(0), /* 125 Unused */
+ _BM(0), /* 126 Unused */
+ _BM(0), /* 127 Unused */
+ _BM(0), /* 128 Unused */
+ _BM(0), /* 129 Unused */
+ _BM(0), /* 130 Unused */
+ _BM(0), /* 131 Unused */
+ _BM(0), /* 132 Unused */
+ _BM(0), /* 133 Unused */
+ _BM(0), /* 134 Unused */
+ _BM(0), /* 135 Unused */
+ _BM(0), /* 136 Unused */
+ _BM(0), /* 137 Unused */
+ _BM(0), /* 138 Unused */
+ _BM(0), /* 139 Unused */
+ _BM(0), /* 140 Unused */
+ _BM(0), /* 141 Unused */
+ _BM(0), /* 142 Unused */
+ _BM(0), /* 143 Unused */
+ _BM(0), /* 144 R_SH_TLS_GD_32 */
+ _BM(0), /* 145 R_SH_TLS_LD_32 */
+ _BM(0), /* 146 R_SH_TLS_LDO_32 */
+ _BM(0), /* 147 R_SH_TLS_IE_32 */
+ _BM(0), /* 148 R_SH_TLS_LE_32 */
+ _BM(0), /* 149 R_SH_TLS_DTPMOD32 */
+ _BM(0), /* 150 R_SH_TLS_DTPOFF32 */
+ _BM(0), /* 151 R_SH_TLS_TPOFF32 */
+ _BM(0), /* 160 R_SH_GOT32 */
+ _BM(0), /* 161 R_SH_PLT32 */
+ _BM(0), /* 162 R_SH_COPY */
+ _BM(32), /* 163 R_SH_GLOB_DAT */
+ _BM(0), /* 164 R_SH_JMP_SLOT */
+ _BM(32), /* 165 R_SH_RELATIVE */
+ _BM(0), /* 166 R_SH_GOTOFF */
+ _BM(0), /* 167 R_SH_GOTPC */
+ _BM(0), /* 168 R_SH_GOTPLT32 */
+ _BM(0), /* 169 R_SH_GOT_LOW16 */
+ _BM(0), /* 170 R_SH_GOT_MEDLOW16 */
+ _BM(0), /* 171 R_SH_GOT_MEDHI16 */
+ _BM(0), /* 172 R_SH_GOT_HI16 */
+ _BM(0), /* 173 R_SH_GOTPLT_LOW16 */
+ _BM(0), /* 174 R_SH_GOTPLT_MEDLOW16 */
+ _BM(0), /* 175 R_SH_GOTPLT_MEDHI16 */
+ _BM(0), /* 176 R_SH_GOTPLT_HI16 */
+ _BM(0), /* 177 R_SH_PLT_LOW16 */
+ _BM(0), /* 178 R_SH_PLT_MEDLOW16 */
+ _BM(0), /* 179 R_SH_PLT_MEDHI16 */
+ _BM(0), /* 180 R_SH_PLT_HI16 */
+ _BM(0), /* 181 R_SH_GOTOFF_LOW16 */
+ _BM(0), /* 182 R_SH_GOTOFF_MEDLOW16 */
+ _BM(0), /* 183 R_SH_GOTOFF_MEDHI16 */
+ _BM(0), /* 184 R_SH_GOTOFF_HI16 */
+ _BM(0), /* 185 R_SH_GOTPC_LOW16 */
+ _BM(0), /* 186 R_SH_GOTPC_MEDLOW16 */
+ _BM(0), /* 187 R_SH_GOTPC_MEDHI16 */
+ _BM(0), /* 188 R_SH_GOTPC_HI16 */
+ _BM(0), /* 189 R_SH_GOT10BY4 */
+ _BM(0), /* 190 R_SH_GOTPLT10BY4 */
+ _BM(0), /* 191 R_SH_GOT10BY8 */
+ _BM(0), /* 192 R_SH_GOTPLT10BY8 */
+#ifdef SH_SUPPORT_64_BIT
+ _BM(0), /* 193 R_SH_COPY64 */
+ _BM(0), /* 194 R_SH_GLOB_DAT64 */
+ _BM(0), /* 195 R_SH_JMP_SLOT64 */
+ _BM(0), /* 196 R_SH_RELATIVE64 */
+ _BM(0), /* 242 R_SH_SHMEDIA_CODE */
+ _BM(0), /* 243 R_SH_PT_16 */
+ _BM(0), /* 244 R_SH_IMMS16 */
+ _BM(0), /* 245 R_SH_IMMU16 */
+ _BM(0), /* 246 R_SH_IMM_LOW16 */
+ _BM(0), /* 247 R_SH_IMM_LOW16_PCREL */
+ _BM(0), /* 248 R_SH_IMM_MEDLOW16 */
+ _BM(0), /* 249 R_SH_IMM_MEDLOW16_PCREL */
+ _BM(0), /* 250 R_SH_IMM_MEDHI16 */
+ _BM(0), /* 251 R_SH_IMM_MEDHI16_PCREL */
+ _BM(0), /* 252 R_SH_IMM_HI16 */
+ _BM(0), /* 253 R_SH_IMM_HI16_PCREL */
+ _BM(0), /* 254 R_SH_64 */
+ _BM(0), /* 255 R_SH_64_PCREL */
+#endif
#undef _BM
};
#define RELOC_VALUE_BITMASK(t) (reloc_target_bitmask[t])
#define R_TYPE(x) R_SH_ ## x
-void _dl_reloc_plt(Elf_Word *where, Elf_Addr value, Elf_Rel *rel);
+void _dl_reloc_plt(Elf_Word *where, Elf_Addr value, Elf_RelA *rel);
+
+void
+_dl_reloc_plt(Elf_Word *where, Elf_Addr value, Elf_RelA *rel)
+{
+ *where = value + rel->r_addend;
+}
int
-_dl_md_reloc(elf_object_t *object, int rel, int relsz)
+_dl_md_reloc(elf_object_t *object, int rel, int relasz)
{
long i;
- long numrel;
+ long numrela;
long fails = 0;
Elf_Addr loff;
- Elf_Rel *rels;
+ Elf_RelA *rels;
struct load_list *llist;
loff = object->load_offs;
- numrel = object->Dyn.info[relsz] / sizeof(Elf_Rel);
- rels = (Elf_Rel *)(object->Dyn.info[rel]);
+ numrela = object->Dyn.info[relasz] / sizeof(Elf_RelA);
+ rels = (Elf_RelA *)(object->Dyn.info[rel]);
if (rels == NULL)
return(0);
@@ -181,12 +611,13 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
llist != NULL;
llist = llist->next) {
if (!(llist->prot & PROT_WRITE))
+ _dl_printf("protecting %x %x\n", llist->start, llist->size);
_dl_mprotect(llist->start, llist->size,
llist->prot|PROT_WRITE);
}
}
- for (i = 0; i < numrel; i++, rels++) {
+ for (i = 0; i < numrela; i++, rels++) {
Elf_Addr *where, value, ooff, mask;
Elf_Word type;
const Elf_Sym *sym, *this;
@@ -195,7 +626,7 @@ _dl_md_reloc(elf_object_t *object, int rel, int relsz)
type = ELF_R_TYPE(rels->r_info);
if (reloc_target_flags[type] & _RF_E) {
- _dl_printf(" bad relocation %d %d\n", i, type);
+ _dl_printf(" bad relocation obj %s %d %d\n", object->load_name, i, type);
_dl_exit(1);
}
if (type == R_TYPE(NONE))
@@ -245,10 +676,7 @@ resolve_failed:
}
if (type == R_TYPE(JMP_SLOT)) {
- /*
_dl_reloc_plt((Elf_Word *)where, value, rels);
- */
- *where = value;
continue;
}
@@ -328,7 +756,10 @@ _dl_md_reloc_got(elf_object_t *object, int lazy)
int i, num;
Elf_Rel *rel;
- if (object->Dyn.info[DT_PLTREL] != DT_REL)
+ /* XXX - lazy binding not supported yet */
+ lazy = 0;
+
+ if (object->Dyn.info[DT_PLTREL] != DT_RELA)
return;
object->got_addr = NULL;