]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Syscall tidying.
authorJulian Seward <jseward@acm.org>
Fri, 10 Nov 2006 22:47:27 +0000 (22:47 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 10 Nov 2006 22:47:27 +0000 (22:47 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6349

coregrind/launcher-aix5.c
coregrind/m_debuglog.c
coregrind/m_syscall.c
coregrind/m_syswrap/syscall-ppc32-aix5.S
coregrind/m_syswrap/syscall-ppc64-aix5.S
coregrind/m_syswrap/syswrap-ppc32-aix5.c
coregrind/m_syswrap/syswrap-ppc64-aix5.c
coregrind/m_trampoline.S

index cf317b14b6f7c2e75e1c4173dd3182aa6ffef55d..08e0c18e766a22429bc27dce2f165f28ff001a03 100644 (file)
@@ -467,6 +467,10 @@ static UInt gen_addi_rd_rs_N ( UInt rd, UInt rs, UInt N ) {
    assert(rs != 0);
    return mkFormD(14, rd, rs, N & 0xFFFF); /* addi rd,rs,N */
 }
+static UInt gen_addis_rd_rs_N ( UInt rd, UInt rs, UInt N ) {
+   assert(rs != 0);
+   return mkFormD(15, rd, rs, N & 0xFFFF); /* addis rd,rs,N */
+}
 static UInt gen_crorc_6_6_6 ( void ) {
    return 0x4CC63342; /* crorc 6,6,6 */
 }
@@ -521,7 +525,8 @@ static Int emit_insn ( UInt* code, Int ix, UInt insn ) {
 }
 static Int emit_li32 ( UInt* code, Int ix, UInt rd, UInt imm32 ) {
    code[ix++] = gen_lis_r_N(rd, imm32 >> 16);
-   code[ix++] = gen_ori_r_r_N(rd, imm32 & 0xFFFF);
+   if (imm32 & 0xFFFF)
+      code[ix++] = gen_ori_r_r_N(rd, imm32 & 0xFFFF);
    return ix;
 }
 static Int emit_dosc ( UInt* code, Int ix ) {
@@ -836,16 +841,18 @@ static char* write_bootstrap_loader_into_child
 
    /* So, the code.  First, prepare for and do a _loadx syscall, to
       get the tool aboard:
+         addis 1, 1, -4
          imm  2, __NR__loadx
          imm  3, VKI_DL_LOAD
-         imm  4, 0
-         mr   5, 4
+         mr   4, 1
+         imm  5, 3<<16
          addi 6, 31, offset_of_toolfile
          mr   7, 4
          mr   8, 4
          mr   9, 4
          mr   10,4
          SYSCALL_SEQUENCE
+         addis 1, 1, 4
 
       If the syscall failed, r4 will be nonzero.  Branch elsewhere if so.
          cmpi 4, 0
@@ -985,17 +992,21 @@ static char* write_bootstrap_loader_into_child
    } else {
 
       /* 32-bit sequence */
+      ix = emit_insn( &block.code[0],ix,
+                      gen_addis_rd_rs_N(1,1,-4) );
       ix = emit_li32( &block.code[0],ix, 2, __nr___loadx );
       ix = emit_li32( &block.code[0],ix, 3, VKI_DL_LOAD );
-      ix = emit_li32( &block.code[0],ix, 4, 0 );
-      ix = emit_insn( &block.code[0],ix, gen_mr_rd_rs(5,4) );
+      ix = emit_insn( &block.code[0],ix, gen_mr_rd_rs(4,1) );
+      ix = emit_li32( &block.code[0],ix, 5, 3<<16 );
       ix = emit_insn( &block.code[0],ix, 
                       gen_addi_rd_rs_N(6,31,offsetof(AIX5Bootblock,toolfile)));
-      ix = emit_insn( &block.code[0],ix, gen_mr_rd_rs(7,4) );
-      ix = emit_insn( &block.code[0],ix, gen_mr_rd_rs(8,4) );
-      ix = emit_insn( &block.code[0],ix, gen_mr_rd_rs(9,4) );
-      ix = emit_insn( &block.code[0],ix, gen_mr_rd_rs(10,4) );
+      ix = emit_li32( &block.code[0],ix, 7, 0);
+      ix = emit_insn( &block.code[0],ix, gen_mr_rd_rs(8,7) );
+      ix = emit_insn( &block.code[0],ix, gen_mr_rd_rs(9,7) );
+      ix = emit_insn( &block.code[0],ix, gen_mr_rd_rs(10,7) );
       ix = emit_dosc( &block.code[0],ix );
+      ix = emit_insn( &block.code[0],ix,
+                     gen_addis_rd_rs_N(1,1,4) );
       ix = emit_insn( &block.code[0],ix, gen_cmpli_cr7_r_N(4,0) );
       Int ix_bne = ix; /* Patch this later */
       ix = emit_insn( &block.code[0],ix, 0 );
index 4d69d08f278ef2930c6f90301800387fa0fe4975..9a93f400f94059373c9d1ac15163d709edb936e8 100644 (file)
@@ -247,11 +247,11 @@ static UInt local_sys_write_stderr ( HChar* buf, Int n )
       "lwz 4,0(28)\n\t"      /* set %r4 = buf */
       "lwz 5,4(28)\n\t"      /* set %r5 = n */
 
+      "crorc 6,6,6\n\t"
       ".long 0x48000005\n\t" /* bl .+4 */
       "mflr  29\n\t"
-      "addi  29,29,20\n\t"
+      "addi  29,29,16\n\t"
       "mtlr  29\n\t"
-      "crorc 6,6,6\n\t"
       "sc\n\t"               /* write() */
 
       "stw 3,0(28)\n\t"      /* result */
@@ -288,11 +288,11 @@ static UInt local_sys_getpid ( void )
 
       "lwz   2,0(28)\n\t"    /* set %r2 = __NR_getpid */
 
+      "crorc 6,6,6\n\t"
       ".long 0x48000005\n\t" /* bl .+4 */
       "mflr  29\n\t"
-      "addi  29,29,20\n\t"
+      "addi  29,29,16\n\t"
       "mtlr  29\n\t"
-      "crorc 6,6,6\n\t"
       "sc\n\t"               /* getpid() */
 
       "stw   3,0(28)\n\t"    /* result -> block[0] */
@@ -330,11 +330,11 @@ static UInt local_sys_write_stderr ( HChar* buf, Int n )
       "ld  4,0(28)\n\t"      /* set %r4 = buf */
       "ld  5,8(28)\n\t"      /* set %r5 = n */
 
+      "crorc 6,6,6\n\t"
       ".long 0x48000005\n\t" /* bl .+4 */
       "mflr  29\n\t"
-      "addi  29,29,20\n\t"
+      "addi  29,29,16\n\t"
       "mtlr  29\n\t"
-      "crorc 6,6,6\n\t"
       "sc\n\t"               /* write() */
 
       "std 3,0(28)\n\t"      /* result */
@@ -369,11 +369,11 @@ static UInt local_sys_getpid ( void )
 
       "ld    2,0(28)\n\t"    /* set %r2 = __NR_getpid */
 
+      "crorc 6,6,6\n\t"
       ".long 0x48000005\n\t" /* bl .+4 */
       "mflr  29\n\t"
-      "addi  29,29,20\n\t"
+      "addi  29,29,16\n\t"
       "mtlr  29\n\t"
-      "crorc 6,6,6\n\t"
       "sc\n\t"               /* getpid() */
 
       "std  3,0(28)\n\t"     /* result -> block[0] */
index b5185fa745c2d069b1c75a49b15245d74b83c2a7..c35eb2c316935857ad63452cb305231f9ede97b8 100644 (file)
@@ -343,16 +343,16 @@ static void do_syscall_WRK ( UWord* res_r3, UWord* res_r4,
       "lwz   9, 28(28)\n\t"
       "lwz  10, 32(28)\n\t"
 
+      // set bit 3 of CR1 otherwise AIX 5.1 returns to the
+      // wrong address after the sc instruction
+      "crorc 6,6,6\n\t"
+
       // set up LR to point just after the sc insn
       ".long 0x48000005\n\t" // "bl here+4" -- lr := & next insn
       "mflr 29\n\t"
-      "addi 29,29,20\n\t"
+      "addi 29,29,16\n\t"
       "mtlr 29\n\t"
 
-      // set bit 3 of CR1 otherwise AIX 5.1 returns to the
-      // wrong address after the sc instruction
-      "crorc 6,6,6\n\t"
-
       // do it!
       "sc\n\t"
 
@@ -414,16 +414,16 @@ static void do_syscall_WRK ( UWord* res_r3, UWord* res_r4,
       "ld    9, 56(28)\n\t"
       "ld   10, 64(28)\n\t"
 
+      // set bit 3 of CR1 otherwise AIX 5.1 returns to the
+      // wrong address after the sc instruction
+      "crorc 6,6,6\n\t"
+
       // set up LR to point just after the sc insn
       ".long 0x48000005\n\t" // "bl here+4" -- lr := & next insn
       "mflr 29\n\t"
-      "addi 29,29,20\n\t"
+      "addi 29,29,16\n\t"
       "mtlr 29\n\t"
 
-      // set bit 3 of CR1 otherwise AIX 5.1 returns to the
-      // wrong address after the sc instruction
-      "crorc 6,6,6\n\t"
-
       // do it!
       "sc\n\t"
 
index 92d7d34cac875cd4ad44b125f96859492d04f93d..dc154e8dfb81271f0e76c27188240c710834337c 100644 (file)
@@ -117,6 +117,7 @@ Lvg1:   /* Even though we can't take a signal until the sigprocmask
        mr      6,7     /* nsigwords -- needed on AIX ? */
 
        /* actually do the sigprocmask */
+       crorc   6,6,6
        .long 0x48000005 /* bl here+4 */
        mflr    26
        addi    26,26,16
@@ -138,6 +139,7 @@ Lvg1:   /* Even though we can't take a signal until the sigprocmask
         lwz     10,OFFSET_ppc32_GPR10(30)
         mr      2,31            /* syscall number */
 
+       crorc   6,6,6
        .long 0x48000005 /* bl here+4 */
        mflr    26
        addi    26,26,16
@@ -165,6 +167,7 @@ Lvg4:   mr  2,27
         mr      6,28   /* nsigwords -- needed on AIX ? */
 
        /* actually do the sigprocmask */
+       crorc   6,6,6
        .long 0x48000005 /* bl here+4 */
        mflr    26
        addi    26,26,16
index edf7bacf31ada4159ab1be46ce703db6e0aa5b6f..acd29454508ab5b4636fde75e9190879e28c9fb5 100644 (file)
@@ -117,6 +117,7 @@ Lvg1:   /* Even though we can't take a signal until the sigprocmask
        mr      6,7     /* nsigwords -- needed on AIX ? */
 
        /* actually do the sigprocmask */
+       crorc   6,6,6
        .long 0x48000005 /* bl here+4 */
        mflr    26
        addi    26,26,16
@@ -138,6 +139,7 @@ Lvg1:   /* Even though we can't take a signal until the sigprocmask
         ld      10,OFFSET_ppc64_GPR10(30)
         mr      2,31            /* syscall number */
 
+       crorc   6,6,6
        .long 0x48000005 /* bl here+4 */
        mflr    26
        addi    26,26,16
@@ -165,6 +167,7 @@ Lvg4:   mr  2,27
         mr      6,28   /* nsigwords -- needed on AIX ? */
 
        /* actually do the sigprocmask */
+       crorc   6,6,6
        .long 0x48000005 /* bl here+4 */
        mflr    26
        addi    26,26,16
index 31e934ccca278ab46208daf77f6c27149fe815cf..c3f9b8947640c4390344a72727ff7ab341dfdd48 100644 (file)
@@ -205,6 +205,7 @@ static void run_a_thread_NORETURN ( Word tidW )
           "mr 2,23\n\t"            /* r2 = __NR_exit */
           "mr 3,22\n\t"            /* set r3 = tst->os_state.exitcode */
           /* set up for syscall */
+          "crorc 6,6,6\n\t"
           ".long 0x48000005\n\t"   /* "bl here+4" */
           "mflr 29\n\t"
           "addi 29,29,16\n\t"
index 6f6c08fa1a2ce051b616344a1ba8e54f10c19061..9c95d46a678eb84fc8ba0f9321eaa6524c2c5bd6 100644 (file)
@@ -205,6 +205,7 @@ static void run_a_thread_NORETURN ( Word tidW )
           "mr 2,23\n\t"            /* r2 = __NR_exit */
           "mr 3,22\n\t"            /* set r3 = tst->os_state.exitcode */
           /* set up for syscall */
+          "crorc 6,6,6\n\t"
           ".long 0x48000005\n\t"   /* "bl here+4" */
           "mflr 29\n\t"
           "addi 29,29,16\n\t"
index 803e34d10e4570a9c55283f227e9640b372c3727..31c4eb3d78b158e93903ba86df652085ed36230c 100644 (file)
@@ -9,7 +9,9 @@
 
   Copyright (C) 2000-2006 Julian Seward 
      jseward@acm.org
-
+  Copyright (C) 2006-2006 OpenWorks LLP
+     info@open-works.co.uk
+       
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2 of the
@@ -416,7 +418,9 @@ VG_(ppc32_aix5_do_preloads_then_start_client):
        lwz     2,0(3)          /* r2 = __NR___loadx */
        lwz     5,20(3)         /* r5 = off_preloadcorename */
        add     6,3,5           /* r6 = preloadcorename */
+       addis   1,1,-4
        bl      do___loadx
+       addis   1,1,4
        cmpwi   0,3,0
        beq     .Lfailed
 
@@ -427,7 +431,9 @@ VG_(ppc32_aix5_do_preloads_then_start_client):
        cmpwi   0,5,0           /* skip tool preload if */
        beq     .Ltry_preload   /* name not present */
        add     6,3,5           /* r6 = preloadtoolname */
+       addis   1,1,-4
        bl      do___loadx
+       addis   1,1,4
        cmpwi   0,3,0
        beq     .Lfailed
 
@@ -439,7 +445,9 @@ VG_(ppc32_aix5_do_preloads_then_start_client):
        cmpwi   0,5,0           /* skip ld_preload if */
        beq     .Lstart_client  /* name not present */
        add     6,3,5           /* r6 = ld_preloadname */
+       addis   1,1,-4
        bl      do___loadx
+       addis   1,1,4
        cmpwi   0,3,0
        beq     .Lfailed
        
@@ -494,14 +502,16 @@ do___loadx:
        /* On entry: r2 = __NR___loadx, r6 = name of module */
        li      3,1
        slwi    3,3,24  /* r3 = 0x1000000 = VKI_DL_LOAD */
-       li      4,0
-       li      5,0
+       mr      4,1
+       lis     5,3
        li      7,0
        li      8,0
        li      9,0
        li      10,0
 do_syscall:
+       crorc   6,6,6
        sc
+       trap
        /* sc continues at 'lr', hence this 
        constitutes an automatic return */
 
@@ -635,6 +645,7 @@ do_kload:
        li      9,0
        li      10,0
 do_syscall:
+       crorc   6,6,6
        sc
        /* sc continues at 'lr', hence this 
        constitutes an automatic return */