Date: Wed, 11 Feb 2004 16:25:49 +0200 From: Ruslan Ermilov <ru@FreeBSD.org> To: Marcel Moolenaar <marcel@FreeBSD.org>, Peter Wemm <peter@wemm.org> Cc: ia64@FreeBSD.org Subject: Help needed cleaning up sys/boot/{efi,ia64}/ makefiles Message-ID: <20040211142549.GA52347@FreeBSD.org.ua>
next in thread | raw e-mail | index | archive | help
--vGgW1X5XWziG23Ko Content-Type: multipart/mixed; boundary="5mCyUwZo2JvN/JJP" Content-Disposition: inline --5mCyUwZo2JvN/JJP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Gang, As you've probably noticed, I've been working towards cleaning up sys/boot/ makefiles for some time already, and now is the time for IA64. I've compile-tested the attached patch on pluto2 today. I tested my changes by binary comparing the resulting binaries, in the same way as I did it for other architectures (i386, amd64 and sparc64). One thing about IA64 surprises me, and I hope you can help me here. With my patch, I get a slightly different "loader.sym" binary, and this is due to linking, i.e., all intermediate objects are the same. I first took away the -M option to ld(1) to not generate the link map. An analysis shown that this was responsible for a difference. I've put it back, and (as could be seen by adding -v to LDFLAGS after applying the patch), the link command now looks like this: : ld -Bshareable -Bsymbolic -o loader.sym \ : -L/usr/lib \ : -T/q/scratch/ru/src/sys/boot/efi/loader/../libefi/arch/ia64/ldscript.ia64= \ : -M -Map loader.list \ : start.o main.o conf.o dev_net.o bcache.o boot.o commands.o console.o \ : devopen.o interp.o interp_backslash.o interp_parse.o ls.o misc.o module.o= \ : panic.o load_elf64.o interp_forth.o vers.o \ : /q/scratch/ru/obj/q/scratch/ru/src/sys/boot/efi/loader/../../ficl/libficl= =2Ea \ : /q/scratch/ru/obj/q/scratch/ru/src/sys/boot/efi/loader/../libefi/libefi.a= \ : -lstand But this still gives a difference. By disassembling the resulting binary, I see the constant difference of 40 bytes in various offset, if I'm guessing the IA64 asm code correctly. Then the constant changes. The elfdump(1) also shows the difference in relocations. But if I change to an object directory, and relink loader.sym manually by tweaking the link command a bit (by changing -L/usr/lib to -nostdlib and replacing -lstand with /usr/lib/libstand.a), I see no difference (except probably for "normal" difference influenced by regenerating vers.c, if I regenerate it). ; ld -Bshareable -Bsymbolic -o loader.sym \ ; - -L/usr/lib \ ; + -nostdlib \ ; -T/q/scratch/ru/src/sys/boot/efi/loader/../libefi/arch/ia64/ldscript.ia= 64 \ ; -M -Map loader.list \ ; start.o main.o conf.o dev_net.o bcache.o boot.o commands.o console.o \ ; devopen.o interp.o interp_backslash.o interp_parse.o ls.o misc.o module= =2Eo \ ; panic.o load_elf64.o interp_forth.o vers.o \ ; /q/scratch/ru/obj/q/scratch/ru/src/sys/boot/efi/loader/../../ficl/libfi= cl.a \ ; /q/scratch/ru/obj/q/scratch/ru/src/sys/boot/efi/loader/../libefi/libefi= =2Ea \ ; - -lstand ; + /usr/lib/libstand.a So I have a few questions: - Why the hell removing -M from linker flags (both in unpatched and patched versions of makefiles) seems to affect the loader.sym binary? - Is it safe to commit my patch? Can someone please run-test it? - Is there a reason why libski is built with -g? Is it safe to remove it? - What is the reason that we cannot strip the skiload binary? (A slightly more verbose explanation than the below would be nice.) : revision 1.12 : date: 2003/11/09 06:53:37; author: marcel; state: Exp; lines: +1 -0 : Do not strip skiload when installed. The stripped binary does not load : in the simulator. - What is the reason that we cannot strip the boot.efi binary? (A slightly more verbose explanation than the below would be nice.) : revision 1.17 : date: 2002/04/07 04:27:50; author: peter; state: Exp; lines: +1 -0 : We must not let install(1) strip loader.efi when installing it, or the : resulting binary will be damaged and no longer work. Cheers, --=20 Ruslan Ermilov FreeBSD committer ru@FreeBSD.org --5mCyUwZo2JvN/JJP Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=p Content-Transfer-Encoding: quoted-printable Index: efi/Makefile.inc =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sys/boot/efi/Makefile.inc,v retrieving revision 1.6 diff -u -r1.6 Makefile.inc --- efi/Makefile.inc 10 Dec 2002 04:20:15 -0000 1.6 +++ efi/Makefile.inc 11 Feb 2004 08:59:03 -0000 @@ -1,4 +1,7 @@ # $FreeBSD: src/sys/boot/efi/Makefile.inc,v 1.6 2002/12/10 04:20:15 marcel= Exp $ =20 +BINDIR?=3D /boot + # Options used when building app-specific efi components CFLAGS+=3D -ffreestanding -fshort-wchar -Wformat +LDFLAGS+=3D -nostdlib Index: efi/libefi/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sys/boot/efi/libefi/Makefile,v retrieving revision 1.12 diff -u -r1.12 Makefile --- efi/libefi/Makefile 2 Jul 2003 11:53:55 -0000 1.12 +++ efi/libefi/Makefile 9 Feb 2004 16:14:21 -0000 @@ -12,28 +12,21 @@ SRCS+=3D efifpswa.c .endif =20 -CFLAGS+=3D -ffreestanding -fpic +CFLAGS+=3D -fpic CFLAGS+=3D -I${.CURDIR}/../include CFLAGS+=3D -I${.CURDIR}/../include/${MACHINE_ARCH} -CFLAGS+=3D -I${.CURDIR}/../../../../lib/libstand/ +CFLAGS+=3D -I${.CURDIR}/../../../../lib/libstand =20 # Pick up the bootstrap header for some interface items -CFLAGS+=3D -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I. +CFLAGS+=3D -I${.CURDIR}/../../common =20 .if ${MACHINE_ARCH} =3D=3D "powerpc" CFLAGS+=3D -msoft-float .endif =20 -.ifdef(BOOT_DISK_DEBUG) +.if defined(BOOT_DISK_DEBUG) # Make the disk code more talkative CFLAGS+=3D -DDISK_DEBUG .endif =20 -machine: - ln -sf ${.CURDIR}/../../../${MACHINE_ARCH}/include machine - -CLEANFILES+=3D machine - .include <bsd.lib.mk> - -beforedepend ${OBJS}: machine Index: efi/loader/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sys/boot/efi/loader/Makefile,v retrieving revision 1.19 diff -u -r1.19 Makefile --- efi/loader/Makefile 26 Feb 2003 06:18:52 -0000 1.19 +++ efi/loader/Makefile 11 Feb 2004 12:45:07 -0000 @@ -1,76 +1,45 @@ # $FreeBSD: src/sys/boot/efi/loader/Makefile,v 1.19 2003/02/26 06:18:52 ob= rien Exp $ =20 -.PATH: ${.CURDIR}/../common - -BASE=3D loader -PROG=3D ${BASE}.efi +PROG=3D loader.sym +INTERNALPROG=3D NOMAN=3D NEWVERSWHAT=3D "EFI boot" ${MACHINE_ARCH} -BINDIR?=3D /boot -STRIP=3D # We must not strip loader.efi at install time. =20 -SRCS+=3D main.c conf.c dev_net.c +SRCS=3D start.S main.c conf.c dev_net.c #vers.c =20 -CFLAGS+=3D -ffreestanding +.PATH: ${.CURDIR}/../libefi/arch/${MACHINE_ARCH} =20 .if !defined(NOFORTH) # Enable BootForth BOOT_FORTH=3D yes CFLAGS+=3D -DBOOT_FORTH CFLAGS+=3D -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/${MACHINE_ARCH} -.if exists(${.OBJDIR}/../../ficl/libficl.a) LIBFICL=3D ${.OBJDIR}/../../ficl/libficl.a -.else -LIBFICL=3D ${.CURDIR}/../../ficl/libficl.a -.endif -.endif - -# where to get libstand from -.if exists(${.OBJDIR}/../../../../lib/libstand/libstand.a) -LIBSTAND=3D ${.OBJDIR}/../../../../lib/libstand/libstand.a -.else -LIBSTAND=3D ${.CURDIR}/../../../../lib/libstand/libstand.a .endif =20 -.if exists(${.OBJDIR}/../libefi/libefi.a) LIBEFI=3D ${.OBJDIR}/../libefi/libefi.a -.else -LIBEFI=3D ${.CURDIR}/../libefi/libefi.a -.endif =20 # Always add MI sources=20 .PATH: ${.CURDIR}/../../common -.include <${.CURDIR}/../../common/Makefile.inc> +.include "${.CURDIR}/../../common/Makefile.inc" =20 -CFLAGS+=3D -I- CFLAGS+=3D -I${.CURDIR}/../include CFLAGS+=3D -I${.CURDIR}/../include/${MACHINE_ARCH} -CFLAGS+=3D -I${.CURDIR}/../../common -I${.CURDIR} -CFLAGS+=3D -I${.CURDIR}/../../.. -I. +CFLAGS+=3D -I${.CURDIR}/../../common CFLAGS+=3D -I${.CURDIR}/../libefi CFLAGS+=3D -I${.CURDIR}/../../../../lib/libstand CFLAGS+=3D -DLOADER =20 LDSCRIPT=3D ${.CURDIR}/../libefi/arch/${MACHINE_ARCH}/ldscript.${MACHINE_A= RCH} -LDFLAGS=3D -nostdlib -T ${LDSCRIPT} -shared -Bsymbolic +LDFLAGS=3D -Wl,-T${LDSCRIPT} -Wl,-M,-Map,loader.list -shared -symbolic OBJCOPY?=3D objcopy =20 -CLEANFILES+=3D setdef0.c setdef0.o setdef1.c setdef1.o setdefs.h start.o \ - vers.c vers.o ${BASE}.efi ${BASE}.sym ${BASE}.list -CLEANFILES+=3D loader.help -CLEANFILES+=3D machine - -CRT=3D start.o - -all: ${BASE} +CLEANFILES=3D vers.c loader.efi loader.list loader.help =20 -vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version +vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} - ${CC} -c vers.c =20 -${BASE}: ${BASE}.efi ${BASE}.help - -${BASE}.efi: ${BASE}.sym +loader.efi: loader.sym ${OBJCOPY} -j .text \ -j .hash \ -j .data \ @@ -81,43 +50,24 @@ -j .dynsym \ -j .dynstr \ --target=3Defi-app-${MACHINE_ARCH} \ - ${BASE}.sym ${BASE}.efi + loader.sym loader.efi =20 -${BASE}.help: help.common +loader.help: help.common cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk \ > ${.TARGET} =20 -beforeinstall: -.if exists(${.OBJDIR}/loader.help) - ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.OBJDIR}/${BASE}.help ${DESTDIR}/boot -.else - ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/${BASE}.help ${DESTDIR}/boot -.endif +.PATH: ${.CURDIR}/../../forth +FILES=3D loader.efi loader.help loader.4th support.4th loader.conf +FILESMODE_loader.efi=3D ${BINMODE} +FILESDIR_loader.conf=3D /boot/defaults + .if !exists(${DESTDIR}/boot/loader.rc) - ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/../../forth/loader.rc ${DESTDIR}/boot +FILES+=3D ${.CURDIR}/loader.rc .endif - ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/../../forth/loader.4th ${DESTDIR}/boot - ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/../../forth/support.4th ${DESTDIR}/boot - ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.CURDIR}/../../forth/loader.conf ${DESTDIR}/boot/defaults =20 +SRCS+=3D vers.c =20 -# Other fragments still to be brought in from ../Makfile.booters? -start.o: ${.CURDIR}/../libefi/arch/${MACHINE_ARCH}/start.S - ${CC} -c ${CFLAGS} ${.IMPSRC} - -machine: - ln -sf ${.CURDIR}/../../../${MACHINE_ARCH}/include machine +DPADD=3D ${LIBFICL} ${LIBEFI} ${LIBSTAND} +LDADD=3D ${LIBFICL} ${LIBEFI} -lstand =20 .include <bsd.prog.mk> - -${BASE}.sym: ${OBJS} ${LIBFICL} ${LIBEFI} ${LIBSTAND} ${CRT} vers.o - ${LD} ${LDFLAGS} -o ${BASE}.sym -M ${CRT} ${OBJS} vers.o \ - ${LIBFICL} ${LIBEFI} ${LIBSTAND} > ${.OBJDIR}/${BASE}.list - -beforedepend ${OBJS}: machine Index: ia64/Makefile.inc =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sys/boot/ia64/Makefile.inc,v retrieving revision 1.2 diff -u -r1.2 Makefile.inc --- ia64/Makefile.inc 1 Feb 2003 22:50:08 -0000 1.2 +++ ia64/Makefile.inc 11 Feb 2004 13:02:05 -0000 @@ -1,4 +1,7 @@ # $FreeBSD: src/sys/boot/ia64/Makefile.inc,v 1.2 2003/02/01 22:50:08 marce= l Exp $ =20 +BINDIR?=3D /boot + # Options used when building standalone components CFLAGS+=3D -ffreestanding -fshort-wchar -Wformat +LDFLAGS+=3D -nostdlib Index: ia64/libski/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sys/boot/ia64/libski/Makefile,v retrieving revision 1.10 diff -u -r1.10 Makefile --- ia64/libski/Makefile 2 Jul 2003 11:47:33 -0000 1.10 +++ ia64/libski/Makefile 11 Feb 2004 13:36:11 -0000 @@ -7,30 +7,21 @@ SRCS+=3D delay.c skifs.c elf_freebsd.c bootinfo.c ssc.c SRCS+=3D acpi_stub.c efi_stub.c pal_stub.S sal_stub.c =20 -CFLAGS+=3D -ffreestanding -fpic -g -CFLAGS+=3D -I${.CURDIR}/../include -CFLAGS+=3D -I${.CURDIR}/../include/${MACHINE_ARCH} -CFLAGS+=3D -I${.CURDIR}/../../../../lib/libstand/ +CFLAGS+=3D -fpic -g +CFLAGS+=3D -I${.CURDIR}/../../../../lib/libstand CFLAGS+=3D -I${.CURDIR}/../../efi/include CFLAGS+=3D -I${.CURDIR}/../../efi/include/${MACHINE_ARCH} =20 # Pick up the bootstrap header for some interface items -CFLAGS+=3D -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I. +CFLAGS+=3D -I${.CURDIR}/../../common -I${.CURDIR}/../../.. =20 .if ${MACHINE_ARCH} =3D=3D "powerpc" CFLAGS+=3D -msoft-float .endif =20 -.ifdef(BOOT_DISK_DEBUG) +.if defined(BOOT_DISK_DEBUG) # Make the disk code more talkative CFLAGS+=3D -DDISK_DEBUG .endif =20 -machine: - ln -sf ${.CURDIR}/../../../${MACHINE_ARCH}/include machine - -CLEANFILES+=3D machine - .include <bsd.lib.mk> - -beforedepend ${OBJS}: machine Index: ia64/skiload/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sys/boot/ia64/skiload/Makefile,v retrieving revision 1.12 diff -u -r1.12 Makefile --- ia64/skiload/Makefile 9 Nov 2003 06:53:37 -0000 1.12 +++ ia64/skiload/Makefile 11 Feb 2004 13:14:24 -0000 @@ -8,78 +8,40 @@ BINDIR?=3D /boot STRIP=3D # We must not strip skiload at install time. =20 -SRCS+=3D conf.c main.c start.S - -CFLAGS+=3D -ffreestanding +SRCS=3D conf.c main.c start.S vers.c =20 .if !defined(NOFORTH) # Enable BootForth BOOT_FORTH=3D yes CFLAGS+=3D -DBOOT_FORTH CFLAGS+=3D -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/${MACHINE_ARCH} -.if exists(${.OBJDIR}/../../ficl/libficl.a) LIBFICL=3D ${.OBJDIR}/../../ficl/libficl.a -.else -LIBFICL=3D ${.CURDIR}/../../ficl/libficl.a -.endif .endif =20 -# where to get libstand from -.if exists(${.OBJDIR}/../../../../lib/libstand/libstand.a) -LIBSTAND=3D ${.OBJDIR}/../../../../lib/libstand/libstand.a -.else -LIBSTAND=3D ${.CURDIR}/../../../../lib/libstand/libstand.a -.endif - -.if exists(${.OBJDIR}/../libski/libski.a) LIBSKI=3D ${.OBJDIR}/../libski/libski.a -.else -LIBSKI=3D ${.CURDIR}/../libski/libski.a -.endif =20 # Always add MI sources=20 .PATH: ${.CURDIR}/../../common -.include <${.CURDIR}/../../common/Makefile.inc> +.include "${.CURDIR}/../../common/Makefile.inc" =20 -CFLAGS+=3D -I- -CFLAGS+=3D -I${.CURDIR}/../include -CFLAGS+=3D -I${.CURDIR}/../include/${MACHINE_ARCH} -CFLAGS+=3D -I${.CURDIR}/../../common -I${.CURDIR} -CFLAGS+=3D -I${.CURDIR}/../../.. -I. +CFLAGS+=3D -I${.CURDIR}/../../common CFLAGS+=3D -I${.CURDIR}/../libski CFLAGS+=3D -DLOADER =20 -LDFLAGS=3D -nostdlib -T ${.CURDIR}/ldscript.ia64 +LDFLAGS=3D -Wl,-T${.CURDIR}/ldscript.ia64 -Wl,-M,-Map,${PROG}.list =20 -CLEANFILES+=3D vers.c vers.o ${PROG}.list -CLEANFILES+=3D loader.help -CLEANFILES+=3D machine +CLEANFILES=3D vers.c ${PROG}.list ${PROG}.help =20 -all: ${PROG} - -vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version +vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} - ${CC} -c vers.c =20 -${PROG}.help: help.common help.efi +${PROG}.help: help.common cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk \ > ${.TARGET} =20 -beforeinstall: -.if exists(${.OBJDIR}/${PROG}.help) - ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${.OBJDIR}/${PROG}.help ${DESTDIR}/boot -.endif - -machine: - ln -sf ${.CURDIR}/../../../${MACHINE_ARCH}/include machine +FILES=3D ${PROG}.help =20 -${PROG}: ${OBJS} ${LIBFICL} ${LIBSKI} ${LIBSTAND} vers.o - ${LD} ${LDFLAGS} -o ${PROG} -M \ - ${OBJS} vers.o \ - ${LIBFICL} ${LIBSTAND} ${LIBSKI} ${LIBSTAND} \ - > ${.OBJDIR}/${PROG}.list +DPADD=3D ${LIBFICL} ${LIBSKI} ${LIBSTAND} +LDADD=3D ${LIBFICL} ${LIBSKI} -lstand =20 .include <bsd.prog.mk> - -beforedepend ${OBJS}: machine --5mCyUwZo2JvN/JJP-- --vGgW1X5XWziG23Ko Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAKjttUkv4P6juNwoRAqDAAJ9PN7Cmp9UK18JkABfQzeR/HItgCgCfSsn6 xVmatIq+HjRTOKbjO9jG+KA= =x8bv -----END PGP SIGNATURE----- --vGgW1X5XWziG23Ko--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040211142549.GA52347>