tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: MI linker script
For reference, this *actually* works, and intermediate *.ro is rm'ed. (This
needs the uncommitted __SYMVAL() change in sys/cdefs_elf.h.)
I'm not committing this soon, to give people time to overcome fear against
ld -r.
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 8 Nov 2014 04:32:56 -0000
@@ -223,8 +223,9 @@ ${_cfile:T:R}.o: ${_cfile}
# load lines for config "xxx" will be emitted as:
# xxx: ${SYSTEM_DEP} swapxxxx.o vers.o build_kernel
+MI_LDSCRIPT= $S/conf/kern.ldscript
SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS:O} ${SYSLIBCOMPAT} ${LIBKERN}
-SYSTEM_DEP+= Makefile ${SYSTEM_OBJ:O} .gdbinit
+SYSTEM_DEP+= Makefile ${SYSTEM_OBJ:O} .gdbinit ${MI_LDSCRIPT}
.if defined(KERNLDSCRIPT)
SYSTEM_DEP+= ${KERNLDSCRIPT}
.endif
@@ -234,10 +235,16 @@ SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS
SYSTEM_CTFMERGE= ${_MKSHECHO}
.endif
SYSTEM_LD_HEAD?=@rm -f $@
+SYSTEM_LD_RO?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}.ro"; \
+ ${_MKSHECHO}\
+ ${LD} -r -T ${MI_LDSCRIPT} -Map $@.ro.map -o $@.ro\
+ '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o; \
+ ${LD} -r -T ${MI_LDSCRIPT} -Map $@.ro.map -o $@.ro\
+ ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
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} -Map $@.map --cref ${LINKFLAGS} -o $@ $@.ro; \
+ ${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ $@.ro
TEXTADDR?= ${LOADADDRESS} # backwards compatibility
LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/}
@@ -346,7 +353,7 @@ assym.h machdep.o: Makefile
.if !target(__CLEANKERNEL)
__CLEANKERNEL: .USE
${_MKMSG} "${.TARGET}ing the kernel objects"
- rm -f ${KERNELS} *.map eddep tags *.[io] *.ko *.ln [a-z]*.s vers.c \
+ rm -f ${KERNELS} *.map eddep tags *.[io] *.ro *.ko *.ln [a-z]*.s vers.c \
[Ee]rrs linterrs makelinks assym.h.tmp assym.h \
${EXTRA_KERNELS} ${EXTRA_CLEAN}
.endif
@@ -553,21 +560,26 @@ CPPFLAGS.kern_ksyms_buf.c+= -DCOPY_SYMTA
.if !defined(COPY_SYMTAB)
build_kernel: .USE
${SYSTEM_LD_HEAD}
- ${SYSTEM_LD} swap${.TARGET}.o
+ ${SYSTEM_LD_RO} swap${.TARGET}.o
+ ${SYSTEM_LD}
${SYSTEM_LD_TAIL_STAGE2}
+ @rm -f ${.TARGET}.ro
.else
build_kernel: .USE
${CC} ${CFLAGS} ${CPPFLAGS} -DCOPY_SYMTAB \
-c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf.o
${SYSTEM_LD_HEAD}
- ${SYSTEM_LD} swap${.TARGET}.o kern_ksyms_buf.o
+ ${SYSTEM_LD_RO} swap${.TARGET}.o kern_ksyms_buf.o
+ ${SYSTEM_LD}
${SYSTEM_LD_TAIL_STAGE1}
${CC} ${CFLAGS} ${CPPFLAGS} -DCOPY_SYMTAB \
-DSYMTAB_SPACE=$$(${DBSYM} -P ${.TARGET}${TARGETSFX}) \
-c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf_real.o
${SYSTEM_LD_HEAD}
- ${SYSTEM_LD} swap${.TARGET}.o kern_ksyms_buf_real.o
+ ${SYSTEM_LD_RO} swap${.TARGET}.o kern_ksyms_buf_real.o
+ ${SYSTEM_LD}
${SYSTEM_LD_TAIL_STAGE2}
+ @rm -f ${.TARGET}.ro
.endif
.include <bsd.files.mk>
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 8 Nov 2014 04:32:56 -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 8 Nov 2014 04:32:57 -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