Index: sys/conf/Makefile.arm =================================================================== --- sys/conf/Makefile.arm +++ sys/conf/Makefile.arm @@ -32,9 +32,6 @@ INCLUDES+= -I$S/contrib/libfdt -I$S/gnu/dts/include -SYSTEM_LD:= ${SYSTEM_LD:$S/conf/ldscript.$M=ldscript.$M} -SYSTEM_DEP:= ${SYSTEM_DEP:$S/conf/ldscript.$M=ldscript.$M} - .if !defined(DEBUG) && !defined(PROFLEVEL) STRIP_FLAGS = -S .endif @@ -58,20 +55,29 @@ KERNVIRTADDR= 0xc0000000 .endif +# Generate both the ELF and the BIN (no elf headers) kernels; we must +# relink to generate the BIN kernel, because without headers the location +# of everything changes. +# Strip the "arm mapping symbols" which have names like $a.0 and $d.2; +# see the document "ELF for the ARM architecture" for details. +SYSTEM_LD= \ + ${SYSTEM_LD_BASECMD} \ + --defsym='kernbase=${KERNVIRTADDR}+SIZEOF_HEADERS' \ + -o ${FULLKERNEL} ${SYSTEM_OBJS} vers.o; \ + $(OBJCOPY) \ + --strip-symbol='$[adt]*' \ + ${FULLKERNEL}; \ + ${SYSTEM_LD_BASECMD} \ + --defsym='kernbase=${KERNVIRTADDR}' \ + -o ${KERNEL_KO}.bin ${SYSTEM_OBJS} vers.o; \ + $(OBJCOPY) \ + --strip-symbol='$[adt]*' \ + --output-target=binary \ + ${KERNEL_KO}.bin + # hack because genassym.c includes sys/bus.h which includes these. genassym.o: bus_if.h device_if.h -SYSTEM_LD_ = ${LD} -m ${LD_EMULATION} -Bdynamic -T ldscript.$M.noheader \ - ${_LDFLAGS} --no-warn-mismatch --warn-common --export-dynamic \ - --dynamic-linker /red/herring \ - -o ${FULLKERNEL}.noheader -X ${SYSTEM_OBJS} vers.o -SYSTEM_LD_TAIL +=;sed s/" + SIZEOF_HEADERS"// ldscript.$M \ - >ldscript.$M.noheader; \ - ${SYSTEM_LD_}; \ - ${OBJCOPY} -S -O binary ${FULLKERNEL}.noheader \ - ${KERNEL_KO}.bin; \ - rm ${FULLKERNEL}.noheader - %BEFORE_DEPEND %OBJS @@ -84,10 +90,7 @@ %CLEAN -CLEAN+= ldscript.$M ${KERNEL_KO}.bin ldscript.$M.noheader - -ldscript.$M: $S/conf/ldscript.$M - sed s/KERNVIRTADDR/${KERNVIRTADDR}/g > ldscript.$M < $S/conf/ldscript.$M +CLEAN+= ${KERNEL_KO}.bin %RULES Index: sys/conf/ldscript.arm =================================================================== --- sys/conf/ldscript.arm +++ sys/conf/ldscript.arm @@ -6,7 +6,7 @@ SECTIONS { /* Read-only sections, merged into text segment: */ - . = KERNVIRTADDR + SIZEOF_HEADERS; + . = kernbase; .text : { *(.text)