diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-06 18:47:43 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-06 18:47:43 -0400 |
| commit | 75571d822dcc89729c7a72cb7bf3ee8568351089 (patch) | |
| tree | a2e424b0064d117c2c921bbb64e12d9363db3a20 | |
| parent | f725492dd16f516c2b67d7cee90b8619d09fd534 (diff) | |
| parent | f36e7495dd3990d6848e6d6703c78f1f17a97538 (diff) | |
Merge branch 'x86-build-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 build updates from Ingo Molnar:
"Misc updates:
- Add link flag quirk to solve LLVM linker bug that removes local
relocations, causing KASLR boot failures.
- Update the defconfigs to remove archaic partition table support
- Fix kernel growing pains: we had a bug in relocs.c handling section
header table entries count larger than 0xff00 (~65k), which can
happen with the -ffunction-sections flag, causing a build failure
with a cryptic error message. Add support for detecting the limit
and using the ELF protocol that extends the sections table via
->sh_size. The new limit is now much larger - over a billion
entries?"
* 'x86-build-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/tools/relocs: Fix big section header tables
x86/defconfig: Remove archaic partition tables support
x86/build: Keep local relocations with ld.lld
| -rw-r--r-- | arch/x86/Makefile | 2 | ||||
| -rw-r--r-- | arch/x86/configs/i386_defconfig | 12 | ||||
| -rw-r--r-- | arch/x86/configs/x86_64_defconfig | 12 | ||||
| -rw-r--r-- | arch/x86/tools/relocs.c | 74 |
4 files changed, 46 insertions, 54 deletions
diff --git a/arch/x86/Makefile b/arch/x86/Makefile index a587805c6687..56e748a7679f 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile | |||
| @@ -47,7 +47,7 @@ export REALMODE_CFLAGS | |||
| 47 | export BITS | 47 | export BITS |
| 48 | 48 | ||
| 49 | ifdef CONFIG_X86_NEED_RELOCS | 49 | ifdef CONFIG_X86_NEED_RELOCS |
| 50 | LDFLAGS_vmlinux := --emit-relocs | 50 | LDFLAGS_vmlinux := --emit-relocs --discard-none |
| 51 | endif | 51 | endif |
| 52 | 52 | ||
| 53 | # | 53 | # |
diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig index 9f908112bbb9..2b2481acc661 100644 --- a/arch/x86/configs/i386_defconfig +++ b/arch/x86/configs/i386_defconfig | |||
| @@ -25,18 +25,6 @@ CONFIG_JUMP_LABEL=y | |||
| 25 | CONFIG_MODULES=y | 25 | CONFIG_MODULES=y |
| 26 | CONFIG_MODULE_UNLOAD=y | 26 | CONFIG_MODULE_UNLOAD=y |
| 27 | CONFIG_MODULE_FORCE_UNLOAD=y | 27 | CONFIG_MODULE_FORCE_UNLOAD=y |
| 28 | CONFIG_PARTITION_ADVANCED=y | ||
| 29 | CONFIG_OSF_PARTITION=y | ||
| 30 | CONFIG_AMIGA_PARTITION=y | ||
| 31 | CONFIG_MAC_PARTITION=y | ||
| 32 | CONFIG_BSD_DISKLABEL=y | ||
| 33 | CONFIG_MINIX_SUBPARTITION=y | ||
| 34 | CONFIG_SOLARIS_X86_PARTITION=y | ||
| 35 | CONFIG_UNIXWARE_DISKLABEL=y | ||
| 36 | CONFIG_SGI_PARTITION=y | ||
| 37 | CONFIG_SUN_PARTITION=y | ||
| 38 | CONFIG_KARMA_PARTITION=y | ||
| 39 | CONFIG_EFI_PARTITION=y | ||
| 40 | CONFIG_SMP=y | 28 | CONFIG_SMP=y |
| 41 | CONFIG_X86_GENERIC=y | 29 | CONFIG_X86_GENERIC=y |
| 42 | CONFIG_HPET_TIMER=y | 30 | CONFIG_HPET_TIMER=y |
diff --git a/arch/x86/configs/x86_64_defconfig b/arch/x86/configs/x86_64_defconfig index 1d3badfda09e..e8829abf063a 100644 --- a/arch/x86/configs/x86_64_defconfig +++ b/arch/x86/configs/x86_64_defconfig | |||
| @@ -24,18 +24,6 @@ CONFIG_JUMP_LABEL=y | |||
| 24 | CONFIG_MODULES=y | 24 | CONFIG_MODULES=y |
| 25 | CONFIG_MODULE_UNLOAD=y | 25 | CONFIG_MODULE_UNLOAD=y |
| 26 | CONFIG_MODULE_FORCE_UNLOAD=y | 26 | CONFIG_MODULE_FORCE_UNLOAD=y |
| 27 | CONFIG_PARTITION_ADVANCED=y | ||
| 28 | CONFIG_OSF_PARTITION=y | ||
| 29 | CONFIG_AMIGA_PARTITION=y | ||
| 30 | CONFIG_MAC_PARTITION=y | ||
| 31 | CONFIG_BSD_DISKLABEL=y | ||
| 32 | CONFIG_MINIX_SUBPARTITION=y | ||
| 33 | CONFIG_SOLARIS_X86_PARTITION=y | ||
| 34 | CONFIG_UNIXWARE_DISKLABEL=y | ||
| 35 | CONFIG_SGI_PARTITION=y | ||
| 36 | CONFIG_SUN_PARTITION=y | ||
| 37 | CONFIG_KARMA_PARTITION=y | ||
| 38 | CONFIG_EFI_PARTITION=y | ||
| 39 | CONFIG_SMP=y | 27 | CONFIG_SMP=y |
| 40 | CONFIG_CALGARY_IOMMU=y | 28 | CONFIG_CALGARY_IOMMU=y |
| 41 | CONFIG_NR_CPUS=64 | 29 | CONFIG_NR_CPUS=64 |
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c index b629f6992d9f..f345586f5e50 100644 --- a/arch/x86/tools/relocs.c +++ b/arch/x86/tools/relocs.c | |||
| @@ -11,7 +11,9 @@ | |||
| 11 | #define Elf_Shdr ElfW(Shdr) | 11 | #define Elf_Shdr ElfW(Shdr) |
| 12 | #define Elf_Sym ElfW(Sym) | 12 | #define Elf_Sym ElfW(Sym) |
| 13 | 13 | ||
| 14 | static Elf_Ehdr ehdr; | 14 | static Elf_Ehdr ehdr; |
| 15 | static unsigned long shnum; | ||
| 16 | static unsigned int shstrndx; | ||
| 15 | 17 | ||
| 16 | struct relocs { | 18 | struct relocs { |
| 17 | uint32_t *offset; | 19 | uint32_t *offset; |
| @@ -241,9 +243,9 @@ static const char *sec_name(unsigned shndx) | |||
| 241 | { | 243 | { |
| 242 | const char *sec_strtab; | 244 | const char *sec_strtab; |
| 243 | const char *name; | 245 | const char *name; |
| 244 | sec_strtab = secs[ehdr.e_shstrndx].strtab; | 246 | sec_strtab = secs[shstrndx].strtab; |
| 245 | name = "<noname>"; | 247 | name = "<noname>"; |
| 246 | if (shndx < ehdr.e_shnum) { | 248 | if (shndx < shnum) { |
| 247 | name = sec_strtab + secs[shndx].shdr.sh_name; | 249 | name = sec_strtab + secs[shndx].shdr.sh_name; |
| 248 | } | 250 | } |
| 249 | else if (shndx == SHN_ABS) { | 251 | else if (shndx == SHN_ABS) { |
| @@ -271,7 +273,7 @@ static const char *sym_name(const char *sym_strtab, Elf_Sym *sym) | |||
| 271 | static Elf_Sym *sym_lookup(const char *symname) | 273 | static Elf_Sym *sym_lookup(const char *symname) |
| 272 | { | 274 | { |
| 273 | int i; | 275 | int i; |
| 274 | for (i = 0; i < ehdr.e_shnum; i++) { | 276 | for (i = 0; i < shnum; i++) { |
| 275 | struct section *sec = &secs[i]; | 277 | struct section *sec = &secs[i]; |
| 276 | long nsyms; | 278 | long nsyms; |
| 277 | char *strtab; | 279 | char *strtab; |
| @@ -366,27 +368,41 @@ static void read_ehdr(FILE *fp) | |||
| 366 | ehdr.e_shnum = elf_half_to_cpu(ehdr.e_shnum); | 368 | ehdr.e_shnum = elf_half_to_cpu(ehdr.e_shnum); |
| 367 | ehdr.e_shstrndx = elf_half_to_cpu(ehdr.e_shstrndx); | 369 | ehdr.e_shstrndx = elf_half_to_cpu(ehdr.e_shstrndx); |
| 368 | 370 | ||
| 369 | if ((ehdr.e_type != ET_EXEC) && (ehdr.e_type != ET_DYN)) { | 371 | shnum = ehdr.e_shnum; |
| 372 | shstrndx = ehdr.e_shstrndx; | ||
| 373 | |||
| 374 | if ((ehdr.e_type != ET_EXEC) && (ehdr.e_type != ET_DYN)) | ||
| 370 | die("Unsupported ELF header type\n"); | 375 | die("Unsupported ELF header type\n"); |
| 371 | } | 376 | if (ehdr.e_machine != ELF_MACHINE) |
| 372 | if (ehdr.e_machine != ELF_MACHINE) { | ||
| 373 | die("Not for %s\n", ELF_MACHINE_NAME); | 377 | die("Not for %s\n", ELF_MACHINE_NAME); |
| 374 | } | 378 | if (ehdr.e_version != EV_CURRENT) |
| 375 | if (ehdr.e_version != EV_CURRENT) { | ||
| 376 | die("Unknown ELF version\n"); | 379 | die("Unknown ELF version\n"); |
| 377 | } | 380 | if (ehdr.e_ehsize != sizeof(Elf_Ehdr)) |
| 378 | if (ehdr.e_ehsize != sizeof(Elf_Ehdr)) { | ||
| 379 | die("Bad Elf header size\n"); | 381 | die("Bad Elf header size\n"); |
| 380 | } | 382 | if (ehdr.e_phentsize != sizeof(Elf_Phdr)) |
| 381 | if (ehdr.e_phentsize != sizeof(Elf_Phdr)) { | ||
| 382 | die("Bad program header entry\n"); | 383 | die("Bad program header entry\n"); |
| 383 | } | 384 | if (ehdr.e_shentsize != sizeof(Elf_Shdr)) |
| 384 | if (ehdr.e_shentsize != sizeof(Elf_Shdr)) { | ||
| 385 | die("Bad section header entry\n"); | 385 | die("Bad section header entry\n"); |
| 386 | |||
| 387 | |||
| 388 | if (shnum == SHN_UNDEF || shstrndx == SHN_XINDEX) { | ||
| 389 | Elf_Shdr shdr; | ||
| 390 | |||
| 391 | if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) | ||
| 392 | die("Seek to %d failed: %s\n", ehdr.e_shoff, strerror(errno)); | ||
| 393 | |||
| 394 | if (fread(&shdr, sizeof(shdr), 1, fp) != 1) | ||
| 395 | die("Cannot read initial ELF section header: %s\n", strerror(errno)); | ||
| 396 | |||
| 397 | if (shnum == SHN_UNDEF) | ||
| 398 | shnum = elf_xword_to_cpu(shdr.sh_size); | ||
| 399 | |||
| 400 | if (shstrndx == SHN_XINDEX) | ||
| 401 | shstrndx = elf_word_to_cpu(shdr.sh_link); | ||
| 386 | } | 402 | } |
| 387 | if (ehdr.e_shstrndx >= ehdr.e_shnum) { | 403 | |
| 404 | if (shstrndx >= shnum) | ||
| 388 | die("String table index out of bounds\n"); | 405 | die("String table index out of bounds\n"); |
| 389 | } | ||
| 390 | } | 406 | } |
| 391 | 407 | ||
| 392 | static void read_shdrs(FILE *fp) | 408 | static void read_shdrs(FILE *fp) |
| @@ -394,20 +410,20 @@ static void read_shdrs(FILE *fp) | |||
| 394 | int i; | 410 | int i; |
| 395 | Elf_Shdr shdr; | 411 | Elf_Shdr shdr; |
| 396 | 412 | ||
| 397 | secs = calloc(ehdr.e_shnum, sizeof(struct section)); | 413 | secs = calloc(shnum, sizeof(struct section)); |
| 398 | if (!secs) { | 414 | if (!secs) { |
| 399 | die("Unable to allocate %d section headers\n", | 415 | die("Unable to allocate %d section headers\n", |
| 400 | ehdr.e_shnum); | 416 | shnum); |
| 401 | } | 417 | } |
| 402 | if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) { | 418 | if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) { |
| 403 | die("Seek to %d failed: %s\n", | 419 | die("Seek to %d failed: %s\n", |
| 404 | ehdr.e_shoff, strerror(errno)); | 420 | ehdr.e_shoff, strerror(errno)); |
| 405 | } | 421 | } |
| 406 | for (i = 0; i < ehdr.e_shnum; i++) { | 422 | for (i = 0; i < shnum; i++) { |
| 407 | struct section *sec = &secs[i]; | 423 | struct section *sec = &secs[i]; |
| 408 | if (fread(&shdr, sizeof(shdr), 1, fp) != 1) | 424 | if (fread(&shdr, sizeof(shdr), 1, fp) != 1) |
| 409 | die("Cannot read ELF section headers %d/%d: %s\n", | 425 | die("Cannot read ELF section headers %d/%d: %s\n", |
| 410 | i, ehdr.e_shnum, strerror(errno)); | 426 | i, shnum, strerror(errno)); |
| 411 | sec->shdr.sh_name = elf_word_to_cpu(shdr.sh_name); | 427 | sec->shdr.sh_name = elf_word_to_cpu(shdr.sh_name); |
| 412 | sec->shdr.sh_type = elf_word_to_cpu(shdr.sh_type); | 428 | sec->shdr.sh_type = elf_word_to_cpu(shdr.sh_type); |
| 413 | sec->shdr.sh_flags = elf_xword_to_cpu(shdr.sh_flags); | 429 | sec->shdr.sh_flags = elf_xword_to_cpu(shdr.sh_flags); |
| @@ -418,7 +434,7 @@ static void read_shdrs(FILE *fp) | |||
| 418 | sec->shdr.sh_info = elf_word_to_cpu(shdr.sh_info); | 434 | sec->shdr.sh_info = elf_word_to_cpu(shdr.sh_info); |
| 419 | sec->shdr.sh_addralign = elf_xword_to_cpu(shdr.sh_addralign); | 435 | sec->shdr.sh_addralign = elf_xword_to_cpu(shdr.sh_addralign); |
| 420 | sec->shdr.sh_entsize = elf_xword_to_cpu(shdr.sh_entsize); | 436 | sec->shdr.sh_entsize = elf_xword_to_cpu(shdr.sh_entsize); |
| 421 | if (sec->shdr.sh_link < ehdr.e_shnum) | 437 | if (sec->shdr.sh_link < shnum) |
| 422 | sec->link = &secs[sec->shdr.sh_link]; | 438 | sec->link = &secs[sec->shdr.sh_link]; |
| 423 | } | 439 | } |
| 424 | 440 | ||
| @@ -427,7 +443,7 @@ static void read_shdrs(FILE *fp) | |||
| 427 | static void read_strtabs(FILE *fp) | 443 | static void read_strtabs(FILE *fp) |
| 428 | { | 444 | { |
| 429 | int i; | 445 | int i; |
| 430 | for (i = 0; i < ehdr.e_shnum; i++) { | 446 | for (i = 0; i < shnum; i++) { |
| 431 | struct section *sec = &secs[i]; | 447 | struct section *sec = &secs[i]; |
| 432 | if (sec->shdr.sh_type != SHT_STRTAB) { | 448 | if (sec->shdr.sh_type != SHT_STRTAB) { |
| 433 | continue; | 449 | continue; |
| @@ -452,7 +468,7 @@ static void read_strtabs(FILE *fp) | |||
| 452 | static void read_symtabs(FILE *fp) | 468 | static void read_symtabs(FILE *fp) |
| 453 | { | 469 | { |
| 454 | int i,j; | 470 | int i,j; |
| 455 | for (i = 0; i < ehdr.e_shnum; i++) { | 471 | for (i = 0; i < shnum; i++) { |
| 456 | struct section *sec = &secs[i]; | 472 | struct section *sec = &secs[i]; |
| 457 | if (sec->shdr.sh_type != SHT_SYMTAB) { | 473 | if (sec->shdr.sh_type != SHT_SYMTAB) { |
| 458 | continue; | 474 | continue; |
| @@ -485,7 +501,7 @@ static void read_symtabs(FILE *fp) | |||
| 485 | static void read_relocs(FILE *fp) | 501 | static void read_relocs(FILE *fp) |
| 486 | { | 502 | { |
| 487 | int i,j; | 503 | int i,j; |
| 488 | for (i = 0; i < ehdr.e_shnum; i++) { | 504 | for (i = 0; i < shnum; i++) { |
| 489 | struct section *sec = &secs[i]; | 505 | struct section *sec = &secs[i]; |
| 490 | if (sec->shdr.sh_type != SHT_REL_TYPE) { | 506 | if (sec->shdr.sh_type != SHT_REL_TYPE) { |
| 491 | continue; | 507 | continue; |
| @@ -528,7 +544,7 @@ static void print_absolute_symbols(void) | |||
| 528 | 544 | ||
| 529 | printf("Absolute symbols\n"); | 545 | printf("Absolute symbols\n"); |
| 530 | printf(" Num: Value Size Type Bind Visibility Name\n"); | 546 | printf(" Num: Value Size Type Bind Visibility Name\n"); |
| 531 | for (i = 0; i < ehdr.e_shnum; i++) { | 547 | for (i = 0; i < shnum; i++) { |
| 532 | struct section *sec = &secs[i]; | 548 | struct section *sec = &secs[i]; |
| 533 | char *sym_strtab; | 549 | char *sym_strtab; |
| 534 | int j; | 550 | int j; |
| @@ -566,7 +582,7 @@ static void print_absolute_relocs(void) | |||
| 566 | else | 582 | else |
| 567 | format = "%08"PRIx32" %08"PRIx32" %10s %08"PRIx32" %s\n"; | 583 | format = "%08"PRIx32" %08"PRIx32" %10s %08"PRIx32" %s\n"; |
| 568 | 584 | ||
| 569 | for (i = 0; i < ehdr.e_shnum; i++) { | 585 | for (i = 0; i < shnum; i++) { |
| 570 | struct section *sec = &secs[i]; | 586 | struct section *sec = &secs[i]; |
| 571 | struct section *sec_applies, *sec_symtab; | 587 | struct section *sec_applies, *sec_symtab; |
| 572 | char *sym_strtab; | 588 | char *sym_strtab; |
| @@ -650,7 +666,7 @@ static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel, | |||
| 650 | { | 666 | { |
| 651 | int i; | 667 | int i; |
| 652 | /* Walk through the relocations */ | 668 | /* Walk through the relocations */ |
| 653 | for (i = 0; i < ehdr.e_shnum; i++) { | 669 | for (i = 0; i < shnum; i++) { |
| 654 | char *sym_strtab; | 670 | char *sym_strtab; |
| 655 | Elf_Sym *sh_symtab; | 671 | Elf_Sym *sh_symtab; |
| 656 | struct section *sec_applies, *sec_symtab; | 672 | struct section *sec_applies, *sec_symtab; |
| @@ -706,7 +722,7 @@ static Elf_Addr per_cpu_load_addr; | |||
| 706 | static void percpu_init(void) | 722 | static void percpu_init(void) |
| 707 | { | 723 | { |
| 708 | int i; | 724 | int i; |
| 709 | for (i = 0; i < ehdr.e_shnum; i++) { | 725 | for (i = 0; i < shnum; i++) { |
| 710 | ElfW(Sym) *sym; | 726 | ElfW(Sym) *sym; |
| 711 | if (strcmp(sec_name(i), ".data..percpu")) | 727 | if (strcmp(sec_name(i), ".data..percpu")) |
| 712 | continue; | 728 | continue; |
