public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@codesourcery.com>
To: "Ellcey, Steve" <sellcey@mips.com>
Cc: "libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
	"libc-ports@sourceware.org" <libc-ports@sourceware.org>,
	Chung-Lin Tang	<cltang@codesourcery.com>
Subject: RE: [PATCH 2/2] MIPS16: MIPS16 support proper
Date: Fri, 25 Jan 2013 05:14:00 -0000	[thread overview]
Message-ID: <alpine.DEB.1.10.1301250451540.4834@tp.orcam.me.uk> (raw)
In-Reply-To: <B3A978AD3152E64BBBA356E6778FB9978A405B@exchdb03.mips.com>

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 <frame_dummy>
  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

  reply	other threads:[~2013-01-25  5:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-23  4:41 [PATCH 0/2] MIPS16: MIPS16 support Maciej W. Rozycki
2013-01-23  4:41 ` [PATCH 1/2] MIPS16: Allocate GLIBC_2.18 Maciej W. Rozycki
2013-01-23  4:42 ` [PATCH 2/2] MIPS16: MIPS16 support proper Maciej W. Rozycki
2013-01-23 17:22   ` Joseph S. Myers
2013-01-24 10:10     ` Chung-Lin Tang
2013-01-24 13:13       ` Maciej W. Rozycki
2013-01-24 13:56         ` Richard Sandiford
2013-02-20 16:19     ` [PATCH v2] MIPS: MIPS16 support Maciej W. Rozycki
2013-02-20 16:29       ` Joseph S. Myers
2013-02-27  1:38         ` [PATCH v3] " Maciej W. Rozycki
2013-02-27 17:50           ` Joseph S. Myers
2013-02-27 23:54             ` Maciej W. Rozycki
2013-01-24 18:08   ` [PATCH 2/2] MIPS16: MIPS16 support proper Ellcey, Steve
2013-01-25  5:14     ` Maciej W. Rozycki [this message]
2013-01-25 13:59       ` Richard Sandiford
2013-01-28 22:18         ` Steve Ellcey
2013-01-25 22:10       ` Steve Ellcey
2013-01-26  0:32         ` Maciej W. Rozycki
2013-01-28 17:36           ` Steve Ellcey
2013-01-28 17:56             ` Steve Ellcey
2013-01-28 21:08               ` Maciej W. Rozycki
2013-01-28 18:58             ` Richard Henderson
2013-01-28 21:06               ` Maciej W. Rozycki
2013-01-28 21:17                 ` Steve Ellcey
2013-01-29 16:24                   ` Richard Henderson
2013-01-29 19:27                     ` Joseph S. Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.1.10.1301250451540.4834@tp.orcam.me.uk \
    --to=macro@codesourcery.com \
    --cc=cltang@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=libc-ports@sourceware.org \
    --cc=sellcey@mips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).