Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MN10300: Fix application of kernel module relocations

This fixes the MN10300 kernel module linking to match the toolchain. RELA
relocs don't use the value at the location being relocated. This has been
working because the tools always leave the value at the target location
cleared.

Signed-off-by: Mark Salter <msalter@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Mark Salter and committed by
Linus Torvalds
1122b19b 026bde12

+7 -28
+7 -28
arch/mn10300/kernel/module.c
··· 1 1 /* MN10300 Kernel module helper routines 2 2 * 3 - * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. 3 + * Copyright (C) 2007, 2008 Red Hat, Inc. All Rights Reserved. 4 4 * Written by Mark Salter (msalter@redhat.com) 5 5 * - Derived from arch/i386/kernel/module.c 6 6 * ··· 62 62 struct module *mod) 63 63 { 64 64 return 0; 65 - } 66 - 67 - static uint32_t reloc_get16(uint8_t *p) 68 - { 69 - return p[0] | (p[1] << 8); 70 - } 71 - 72 - static uint32_t reloc_get24(uint8_t *p) 73 - { 74 - return reloc_get16(p) | (p[2] << 16); 75 - } 76 - 77 - static uint32_t reloc_get32(uint8_t *p) 78 - { 79 - return reloc_get16(p) | (reloc_get16(p+2) << 16); 80 65 } 81 66 82 67 static void reloc_put16(uint8_t *p, uint32_t val) ··· 129 144 relocation = sym->st_value + rel[i].r_addend; 130 145 131 146 switch (ELF32_R_TYPE(rel[i].r_info)) { 132 - /* for the first four relocation types, we add the 133 - * adjustment into the value at the location given */ 147 + /* for the first four relocation types, we simply 148 + * store the adjustment at the location given */ 134 149 case R_MN10300_32: 135 - value = reloc_get32(location); 136 - value += relocation; 137 - reloc_put32(location, value); 150 + reloc_put32(location, relocation); 138 151 break; 139 152 case R_MN10300_24: 140 - value = reloc_get24(location); 141 - value += relocation; 142 - reloc_put24(location, value); 153 + reloc_put24(location, relocation); 143 154 break; 144 155 case R_MN10300_16: 145 - value = reloc_get16(location); 146 - value += relocation; 147 - reloc_put16(location, value); 156 + reloc_put16(location, relocation); 148 157 break; 149 158 case R_MN10300_8: 150 - *location += relocation; 159 + *location = relocation; 151 160 break; 152 161 153 162 /* for the next three relocation types, we write the