From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18595 invoked by alias); 25 Jan 2013 05:14:41 -0000 Received: (qmail 18577 invoked by uid 22791); 25 Jan 2013 05:14:38 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_EQ,TW_QE X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Jan 2013 05:14:07 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1Tybc5-000267-Tb from Maciej_Rozycki@mentor.com ; Thu, 24 Jan 2013 21:14:05 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 24 Jan 2013 21:14:05 -0800 Received: from [172.30.4.21] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Fri, 25 Jan 2013 05:14:03 +0000 Date: Fri, 25 Jan 2013 05:14:00 -0000 From: "Maciej W. Rozycki" To: "Ellcey, Steve" CC: "libc-alpha@sourceware.org" , "libc-ports@sourceware.org" , Chung-Lin Tang Subject: RE: [PATCH 2/2] MIPS16: MIPS16 support proper In-Reply-To: Message-ID: References: User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Mailing-List: contact libc-ports-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: libc-ports-owner@sourceware.org X-SW-Source: 2013-01/txt/msg00053.txt.bz2 Steve, > After some poking around I think the problem is not the glibc that I built but with crti.o and crtn.o. If I use > regular mips32 versions of these crt files and mips16 built versions of everything else (main program, glibc, > libgcc, etc.) then I can run a simple hello world program, if I use the mips16 versions of crti and crtn I get: > > > mips-mti-linux-gnu-gcc -mips32r2 -mips16 '-Wl,--dynamic-linker=/local/home/sellcey/gcc/mips16/sysroot-mips-mti-linux-gnu/mips16/usr/lib/ld-2.17.90.so' '-Wl,-rpath=/local/home/sellcey/gcc/mips16/sysroot-mips-mti-linux-gnu/mips16/usr/lib:/local/home/sellcey/gcc/mips16/install-mips-mti-linux-gnu/mips-mti-linux-gnu/lib/mips16' hi.c -o x > > mips-mti-linux-gnu-qemu -r 2.6.38 ./x > hi > qemu: uncaught target signal 11 (Segmentation fault) - core dumped > > Note that it did print 'hi' before getting the signal. > > If I try adding '-static' then I get: > > mips-mti-linux-gnu-gcc -static -mips32r2 -mips16 hi.c -o x > mips-mti-linux-gnu-qemu -r 2.6.38 ./x > qemu: uncaught target signal 4 (Illegal instruction) - core dumped > > > > I was wondering if you have any idea what could be causing this. Should the standard qemu be able > to run mips16 executables with no changes? I am fairly sure QEMU has issues with MIPS16 code, and I wouldn't be surprised if user-mode emulation actually required porting QEMU, rather than merely fixing bugs, to support MIPS16 binaries -- it may not be prepared to handle the ISA bit at all. Have you tried running your code on actual hardware? This is how we did testing of all these changes. Please also note that as I mentioned along the patch submission mixing execution modes in static constructors or destructors installed as single lumps of code (that is with the use of the DT_INIT or DT_FINI dynamic tags) cannot be supported. Can you run `objdump -j .init -j .fini -d' on your binary and make sure the disassembly looks right? Here's an example of correct MIPS16 code from one of the test cases: Disassembly of section .init: 00400a2c <_init>: 400a2c: f000 6a02 li v0,2 400a30: f692 0b10 la v1,3fa0c0 <_DYNAMIC-0x60dc> 400a34: f400 3240 sll v0,16 400a38: e269 addu v0,v1 400a3a: 64c4 save 32,ra 400a3c: 659a move gp,v0 400a3e: d204 sw v0,16(sp) 400a40: f030 9a6c lw v1,-32724(v0) 400a44: 2304 beqz v1,400a4e <_init+0x22> 400a46: f030 9a4c lw v0,-32724(v0) 400a4a: ea40 jalr v0 400a4c: 653a move t9,v0 400a4e: 6500 nop 400a50: 1a00 036e jal 400db8 400a54: 6500 nop 400a56: 1a00 0400 jal 401000 <__do_global_ctors_aux> 400a5a: 6500 nop 400a5c: 6444 restore 32,ra 400a5e: e8a0 jrc ra Disassembly of section .fini: 00401050 <_fini>: 401050: f000 6a02 li v0,2 401054: f072 0b0c la v1,3fa0c0 <_DYNAMIC-0x60dc> 401058: f400 3240 sll v0,16 40105c: e269 addu v0,v1 40105e: 64c4 save 32,ra 401060: 659a move gp,v0 401062: d204 sw v0,16(sp) 401064: 1a00 035a jal 400d68 <__do_global_dtors_aux> 401068: 6500 nop 40106a: 6444 restore 32,ra 40106c: e8a0 jrc ra Maciej