diff options
author | Catalin Marinas <catalin.marinas@arm.com> | 2010-06-21 10:10:37 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-08-05 05:35:46 -0400 |
commit | 8dd47741d191400c46173ed9fba9d14b4033ce23 (patch) | |
tree | 779be0554c1391a5f74e4598dce92cbdaa29b9c5 /arch/arm/kernel | |
parent | 3cfc2c42c1cbc8e238bb9c0612c0df4565e3a8b4 (diff) |
ARM: 6189/1: Add support for the MOVW/MOVT relocations in Thumb-2
The patch adds handling case for the R_ARM_THM_MOVW_ABS_NC and
R_ARM_THM_MOVT_ABS relocations in arch/arm/kernel/module.c. Such
relocations may appear in Thumb-2 compiled kernel modules.
Reported-by: Kyungmin Park <kmpark@infradead.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/kernel')
-rw-r--r-- | arch/arm/kernel/module.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c index c628bdf6c430..ae3c80453a09 100644 --- a/arch/arm/kernel/module.c +++ b/arch/arm/kernel/module.c | |||
@@ -237,6 +237,38 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, | |||
237 | lower = *(u16 *)(loc + 2); | 237 | lower = *(u16 *)(loc + 2); |
238 | break; | 238 | break; |
239 | 239 | ||
240 | case R_ARM_THM_MOVW_ABS_NC: | ||
241 | case R_ARM_THM_MOVT_ABS: | ||
242 | upper = *(u16 *)loc; | ||
243 | lower = *(u16 *)(loc + 2); | ||
244 | |||
245 | /* | ||
246 | * MOVT/MOVW instructions encoding in Thumb-2: | ||
247 | * | ||
248 | * i = upper[10] | ||
249 | * imm4 = upper[3:0] | ||
250 | * imm3 = lower[14:12] | ||
251 | * imm8 = lower[7:0] | ||
252 | * | ||
253 | * imm16 = imm4:i:imm3:imm8 | ||
254 | */ | ||
255 | offset = ((upper & 0x000f) << 12) | | ||
256 | ((upper & 0x0400) << 1) | | ||
257 | ((lower & 0x7000) >> 4) | (lower & 0x00ff); | ||
258 | offset = (offset ^ 0x8000) - 0x8000; | ||
259 | offset += sym->st_value; | ||
260 | |||
261 | if (ELF32_R_TYPE(rel->r_info) == R_ARM_THM_MOVT_ABS) | ||
262 | offset >>= 16; | ||
263 | |||
264 | *(u16 *)loc = (u16)((upper & 0xfbf0) | | ||
265 | ((offset & 0xf000) >> 12) | | ||
266 | ((offset & 0x0800) >> 1)); | ||
267 | *(u16 *)(loc + 2) = (u16)((lower & 0x8f00) | | ||
268 | ((offset & 0x0700) << 4) | | ||
269 | (offset & 0x00ff)); | ||
270 | break; | ||
271 | |||
240 | default: | 272 | default: |
241 | printk(KERN_ERR "%s: unknown relocation: %u\n", | 273 | printk(KERN_ERR "%s: unknown relocation: %u\n", |
242 | module->name, ELF32_R_TYPE(rel->r_info)); | 274 | module->name, ELF32_R_TYPE(rel->r_info)); |