Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Dec 2010 20:58:07 +0530
From:      "Jayachandran C." <c.jayachandran@gmail.com>
To:        freebsd-mips@freebsd.org, gonzo@freebsd.org
Subject:   Cleanup for ELF trampoline code.
Message-ID:  <AANLkTimX_zdB7=OUAyjmQEcfK8V_fe0qZj9M7HDMq3g4@mail.gmail.com>

index | next in thread | raw e-mail

[-- Attachment #1 --]
I've attached a patch which cleans up sys/conf/Makefile.mips a bit,
the changes are:
- don't use -shared flag for the trampoline binary, now we generate a
shared obj, elf executable would be a better choice.
- don't generate tmphack.S,  move the code to sys/mips/mips/inckern.S
- don't generate opt_kernname.h, pass KERNNAME with -D

Please let me know your comments. I'm not sure which other platforms
use the elf trampoline code, let me know if this will break any
platform.

Thanks,
JC

[-- Attachment #2 --]
Index: sys/conf/Makefile.mips
===================================================================
--- sys/conf/Makefile.mips	(revision 216318)
+++ sys/conf/Makefile.mips	(working copy)
@@ -50,6 +50,7 @@
 # is extremely poor, as well as -mno-abicalls to force no ABI usage.
 CFLAGS+=${EXTRA_FLAGS} $(ARCH_FLAGS)
 HACK_EXTRA_FLAGS+=${EXTRA_FLAGS} $(ARCH_FLAGS)
+TRAMP_EXTRA_FLAGS=${EXTRA_FLAGS} $(ARCH_FLAGS)
 
 # XXX hardcoded kernel entry point
 ASM_CFLAGS+=${CFLAGS} -D_LOCORE -DLOCORE
@@ -62,21 +63,10 @@
 	-g --strip-symbol '$$t' ${FULLKERNEL} ${KERNEL_KO}.tmp
 	sed s/${KERNLOADADDR}/${TRAMPLOADADDR}/ ${LDSCRIPT_NAME} | \
 		sed s/" + SIZEOF_HEADERS"//  > ${LDSCRIPT_NAME}.tramp.noheader
-	# Generate .S file that setups stack and jumps to trampoline
-	echo "#include <machine/asm.h>" >tmphack.S
-	echo "ENTRY(_start)" >>tmphack.S
-	echo "PTR_LA t0, kernel_end" >>tmphack.S
-	echo "move sp, t0" >>tmphack.S
-	echo "add sp, 0x2000" >>tmphack.S
-	echo "and sp, ~0x7" >>tmphack.S
-	echo "PTR_LA t0, _startC" >>tmphack.S
-	echo "j t0" >>tmphack.S
-	echo "END(_start)" >>tmphack.S
-	echo "#define KERNNAME \"${KERNEL_KO}.tmp\""  >opt_kernname.h 
-	${CC} -O -nostdlib -I. -I$S ${HACK_EXTRA_FLAGS} ${TRAMP_LDFLAGS} -Xlinker \
-		-T -Xlinker ${LDSCRIPT_NAME}.tramp.noheader tmphack.S \
-		$S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \
-		-o ${KERNEL_KO}.tramp.noheader 
+	${CC} -O -nostdlib -I. -I$S ${TRAMP_EXTRA_FLAGS} ${TRAMP_LDFLAGS} -Xlinker \
+		-T -Xlinker ${LDSCRIPT_NAME}.tramp.noheader  \
+		-DKERNNAME="\"${KERNEL_KO}.tmp\"" $S/$M/$M/elf_trampoline.c \
+		$S/$M/$M/inckern.S  -o ${KERNEL_KO}.tramp.noheader 
 	${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
 		${KERNEL_KO}.tramp.bin \
 
Index: sys/mips/mips/inckern.S
===================================================================
--- sys/mips/mips/inckern.S	(revision 216318)
+++ sys/mips/mips/inckern.S	(working copy)
@@ -22,10 +22,23 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "opt_kernname.h"
-
 #include <machine/asm.h>
 __FBSDID("$FreeBSD$")
+
+ENTRY(_start)
+	PTR_LA	t0, kernel_end
+	move	sp, t0
+	add	sp, 0x2000
+	and	sp, ~0x7
+	PTR_LA	t0, _startC
+	j	t0
+	nop
+END(_start)
+
+#ifndef KERNNAME
+#error Need a kernel name here
+#endif
+
 .section ".real_kernel","aw"
 .globl kernel_start;
 kernel_start:
Index: sys/mips/mips/elf_trampoline.c
===================================================================
--- sys/mips/mips/elf_trampoline.c	(revision 216318)
+++ sys/mips/mips/elf_trampoline.c	(working copy)
@@ -42,8 +42,11 @@
  * need to include opt_global.h manually.
  */
 #include "opt_global.h"
-#include "opt_kernname.h"
 
+#ifndef KERNNAME
+#error Kernel name not provided
+#endif
+
 extern char kernel_start[];
 extern char kernel_end[];
 
home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimX_zdB7=OUAyjmQEcfK8V_fe0qZj9M7HDMq3g4>