]> git.neil.brown.name Git - history.git/commitdiff
kbuild: Put .bss back to the end of vmlinux
authorKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Sat, 5 Oct 2002 12:20:36 +0000 (07:20 -0500)
committerKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Sat, 5 Oct 2002 12:20:36 +0000 (07:20 -0500)
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.

Makefile
arch/i386/vmlinux.lds.S
kernel/kallsyms.c

index b2550568e5c6c6a8331e12251da816daf7d92e74..ce499cba9376a590247727dc7ff15e73fbcfe400 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -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)
index 3afaad74bf2fe91c264ee4404d4ad1216afc303a..09570eab04d8b250f9cba884f1385cbec32c5dc1 100644 (file)
@@ -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 */
index 3c168c77d3fee90b11d02ef1b1d58ec4ce952d69..36d2da107b751f5ff6098a56dff654117ed7d3bc 100644 (file)
@@ -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");