Skip to content

Commit 21a48ff

Browse files
author
Alex Shi
committed
Merge tag 'lsk-v4.4-arm64-v4.8-kaslr-updates' of git://git.linaro.org/people/ard.biesheuvel/linux-arm into v4.4/topic/mm-kaslr
2 parents 3d27bcb + f56fa8c commit 21a48ff

3 files changed

Lines changed: 6 additions & 30 deletions

File tree

arch/arm64/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ OBJCOPYFLAGS :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
1616
GZFLAGS :=-9
1717

1818
ifneq ($(CONFIG_RELOCATABLE),)
19-
LDFLAGS_vmlinux += -pie
19+
LDFLAGS_vmlinux += -pie -Bsymbolic
2020
endif
2121

2222
KBUILD_DEFCONFIG := defconfig

arch/arm64/kernel/head.S

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -717,40 +717,25 @@ __primary_switch:
717717
* Iterate over each entry in the relocation table, and apply the
718718
* relocations in place.
719719
*/
720-
ldr w8, =__dynsym_offset // offset to symbol table
721720
ldr w9, =__rela_offset // offset to reloc table
722721
ldr w10, =__rela_size // size of reloc table
723722

724723
mov_q x11, KIMAGE_VADDR // default virtual offset
725724
add x11, x11, x23 // actual virtual offset
726-
add x8, x8, x11 // __va(.dynsym)
727725
add x9, x9, x11 // __va(.rela)
728726
add x10, x9, x10 // __va(.rela) + sizeof(.rela)
729727

730728
0: cmp x9, x10
731-
b.hs 2f
729+
b.hs 1f
732730
ldp x11, x12, [x9], #24
733731
ldr x13, [x9, #-8]
734732
cmp w12, #R_AARCH64_RELATIVE
735-
b.ne 1f
733+
b.ne 0b
736734
add x13, x13, x23 // relocate
737735
str x13, [x11, x23]
738736
b 0b
739737

740-
1: cmp w12, #R_AARCH64_ABS64
741-
b.ne 0b
742-
add x12, x12, x12, lsl #1 // symtab offset: 24x top word
743-
add x12, x8, x12, lsr #(32 - 3) // ... shifted into bottom word
744-
ldrsh w14, [x12, #6] // Elf64_Sym::st_shndx
745-
ldr x15, [x12, #8] // Elf64_Sym::st_value
746-
cmp w14, #-0xf // SHN_ABS (0xfff1) ?
747-
add x14, x15, x23 // relocate
748-
csel x15, x14, x15, ne
749-
add x15, x13, x15
750-
str x15, [x11, x23]
751-
b 0b
752-
753-
2:
738+
1:
754739
#endif
755740
ldr x8, =__primary_switched
756741
br x8

arch/arm64/kernel/vmlinux.lds.S

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ SECTIONS
9393
*(.discard)
9494
*(.discard.*)
9595
*(.interp .dynamic)
96+
*(.dynsym .dynstr .hash)
9697
}
9798

9899
. = KIMAGE_VADDR + TEXT_OFFSET;
@@ -158,19 +159,9 @@ SECTIONS
158159
.rela : ALIGN(8) {
159160
*(.rela .rela*)
160161
}
161-
.dynsym : ALIGN(8) {
162-
*(.dynsym)
163-
}
164-
.dynstr : {
165-
*(.dynstr)
166-
}
167-
.hash : {
168-
*(.hash)
169-
}
170162

171-
__rela_offset = ADDR(.rela) - KIMAGE_VADDR;
163+
__rela_offset = ABSOLUTE(ADDR(.rela) - KIMAGE_VADDR);
172164
__rela_size = SIZEOF(.rela);
173-
__dynsym_offset = ADDR(.dynsym) - KIMAGE_VADDR;
174165

175166
. = ALIGN(SEGMENT_ALIGN);
176167
__init_end = .;

0 commit comments

Comments
 (0)