From 79b4bbd6ec763ecb9b06a7615f1b6831ca04dc94 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 8 Jul 2009 10:52:32 -0700 Subject: [PATCH] AMD64 - Fix native-built sys/boot install * Pass the proper elf format to the linker when compiling programs in sys/boot. * include btxld in the 64 bit buildworld. It is needed by sys/boot. * a.out.h / imgact_aout.h needed a special case to generate a 32 bit struct exec when compiled from a 64 bit environment. --- sys/boot/pc32/boot0/Makefile | 2 +- sys/boot/pc32/boot2/boot2.c | 1 + sys/boot/pc32/btx/btxldr/Makefile | 2 +- sys/boot/pc32/cdboot/Makefile | 2 +- sys/boot/pc32/mbr/Makefile | 2 +- sys/boot/pc32/pxeldr/Makefile | 2 +- sys/sys/imgact_aout.h | 25 +++++++++++++++++-------- usr.sbin/Makefile | 5 ++++- usr.sbin/btxld/btxld.c | 1 + 9 files changed, 28 insertions(+), 14 deletions(-) diff --git a/sys/boot/pc32/boot0/Makefile b/sys/boot/pc32/boot0/Makefile index d440da6649..89662b4ffd 100644 --- a/sys/boot/pc32/boot0/Makefile +++ b/sys/boot/pc32/boot0/Makefile @@ -61,7 +61,7 @@ CFLAGS+=-DFLAGS=${BOOT_BOOT0_FLAGS} \ # ${PROG}: boot0.o bootasmdef.nx @echo "boot0 origin set to `${.OBJDIR}/bootasmdef.nx BOOT0_ORIGIN`" - ${LD} -N -e start -Ttext `${.OBJDIR}/bootasmdef.nx BOOT0_ORIGIN` -o boot0.out boot0.o + ${LD} ${LDFLAGS} -N -e start -Ttext `${.OBJDIR}/bootasmdef.nx BOOT0_ORIGIN` -o boot0.out boot0.o objcopy -S -O binary boot0.out ${.TARGET} boot0.o: boot0.S diff --git a/sys/boot/pc32/boot2/boot2.c b/sys/boot/pc32/boot2/boot2.c index dd0aff91d9..34bddfbf0d 100644 --- a/sys/boot/pc32/boot2/boot2.c +++ b/sys/boot/pc32/boot2/boot2.c @@ -48,6 +48,7 @@ * $DragonFly: src/sys/boot/pc32/boot2/boot2.c,v 1.18 2008/09/13 11:45:45 corecode Exp $ */ +#define AOUT_H_FORCE32 #include #ifdef DISKLABEL64 #include diff --git a/sys/boot/pc32/btx/btxldr/Makefile b/sys/boot/pc32/btx/btxldr/Makefile index d29075e22b..e5dfd9e604 100644 --- a/sys/boot/pc32/btx/btxldr/Makefile +++ b/sys/boot/pc32/btx/btxldr/Makefile @@ -11,7 +11,7 @@ CFLAGS+= -DBTXLDR_VERBOSE all: btxldr btxldr: btxldr.o - ${LD} -N -e start -Ttext ${LOADER_ADDRESS} -o btxldr.out btxldr.o + ${LD} ${LDFLAGS} -N -e start -Ttext ${LOADER_ADDRESS} -o btxldr.out btxldr.o objcopy -S -O binary btxldr.out ${.TARGET} btxldr.o: btxldr.S diff --git a/sys/boot/pc32/cdboot/Makefile b/sys/boot/pc32/cdboot/Makefile index c19a4a8949..93ac4a6cc0 100644 --- a/sys/boot/pc32/cdboot/Makefile +++ b/sys/boot/pc32/cdboot/Makefile @@ -9,7 +9,7 @@ STRIP= BINDIR?= /boot ${PROG}: ${PROG}.o - ${LD} -N -e start -Ttext ${ORG} -o ${PROG}.out ${PROG}.o + ${LD} ${LDFLAGS} -N -e start -Ttext ${ORG} -o ${PROG}.out ${PROG}.o objcopy -S -O binary ${PROG}.out ${.TARGET} CLEANFILES+= ${PROG}.o ${PROG}.out diff --git a/sys/boot/pc32/mbr/Makefile b/sys/boot/pc32/mbr/Makefile index 3a6442bc7a..343a91c6d4 100644 --- a/sys/boot/pc32/mbr/Makefile +++ b/sys/boot/pc32/mbr/Makefile @@ -10,7 +10,7 @@ BINMODE= 444 ORG= 0x600 mbr: mbr.o - ${LD} -N -e start -Ttext ${ORG} -o mbr.out mbr.o + ${LD} ${LDFLAGS} -N -e start -Ttext ${ORG} -o mbr.out mbr.o objcopy -S -O binary mbr.out ${.TARGET} CLEANFILES+= mbr.out mbr.o diff --git a/sys/boot/pc32/pxeldr/Makefile b/sys/boot/pc32/pxeldr/Makefile index cd9467d6ba..8259b0d103 100644 --- a/sys/boot/pc32/pxeldr/Makefile +++ b/sys/boot/pc32/pxeldr/Makefile @@ -46,7 +46,7 @@ ${LOADER}: ${LOADERBIN} ${BTXLDR} ${BTXKERN} ${BTXCRT} -b ${BTXKERN} ${LOADERBIN} ${LDR}: ${LDR}.o - ${LD} -N -e start -Ttext ${ORG} -o ${LDR}.out ${LDR}.o + ${LD} ${LDFLAGS} -N -e start -Ttext ${ORG} -o ${LDR}.out ${LDR}.o objcopy -S -O binary ${LDR}.out ${.TARGET} ${LDR}.o: ${LDR}.S diff --git a/sys/sys/imgact_aout.h b/sys/sys/imgact_aout.h index ab7faa736d..adf90b8a95 100644 --- a/sys/sys/imgact_aout.h +++ b/sys/sys/imgact_aout.h @@ -114,17 +114,26 @@ * Header prepended to each a.out file. * only manipulate the a_midmag field via the * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros in a.out.h + * + * AOUT_H_FORCE32 is used by btxld and sys/boot when compiling + * from a 64 bit environment to generate a 32 bit a.out.h header. */ +#ifdef AOUT_H_FORCE32 +typedef u_int32_t aout_register_t; +#else +typedef unsigned long aout_register_t; +#endif + struct exec { - unsigned long a_midmag; /* flags<<26 | mid<<16 | magic */ - unsigned long a_text; /* text segment size */ - unsigned long a_data; /* initialized data size */ - unsigned long a_bss; /* uninitialized data size */ - unsigned long a_syms; /* symbol table size */ - unsigned long a_entry; /* entry point */ - unsigned long a_trsize; /* text relocation size */ - unsigned long a_drsize; /* data relocation size */ + aout_register_t a_midmag; /* flags<<26 | mid<<16 | magic */ + aout_register_t a_text; /* text segment size */ + aout_register_t a_data; /* initialized data size */ + aout_register_t a_bss; /* uninitialized data size */ + aout_register_t a_syms; /* symbol table size */ + aout_register_t a_entry; /* entry point */ + aout_register_t a_trsize; /* text relocation size */ + aout_register_t a_drsize; /* data relocation size */ }; #define a_magic a_midmag /* XXX Hack to work with current kern_execve.c */ diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index 97e627736e..a23f8e9d87 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -171,11 +171,14 @@ SUBDIR+=editmap \ sendmail .endif +.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" +SUBDIR+= btxld +.endif + .if ${MACHINE_ARCH} == "i386" SUBDIR+=apm \ apmd \ battd \ - btxld \ kgmon \ kgzip \ lptcontrol \ diff --git a/usr.sbin/btxld/btxld.c b/usr.sbin/btxld/btxld.c index bcf6392675..5d43ada667 100644 --- a/usr.sbin/btxld/btxld.c +++ b/usr.sbin/btxld/btxld.c @@ -27,6 +27,7 @@ * $DragonFly: src/usr.sbin/btxld/btxld.c,v 1.3 2004/08/19 21:38:30 joerg Exp $ */ +#define AOUT_H_FORCE32 #include #include #include -- 2.11.4.GIT