==== //depot/projects/hammer/contrib/binutils/bfd/elf32-i386-fbsd.c#1 - /home/src/contrib/binutils/bfd/elf32-i386-fbsd.c ==== @@ -22,6 +22,7 @@ #define ELF_ARCH bfd_arch_i386 #define ELF_MACHINE_CODE EM_386 #define ELF_MAXPAGESIZE 0x1000 +#define ELF_OSABI ELFOSABI_FREEBSD #include "bfd.h" #include "sysdep.h" ==== //depot/projects/hammer/contrib/binutils/bfd/elf32-i386.c#3 - /home/src/contrib/binutils/bfd/elf32-i386.c ==== @@ -629,6 +629,18 @@ /* Allocate our special target data. */ struct elf_i386_obj_tdata *new_tdata; bfd_size_type amt = sizeof (struct elf_i386_obj_tdata); + Elf_Internal_Ehdr * i_ehdrp; /* ELF file header, internal form. */ + + i_ehdrp = elf_elfheader (abfd); + +#ifdef ELF_OSABI + if (i_ehdrp->e_ident[EI_OSABI] != ELF_OSABI) + return false; +#endif +#if defined(__FreeBSD__) && !defined(ELF_OSABI) + if (i_ehdrp->e_ident[EI_OSABI] == ELFOSABI_FREEBSD) + return false; +#endif new_tdata = bfd_zalloc (abfd, amt); if (new_tdata == NULL) return false; ==== //depot/projects/hammer/gnu/usr.bin/binutils/libbfd/Makefile.amd64#1 - /home/src/gnu/usr.bin/binutils/libbfd/Makefile.amd64 ==== @@ -1,13 +1,14 @@ # $FreeBSD: src/gnu/usr.bin/binutils/libbfd/Makefile.amd64,v 1.1 2003/04/26 03:28:21 obrien Exp $ -.include "${.CURDIR}/Makefile.i386" +SRCS+= cpu-i386.c elf32-i386-fbsd.c elf32-i386.c elf32-target.h elf32.c elflink.c -# Get the i386 DEFAULT_VECTOR and VECS. -I386_VECS:= ${DEFAULT_VECTOR} ${VECS} +CLEANFILES+= elf32-target.h +elf32-target.h: elfxx-target.h + sed -e s/NN/32/g ${.ALLSRC} > ${.TARGET} DEFAULT_VECTOR= bfd_elf64_x86_64_vec -VECS= bfd_elf64_x86_64_vec ${I386_VECS} +VECS= bfd_elf64_x86_64_vec bfd_elf32_i386_freebsd_vec bfd_elf32_i386_vec SRCS+= elf64-amd64-fbsd.c elf64-target.h elf64-gen.c elf64.c ==== //depot/projects/hammer/lib/Makefile#13 - /home/src/lib/Makefile ==== @@ -29,7 +29,7 @@ libipx libisc libmenu ${_libmilter} ${_libmp} ${_libncp} \ libnetgraph libopie libpam libpanel libpcap ${_libpthread} \ ${_libsm} ${_libsmb} ${_libsmdb} ${_libsmutil} \ - ${_libstand} ${_libtelnet} libufs libugidfw libusbhid ${_libvgl} \ + libstand ${_libtelnet} libufs libugidfw libusbhid ${_libvgl} \ libwrap libxpg4 liby libz .if exists(${.CURDIR}/csu/${MACHINE_ARCH}-elf) @@ -41,7 +41,6 @@ .endif .if ${MACHINE_ARCH} != "amd64" -_libstand= libstand .if !defined(NOLIBC_R) _libc_r= libc_r .endif ==== //depot/projects/hammer/lib/libstand/Makefile#3 - /home/src/lib/libstand/Makefile ==== @@ -24,6 +24,16 @@ .if ${MACHINE_ARCH} == "powerpc" CFLAGS+= -msoft-float .endif +.if ${MACHINE_ARCH} == "amd64" +CFLAGS+= -m32 +LDFLAGS+= -m elf_i386_fbsd +NM= nm --target=i386-unknown-freebsd5 + +beforedepend: machine + +machine: + ln -s ${.CURDIR}/../../sys/i386/include machine +.endif # standalone components and stuff we have modified locally SRCS+= zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \ @@ -34,13 +44,17 @@ SRCS+= strcasecmp.c # byte order functions from libc +.if ${MACHINE_ARCH} != "amd64" .PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/net +.else +.PATH: ${.CURDIR}/../libc/i386/net +.endif SRCS+= htons.S ntohs.S htonl.S ntohl.S # string functions from libc .PATH: ${.CURDIR}/../libc/string .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \ - ${MACHINE_ARCH} == "sparc64" + ${MACHINE_ARCH} == "sparc64" || ${MACHINE_ARCH} == "amd64" SRCS+= bcmp.c bcopy.c bzero.c ffs.c index.c memccpy.c memchr.c memcmp.c \ memcpy.c memmove.c memset.c qdivrem.c rindex.c strcat.c strchr.c \ strcmp.c strcpy.c strcspn.c strlen.c strncat.c strncmp.c strncpy.c \ @@ -107,7 +121,11 @@ .endif # _setjmp/_longjmp +.if ${MACHINE_ARCH} == "amd64" +.PATH: ${.CURDIR}/i386 +.else .PATH: ${.CURDIR}/${MACHINE_ARCH} +.endif SRCS+= _setjmp.S # decompression functionality from libbz2 ==== //depot/projects/hammer/share/mk/bsd.lib.mk#4 - /home/src/share/mk/bsd.lib.mk ==== @@ -54,12 +54,12 @@ .c.o: ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} - @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET} + @${LD} ${LDFLAGS} -o ${.TARGET}.tmp -x -r ${.TARGET} @mv ${.TARGET}.tmp ${.TARGET} .c.po: ${CC} -pg ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} - @${LD} -o ${.TARGET}.tmp -X -r ${.TARGET} + @${LD} ${LDFLAGS} -o ${.TARGET}.tmp -X -r ${.TARGET} @mv ${.TARGET}.tmp ${.TARGET} .c.So: @@ -69,12 +69,12 @@ .cc.o .C.o .cpp.o .cxx.o: ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} - @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET} + @${LD} ${LDFLAGS} -o ${.TARGET}.tmp -x -r ${.TARGET} @mv ${.TARGET}.tmp ${.TARGET} .cc.po .C.po .cpp.po .cxx.po: ${CXX} -pg ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} - @${LD} -o ${.TARGET}.tmp -X -r ${.TARGET} + @${LD} ${LDFLAGS} -o ${.TARGET}.tmp -X -r ${.TARGET} @mv ${.TARGET}.tmp ${.TARGET} .cc.So .C.So .cpp.So .cxx.So: @@ -84,12 +84,12 @@ .f.o: ${FC} ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} - @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET} + @${LD} ${LDFLAGS} -o ${.TARGET}.tmp -x -r ${.TARGET} @mv ${.TARGET}.tmp ${.TARGET} .f.po: ${FC} -pg ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} - @${LD} -o ${.TARGET}.tmp -X -r ${.TARGET} + @${LD} ${LDFLAGS} -o ${.TARGET}.tmp -X -r ${.TARGET} @mv ${.TARGET}.tmp ${.TARGET} .f.So: @@ -99,12 +99,12 @@ .m.o: ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET} - @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET} + @${LD} ${LDFLAGS} -o ${.TARGET}.tmp -x -r ${.TARGET} @mv ${.TARGET}.tmp ${.TARGET} .m.po: ${OBJC} ${OBJCFLAGS} -pg -c ${.IMPSRC} -o ${.TARGET} - @${LD} -o ${.TARGET}.tmp -X -r ${.TARGET} + @${LD} ${LDFLAGS} -o ${.TARGET}.tmp -X -r ${.TARGET} @mv ${.TARGET}.tmp ${.TARGET} .m.So: @@ -127,7 +127,7 @@ .s.So .asm.So: ${CC} -x assembler-with-cpp ${PICFLAG} -DPIC ${CFLAGS} \ ${AINC} -c ${.IMPSRC} -o ${.TARGET} - @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET} + @${LD} ${LDFLAGS} -o ${.TARGET}.tmp -x -r ${.TARGET} @mv ${.TARGET}.tmp ${.TARGET} .S.o: @@ -143,7 +143,7 @@ .S.So: ${CC} ${PICFLAG} -DPIC ${CFLAGS} ${AINC} -c ${.IMPSRC} \ -o ${.TARGET} - @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET} + @${LD} ${LDFLAGS} -o ${.TARGET}.tmp -x -r ${.TARGET} @mv ${.TARGET}.tmp ${.TARGET} all: objwarn @@ -158,7 +158,7 @@ lib${LIB}.a: ${OBJS} ${STATICOBJS} @${ECHO} building static ${LIB} library @rm -f ${.TARGET} - @${AR} cq ${.TARGET} `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD} + @${AR} cq ${.TARGET} `NM="${NM}" lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD} ${RANLIB} ${.TARGET} .endif @@ -171,7 +171,7 @@ lib${LIB}_p.a: ${POBJS} @${ECHO} building profiled ${LIB} library @rm -f ${.TARGET} - @${AR} cq ${.TARGET} `lorder ${POBJS} | tsort -q` ${ARADD} + @${AR} cq ${.TARGET} `NM="${NM}" lorder ${POBJS} | tsort -q` ${ARADD} ${RANLIB} ${.TARGET} .endif @@ -193,7 +193,7 @@ .endif @${CC} ${LDFLAGS} -shared -Wl,-x \ -o ${.TARGET} -Wl,-soname,${SONAME} \ - `lorder ${SOBJS} | tsort -q` ${LDADD} + `NM="${NM}" lorder ${SOBJS} | tsort -q` ${LDADD} .endif .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) ==== //depot/projects/hammer/sys/Makefile#3 - /home/src/sys/Makefile ==== @@ -1,10 +1,7 @@ # $FreeBSD: src/sys/Makefile,v 1.27 2003/05/08 06:35:39 peter Exp $ -SUBDIR= # The boot loader -.if ${MACHINE_ARCH} != "amd64" -SUBDIR+=boot -.endif +SUBDIR= boot # KLD modules build for both a.out and ELF .if defined(MODULES_WITH_WORLD) ==== //depot/projects/hammer/sys/boot/Makefile#5 - /home/src/sys/boot/Makefile ==== @@ -1,8 +1,7 @@ # $FreeBSD: src/sys/boot/Makefile,v 1.16 2003/04/30 22:13:36 peter Exp $ .if ${MACHINE_ARCH} == "amd64" -MACHINE_ARCH=i386 -MACHINE=i386 +.MAKEFLAGS: MACHINE_ARCH=i386 MACHINE=i386 REALLY_AMD64=true .endif .if !defined(NOFORTH) ==== //depot/projects/hammer/sys/boot/common/Makefile.inc#5 - /home/src/sys/boot/common/Makefile.inc ==== @@ -34,7 +34,3 @@ .endif MAN+= loader.8 - -.if ${MACHINE_ARCH} == "amd64" -CFLAGS+= -m32 -.endif ==== //depot/projects/hammer/sys/boot/ficl/Makefile#1 - /home/src/sys/boot/ficl/Makefile ==== @@ -34,8 +34,29 @@ # Optional OO extension softwords #SOFTWORDS+= oo.fr classes.fr -CFLAGS+= -I${.CURDIR} -I${.CURDIR}/${MACHINE_ARCH} -I${.CURDIR}/../common +CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/${MACHINE_ARCH} -I${.CURDIR}/../common softcore.c: ${SOFTWORDS} softcore.awk (cd ${.CURDIR}/softwords; cat ${SOFTWORDS} \ | awk -f softcore.awk -v datestamp="`LC_ALL=C date`") > ${.TARGET} + +.if defined(REALLY_AMD64) +CC+= -m32 +LD+= -m elf_i386_fbsd +NM= nm --target=i386-unknown-freebsd +# Make "machine" required for all objects +# (based on the more complete case in sys/i386/boot/Makefile.inc) +${SRCS:M*.c:R:S/$/.o/g}: machine + +# If it's not there, don't consider it a target +.if exists(${.CURDIR}/../../i386/include) +beforedepend ${OBJS}: machine + +machine: + ln -sf ${.CURDIR}/../../i386/include machine + +.endif + +CLEANFILES+= machine +.endif + ==== //depot/projects/hammer/sys/boot/i386/Makefile.inc#1 - /home/src/sys/boot/i386/Makefile.inc ==== @@ -4,3 +4,12 @@ LOADER_ADDRESS?= 0x200000 CFLAGS+= -ffreestanding -mpreferred-stack-boundary=2 + +.if defined(REALLY_AMD64) && !defined(been_to_Makefile_inc) +been_to_Makefile_inc= 1 +CC+= -m32 +LD+= -m elf_i386_fbsd +AS+= --32 +NM= nm --target=i386-unknown-freebsd +.endif + ==== //depot/projects/hammer/sys/boot/i386/boot0/Makefile#2 - /home/src/sys/boot/i386/boot0/Makefile ==== @@ -25,7 +25,7 @@ boot0: boot0.o ${LD} -N -e start -Ttext ${BOOT_BOOT0_ORG} -o boot0.out boot0.o - objcopy -S -O binary boot0.out ${.TARGET} + objcopy -I i386-unknown-freebsd -S -O binary boot0.out ${.TARGET} boot0.o: boot0.s ${AS} ${AFLAGS} --defsym FLAGS=${BOOT_BOOT0_FLAGS} \ ==== //depot/projects/hammer/sys/boot/i386/boot2/Makefile#3 - /home/src/sys/boot/i386/boot2/Makefile ==== @@ -53,7 +53,7 @@ cat boot1 boot2 > boot boot1: boot1.out - objcopy -S -O binary boot1.out ${.TARGET} + objcopy -I i386-unknown-freebsd -S -O binary boot1.out ${.TARGET} boot1.out: boot1.o ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o @@ -86,7 +86,7 @@ dd if=/dev/zero of=${.TARGET} bs=276 count=1 2>/dev/null boot2.bin: boot2.out - objcopy -S -O binary boot2.out ${.TARGET} + objcopy -I i386-unknown-freebsd -S -O binary boot2.out ${.TARGET} boot2.out: boot2.o sio.o ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \ @@ -109,3 +109,21 @@ boot2 ${DESTDIR}${BINDIR}/boot2 .include + +.if defined(REALLY_AMD64) +# Make "machine" required for all objects +# (based on the more complete case in sys/i386/boot/Makefile.inc) +${SRCS:M*.c:R:S/$/.o/g}: machine + +# If it's not there, don't consider it a target +.if exists(${.CURDIR}/../../../i386/include) +beforedepend ${OBJS}: machine + +machine: + ln -sf ${.CURDIR}/../../../i386/include machine + +.endif + +CLEANFILES+= machine +.endif + ==== //depot/projects/hammer/sys/boot/i386/btx/btx/Makefile#2 - /home/src/sys/boot/i386/btx/btx/Makefile ==== @@ -29,7 +29,7 @@ btx: btx.o ${LD} -N -e start -Ttext ${ORG} -o btx.out btx.o - objcopy -S -O binary btx.out ${.TARGET} + objcopy -I i386-unknown-freebsd -S -O binary btx.out ${.TARGET} btx.o: btx.s (cd ${.CURDIR}; ${M4} ${M4FLAGS} btx.s) | \ ==== //depot/projects/hammer/sys/boot/i386/btx/btxldr/Makefile#2 - /home/src/sys/boot/i386/btx/btxldr/Makefile ==== @@ -11,7 +11,7 @@ btxldr: btxldr.o ${LD} -N -e start -Ttext ${LOADER_ADDRESS} -o btxldr.out btxldr.o - objcopy -S -O binary btxldr.out ${.TARGET} + objcopy -I i386-unknown-freebsd -S -O binary btxldr.out ${.TARGET} btxldr.o: btxldr.s (cd ${.CURDIR}; ${M4} ${M4FLAGS} btxldr.s ) | \ @@ -19,5 +19,4 @@ CLEANFILES+= btxldr btxldr.out btxldr.o -.include <${.CURDIR}/../../Makefile.inc> .include ==== //depot/projects/hammer/sys/boot/i386/cdboot/Makefile#2 - /home/src/sys/boot/i386/cdboot/Makefile ==== @@ -11,7 +11,7 @@ ${PROG}: ${PROG}.o ${LD} -N -e start -Ttext ${ORG} -o ${PROG}.out ${PROG}.o - objcopy -S -O binary ${PROG}.out ${.TARGET} + objcopy -I i386-unknown-freebsd -S -O binary ${PROG}.out ${.TARGET} CLEANFILES+= ${PROG}.o ${PROG}.out ==== //depot/projects/hammer/sys/boot/i386/mbr/Makefile#2 - /home/src/sys/boot/i386/mbr/Makefile ==== @@ -10,7 +10,7 @@ mbr: mbr.o ${LD} -N -e start -Ttext ${ORG} -o mbr.out mbr.o - objcopy -S -O binary mbr.out ${.TARGET} + objcopy -I i386-unknown-freebsd -S -O binary mbr.out ${.TARGET} CLEANFILES+= mbr.out mbr.o ==== //depot/projects/hammer/sys/boot/i386/pxeldr/Makefile#4 - /home/src/sys/boot/i386/pxeldr/Makefile ==== @@ -45,7 +45,7 @@ ${LDR}: ${LDR}.o ${LD} -N -e start -Ttext ${ORG} -o ${LDR}.out ${LDR}.o - objcopy -S -O binary ${LDR}.out ${.TARGET} + objcopy -I i386-unknown-freebsd -S -O binary ${LDR}.out ${.TARGET} ${LDR}.o: ${LDR}.s (cd ${.CURDIR}; ${M4} ${M4FLAGS} ${LDR}.s) | \ ==== //depot/projects/hammer/usr.sbin/Makefile#16 - /home/src/usr.sbin/Makefile ==== @@ -193,6 +193,10 @@ .endif .endif +.if ${MACHINE_ARCH} == "amd64" +SUBDIR+= btxld +.endif + .if ${MACHINE} == "i386" SUBDIR+=boot0cfg .endif