From owner-freebsd-mips@freebsd.org Fri Feb 5 04:15:14 2016 Return-Path: Delivered-To: freebsd-mips@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43381A9C12E for ; Fri, 5 Feb 2016 04:15:14 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qk0-x22d.google.com (mail-qk0-x22d.google.com [IPv6:2607:f8b0:400d:c09::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EDDBA859 for ; Fri, 5 Feb 2016 04:15:13 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qk0-x22d.google.com with SMTP id s68so29745317qkh.3 for ; Thu, 04 Feb 2016 20:15:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=a0g8SWus+OL8ab7JJs2+9UGm48gJoLRXtWkJv8bNzKc=; b=ynuNy7EBfHiSbxOzCGkuOjSlNth8rlgdAzwNwa97qOIsoNiFLpWcUTys5nVqeNAuoS 14n61FM0lTfz8u8E9NF6ua07jNmu6MTaZxbJwl6YAsTV3eB3PURiw5sz34dJQw9EvRKo ksua7faKOuvCwiQ9TYCraNyZ7KLEP8gsUrOEAPP70f5VXjLpNSO4eVloeIgYCIrxDhUw vr0tQLqCRBpwJLoEt1Krtm4fd9n0Oo9j5RYVLTFxtgFv+WqKbfo7lywmRN9MT3dSZpBy AMBZfjCfInZWLb1HwAG1xNSafUvXaEX7V8v8DmW82jz2LsmfPrIy2ctmW6imz70W3op/ 1LKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=a0g8SWus+OL8ab7JJs2+9UGm48gJoLRXtWkJv8bNzKc=; b=mYE5mWJ7OXToeC7r2I+q/gxD6AuWx+fXHntUkjycKGl4nnCYyKUtrY88wKmppjcwxz STSN3ZRRGeZ9ekVjWxTMrcrHZmCqO+Wnd8i+8U3A3PYYn6oQfwIodjzwbl4RGLXgIqj+ w66WZzpxK+TULAy/d9mbBJ06zMZOzUGlGgQaYLESEJ4aPhvQSv3qECgO1CZXaUZeXp+0 G3LvhEH42xgY+hdyUj2TSUFUrWoDgZwCYPxbJQ/4TzHjr2X0UnI+xL1BPaY6qGh3YB8C Ii15wBflITLbtQ9txNLFi6kWF3YScXtOGqCtzv1YIh1OlSwZz43jLVI28g5J7sunNB4L 72TQ== X-Gm-Message-State: AG10YORRqkfKfr6RfbXgSFz1b/b6hZiKa8XHEuF+B4FxMy5B626b0ytg51sEvvd7xzXmdkGewIAAXcyY+bAbSQ== MIME-Version: 1.0 X-Received: by 10.55.15.199 with SMTP id 68mr8442388qkp.42.1454645713143; Thu, 04 Feb 2016 20:15:13 -0800 (PST) Sender: wlosh@bsdimp.com Received: by 10.140.30.166 with HTTP; Thu, 4 Feb 2016 20:15:13 -0800 (PST) X-Originating-IP: [50.253.99.174] In-Reply-To: <20160205002626.GA93874@anubis.morrow.me.uk> References: <20160205002626.GA93874@anubis.morrow.me.uk> Date: Thu, 4 Feb 2016 21:15:13 -0700 X-Google-Sender-Auth: oWAd7NZn6iEnf-c9lPQw9Kv2nCc Message-ID: Subject: Re: mips/qemu jails with native-xtools From: Warner Losh To: Ben Morrow Cc: "freebsd-mips@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Feb 2016 04:15:14 -0000 On Thu, Feb 4, 2016 at 5:26 PM, Ben Morrow wrote: > I've finally got a mips/qemu poudriere jail working properly with a > native toolchain, but it took a bit of fiddling to make it work, so I > thought I'd report on what I did. > > First I tried installing things the way poudriere -x does, with an > /nxb-bin directory in the jail and redirections in make.conf. That > doesn't work because /nxb-bin/usr/bin/cc just invokes /usr/libexec/cc1, > which is still a mips executable. > > Then I tried copying the nxb-bin tree directly into the root of the > jail. This caused a problem immediately: the nxb-bin tree includes the > static flex libraries (/usr/lib/lib{l,fl,ln}.a) built for amd64. > Obviously this isn't going to work; it's the cause of the bison build > failures I found mentioned in the archives. > > Having put the proper libraries back, the next problem was that ld was > failing to find shared libraries that were implicitly linked (DT_NEEDED) > by other shared libraries. The specific port I was building was > net/tshark, which links glib, which implicitly pulls in libpcre and > libiconv. The configure step was failing because ld couldn't find > libpcre.so.3. > > It turns out that ld finds the path to search for DT_NEEDED libraries by > reading ld-elf.so.hints. That file (in the jail) is BE, because this is > a mips world with a mips ldconfig, but the ld binary is LE, so it can't > read the file. With the patch below, it can; since endianness is the > only difference between architectures, I think it should be safe for > general use, but I don't really know > I'd think it would be better to generate the ld.so in the proper binary format. How hard is that? Warner > Ben > > diff --git a/contrib/binutils/ld/emultempl/elf32.em > b/contrib/binutils/ld/emultempl/elf32.em > index 4f707ff..5219820 100644 > --- a/contrib/binutils/ld/emultempl/elf32.em > +++ b/contrib/binutils/ld/emultempl/elf32.em > @@ -539,6 +539,7 @@ EOF > #else > #include "elf-hints-local.h" > #endif > +#include > > static bfd_boolean > gld${EMULATION_NAME}_check_ld_elf_hints (const struct > bfd_link_needed_list *l, > @@ -560,17 +561,28 @@ gld${EMULATION_NAME}_check_ld_elf_hints (const > struct bfd_link_needed_list *l, > { > struct elfhints_hdr hdr; > > - if (fread (&hdr, 1, sizeof (hdr), f) == sizeof (hdr) > - && hdr.magic == ELFHINTS_MAGIC > - && hdr.version == 1) > - { > - if (fseek (f, hdr.strtab + hdr.dirlist, SEEK_SET) != -1) > + if (fread (&hdr, 1, sizeof (hdr), f) == sizeof (hdr)) > + { > + u_int32_t start = 0, len; > + > + if (hdr.magic == ELFHINTS_MAGIC > + && hdr.version == 1) > + { > + start = hdr.strtab + hdr.dirlist; > + len = hdr.dirlistlen; > + } > + if (bswap32(hdr.magic) == ELFHINTS_MAGIC > + && bswap32(hdr.version) == 1) > + { > + start = bswap32(hdr.strtab) + bswap32(hdr.dirlist); > + len = bswap32(hdr.dirlistlen); > + } > + if (start && fseek (f, start, SEEK_SET) != -1) > { > char *b; > > - b = xmalloc (hdr.dirlistlen + 1); > - if (fread (b, 1, hdr.dirlistlen + 1, f) == > - hdr.dirlistlen + 1) > + b = xmalloc (len + 1); > + if (fread (b, 1, len + 1, f) == len + 1) > ld_elf_hints = gld${EMULATION_NAME}_add_sysroot (b); > > free (b); > _______________________________________________ > freebsd-mips@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-mips > To unsubscribe, send any mail to "freebsd-mips-unsubscribe@freebsd.org" >