Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Mar 2013 17:40:38 +0000 (UTC)
From:      Juergen Lock <nox@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r315552 - in head: emulators/qemu-devel emulators/qemu-devel/files net/usbredir
Message-ID:  <201303291740.r2THecer075205@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nox
Date: Fri Mar 29 17:40:38 2013
New Revision: 315552
URL: http://svnweb.freebsd.org/changeset/ports/315552

Log:
  - Update net/usbredir to 0.6 .
  - Update emulators/qemu-devel to 1.4.0 with preliminary bsd-user patches.
  
  Thanx to:	sson, cognet, and others for much improved bsd-user support -
  		it now runs at least quite a few mips64 and single-threaded
  		arm binaries, see:
  
  	https://wiki.freebsd.org/QemuUserModeHowTo

Added:
  head/emulators/qemu-devel/files/patch-bsd-user-qemu.h   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z2-bsd-user-cognet-sson-002   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z2b-bsd-user-sson-002b   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z2c-bsd-user-sson-002c   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z2d-bsd-user-sson-002d   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z2e-bsd-user-sson-002e   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z3-bsd-user-8fix   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z3b-bsd-user-8fix   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z3c-bsd-user-8fix   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z3d-bsd-user-8fix   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z4-bsd-user-elfload   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z6-bsd-user-usrstack1   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z7-bsd-user-tls1-cognet   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z7b-bsd-user-tls2   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z8-bsd-user-unref   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z9-bsd-user-sson003a   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z9b-bsd-user-sson003b   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z9c-bsd-user-sson003c   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z9d-bsd-user-sson003d   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z9e-bsd-user-cognet-elfload   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z9f-bsd-user-sson003f   (contents, props changed)
  head/emulators/qemu-devel/files/patch-za-bsd-user-8fix   (contents, props changed)
  head/emulators/qemu-devel/files/patch-zb-bsd-user-sson004a   (contents, props changed)
Deleted:
  head/emulators/qemu-devel/files/Makefile_objs.patch
  head/emulators/qemu-devel/files/gns3-qemu-options.hx.patch
  head/emulators/qemu-devel/files/net_c.patch
  head/emulators/qemu-devel/files/net_h.patch
  head/emulators/qemu-devel/files/net_udp_c.patch
  head/emulators/qemu-devel/files/net_udp_h.patch
  head/emulators/qemu-devel/files/patch-e1000-rx
Modified:
  head/emulators/qemu-devel/Makefile
  head/emulators/qemu-devel/distinfo   (contents, props changed)
  head/emulators/qemu-devel/files/patch-90_security   (contents, props changed)
  head/emulators/qemu-devel/files/patch-Makefile   (contents, props changed)
  head/emulators/qemu-devel/files/patch-bg   (contents, props changed)
  head/emulators/qemu-devel/files/patch-bsd-user-ld   (contents, props changed)
  head/emulators/qemu-devel/files/patch-hw-ppc_newworld.c   (contents, props changed)
  head/emulators/qemu-devel/files/patch-hw-ppc_oldworld.c   (contents, props changed)
  head/emulators/qemu-devel/files/patch-ppc.ld   (contents, props changed)
  head/emulators/qemu-devel/files/patch-tapclose   (contents, props changed)
  head/emulators/qemu-devel/files/patch-z-arm-bsd-user-001   (contents, props changed)
  head/emulators/qemu-devel/files/pcap-patch   (contents, props changed)
  head/emulators/qemu-devel/pkg-plist   (contents, props changed)
  head/net/usbredir/Makefile   (contents, props changed)
  head/net/usbredir/distinfo   (contents, props changed)
  head/net/usbredir/pkg-descr   (contents, props changed)
  head/net/usbredir/pkg-plist   (contents, props changed)

Modified: head/emulators/qemu-devel/Makefile
==============================================================================
--- head/emulators/qemu-devel/Makefile	Fri Mar 29 17:10:52 2013	(r315551)
+++ head/emulators/qemu-devel/Makefile	Fri Mar 29 17:40:38 2013	(r315552)
@@ -2,8 +2,7 @@
 # $FreeBSD$
 
 PORTNAME=	qemu
-PORTVERSION=	1.1.1
-PORTREVISION=	2
+PORTVERSION=	1.4.0
 CATEGORIES=	emulators
 MASTER_SITES=	http://wiki.qemu.org/download/:release \
 		LOCAL/nox:snapshot
@@ -14,8 +13,10 @@ DIST_SUBDIR=	qemu/${PORTVERSION}
 MAINTAINER=	nox@FreeBSD.org
 COMMENT=	QEMU CPU Emulator - development version
 
+LIB_DEPENDS=	pixman-1:${PORTSDIR}/x11/pixman
+
 HAS_CONFIGURE=	yes
-EXTRACT_SUFX=	.tar.bz2
+USE_BZIP2=	yes
 USE_GMAKE=	yes
 USE_PERL5_BUILD=	yes
 USE_PYTHON_BUILD=	yes
@@ -29,7 +30,8 @@ CONFLICTS_INSTALL=	qemu-[0-9]*
 MAKE_JOBS_SAFE=	yes
 
 OPTIONS_DEFINE=	SAMBA SDL OPENGL GNUTLS SASL JPEG PNG CURL CDROM_DMA PCAP \
-		USBREDIR GNS3 ADD_AUDIO CLANG_HACK X86_TARGETS BSD_USER
+		USBREDIR GNS3 ADD_AUDIO CLANG_HACK X86_TARGETS BSD_USER \
+		STATIC_LINK
 SAMBA_DESC=		samba dependency (for -smb)
 GNUTLS_DESC=		gnutls dependency (vnc encryption)
 SASL_DESC=		cyrus-sasl dependency (vnc encryption)
@@ -40,11 +42,12 @@ CDROM_DMA_DESC=		IDE CDROM DMA
 PCAP_DESC=		pcap dependency (networking with bpf)
 SEABIOS_GIT_DESC=	add seabios snapshot (-bios bios.bin-1.6.3.1)
 USBREDIR_DESC=		usb device network redirection (experimental!)
-GNS3_DESC=		gns3 patches (udp, promiscuous multicast)
+GNS3_DESC=		gns3 patches (promiscuous multicast)
 ADD_AUDIO_DESC=		Emulate more audio hardware (experimental!)
 CLANG_HACK_DESC=		clang workaround (result slow and less stable!)
 X86_TARGETS_DESC=	Don't build non-x86 system targets
 BSD_USER_DESC=		Also build bsd-user targets (for testing)
+STATIC_LINK_DESC=	Statically link the executables
 OPTIONS_DEFAULT=SDL OPENGL GNUTLS SASL JPEG PNG CURL CDROM_DMA PCAP
 
 .include <bsd.port.options.mk>
@@ -64,13 +67,22 @@ USE_GCC=	any
 
 .if ${PORT_OPTIONS:MX86_TARGETS}
 .if ${PORT_OPTIONS:MBSD_USER}
-CONFIGURE_ARGS+=	--target-list=i386-softmmu,x86_64-softmmu,i386-bsd-user,x86_64-bsd-user,sparc-bsd-user,sparc64-bsd-user,arm-bsd-user
+.if ${ARCH} != "amd64"
+CONFIGURE_ARGS+=	--enable-nptl --target-list=i386-softmmu,x86_64-softmmu,i386-bsd-user,sparc-bsd-user,arm-bsd-user,armeb-bsd-user,mips-bsd-user,mipsel-bsd-user
+.else
+CONFIGURE_ARGS+=	--enable-nptl --target-list=i386-softmmu,x86_64-softmmu,i386-bsd-user,x86_64-bsd-user,sparc-bsd-user,sparc64-bsd-user,arm-bsd-user,armeb-bsd-user,mips-bsd-user,mipsel-bsd-user,mips64-bsd-user
+.endif
 .else
 CONFIGURE_ARGS+=	--target-list=i386-softmmu,x86_64-softmmu
 .endif
 .else
 .if empty(PORT_OPTIONS:MBSD_USER)
 CONFIGURE_ARGS+=	--disable-bsd-user
+.else
+CONFIGURE_ARGS+=	--enable-nptl
+.if ${ARCH} != "amd64"
+CONFIGURE_ARGS+=	--target-list=i386-softmmu,x86_64-softmmu,alpha-softmmu,arm-softmmu,cris-softmmu,lm32-softmmu,m68k-softmmu,microblaze-softmmu,microblazeel-softmmu,mips-softmmu,mipsel-softmmu,mips64-softmmu,mips64el-softmmu,or32-softmmu,ppc-softmmu,ppcemb-softmmu,ppc64-softmmu,sh4-softmmu,sh4eb-softmmu,sparc-softmmu,sparc64-softmmu,s390x-softmmu,xtensa-softmmu,xtensaeb-softmmu,unicore32-softmmu,i386-bsd-user,sparc-bsd-user,arm-bsd-user,armeb-bsd-user,mips-bsd-user,mipsel-bsd-user
+.endif
 .endif
 .endif
 
@@ -82,6 +94,11 @@ PLIST_SUB+=	BSD_USER=""
 IGNORE=		bsd-user targets not tested on sparc64
 .endif
 .endif
+.if empty(PORT_OPTIONS:MBSD_USER) || ${ARCH} != "amd64"
+PLIST_SUB+=	BSD_USER64="@comment "
+.else
+PLIST_SUB+=	BSD_USER64=""
+.endif
 
 .if ${PORT_OPTIONS:MX86_TARGETS}
 PLIST_SUB+=	NONX86="@comment "
@@ -90,13 +107,7 @@ PLIST_SUB+=	NONX86=""
 .endif
 
 .if ${PORT_OPTIONS:MGNS3}
-EXTRA_PATCHES+=	${FILESDIR}/hw_e1000_c.patch \
-		${FILESDIR}/net_c.patch \
-		${FILESDIR}/net_h.patch \
-		${FILESDIR}/net_udp_c.patch \
-		${FILESDIR}/net_udp_h.patch \
-		${FILESDIR}/Makefile_objs.patch \
-		${FILESDIR}/gns3-qemu-options.hx.patch
+EXTRA_PATCHES+=	${FILESDIR}/hw_e1000_c.patch
 .endif
 
 WITHOUT_CPU_CFLAGS=yes	#to avoid problems with register allocation
@@ -105,6 +116,8 @@ CONFIGURE_ARGS+=	--prefix=${PREFIX} --cc
 	--disable-linux-user --disable-linux-aio \
 	--disable-kvm --disable-xen \
 	--smbd=${LOCALBASE}/sbin/smbd \
+	--enable-debug \
+	--enable-debug-info \
 	--extra-cflags=-I${WRKSRC}\ -I${LOCALBASE}/include\ -DPREFIX=\\\"${PREFIX}\\\"
 
 .if empty(PORT_OPTIONS:MSDL)
@@ -160,6 +173,10 @@ RUN_DEPENDS+=	usbredir>=0.4.3:${PORTSDIR
 CONFIGURE_ARGS+=	--enable-pcap
 .endif
 
+.if ${PORT_OPTIONS:MSTATIC_LINK}
+CONFIGURE_ARGS+=	--static
+.endif
+
 .if ${PORT_OPTIONS:MADD_AUDIO}
 CONFIGURE_ARGS+=	--audio-card-list=ac97,es1370,sb16,cs4231a,adlib,gus,hda
 .endif
@@ -201,9 +218,11 @@ MAKE_ENV+=	COMPILER_PATH=${LOCALBASE}/bi
 .endif
 
 post-patch:
+.if ${OSVERSION} < 900000
+	@${REINPLACE_CMD} -e '/LIBS/s|-lprocstat||' ${WRKSRC}/configure
+.endif
 .if ${PORT_OPTIONS:MPCAP}
 	@cd ${WRKSRC} && ${PATCH} --quiet < ${FILESDIR}/pcap-patch
-	@${REINPLACE_CMD} -f ${FILESDIR}/pcap-client-type.sed ${WRKSRC}/net.h
 .endif
 .if empty(PORT_OPTIONS:MCDROM_DMA)
 	@cd ${WRKSRC} && ${PATCH} --quiet < ${FILESDIR}/cdrom-dma-patch

Modified: head/emulators/qemu-devel/distinfo
==============================================================================
--- head/emulators/qemu-devel/distinfo	Fri Mar 29 17:10:52 2013	(r315551)
+++ head/emulators/qemu-devel/distinfo	Fri Mar 29 17:40:38 2013	(r315552)
@@ -1,2 +1,2 @@
-SHA256 (qemu/1.1.1/qemu-1.1.1.tar.bz2) = 004a3032b504e70174c504d6c156b1ec3445abd9913602af0d7a5ac0703ddf5c
-SIZE (qemu/1.1.1/qemu-1.1.1.tar.bz2) = 11712524
+SHA256 (qemu/1.4.0/qemu-1.4.0.tar.bz2) = 066297ed77408fb7588889c271a85cf3c259ad55c939315988e6062d7708eda8
+SIZE (qemu/1.4.0/qemu-1.4.0.tar.bz2) = 10419510

Modified: head/emulators/qemu-devel/files/patch-90_security
==============================================================================
--- head/emulators/qemu-devel/files/patch-90_security	Fri Mar 29 17:10:52 2013	(r315551)
+++ head/emulators/qemu-devel/files/patch-90_security	Fri Mar 29 17:40:38 2013	(r315552)
@@ -15,7 +15,7 @@ Index: qemu/hw/dma.c
  }
  
 Index: qemu/hw/fdc.c
-@@ -1322,7 +1322,8 @@
+@@ -1445,7 +1445,8 @@ static uint32_t fdctrl_read_data(FDCtrl 
                                     fd_sector(cur_drv));
                      return 0;
                  }
@@ -25,16 +25,16 @@ Index: qemu/hw/fdc.c
                  FLOPPY_DPRINTF("error getting sector %d\n",
                                 fd_sector(cur_drv));
                  /* Sure, image size is too small... */
-@@ -1776,7 +1777,8 @@
+@@ -1905,7 +1906,8 @@ static void fdctrl_write_data(FDCtrl *fd
          if (pos == FD_SECTOR_LEN - 1 ||
              fdctrl->data_pos == fdctrl->data_len) {
              cur_drv = get_cur_drv(fdctrl);
 -            if (bdrv_write(cur_drv->bs, fd_sector(cur_drv), fdctrl->fifo, 1) < 0) {
 +            if (cur_drv->bs == NULL ||
 +                bdrv_write(cur_drv->bs, fd_sector(cur_drv), fdctrl->fifo, 1) < 0) {
-                 FLOPPY_ERROR("writing sector %d\n", fd_sector(cur_drv));
+                 FLOPPY_DPRINTF("error writing sector %d\n",
+                                fd_sector(cur_drv));
                  return;
-             }
 Index: qemu-0.8.2/hw/sb16.c
 ===================================================================
 --- qemu-0.8.2.orig/hw/sb16.c	2006-07-22 20:23:34.000000000 +0300

Modified: head/emulators/qemu-devel/files/patch-Makefile
==============================================================================
--- head/emulators/qemu-devel/files/patch-Makefile	Fri Mar 29 17:10:52 2013	(r315551)
+++ head/emulators/qemu-devel/files/patch-Makefile	Fri Mar 29 17:40:38 2013	(r315552)
@@ -1,5 +1,5 @@
 Index: qemu/Makefile
-@@ -40,7 +40,11 @@ LIBS+=-lz $(LIBS_TOOLS)
+@@ -53,7 +53,11 @@ LIBS+=-lz $(LIBS_TOOLS)
  HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF)
  
  ifdef BUILD_DOCS
@@ -11,7 +11,7 @@ Index: qemu/Makefile
  ifdef CONFIG_VIRTFS
  DOCS+=fsdev/virtfs-proxy-helper.1
  endif
-@@ -270,8 +274,10 @@ endif
+@@ -311,8 +315,10 @@ endif
  
  install-doc: $(DOCS)
  	$(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
@@ -22,7 +22,7 @@ Index: qemu/Makefile
  ifdef CONFIG_POSIX
  	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
  	$(INSTALL_DATA) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
-@@ -290,7 +296,10 @@ install-confdir:
+@@ -331,7 +337,10 @@ install-confdir:
  	$(INSTALL_DIR) "$(DESTDIR)$(qemu_confdir)"
  
  install-sysconfig: install-datadir install-confdir
@@ -31,6 +31,6 @@ Index: qemu/Makefile
 +	if [ ! -f "$(qemu_confdir)/target-x86_64.conf" ]; then \
 +	    $(INSTALL_DATA) $(SRC_PATH)/sysconfigs/target/target-x86_64.conf "$(qemu_confdir)"; \
 +	fi
- 	$(INSTALL_DATA) $(SRC_PATH)/sysconfigs/target/cpus-x86_64.conf "$(DESTDIR)$(qemu_datadir)"
  
  install: all $(if $(BUILD_DOCS),install-doc) install-sysconfig install-datadir
+ 	$(INSTALL_DIR) "$(DESTDIR)$(bindir)"

Modified: head/emulators/qemu-devel/files/patch-bg
==============================================================================
--- head/emulators/qemu-devel/files/patch-bg	Fri Mar 29 17:10:52 2013	(r315551)
+++ head/emulators/qemu-devel/files/patch-bg	Fri Mar 29 17:40:38 2013	(r315552)
@@ -1,4 +1,4 @@
-Index: qemu/net.h
+Index: qemu/include/net/net.h
 @@ -174,8 +174,8 @@ void net_host_device_remove(Monitor *mon
  int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
  int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
@@ -10,7 +10,7 @@ Index: qemu/net.h
  #define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper"
  #define DEFAULT_BRIDGE_INTERFACE "br0"
  
-Index: qemu/net/tap.h
+Index: qemu/net/tap_int.h
 @@ -29,8 +29,8 @@
  #include "qemu-common.h"
  #include "qemu-option.h"

Modified: head/emulators/qemu-devel/files/patch-bsd-user-ld
==============================================================================
--- head/emulators/qemu-devel/files/patch-bsd-user-ld	Fri Mar 29 17:10:52 2013	(r315551)
+++ head/emulators/qemu-devel/files/patch-bsd-user-ld	Fri Mar 29 17:40:38 2013	(r315552)
@@ -1,5 +1,5 @@
---- a/x86_64.ld
-+++ b/x86_64.ld
+--- a/ldscripts/x86_64.ld
++++ b/ldscripts/x86_64.ld
 @@ -1,54 +1,58 @@
 -/* Default linker script, for normal executables */
 -OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
@@ -256,8 +256,8 @@
 +  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
 +  /DISCARD/ : { *(.note.GNU-stack) }
  }
---- a/i386.ld
-+++ b/i386.ld
+--- a/ldscripts/i386.ld
++++ b/ldscripts/i386.ld
 @@ -1,45 +1,47 @@
 -/* ld script to make i386 Linux kernel
 - * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;

Added: head/emulators/qemu-devel/files/patch-bsd-user-qemu.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/emulators/qemu-devel/files/patch-bsd-user-qemu.h	Fri Mar 29 17:40:38 2013	(r315552)
@@ -0,0 +1,31 @@
+--- a/bsd-user/qemu.h
++++ b/bsd-user/qemu.h
+@@ -50,6 +50,10 @@ struct image_info {
+     abi_ulong entry;
+     abi_ulong code_offset;
+     abi_ulong data_offset;
++#if 1
++    abi_ulong arg_start;
++    abi_ulong arg_end;
++#endif
+     int       personality;
+ };
+ 
+@@ -72,6 +76,17 @@ struct emulated_sigtable {
+ typedef struct TaskState {
+     struct TaskState *next;
+     int used; /* non zero if used */
++#if 1
++#ifdef TARGET_ARM
++    int swi_errno;
++#endif
++#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32)
++    /* Extra fields for semihosted binaries.  */
++    uint32_t heap_base;
++    uint32_t heap_limit;
++#endif
++    uint32_t stack_base;
++#endif
+     struct image_info *info;
+ 
+     struct emulated_sigtable sigtab[TARGET_NSIG];

Modified: head/emulators/qemu-devel/files/patch-hw-ppc_newworld.c
==============================================================================
--- head/emulators/qemu-devel/files/patch-hw-ppc_newworld.c	Fri Mar 29 17:10:52 2013	(r315551)
+++ head/emulators/qemu-devel/files/patch-hw-ppc_newworld.c	Fri Mar 29 17:40:38 2013	(r315552)
@@ -1,5 +1,5 @@
---- a/hw/ppc_newworld.c
-+++ b/hw/ppc_newworld.c
+--- a/hw/ppc/mac_newworld.c
++++ b/hw/ppc/mac_newworld.c
 @@ -68,6 +68,11 @@
  #include "hw/usb.h"
  #include "blockdev.h"

Modified: head/emulators/qemu-devel/files/patch-hw-ppc_oldworld.c
==============================================================================
--- head/emulators/qemu-devel/files/patch-hw-ppc_oldworld.c	Fri Mar 29 17:10:52 2013	(r315551)
+++ head/emulators/qemu-devel/files/patch-hw-ppc_oldworld.c	Fri Mar 29 17:40:38 2013	(r315552)
@@ -1,5 +1,5 @@
---- a/hw/ppc_oldworld.c
-+++ b/hw/ppc_oldworld.c
+--- a/hw/ppc/mac_oldworld.c
++++ b/hw/ppc/mac_oldworld.c
 @@ -47,6 +47,11 @@
  #define MAX_IDE_BUS 2
  #define CFG_ADDR 0xf0000510

Modified: head/emulators/qemu-devel/files/patch-ppc.ld
==============================================================================
--- head/emulators/qemu-devel/files/patch-ppc.ld	Fri Mar 29 17:10:52 2013	(r315551)
+++ head/emulators/qemu-devel/files/patch-ppc.ld	Fri Mar 29 17:40:38 2013	(r315552)
@@ -1,5 +1,5 @@
---- a/ppc.ld
-+++ b/ppc.ld
+--- a/ldscripts/ppc.ld
++++ b/ldscripts/ppc.ld
 @@ -99,7 +99,7 @@ SECTIONS
       PROVIDE (__init_array_start = .);
       KEEP (*(SORT(.init_array.*)))

Modified: head/emulators/qemu-devel/files/patch-tapclose
==============================================================================
--- head/emulators/qemu-devel/files/patch-tapclose	Fri Mar 29 17:10:52 2013	(r315551)
+++ head/emulators/qemu-devel/files/patch-tapclose	Fri Mar 29 17:40:38 2013	(r315552)
@@ -1,13 +1,13 @@
 Index: qemu/net/tap.c
-@@ -287,12 +287,13 @@ static void tap_cleanup(VLANClientState 
+@@ -286,12 +286,13 @@ static void tap_cleanup(NetClientState *
  
      qemu_purge_queued_packets(nc);
  
 -    if (s->down_script[0])
 -        launch_script(s->down_script, s->down_script_arg, s->fd);
 -
-     tap_read_poll(s, 0);
-     tap_write_poll(s, 0);
+     tap_read_poll(s, false);
+     tap_write_poll(s, false);
      close(s->fd);
 +
 +    if (s->down_script[0])

Modified: head/emulators/qemu-devel/files/patch-z-arm-bsd-user-001
==============================================================================
--- head/emulators/qemu-devel/files/patch-z-arm-bsd-user-001	Fri Mar 29 17:10:52 2013	(r315551)
+++ head/emulators/qemu-devel/files/patch-z-arm-bsd-user-001	Fri Mar 29 17:40:38 2013	(r315552)
@@ -289,6 +289,18 @@
  #endif
 --- a/bsd-user/syscall.c.orig
 +++ b/bsd-user/syscall.c
+@@ -96,6 +96,11 @@ static abi_long do_obreak(abi_ulong new_
+     return 0;
+ }
+ 
++abi_long do_brk(abi_ulong new_brk)
++{
++    return do_obreak(new_brk);
++}
++
+ #if defined(TARGET_I386)
+ static abi_long do_freebsd_sysarch(CPUX86State *env, int op, abi_ulong parms)
+ {
 @@ -157,6 +161,12 @@ static abi_long do_freebsd_sysarch(void 
  }
  #endif

Added: head/emulators/qemu-devel/files/patch-z2-bsd-user-cognet-sson-002
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/emulators/qemu-devel/files/patch-z2-bsd-user-cognet-sson-002	Fri Mar 29 17:40:38 2013	(r315552)
@@ -0,0 +1,8355 @@
+#diff --git a/Makefile b/Makefile
+#index 5fa0f1d..55e151e 100644
+#--- a/Makefile
+#+++ b/Makefile
+#@@ -65,7 +65,8 @@ CLANG_CFLAGS_AS+=	-no-integrated-as
+# 
+# .if ${PORT_OPTIONS:MX86_TARGETS}
+# .if ${PORT_OPTIONS:MBSD_USER}
+#-CONFIGURE_ARGS+=	--target-list=i386-softmmu,x86_64-softmmu,i386-bsd-user,x86_64-bsd-user,sparc-bsd-user,sparc64-bsd-user,arm-bsd-user
+#+#CONFIGURE_ARGS+=	--target-list=i386-softmmu,x86_64-softmmu,i386-bsd-user,x86_64-bsd-user,sparc-bsd-user,sparc64-bsd-user,arm-bsd-user,armeb-bsd-user,mips-bsd-user,mipsel-bsd-user
+#+CONFIGURE_ARGS+=	--target-list=arm-bsd-user,armeb-bsd-user,mips-bsd-user,mipsel-bsd-user,mips64-bsd-user
+# .else
+# CONFIGURE_ARGS+=	--target-list=i386-softmmu,x86_64-softmmu
+# .endif
+#@@ -106,6 +107,8 @@ CONFIGURE_ARGS+=	--prefix=${PREFIX} --cc=${CC} --enable-docs \
+# 	--disable-linux-user --disable-linux-aio \
+# 	--disable-kvm --disable-xen \
+# 	--smbd=${LOCALBASE}/sbin/smbd \
+#+	--enable-debug \
+#+	--enable-debug-info \
+# 	--extra-cflags=-I${WRKSRC}\ -I${LOCALBASE}/include\ -DPREFIX=\\\"${PREFIX}\\\"
+# 
+# .if empty(PORT_OPTIONS:MSDL)
+diff --git a/bsd-user/arm/target_signal.h b/bsd-user/arm/target_signal.h
+index 1b644cc..19cc188 100644
+--- a/bsd-user/arm/target_signal.h
++++ b/bsd-user/arm/target_signal.h
+@@ -3,17 +3,12 @@
+ 
+ #include "cpu.h"
+ 
+-/* this struct defines a stack used during syscall handling */
+-
+-typedef struct target_sigaltstack {
+-	abi_ulong ss_sp;
+-	abi_long ss_flags;
+-	abi_ulong ss_size;
+-} target_stack_t;
+-
+ static inline abi_ulong get_sp_from_cpustate(CPUARMState *state)
+ {
+     return state->regs[13];
+ }
+ 
++#define	TARGET_MINSIGSTKSZ	(1024 * 4)
++#define	TARGET_SIGSTKSZ		(TARGET_MINSIGSTKSZ + 32768)
++
+ #endif /* TARGET_SIGNAL_H */
+diff --git a/bsd-user/arm/target_vmparam.h b/bsd-user/arm/target_vmparam.h
+new file mode 100644
+index 0000000..0427244
+--- /dev/null
++++ b/bsd-user/arm/target_vmparam.h
+@@ -0,0 +1,28 @@
++#ifndef _TARGET_VMPARAM_H_
++#define _TARGET_VMPARAM_H_
++
++#if defined(__FreeBSD__)
++					/* KERNBASE - 512 MB */
++#define TARGET_VM_MAXUSER_ADDRESS	(0xc0000000 - (512 * 1024 * 1024))
++#define TARGET_USRSTACK			TARGET_VM_MAXUSER_ADDRESS
++
++struct target_ps_strings {
++	abi_ulong ps_argvstr;
++	uint32_t ps_nargvstr;
++	abi_ulong ps_envstr;
++	uint32_t ps_nenvstr;
++};
++
++#define TARGET_SPACE_USRSPACE   4096
++#define TARGET_ARG_MAX          262144
++
++#define TARGET_PS_STRINGS  (TARGET_USRSTACK - sizeof(struct target_ps_strings))
++
++#define TARGET_SZSIGCODE 0
++
++#else
++
++#define TARGET_USRSTACK			0
++#endif
++
++#endif /* _TARGET_VMPARAM_H_ */
+diff --git a/bsd-user/bsdload.c b/bsd-user/bsdload.c
+index 2abc713..dcf6f66 100644
+--- a/bsd-user/bsdload.c
++++ b/bsd-user/bsdload.c
+@@ -53,7 +53,7 @@ static int count(char ** vec)
+     return(i);
+ }
+ 
+-static int prepare_binprm(struct linux_binprm *bprm)
++static int prepare_binprm(struct bsd_binprm *bprm)
+ {
+     struct stat         st;
+     int mode;
+@@ -155,33 +155,33 @@ abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
+ }
+ 
+ int loader_exec(const char * filename, char ** argv, char ** envp,
+-             struct target_pt_regs * regs, struct image_info *infop)
++             struct target_pt_regs * regs, struct image_info *infop,
++	     struct bsd_binprm *bprm)
+ {
+-    struct linux_binprm bprm;
+     int retval;
+     int i;
+ 
+-    bprm.p = TARGET_PAGE_SIZE*MAX_ARG_PAGES-sizeof(unsigned int);
++    bprm->p = TARGET_PAGE_SIZE*MAX_ARG_PAGES /*-sizeof(unsigned int) XXX */;
+     for (i=0 ; i<MAX_ARG_PAGES ; i++)       /* clear page-table */
+-            bprm.page[i] = NULL;
++            bprm->page[i] = NULL;
+     retval = open(filename, O_RDONLY);
+     if (retval < 0)
+         return retval;
+-    bprm.fd = retval;
+-    bprm.filename = (char *)filename;
+-    bprm.argc = count(argv);
+-    bprm.argv = argv;
+-    bprm.envc = count(envp);
+-    bprm.envp = envp;
++    bprm->fd = retval;
++    bprm->filename = (char *)filename;
++    bprm->argc = count(argv);
++    bprm->argv = argv;
++    bprm->envc = count(envp);
++    bprm->envp = envp;
+ 
+-    retval = prepare_binprm(&bprm);
++    retval = prepare_binprm(bprm);
+ 
+     if(retval>=0) {
+-        if (bprm.buf[0] == 0x7f
+-                && bprm.buf[1] == 'E'
+-                && bprm.buf[2] == 'L'
+-                && bprm.buf[3] == 'F') {
+-            retval = load_elf_binary(&bprm,regs,infop);
++        if (bprm->buf[0] == 0x7f
++                && bprm->buf[1] == 'E'
++                && bprm->buf[2] == 'L'
++                && bprm->buf[3] == 'F') {
++            retval = load_elf_binary(bprm,regs,infop);
+         } else {
+             fprintf(stderr, "Unknown binary format\n");
+             return -1;
+@@ -196,7 +196,7 @@ int loader_exec(const char * filename, char ** argv, char ** envp,
+ 
+     /* Something went wrong, return the inode and free the argument pages*/
+     for (i=0 ; i<MAX_ARG_PAGES ; i++) {
+-        g_free(bprm.page[i]);
++        g_free(bprm->page[i]);
+     }
+     return(retval);
+ }
+diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
+index 993dcf7..15cf3a6 100644
+--- a/bsd-user/elfload.c
++++ b/bsd-user/elfload.c
+@@ -9,6 +9,8 @@
+ #include <stdlib.h>
+ #include <string.h>
+ 
++#include <sys/param.h>
++
+ #include "qemu.h"
+ #include "disas.h"
+ 
+@@ -93,6 +95,7 @@ enum {
+ 
+ #ifdef TARGET_I386
+ 
++#ifndef __FreeBSD__
+ #define ELF_PLATFORM get_elf_platform()
+ 
+ static const char *get_elf_platform(void)
+@@ -112,6 +115,7 @@ static uint32_t get_elf_hwcap(void)
+ {
+   return thread_env->cpuid_features;
+ }
++#endif /* ! __FreeBSD__ */
+ 
+ #ifdef TARGET_X86_64
+ #define ELF_START_MMAP 0x2aaaaab000ULL
+@@ -378,13 +382,14 @@ static inline void init_thread(struct target_pt_regs *_regs, struct image_info *
+ 
+ #ifdef TARGET_MIPS
+ 
+-#define ELF_START_MMAP 0x80000000
+ 
+ #define elf_check_arch(x) ( (x) == EM_MIPS )
+ 
+-#ifdef TARGET_MIPS64
++#if defined(TARGET_MIPS64)
++#define ELF_START_MMAP 0x2aaaaab000ULL
+ #define ELF_CLASS   ELFCLASS64
+ #else
++#define ELF_START_MMAP 0x80000000
+ #define ELF_CLASS   ELFCLASS32
+ #endif
+ #ifdef TARGET_WORDS_BIGENDIAN
+@@ -396,9 +401,10 @@ static inline void init_thread(struct target_pt_regs *_regs, struct image_info *
+ 
+ static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop)
+ {
++
+     regs->cp0_status = 2 << CP0St_KSU;
+-    regs->cp0_epc = infop->entry;
+-    regs->regs[29] = infop->start_stack;
++    regs->regs[25] = regs->cp0_epc = infop->entry;	 /* t9 = pc = entry */
++    regs->regs[4] = regs->regs[29] = infop->start_stack; /* a0 = sp = start_stack */
+ }
+ 
+ #define USE_ELF_CORE_DUMP
+@@ -576,30 +582,38 @@ static void bswap_ehdr(struct elfhdr *ehdr)
+     bswap16s(&ehdr->e_shstrndx);                /* Section header string table index */
+ }
+ 
+-static void bswap_phdr(struct elf_phdr *phdr)
++static void bswap_phdr(struct elf_phdr *phdr, int phnum)
+ {
+-    bswap32s(&phdr->p_type);                    /* Segment type */
+-    bswaptls(&phdr->p_offset);          /* Segment file offset */
+-    bswaptls(&phdr->p_vaddr);           /* Segment virtual address */
+-    bswaptls(&phdr->p_paddr);           /* Segment physical address */
+-    bswaptls(&phdr->p_filesz);          /* Segment size in file */
+-    bswaptls(&phdr->p_memsz);           /* Segment size in memory */
+-    bswap32s(&phdr->p_flags);           /* Segment flags */
+-    bswaptls(&phdr->p_align);           /* Segment alignment */
++    int i;
++
++    for (i = 0; i < phnum; ++i, ++phdr) {
++	bswap32s(&phdr->p_type);	/* Segment type */
++	bswap32s(&phdr->p_flags);	/* Segment flags */
++	bswaptls(&phdr->p_offset);	/* Segment file offset */
++	bswaptls(&phdr->p_vaddr);	/* Segment virtual address */
++	bswaptls(&phdr->p_paddr);	/* Segment physical address */
++	bswaptls(&phdr->p_filesz);	/* Segment size in file */
++	bswaptls(&phdr->p_memsz);	/* Segment size in memory */
++	bswaptls(&phdr->p_align);	/* Segment alignment */
++    }
+ }
+ 
+-static void bswap_shdr(struct elf_shdr *shdr)
++static void bswap_shdr(struct elf_shdr *shdr, int shnum)
+ {
+-    bswap32s(&shdr->sh_name);
+-    bswap32s(&shdr->sh_type);
+-    bswaptls(&shdr->sh_flags);
+-    bswaptls(&shdr->sh_addr);
+-    bswaptls(&shdr->sh_offset);
+-    bswaptls(&shdr->sh_size);
+-    bswap32s(&shdr->sh_link);
+-    bswap32s(&shdr->sh_info);
+-    bswaptls(&shdr->sh_addralign);
+-    bswaptls(&shdr->sh_entsize);
++    int i;
++
++    for (i = 0; i < shnum; ++i, ++shdr) {
++	bswap32s(&shdr->sh_name);
++	bswap32s(&shdr->sh_type);
++	bswaptls(&shdr->sh_flags);
++	bswaptls(&shdr->sh_addr);
++	bswaptls(&shdr->sh_offset);
++	bswaptls(&shdr->sh_size);
++	bswap32s(&shdr->sh_link);
++	bswap32s(&shdr->sh_info);
++	bswaptls(&shdr->sh_addralign);
++	bswaptls(&shdr->sh_entsize);
++    }
+ }
+ 
+ static void bswap_sym(struct elf_sym *sym)
+@@ -609,7 +623,14 @@ static void bswap_sym(struct elf_sym *sym)
+     bswaptls(&sym->st_size);
+     bswap16s(&sym->st_shndx);
+ }
+-#endif
++
++#else /* ! BSWAP_NEEDED */
++
++static inline void bswap_ehdr(struct elfhdr *ehdr) { }
++static inline void bswap_phdr(struct elf_phdr *phdr, int phnum) { }
++static inline void bswap_shdr(struct elf_shdr *shdr, int shnum) { }
++static inline void bswap_sym(struct elf_sym *sym) { }
++#endif /* ! BSWAP_NEEDED */
+ 
+ /*
+  * 'copy_elf_strings()' copies argument/envelope strings from user
+@@ -666,7 +687,26 @@ static abi_ulong copy_elf_strings(int argc,char ** argv, void **page,
+     return p;
+ }
+ 
+-static abi_ulong setup_arg_pages(abi_ulong p, struct linux_binprm *bprm,
++#if defined(TARGET_MIPS64)
++static inline int
++install_sigtramp(abi_ulong offset, unsigned sigf_uc, unsigned syscall)
++{
++	int i;
++	uint32_t sigtramp_code[] = {
++		0x67A40000 + sigf_uc,   /* daddu   $a0, $sp, (sigf_uc) */
++		0x24020000 + syscall,   /* li      $v0, (syscall) */
++		0x0000000C,             /* syscall */
++		0x0000000D              /* break */
++	};
++
++	for(i = 0; i < 4; i++)
++		tswap32s(&sigtramp_code[i]);
++
++	return (memcpy_to_target(offset, sigtramp_code, TARGET_SZSIGCODE));
++}
++#endif
++
++static abi_ulong setup_arg_pages(abi_ulong p, struct bsd_binprm *bprm,
+                                  struct image_info *info)
+ {
+     abi_ulong stack_base, size, error;
+@@ -678,7 +718,13 @@ static abi_ulong setup_arg_pages(abi_ulong p, struct linux_binprm *bprm,
+     size = x86_stack_size;
+     if (size < MAX_ARG_PAGES*TARGET_PAGE_SIZE)
+         size = MAX_ARG_PAGES*TARGET_PAGE_SIZE;
+-    error = target_mmap(0,
++
++#ifdef TARGET_USRSTACK
++    stack_base = TARGET_USRSTACK - size;
++#else
++    stack_base = (abi_ulong)0;
++#endif
++    error = target_mmap(stack_base,
+                         size + qemu_host_page_size,
+                         PROT_READ | PROT_WRITE,
+                         MAP_PRIVATE | MAP_ANON,
+@@ -690,6 +736,113 @@ static abi_ulong setup_arg_pages(abi_ulong p, struct linux_binprm *bprm,
+     /* we reserve one extra page at the top of the stack as guard */
+     target_mprotect(error + size, qemu_host_page_size, PROT_NONE);
+ 
++#if defined(__FreeBSD__)
++    /*
++     * The inital FreeBSD stack looks like follows:
++     * (see kern/kern_exec.c exec_copyout_strings() )
++     *
++     *  Hi Address -> char **ps_argvstr  (struct ps_strings for ps, w, etc.)
++     *                unsigned ps_nargvstr
++     *                char **ps_envstr
++     *  PS_STRINGS -> unsigned ps_nenvstr
++     *
++     *                machine dependent sigcode (sv_sigcode of size
++     *                                           sv_szsigcode)
++     *
++     *                execpath          (absolute image path for rtld)
++     *
++     *                SSP Canary        (sizeof(long) * 8)
++     *
++     *                page sizes array  (usually sizeof(u_long) )
++     *
++     *  "destp" ->    argv, env strings (up to 262144 bytes)
++     */
++
++    {
++	    abi_ulong stack_hi_addr;
++	    size_t execpath_len;
++	    abi_ulong destp;
++	    struct target_ps_strings ps_strs;
++	    char canary[sizeof(abi_long) * 8];
++	    char execpath[PATH_MAX];
++
++	    stack_hi_addr = p = error + size;
++
++	    /* Save some space for ps_strings. */
++	    p -= sizeof(struct target_ps_strings);
++
++#if TARGET_SZSIGCODE > 0
++	    /* Add machine depedent sigcode. */
++	    p -= TARGET_SZSIGCODE;
++	    /* XXX - check return value of memcpy_to_target() for failure */
++	    install_sigtramp( p, (unsigned)offsetof(struct target_sigframe,
++		    sf_uc), TARGET_FREEBSD_NR_sigreturn);
++#endif
++
++	    /* Add execpath for rtld. */
++	    if (strlen(bprm->filename)) {
++		    /* XXX - check return value of realpath() */
++		    realpath(bprm->filename, execpath);
++		    execpath_len = strlen(execpath) + 1;
++	    } else
++		    execpath_len = 0;
++
++	    if (execpath_len) {
++		    p -= roundup(execpath_len, sizeof(abi_ulong));
++		    /* XXX - check return value of memcpy_to_target() */
++		    memcpy_to_target(p, execpath, execpath_len);
++	    }
++
++	    /* Add canary for SSP. */
++	    arc4random_buf(canary, sizeof(canary));
++	    p -= roundup(sizeof(canary), sizeof(abi_ulong));
++	    /* XXX - check return value of memcpy_to_target(). */
++	    memcpy_to_target(p, canary, sizeof(canary));
++
++	    /* Add page sizes array. */
++	    p -= sizeof(abi_ulong);
++	    /* XXX - check return value of put_user_ual(). */
++	    put_user_ual(TARGET_PAGE_SIZE, p);
++
++	    p = destp = p - TARGET_SPACE_USRSPACE - TARGET_ARG_MAX;
++
++	    /* XXX should check strlen(argv and envp strings) < TARGET_ARG_MAX */
++
++	    /*
++	     * Add argv strings.  Note that the argv[] vectors are added by
++	     * loader_build_argptr()
++	     */
++	    i = bprm->argc;
++	    while (i-- > 0) {
++		    size_t len = strlen(bprm->argv[i]) + 1;
++		    /* XXX - check return value of memcpy_to_target(). */
++		    memcpy_to_target(destp, bprm->argv[i], len);
++		    destp += len;
++	    }
++	    ps_strs.ps_argvstr = tswapl(destp);
++	    ps_strs.ps_nargvstr = tswap32(bprm->argc);
++
++	    /*
++	     * Add env strings. Note that the envp[] vectors are added by
++	     * loader_build_argptr().
++	     */
++	    i = bprm->envc;
++	    while(i-- > 0) {
++		    size_t len = strlen(bprm->envp[i]) + 1;
++		    /* XXX - check return value of memcpy_to_target(). */
++		    memcpy_to_target(destp, bprm->envp[i], len);
++		    destp += len;
++	    }
++	    ps_strs.ps_envstr = tswapl(destp);
++	    ps_strs.ps_nenvstr = tswap32(bprm->envc);
++
++	    /* XXX - check return value of memcpy_to_target(). */
++	    memcpy_to_target(stack_hi_addr - sizeof(ps_strs), &ps_strs,
++		sizeof(ps_strs));
++    }
++
++#else
++
+     stack_base = error + size - MAX_ARG_PAGES*TARGET_PAGE_SIZE;
+     p += stack_base;
+ 
+@@ -702,6 +855,8 @@ static abi_ulong setup_arg_pages(abi_ulong p, struct linux_binprm *bprm,
+         }
+         stack_base += TARGET_PAGE_SIZE;
+     }
++#endif
++
+     return p;
+ }
+ 
+@@ -769,11 +924,14 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
+ {
+         abi_ulong sp;
+         int size;
++#ifndef __FreeBSD__
+         abi_ulong u_platform;
+         const char *k_platform;
++#endif
+         const int n = sizeof(elf_addr_t);
+ 
+         sp = p;
++#ifndef __FreeBSD__
+         u_platform = 0;
+         k_platform = ELF_PLATFORM;
+         if (k_platform) {
+@@ -783,22 +941,28 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
+             /* FIXME - check return value of memcpy_to_target() for failure */
+             memcpy_to_target(sp, k_platform, len);
+         }
++#endif /* ! __FreeBSD__ */
+         /*
+          * Force 16 byte _final_ alignment here for generality.
+          */
+         sp = sp &~ (abi_ulong)15;
++#ifdef __FreeBSD__
++	size = 0;
++#else
+         size = (DLINFO_ITEMS + 1) * 2;
+         if (k_platform)
+           size += 2;
+ #ifdef DLINFO_ARCH_ITEMS
+         size += DLINFO_ARCH_ITEMS * 2;
+ #endif
++#endif /* ! __FreeBSD__ */
+         size += envc + argc + 2;
+         size += (!ibcs ? 3 : 1);        /* argc itself */
+         size *= n;
+         if (size & 15)
+             sp -= 16 - (size & 15);
+ 
++#ifndef __FreeBSD__
+         /* This is correct because Linux defines
+          * elf_addr_t as Elf32_Off / Elf64_Off
+          */
+@@ -833,6 +997,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
+         ARCH_DLINFO;
+ #endif
+ #undef NEW_AUX_ENT
++#endif /* ! __FreeBSD__ */
+ 
+         sp = loader_build_argptr(envc, argc, sp, p, !ibcs);
+         return sp;
+@@ -856,9 +1021,7 @@ static abi_ulong load_elf_interp(struct elfhdr * interp_elf_ex,
+         last_bss = 0;
+         error = 0;
+ 
+-#ifdef BSWAP_NEEDED
+         bswap_ehdr(interp_elf_ex);
+-#endif
+         /* First of all, some simple consistency checks */
+         if ((interp_elf_ex->e_type != ET_EXEC &&
+              interp_elf_ex->e_type != ET_DYN) ||
+@@ -899,12 +1062,7 @@ static abi_ulong load_elf_interp(struct elfhdr * interp_elf_ex,
+                 free (elf_phdata);
+                 return retval;
+         }
+-#ifdef BSWAP_NEEDED
+-        eppnt = elf_phdata;
+-        for (i=0; i<interp_elf_ex->e_phnum; i++, eppnt++) {
+-            bswap_phdr(eppnt);
+-        }
+-#endif
++	bswap_phdr(elf_phdata, interp_elf_ex->e_phnum);
+ 
+         if (interp_elf_ex->e_type == ET_DYN) {
+             /* in order to avoid hardcoding the interpreter load
+@@ -1049,9 +1207,7 @@ static void load_symbols(struct elfhdr *hdr, int fd)
+     for (i = 0; i < hdr->e_shnum; i++) {
+         if (read(fd, &sechdr, sizeof(sechdr)) != sizeof(sechdr))
+             return;
+-#ifdef BSWAP_NEEDED
+-        bswap_shdr(&sechdr);
+-#endif
++	bswap_shdr(&sechdr, 1);
+         if (sechdr.sh_type == SHT_SYMTAB) {
+             symtab = sechdr;
+             lseek(fd, hdr->e_shoff
+@@ -1059,9 +1215,7 @@ static void load_symbols(struct elfhdr *hdr, int fd)
+             if (read(fd, &strtab, sizeof(strtab))
+                 != sizeof(strtab))
+                 return;
+-#ifdef BSWAP_NEEDED
+-            bswap_shdr(&strtab);
+-#endif
++	    bswap_shdr(&strtab, 1);
+             goto found;
+         }
+     }
+@@ -1094,9 +1248,7 @@ static void load_symbols(struct elfhdr *hdr, int fd)
+ 
+     i = 0;
+     while (i < nsyms) {
+-#ifdef BSWAP_NEEDED
+         bswap_sym(syms + i);
+-#endif
+         // Throw away entries which we do not need.
+         if (syms[i].st_shndx == SHN_UNDEF ||
+                 syms[i].st_shndx >= SHN_LORESERVE ||
+@@ -1148,7 +1300,7 @@ static void load_symbols(struct elfhdr *hdr, int fd)
+     syminfos = s;
+ }
+ 
+-int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
++int load_elf_binary(struct bsd_binprm * bprm, struct target_pt_regs * regs,
+                     struct image_info * info)
+ {
+     struct elfhdr elf_ex;
+@@ -1178,9 +1330,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
+     load_addr = 0;
+     load_bias = 0;
+     elf_ex = *((struct elfhdr *) bprm->buf);          /* exec-header */
+-#ifdef BSWAP_NEEDED
+     bswap_ehdr(&elf_ex);
+-#endif
+ 
+     /* First of all, some simple consistency checks */
+     if ((elf_ex.e_type != ET_EXEC && elf_ex.e_type != ET_DYN) ||
+@@ -1188,12 +1338,14 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
+             return -ENOEXEC;
+     }
+ 
++#ifndef __FreeBSD__
+     bprm->p = copy_elf_strings(1, &bprm->filename, bprm->page, bprm->p);
+     bprm->p = copy_elf_strings(bprm->envc,bprm->envp,bprm->page,bprm->p);
+     bprm->p = copy_elf_strings(bprm->argc,bprm->argv,bprm->page,bprm->p);
+     if (!bprm->p) {
+         retval = -E2BIG;
+     }
++#endif /* ! __FreeBSD__ */
+ 
+     /* Now read in all of the header information */
+     elf_phdata = (struct elf_phdr *)malloc(elf_ex.e_phentsize*elf_ex.e_phnum);
+@@ -1214,12 +1366,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
+         return -errno;
+     }
+ 
+-#ifdef BSWAP_NEEDED
+-    elf_ppnt = elf_phdata;
+-    for (i=0; i<elf_ex.e_phnum; i++, elf_ppnt++) {
+-        bswap_phdr(elf_ppnt);
+-    }
+-#endif
++    bswap_phdr(elf_phdata, elf_ex.e_phnum);
+     elf_ppnt = elf_phdata;
+ 
+     elf_bss = 0;
+@@ -1229,9 +1376,9 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
+     elf_stack = ~((abi_ulong)0UL);
+     elf_interpreter = NULL;
+     start_code = ~((abi_ulong)0UL);
+-    end_code = 0;
+-    start_data = 0;
+-    end_data = 0;
++    end_code = (abi_ulong)0UL;
++    start_data = (abi_ulong)0UL;
++    end_data = (abi_ulong)0UL;
+     interp_ex.a_info = 0;
+ 
+     for(i=0;i < elf_ex.e_phnum; i++) {
+@@ -1431,7 +1578,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
+                 perror("mmap");
+                 exit(-1);
+             }
+-            load_bias = TARGET_ELF_PAGESTART(error - elf_ppnt->p_vaddr);
++	    load_bias = TARGET_ELF_PAGESTART(error - elf_ppnt->p_vaddr);
+         }
+ 
+         error = target_mmap(TARGET_ELF_PAGESTART(load_bias + elf_ppnt->p_vaddr),
+@@ -1541,12 +1688,13 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
+     padzero(elf_bss, elf_brk);
+ 
+ #if 0
+-    printf("(start_brk) %x\n" , info->start_brk);
+-    printf("(end_code) %x\n" , info->end_code);
+-    printf("(start_code) %x\n" , info->start_code);
+-    printf("(end_data) %x\n" , info->end_data);
+-    printf("(start_stack) %x\n" , info->start_stack);
+-    printf("(brk) %x\n" , info->brk);
++    printf("(start_brk) 0x" TARGET_FMT_lx "\n" , info->start_brk);
++    printf("(end_code) 0x" TARGET_FMT_lx "\n" , info->end_code);
++    printf("(start_code) 0x" TARGET_FMT_lx "\n" , info->start_code);
++    printf("(start_data) 0x" TARGET_FMT_lx "\n" , info->start_data);
++    printf("(end_data) 0x" TARGET_FMT_lx "\n" , info->end_data);
++    printf("(start_stack) 0x" TARGET_FMT_lx "\n" , info->start_stack);
++    printf("(brk) 0x" TARGET_FMT_lx "\n" , info->brk);
+ #endif

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303291740.r2THecer075205>