tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

MI linker script



I want to make kernel linkage use MI linker script, so that MI ELF
section/symbol handling is centralized into the one place.  Instead of
directly link *.o into "netbsd", link an intermediate relocatable
"netbsd.ro".

The downside of this is that build uses more disk space.  I mean to
compensate that by making kernel build share objects in the long run,
but it will take Long Time...

Index: sys/conf/Makefile.kern.inc
===================================================================
RCS file: /cvsroot/src/sys/conf/Makefile.kern.inc,v
retrieving revision 1.178
diff -p -u -r1.178 Makefile.kern.inc
--- sys/conf/Makefile.kern.inc	6 Nov 2014 12:02:59 -0000	1.178
+++ sys/conf/Makefile.kern.inc	7 Nov 2014 14:43:53 -0000
@@ -236,8 +236,11 @@ SYSTEM_CTFMERGE= ${_MKSHECHO}
 SYSTEM_LD_HEAD?=@rm -f $@
 SYSTEM_LD?=	@${_MKSHMSG} "   link  ${.CURDIR:T}/${.TARGET}"; \
 		${_MKSHECHO}\
-		${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o; \
-		${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
+		${LD} -r -T $S/conf/kern.ldscript -Map $@.ro.map -o $@.ro '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o; \
+		${LD} -r -T $S/conf/kern.ldscript -Map $@.ro.map -o $@.ro ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o; \
+		${_MKSHECHO}\
+		${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ $@.ro; \
+		${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ $@.ro
 
 TEXTADDR?=	${LOADADDRESS}			# backwards compatibility
 LINKTEXT?=	${TEXTADDR:C/.+/-Ttext &/}
Index: sys/conf/kern.ldscript
===================================================================
RCS file: sys/conf/kern.ldscript
diff -N sys/conf/kern.ldscript
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sys/conf/kern.ldscript	7 Nov 2014 14:43:53 -0000
@@ -0,0 +1,20 @@
+/*	$NetBSD$	*/
+
+SECTIONS
+{
+  .data :
+  {
+    *(.data)
+  }
+  . = ALIGN(COHERENCY_UNIT);
+  .data.cacheline_aligned :
+  {
+    *(.data.cacheline_aligned)
+  }
+  . = ALIGN(COHERENCY_UNIT);
+  .data.read_mostly :
+  {
+    *(.data.read_mostly)
+  }
+  . = ALIGN(COHERENCY_UNIT);
+}
Index: sys/conf/param.c
===================================================================
RCS file: /cvsroot/src/sys/conf/param.c,v
retrieving revision 1.64
diff -p -u -r1.64 param.c
--- sys/conf/param.c	9 Jun 2012 02:31:14 -0000	1.64
+++ sys/conf/param.c	7 Nov 2014 14:43:53 -0000
@@ -219,3 +219,8 @@ const	int mclbytes = MCLBYTES;
  * Values in support of POSIX semaphores.
  */
 int	ksem_max = KSEM_MAX;
+
+/*
+ * Symbols for linker script.
+ */
+__SYMVAL(COHERENCY_UNIT, COHERENCY_UNIT);


Home | Main Index | Thread Index | Old Index