Allow the "--kaslr=<offset>" and/or "--kaslr=auto" command line

options to be used with the 32-bit X86 architecture.
(anderson@redhat.com)
This commit is contained in:
Dave Anderson 2017-02-17 15:01:06 -05:00
parent fc9c517acd
commit e4fbec3d41
3 changed files with 9 additions and 5 deletions

4
help.c
View File

@ -331,8 +331,8 @@ char *program_usage_info[] = {
" and verification. The default count is 32768.",
"",
" --kaslr offset | auto",
" If an x86_64 kernel was configured with CONFIG_RANDOMIZE_BASE, the",
" offset value is equal to the difference between the symbol values ",
" If an x86 or x86_64 kernel was configured with CONFIG_RANDOMIZE_BASE,",
" the offset value is equal to the difference between the symbol values ",
" compiled into the vmlinux file and their relocated KASLR value. If",
" set to auto, the KASLR offset value will be automatically calculated.",
"",

2
main.c
View File

@ -228,7 +228,7 @@ main(int argc, char **argv)
}
} else if (STREQ(long_options[option_index].name, "kaslr")) {
if (!machine_type("X86_64") &&
!machine_type("ARM64"))
!machine_type("ARM64") && !machine_type("X86"))
error(INFO, "--kaslr not valid "
"with this machine type.\n");
else if (STREQ(optarg, "auto"))

View File

@ -594,7 +594,7 @@ kaslr_init(void)
{
char *string;
if ((!machine_type("X86_64") && !machine_type("ARM64")) ||
if ((!machine_type("X86_64") && !machine_type("ARM64") && !machine_type("X86")) ||
(kt->flags & RELOC_SET))
return;
@ -712,7 +712,11 @@ store_symbols(bfd *abfd, int dynamic, void *minisyms, long symcount,
fromend = from + symcount * size;
if (machine_type("X86")) {
if (!(kt->flags & RELOC_SET))
if (kt->flags2 & KASLR) {
if ((kt->flags2 & RELOC_AUTO) && !(kt->flags & RELOC_SET))
derive_kaslr_offset(abfd, dynamic, from,
fromend, size, store);
} else if (!(kt->flags & RELOC_SET))
kt->flags |= RELOC_FORCE;
} else if (machine_type("X86_64") || machine_type("ARM64")) {
if ((kt->flags2 & RELOC_AUTO) && !(kt->flags & RELOC_SET))