Commit 345af2c9 authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Put .bss back to the end of vmlinux

The kallsyms patches added __kallsyms as last section into vmlinux,
behind .bss.

This was done to save two additional kallsyms passes, since as the
added section was last, it did not change the symbols before it.

With the new infrastructure in the top-level Makefile, we do not need
to do full relinks for these passes, so they are cheaper. We now
use one additional link/kallsyms run to be able to place the __kallsyms
section before .bss. The other pass is saved by adding an empty but 
allocated __kallsyms section in kernel/kallsyms.c, so the first kallsyms
pass already generates a section of the final size.
parent 8cc7a297
......@@ -312,15 +312,28 @@ endef
LDFLAGS_vmlinux += -T arch/$(ARCH)/vmlinux.lds.s
# Generate section listing all symbols and add it into vmlinux
# It's a three stage process:
# o .tmp_vmlinux has all symbols and sections, but __kallsyms is
# empty
# Running kallsyms on that gives as .tmp_kallsyms1.o with
# the right size
# o .tmp_vmlinux1 now has a __kallsyms section of the right size,
# but due to the added section, some addresses have shifted
# From here, we generate a correct .tmp_kallsyms.o
# o The correct .tmp_kallsyms.o is linked into the final vmlinux
# below.
ifdef CONFIG_KALLSYMS
final-objs += .tmp_kallsyms.o
quiet_cmd_kallsyms = KSYM $@
define cmd_kallsyms
$(KALLSYMS) $< > $@
endef
cmd_kallsyms = \
$(KALLSYMS) $< > .tmp_kallsyms1.o; \
$(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) .tmp_vmlinux .tmp_kallsyms1.o \
-o .tmp_vmlinux1; \
$(KALLSYMS) .tmp_vmlinux1 > $@; \
rm -f .tmp_kallsyms1.o .tmp_vmlinux1
.tmp_kallsyms.o: .tmp_vmlinux
$(call cmd,kallsyms)
......
......@@ -78,14 +78,14 @@ SECTIONS
. = ALIGN(32);
.data.cacheline_aligned : { *(.data.cacheline_aligned) }
__bss_start = .; /* BSS */
.bss : { *(.bss) }
__bss_stop = .;
__start___kallsyms = .; /* All kernel symbols */
__kallsyms : { *(__kallsyms) }
__stop___kallsyms = .;
__bss_start = .; /* BSS */
.bss : { *(.bss) }
__bss_stop = .;
_end = . ;
/* Sections to be discarded */
......
......@@ -225,3 +225,9 @@ int kallsyms_sections(void *token,
}
return(1);
}
/* Allocate the __kallsyms section, so it's already present in
* the temporary vmlinux that kallsyms is run on, so the first
* run will pick up the section info already. */
__asm__(".section __kallsyms,\"a\"\n.previous");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment