diff options
author | Mark Salter <msalter@redhat.com> | 2008-12-02 09:38:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-02 18:52:07 -0500 |
commit | 1122b19b8f4da2ee6d6b21780f86bea7957f641e (patch) | |
tree | bcdd0d1c4d12019bbf3a38f1d0d9147310bb11a0 /arch/mn10300 | |
parent | 026bde120a161d9035502a47dd311bd572f6d31f (diff) |
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>
Diffstat (limited to 'arch/mn10300')
-rw-r--r-- | arch/mn10300/kernel/module.c | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/arch/mn10300/kernel/module.c b/arch/mn10300/kernel/module.c index 8fa36893df7a..6b287f2e8e84 100644 --- a/arch/mn10300/kernel/module.c +++ b/arch/mn10300/kernel/module.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* MN10300 Kernel module helper routines | 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 | * Written by Mark Salter (msalter@redhat.com) | 4 | * Written by Mark Salter (msalter@redhat.com) |
5 | * - Derived from arch/i386/kernel/module.c | 5 | * - Derived from arch/i386/kernel/module.c |
6 | * | 6 | * |
@@ -64,21 +64,6 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, | |||
64 | return 0; | 64 | return 0; |
65 | } | 65 | } |
66 | 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 | } | ||
81 | |||
82 | static void reloc_put16(uint8_t *p, uint32_t val) | 67 | static void reloc_put16(uint8_t *p, uint32_t val) |
83 | { | 68 | { |
84 | p[0] = val & 0xff; | 69 | p[0] = val & 0xff; |
@@ -144,25 +129,19 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, | |||
144 | relocation = sym->st_value + rel[i].r_addend; | 129 | relocation = sym->st_value + rel[i].r_addend; |
145 | 130 | ||
146 | switch (ELF32_R_TYPE(rel[i].r_info)) { | 131 | switch (ELF32_R_TYPE(rel[i].r_info)) { |
147 | /* for the first four relocation types, we add the | 132 | /* for the first four relocation types, we simply |
148 | * adjustment into the value at the location given */ | 133 | * store the adjustment at the location given */ |
149 | case R_MN10300_32: | 134 | case R_MN10300_32: |
150 | value = reloc_get32(location); | 135 | reloc_put32(location, relocation); |
151 | value += relocation; | ||
152 | reloc_put32(location, value); | ||
153 | break; | 136 | break; |
154 | case R_MN10300_24: | 137 | case R_MN10300_24: |
155 | value = reloc_get24(location); | 138 | reloc_put24(location, relocation); |
156 | value += relocation; | ||
157 | reloc_put24(location, value); | ||
158 | break; | 139 | break; |
159 | case R_MN10300_16: | 140 | case R_MN10300_16: |
160 | value = reloc_get16(location); | 141 | reloc_put16(location, relocation); |
161 | value += relocation; | ||
162 | reloc_put16(location, value); | ||
163 | break; | 142 | break; |
164 | case R_MN10300_8: | 143 | case R_MN10300_8: |
165 | *location += relocation; | 144 | *location = relocation; |
166 | break; | 145 | break; |
167 | 146 | ||
168 | /* for the next three relocation types, we write the | 147 | /* for the next three relocation types, we write the |