xpcom-ppc64le.patch
branchesr24
changeset 713 3c7719dfcafa
parent 706 4639b5ad4fce
child 728 6820714d53f4
equal deleted inserted replaced
706:4639b5ad4fce 713:3c7719dfcafa
     1 Index: mozilla/xpcom/reflect/xptcall/src/md/unix/Makefile.in
       
     2 ===================================================================
       
     3 --- mozilla.orig/xpcom/reflect/xptcall/src/md/unix/Makefile.in
       
     4 +++ mozilla/xpcom/reflect/xptcall/src/md/unix/Makefile.in
       
     5 @@ -278,7 +278,7 @@ endif
       
     6  #
       
     7  # Linux/PPC64
       
     8  #
       
     9 -ifneq (,$(filter Linuxpowerpc64 FreeBSDpowerpc64,$(OS_ARCH)$(OS_TEST)))
       
    10 +ifneq (,$(filter Linuxpowerpc64 Linuxpowerpc64le FreeBSDpowerpc64,$(OS_ARCH)$(OS_TEST)))
       
    11  CPPSRCS                := xptcinvoke_ppc64_linux.cpp xptcstubs_ppc64_linux.cpp
       
    12  ASFILES                := xptcinvoke_asm_ppc64_linux.s xptcstubs_asm_ppc64_linux.s
       
    13  AS             := $(CC) -c -x assembler-with-cpp
       
    14 Index: mozilla/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.s
       
    15 ===================================================================
       
    16 --- mozilla.orig/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.s
       
    17 +++ mozilla/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.s
       
    18 @@ -17,12 +17,29 @@
       
    19  .set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29
       
    20  .set f30,30; .set f31,31
       
    21  
       
    22 +#if _CALL_ELF == 2
       
    23 +#define STACK_TOC      28
       
    24 +#define STACK_PARAMS   96
       
    25 +#else
       
    26 +#define STACK_TOC      40
       
    27 +#define STACK_PARAMS   112
       
    28 +#endif
       
    29  
       
    30  #
       
    31  # NS_InvokeByIndex_P(nsISupports* that, uint32_t methodIndex,
       
    32  #                    uint32_t paramCount, nsXPTCVariant* params)
       
    33  #
       
    34  
       
    35 +#if _CALL_ELF == 2
       
    36 +        .section ".text"
       
    37 +        .type   NS_InvokeByIndex_P,@function
       
    38 +        .globl  NS_InvokeByIndex_P
       
    39 +        .align 2
       
    40 +NS_InvokeByIndex_P:
       
    41 +0:      addis 2,12,(.TOC.-0b)@ha
       
    42 +        addi 2,2,(.TOC.-0b)@l
       
    43 +        .localentry NS_InvokeByIndex_P,.-NS_InvokeByIndex_P
       
    44 +#else
       
    45          .section ".toc","aw"
       
    46          .section ".text"
       
    47          .align 2
       
    48 @@ -34,6 +51,7 @@ NS_InvokeByIndex_P:
       
    49          .previous
       
    50          .type   NS_InvokeByIndex_P,@function
       
    51  .NS_InvokeByIndex_P:
       
    52 +#endif
       
    53          mflr    0
       
    54          std     0,16(r1)
       
    55  
       
    56 @@ -56,7 +74,7 @@ NS_InvokeByIndex_P:
       
    57          #                               (-23*8).(-16*8).(-3*8)..(r31)
       
    58  
       
    59          # +stack frame, -unused stack params, +regs storage, +1 for alignment
       
    60 -        addi    r7,r5,((112/8)-7+7+13+3+1)
       
    61 +        addi    r7,r5,((STACK_PARAMS/8)-7+7+13+3+1)
       
    62          rldicr  r7,r7,3,59              # multiply by 8 and mask with ~15
       
    63          neg     r7,r7
       
    64          stdux   r1,r1,r7
       
    65 @@ -72,7 +90,7 @@ NS_InvokeByIndex_P:
       
    66  
       
    67          subi    r3,r31,(23*8)           # r3 --> GPRS
       
    68          subi    r4,r31,(16*8)           # r4 --> FPRS
       
    69 -        addi    r7,r1,112               # r7 --> params
       
    70 +        addi    r7,r1,STACK_PARAMS      # r7 --> params
       
    71          bl      invoke_copy_to_stack
       
    72          nop
       
    73  
       
    74 @@ -83,14 +101,18 @@ NS_InvokeByIndex_P:
       
    75  
       
    76          sldi    r30,r30,3               # Find function descriptor 
       
    77          add     r9,r9,r30
       
    78 -        ld      r9,0(r9)
       
    79 +        ld      r12,0(r9)
       
    80  
       
    81 -        ld      r0,0(r9)                # Actual address from fd.
       
    82 -        std     r2,40(r1)               # Save r2 (TOC pointer)
       
    83 +        std     r2,STACK_TOC(r1)        # Save r2 (TOC pointer)
       
    84  
       
    85 +#if _CALL_ELF == 2
       
    86 +        mtctr   r12
       
    87 +#else
       
    88 +        ld      r0,0(r12)               # Actual address from fd.
       
    89          mtctr   0
       
    90 -        ld      r11,16(r9)              # Environment pointer from fd.
       
    91 -        ld      r2,8(r9)                # TOC pointer from fd.
       
    92 +        ld      r11,16(r12)             # Environment pointer from fd.
       
    93 +        ld      r2,8(r12)               # TOC pointer from fd.
       
    94 +#endif
       
    95  
       
    96          # Load FP and GP registers as required
       
    97          ld      r4, -(23*8)(r31) 
       
    98 @@ -117,7 +139,7 @@ NS_InvokeByIndex_P:
       
    99  
       
   100          bctrl                           # Do it
       
   101  
       
   102 -        ld      r2,40(r1)               # Load our own TOC pointer
       
   103 +        ld      r2,STACK_TOC(r1)        # Load our own TOC pointer
       
   104          ld      r1,0(r1)                # Revert stack frame
       
   105          ld      0,16(r1)                # Reload lr
       
   106          ld      29,-24(r1)              # Restore NVGPRS
       
   107 @@ -126,7 +148,11 @@ NS_InvokeByIndex_P:
       
   108          mtlr    0
       
   109          blr
       
   110  
       
   111 +#if _CALL_ELF == 2
       
   112 +        .size   NS_InvokeByIndex_P,.-NS_InvokeByIndex_P
       
   113 +#else
       
   114          .size   NS_InvokeByIndex_P,.-.NS_InvokeByIndex_P
       
   115 +#endif
       
   116  
       
   117          # Magic indicating no need for an executable stack
       
   118          .section .note.GNU-stack, "", @progbits ; .previous
       
   119 Index: mozilla/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc64_linux.cpp
       
   120 ===================================================================
       
   121 --- mozilla.orig/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc64_linux.cpp
       
   122 +++ mozilla/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc64_linux.cpp
       
   123 @@ -74,7 +74,9 @@ invoke_copy_to_stack(uint64_t* gpregs,
       
   124                  fpregs[i]   = s->val.f; // if passed in registers, floats are promoted to doubles
       
   125              } else {
       
   126                  float *p = (float *)d;
       
   127 +#ifndef __LITTLE_ENDIAN__
       
   128                  p++;
       
   129 +#endif
       
   130                  *p = s->val.f;
       
   131              }
       
   132          }
       
   133 Index: mozilla/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc64_linux.s
       
   134 ===================================================================
       
   135 --- mozilla.orig/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc64_linux.s
       
   136 +++ mozilla/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc64_linux.s
       
   137 @@ -17,6 +17,27 @@
       
   138  .set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29
       
   139  .set f30,30; .set f31,31
       
   140  
       
   141 +#if _CALL_ELF == 2
       
   142 +#define STACK_PARAMS   96
       
   143 +#else
       
   144 +#define STACK_PARAMS   112
       
   145 +#endif
       
   146 +
       
   147 +#if _CALL_ELF == 2
       
   148 +        .section ".text"
       
   149 +        .type   SharedStub,@function
       
   150 +        .globl  SharedStub
       
   151 +        # Make the symbol hidden so that the branch from the stub does
       
   152 +        # not go via a PLT.  This is not only better for performance,
       
   153 +        # but may be necessary to avoid linker errors since there is
       
   154 +        # no place to restore the TOC register in a sibling call.
       
   155 +        .hidden SharedStub
       
   156 +        .align 2
       
   157 +SharedStub:
       
   158 +0:      addis 2,12,(.TOC.-0b)@ha
       
   159 +        addi 2,2,(.TOC.-0b)@l
       
   160 +        .localentry SharedStub,.-SharedStub
       
   161 +#else
       
   162          .section ".text"
       
   163          .align 2
       
   164          .globl SharedStub
       
   165 @@ -29,6 +50,7 @@ SharedStub:
       
   166          .type   SharedStub,@function
       
   167  
       
   168  .SharedStub:
       
   169 +#endif
       
   170          mflr    r0
       
   171  
       
   172          std     r4, -56(r1)                     # Save all GPRS
       
   173 @@ -55,7 +77,7 @@ SharedStub:
       
   174  
       
   175          subi    r6,r1,56                        # r6 --> gprData
       
   176          subi    r7,r1,160                       # r7 --> fprData
       
   177 -        addi    r5,r1,112                       # r5 --> extra stack args
       
   178 +        addi    r5,r1,STACK_PARAMS              # r5 --> extra stack args
       
   179  
       
   180          std     r0, 16(r1)
       
   181  	
       
   182 @@ -75,7 +97,11 @@ SharedStub:
       
   183          mtlr    r0
       
   184          blr
       
   185  
       
   186 +#if _CALL_ELF == 2
       
   187 +        .size   SharedStub,.-SharedStub
       
   188 +#else
       
   189          .size   SharedStub,.-.SharedStub
       
   190 +#endif
       
   191  
       
   192          # Magic indicating no need for an executable stack
       
   193          .section .note.GNU-stack, "", @progbits ; .previous
       
   194 Index: mozilla/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc64_linux.cpp
       
   195 ===================================================================
       
   196 --- mozilla.orig/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc64_linux.cpp
       
   197 +++ mozilla/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc64_linux.cpp
       
   198 @@ -83,7 +83,9 @@ PrepareAndDispatch(nsXPTCStubBase* self,
       
   199                  dp->val.f = (float) fprData[i]; // in registers floats are passed as doubles
       
   200              else {
       
   201                  float *p = (float *)ap;
       
   202 +#ifndef __LITTLE_ENDIAN__
       
   203                  p++;
       
   204 +#endif
       
   205                  dp->val.f = *p;
       
   206              }
       
   207          } else { /* integer type or pointer */
       
   208 @@ -153,6 +155,43 @@ PrepareAndDispatch(nsXPTCStubBase* self,
       
   209  // etc.
       
   210  // Use assembler directives to get the names right...
       
   211  
       
   212 +#if _CALL_ELF == 2
       
   213 +# define STUB_ENTRY(n)                                                  \
       
   214 +__asm__ (                                                               \
       
   215 +        ".section \".text\" \n\t"                                       \
       
   216 +        ".align 2 \n\t"                                                 \
       
   217 +        ".if "#n" < 10 \n\t"                                            \
       
   218 +        ".globl _ZN14nsXPTCStubBase5Stub"#n"Ev \n\t"                    \
       
   219 +        ".type  _ZN14nsXPTCStubBase5Stub"#n"Ev,@function \n\n"          \
       
   220 +"_ZN14nsXPTCStubBase5Stub"#n"Ev: \n\t"                                  \
       
   221 +        "0: addis 2,12,.TOC.-0b@ha \n\t"                                \
       
   222 +        "addi     2,2,.TOC.-0b@l \n\t"                                  \
       
   223 +        ".localentry _ZN14nsXPTCStubBase5Stub"#n"Ev,.-_ZN14nsXPTCStubBase5Stub"#n"Ev \n\t" \
       
   224 +                                                                        \
       
   225 +        ".elseif "#n" < 100 \n\t"                                       \
       
   226 +        ".globl _ZN14nsXPTCStubBase6Stub"#n"Ev \n\t"                    \
       
   227 +        ".type  _ZN14nsXPTCStubBase6Stub"#n"Ev,@function \n\n"          \
       
   228 +"_ZN14nsXPTCStubBase6Stub"#n"Ev: \n\t"                                  \
       
   229 +        "0: addis 2,12,.TOC.-0b@ha \n\t"                                \
       
   230 +        "addi     2,2,.TOC.-0b@l \n\t"                                  \
       
   231 +        ".localentry _ZN14nsXPTCStubBase6Stub"#n"Ev,.-_ZN14nsXPTCStubBase6Stub"#n"Ev \n\t" \
       
   232 +                                                                        \
       
   233 +        ".elseif "#n" < 1000 \n\t"                                      \
       
   234 +        ".globl _ZN14nsXPTCStubBase7Stub"#n"Ev \n\t"                    \
       
   235 +        ".type  _ZN14nsXPTCStubBase7Stub"#n"Ev,@function \n\n"          \
       
   236 +"_ZN14nsXPTCStubBase7Stub"#n"Ev: \n\t"                                  \
       
   237 +        "0: addis 2,12,.TOC.-0b@ha \n\t"                                \
       
   238 +        "addi     2,2,.TOC.-0b@l \n\t"                                  \
       
   239 +        ".localentry _ZN14nsXPTCStubBase7Stub"#n"Ev,.-_ZN14nsXPTCStubBase7Stub"#n"Ev \n\t" \
       
   240 +                                                                        \
       
   241 +        ".else  \n\t"                                                   \
       
   242 +        ".err   \"stub number "#n" >= 1000 not yet supported\"\n"       \
       
   243 +        ".endif \n\t"                                                   \
       
   244 +                                                                        \
       
   245 +        "li     11,"#n" \n\t"                                           \
       
   246 +        "b      SharedStub \n"                                          \
       
   247 +);
       
   248 +#else
       
   249  # define STUB_ENTRY(n)                                                  \
       
   250  __asm__ (                                                               \
       
   251          ".section \".toc\",\"aw\" \n\t"                                 \
       
   252 @@ -195,6 +234,7 @@ __asm__ (
       
   253          "li     11,"#n" \n\t"                                           \
       
   254          "b      SharedStub \n"                                          \
       
   255  );
       
   256 +#endif
       
   257  
       
   258  #define SENTINEL_ENTRY(n)                                               \
       
   259  nsresult nsXPTCStubBase::Sentinel##n()                                  \