From owner-freebsd-arm@freebsd.org Tue Aug 25 01:55:20 2015 Return-Path: Delivered-To: freebsd-arm@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 9158E9C296E for ; Tue, 25 Aug 2015 01:55:20 +0000 (UTC) (envelope-from serge0x76@gmail.com) Received: from mail-qg0-x22f.google.com (mail-qg0-x22f.google.com [IPv6:2607:f8b0:400d:c04::22f]) (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 5390FF32 for ; Tue, 25 Aug 2015 01:55:20 +0000 (UTC) (envelope-from serge0x76@gmail.com) Received: by qgeb6 with SMTP id b6so98393077qge.3 for ; Mon, 24 Aug 2015 18:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=QiT7D87g5ChdEDd6eD54YRWI2fDZKwWL1EBbtLP3iP4=; b=w+1IGbsPr74N0V46M+WotoQX/1lE4LyjF+bUBeUpEq4CWrufcZnPK9vkFHXu4XUmle 95gaKJsxQ/EH1/K9KHmrt67Agt5LDjub2FaJC6DXxYYqSzo6MkC/TSC05pY0xxY6D46l E+lpYtAk5Jgb2Z3xjIGpt8DUYubl/Xidzdv5bM6ILhJ1jcu8Xd2hI9oFDOtjKFmB//eV IVr5IXgoaMWRDp4lV7RII1Tf2ORW9owBY/+yD9fHjPYS6AODdG22RW2qifnAcSWyFKRp eDyrtVkg+Av0cB6kuxis8RTbQfZyg7MmUPYkhKFk9YW+IxyAB2wvPhbFYopGN9Xzqbxi KnTA== MIME-Version: 1.0 X-Received: by 10.140.218.149 with SMTP id o143mr61243151qhb.25.1440467719067; Mon, 24 Aug 2015 18:55:19 -0700 (PDT) Received: by 10.55.167.212 with HTTP; Mon, 24 Aug 2015 18:55:19 -0700 (PDT) Date: Mon, 24 Aug 2015 21:55:19 -0400 Message-ID: Subject: cross-compiling on OSX for RPI From: Serge Voilokov To: freebsd-arm@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Aug 2015 01:55:20 -0000 Hi, I have built some hello world app on OSX for Raspberry PI using clang and GNU binutils. Resulting a.out fails on RPI with the error: Invalid PT_INTERP ./a.out: Exec format error. Binary file not executable. Loading of a.out fails in the kernel on imgact_elf.c:780 when it verifies offsets and page size for INTERP section. When comparing readelfs for native (6k) and osx a.out(38k) variants I found that sizes differs and INTERP sections have different positions: --- a.out.cross +++ a.out.native Start of program headers: 52 (bytes into file) - Start of section headers: 35076 (bytes into file) - Flags: 0x5000002, has entry point, Version5 EABI + Start of section headers: 2652 (bytes into file) + Flags: 0x5000202, has entry point, Version5 EABI, soft-float ABI Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align - INTERP 0x008000 0x00008000 0x00008000 0x00015 0x00015 R 0x1 + INTERP 0x000134 0x00008134 0x00008134 0x00015 0x00015 R 0x1 How can I fix this? I see following options: - fix binutils-2.24/ld somehow to put valid section offsets. - try to compile freebsd/contrib/binutils on OSX and use it. - static linking (less preferred). - as a last resort install FreeBSD x86 VM and compile there. Please advice. -serge P.S. Compiler command line: clang-mp-3.7 --sysroot=/sd_sysroot --target=armv6--freebsd11.0-eabi -o test.o -c test.c Ld command line: arm-eabi-freebsd11.0-ld -dynamic-linker /libexec/ld-elf.so.1 test.o -o a.out [other crt files and libs]. (Linker is from binutils-2.24 configured with sysroot and target=arm-eabi-freebsd11.0)