diff options
author | Jon Medhurst <tixy@linaro.org> | 2014-09-30 05:25:10 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-09-30 11:55:24 -0400 |
commit | ad684dce87fac52738649e62b4afa25081b52a28 (patch) | |
tree | 42b37e2d471f9cdecc61018217cb4ad771f63149 /arch | |
parent | 9cc6d9e5daaa147a9a3e31557efcb331989e77be (diff) |
ARM: 8179/1: kprobes-test: Fix compile error "bad immediate value for offset"
When compiling kprobes-test-arm.c the following error has been observed
/tmp/ccoT403o.s:21439: Error: bad immediate value for offset (4168)
This is caused by the compiler spilling it's literal pool too far away
from the site which is trying to reference it with a PC relative load.
This arises because the compiler is underestimating the size of the
inline assembler code present, which apparently it approximates as 4
bytes per line or instruction.
We fix this problem by moving the operations which generate more than
4 bytes out of the text section. Specifically, moving the .ascii
directives to the .rodata section.
Signed-off-by: Jon Medhurst <tixy@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/kernel/kprobes-test.c | 16 | ||||
-rw-r--r-- | arch/arm/kernel/kprobes-test.h | 5 |
2 files changed, 13 insertions, 8 deletions
diff --git a/arch/arm/kernel/kprobes-test.c b/arch/arm/kernel/kprobes-test.c index 08d731294bcd..b206d7790c77 100644 --- a/arch/arm/kernel/kprobes-test.c +++ b/arch/arm/kernel/kprobes-test.c | |||
@@ -110,10 +110,13 @@ | |||
110 | * | 110 | * |
111 | * @ TESTCASE_START | 111 | * @ TESTCASE_START |
112 | * bl __kprobes_test_case_start | 112 | * bl __kprobes_test_case_start |
113 | * @ start of inline data... | 113 | * .pushsection .rodata |
114 | * "10: | ||
114 | * .ascii "mov r0, r7" @ text title for test case | 115 | * .ascii "mov r0, r7" @ text title for test case |
115 | * .byte 0 | 116 | * .byte 0 |
116 | * .align 2, 0 | 117 | * .popsection |
118 | * @ start of inline data... | ||
119 | * .word 10b @ pointer to title in .rodata section | ||
117 | * | 120 | * |
118 | * @ TEST_ARG_REG | 121 | * @ TEST_ARG_REG |
119 | * .byte ARG_TYPE_REG | 122 | * .byte ARG_TYPE_REG |
@@ -971,7 +974,7 @@ void __naked __kprobes_test_case_start(void) | |||
971 | __asm__ __volatile__ ( | 974 | __asm__ __volatile__ ( |
972 | "stmdb sp!, {r4-r11} \n\t" | 975 | "stmdb sp!, {r4-r11} \n\t" |
973 | "sub sp, sp, #"__stringify(TEST_MEMORY_SIZE)"\n\t" | 976 | "sub sp, sp, #"__stringify(TEST_MEMORY_SIZE)"\n\t" |
974 | "bic r0, lr, #1 @ r0 = inline title string \n\t" | 977 | "bic r0, lr, #1 @ r0 = inline data \n\t" |
975 | "mov r1, sp \n\t" | 978 | "mov r1, sp \n\t" |
976 | "bl kprobes_test_case_start \n\t" | 979 | "bl kprobes_test_case_start \n\t" |
977 | "bx r0 \n\t" | 980 | "bx r0 \n\t" |
@@ -1349,15 +1352,14 @@ static unsigned long next_instruction(unsigned long pc) | |||
1349 | return pc + 4; | 1352 | return pc + 4; |
1350 | } | 1353 | } |
1351 | 1354 | ||
1352 | static uintptr_t __used kprobes_test_case_start(const char *title, void *stack) | 1355 | static uintptr_t __used kprobes_test_case_start(const char **title, void *stack) |
1353 | { | 1356 | { |
1354 | struct test_arg *args; | 1357 | struct test_arg *args; |
1355 | struct test_arg_end *end_arg; | 1358 | struct test_arg_end *end_arg; |
1356 | unsigned long test_code; | 1359 | unsigned long test_code; |
1357 | 1360 | ||
1358 | args = (struct test_arg *)PTR_ALIGN(title + strlen(title) + 1, 4); | 1361 | current_title = *title++; |
1359 | 1362 | args = (struct test_arg *)title; | |
1360 | current_title = title; | ||
1361 | current_args = args; | 1363 | current_args = args; |
1362 | current_stack = stack; | 1364 | current_stack = stack; |
1363 | 1365 | ||
diff --git a/arch/arm/kernel/kprobes-test.h b/arch/arm/kernel/kprobes-test.h index eecc90a0fd91..4430990e90e7 100644 --- a/arch/arm/kernel/kprobes-test.h +++ b/arch/arm/kernel/kprobes-test.h | |||
@@ -111,11 +111,14 @@ struct test_arg_end { | |||
111 | #define TESTCASE_START(title) \ | 111 | #define TESTCASE_START(title) \ |
112 | __asm__ __volatile__ ( \ | 112 | __asm__ __volatile__ ( \ |
113 | "bl __kprobes_test_case_start \n\t" \ | 113 | "bl __kprobes_test_case_start \n\t" \ |
114 | ".pushsection .rodata \n\t" \ | ||
115 | "10: \n\t" \ | ||
114 | /* don't use .asciz here as 'title' may be */ \ | 116 | /* don't use .asciz here as 'title' may be */ \ |
115 | /* multiple strings to be concatenated. */ \ | 117 | /* multiple strings to be concatenated. */ \ |
116 | ".ascii "#title" \n\t" \ | 118 | ".ascii "#title" \n\t" \ |
117 | ".byte 0 \n\t" \ | 119 | ".byte 0 \n\t" \ |
118 | ".align 2, 0 \n\t" | 120 | ".popsection \n\t" \ |
121 | ".word 10b \n\t" | ||
119 | 122 | ||
120 | #define TEST_ARG_REG(reg, val) \ | 123 | #define TEST_ARG_REG(reg, val) \ |
121 | ".byte "__stringify(ARG_TYPE_REG)" \n\t" \ | 124 | ".byte "__stringify(ARG_TYPE_REG)" \n\t" \ |