From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] more on why vc can't produce amd64 executables
Date: Wed, 21 Aug 2013 17:44:03 -0400 [thread overview]
Message-ID: <1c77ed407dc1ed28544e2033df7088ce@brasstown.quanstro.net> (raw)
In-Reply-To: <0A2E2FB2-B2F1-444E-AF62-85FAC05335EA@bitblocks.com>
#include <u.h>
#include <libc.h>
void
f(void)
{
write(1, "hello\n", 6);
}
void (*call)(void) = f;
void
main(void)
{
call();
exits("");
}
the asm is the same when compiled on any arch,
; acid 6.crash4-mips
6.crash4-mips:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid; asm(main)
main 0x0020004e SUBQ $0x8,SP
main+0x4 0x00200052 MOVQ call(SB),AX
main+0xc 0x0020005a CALL* AX
main+0xe 0x0020005c MOVL $.string+0x7(SB),BP
main+0x13 0x00200061 CALL exits(SB)
main+0x18 0x00200066 ADDQ $0x8,SP
main+0x1c 0x0020006a RET
_main 0x0020006b SUBQ $0x90,SP
but the data is incorrect in the mips-compiled binary.
acid; *(call\Y)
0x0020002800000000
mikro; diff -c crash4-mipsa crash4-amd64a
crash4-mipsa:417,423 - crash4-amd64a:417,423
2005af 48c7c532000000 (4) MOVQ $50,BP
2005b6 0f05 (5) SYSCALL ,
2005b8 c3 (6) RET ,
- 400010 0000000028002000 (823) DATA call+0(SB)/8,$f+0(SB)
+ 400010 2800200000000000 (823) DATA call+0(SB)/8,$f+0(SB)
400030 68656c6c6f0a0000 (829) DATA .string<1>+0(SB)/8,$"hello\n\z\z"
400028 6d61696e (18) DATA _exits<2>+0(SB)/4,$"main\z\z\z\z"
400000 23632f7069640000 (829) DATA .string<7>+0(SB)/8,$"#c/pid\z\z"
i think a bug is setting inuxi8[i+4] = inuxi8[i] for 0<=i<4.
mikro; diffy -c *.c
diff -c /n/dump/2013/0821/sys/src/cmd/6l/obj.c obj.c
/n/dump/2013/0821/sys/src/cmd/6l/obj.c:1455,1471 - obj.c:1455,1471
int i, c;
for(i=0; i<4; i++) {
- c = find1(0x04030201L, i+1);
+ c = find1(0x0807060504030201ULL, i+1);
if(i < 2)
inuxi2[i] = c;
if(i < 1)
inuxi1[i] = c;
- inuxi4[i] = c;
+ if(i < 4){
+ inuxi4[i] = c;
+ fnuxi4[i] = c;
+ }
inuxi8[i] = c;
- inuxi8[i+4] = c+4;
- fnuxi4[i] = c;
fnuxi8[i] = c;
- fnuxi8[i+4] = c+4;
}
if(debug['v']) {
Bprint(&bso, "inuxi = ");
/n/dump/2013/0821/sys/src/cmd/6l/obj.c:1492,1504 - obj.c:1492,1504
}
int
- find1(long l, int c)
+ find1(uvlong l, int c)
{
char *p;
int i;
p = (char*)&l;
- for(i=0; i<4; i++)
+ for(i=0; i<8; i++)
if(*p++ == c)
return i;
return 0;
/n/dump/2013/0821/sys/src/cmd/6l/obj.c:1505,1517 - obj.c:1505,1517
}
int
- find2(long l, int c)
+ find2(uvlong l, int c)
{
short *p;
int i;
p = (short*)&l;
- for(i=0; i<4; i+=2) {
+ for(i=0; i<8; i+=2) {
if(((*p >> 8) & 0xff) == c)
return i;
if((*p++ & 0xff) == c)
unfortunately, compiling on mips *still* doesn't work right.
print prints %%p for %p. i don't know if my fix is wrong, or
if there is another bug.
- erik
next prev parent reply other threads:[~2013-08-21 21:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-21 18:36 erik quanstrom
2013-08-21 18:49 ` Bakul Shah
2013-08-21 18:57 ` erik quanstrom
2013-08-21 19:25 ` Bakul Shah
2013-08-21 19:29 ` erik quanstrom
2013-08-21 21:44 ` erik quanstrom [this message]
2013-08-22 15:32 ` Bakul Shah
2013-08-22 16:54 ` erik quanstrom
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=1c77ed407dc1ed28544e2033df7088ce@brasstown.quanstro.net \
--to=quanstro@quanstro.net \
--cc=9fans@9fans.net \
/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 NNTP newsgroup(s).