Skip to content

Commit b9b32bf

Browse files
author
Russell King
committed
ARM: use linker magic for vectors and vector stubs
Use linker magic to create the vectors and vector stubs: we can tell the linker to place them at an appropriate VMA, but keep the LMA within the kernel. This gets rid of some unnecessary symbol manipulation, and have the linker calculate the relocations appropriately. Cc: <stable@vger.kernel.org> Acked-by: Nicolas Pitre <nico@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 19accfd commit b9b32bf

2 files changed

Lines changed: 27 additions & 18 deletions

File tree

‎arch/arm/kernel/entry-armv.S‎

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ ENDPROC(vector_\name)
993993
1:
994994
.endm
995995

996-
.globl __stubs_start
996+
.section .stubs, "ax", %progbits
997997
__stubs_start:
998998
@ This must be the first word
999999
.word vector_swi
@@ -1120,24 +1120,16 @@ vector_addrexcptn:
11201120
vector_fiq:
11211121
subs pc, lr, #4
11221122

1123-
.globl __stubs_end
1124-
__stubs_end:
1125-
1126-
.equ stubs_offset, __vectors_start + 0x1000 - __stubs_start
1127-
1128-
.globl __vectors_start
1123+
.section .vectors, "ax", %progbits
11291124
__vectors_start:
1130-
W(b) vector_rst + stubs_offset
1131-
W(b) vector_und + stubs_offset
1132-
W(ldr) pc, .LCvswi + stubs_offset
1133-
W(b) vector_pabt + stubs_offset
1134-
W(b) vector_dabt + stubs_offset
1135-
W(b) vector_addrexcptn + stubs_offset
1136-
W(b) vector_irq + stubs_offset
1137-
W(b) vector_fiq + stubs_offset
1138-
1139-
.globl __vectors_end
1140-
__vectors_end:
1125+
W(b) vector_rst
1126+
W(b) vector_und
1127+
W(ldr) pc, __vectors_start + 0x1000
1128+
W(b) vector_pabt
1129+
W(b) vector_dabt
1130+
W(b) vector_addrexcptn
1131+
W(b) vector_irq
1132+
W(b) vector_fiq
11411133

11421134
.data
11431135

‎arch/arm/kernel/vmlinux.lds.S‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,23 @@ SECTIONS
148148
. = ALIGN(PAGE_SIZE);
149149
__init_begin = .;
150150
#endif
151+
/*
152+
* The vectors and stubs are relocatable code, and the
153+
* only thing that matters is their relative offsets
154+
*/
155+
__vectors_start = .;
156+
.vectors 0 : AT(__vectors_start) {
157+
*(.vectors)
158+
}
159+
. = __vectors_start + SIZEOF(.vectors);
160+
__vectors_end = .;
161+
162+
__stubs_start = .;
163+
.stubs 0x1000 : AT(__stubs_start) {
164+
*(.stubs)
165+
}
166+
. = __stubs_start + SIZEOF(.stubs);
167+
__stubs_end = .;
151168

152169
INIT_TEXT_SECTION(8)
153170
.exit.text : {

0 commit comments

Comments
 (0)