Print this page
8609 want a position independent CRT

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/common/i386/fsr.s
          +++ new/usr/src/lib/crt/i86/fsr.s
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27      -        .ident  "%Z%%M% %I%     %E% SMI"
       27 +#include <sys/asm_linkage.h>
  28   28  
  29   29          .file   "fsr.s"
  30   30  
  31   31          .section        .data
  32   32          .align 4
  33   33  
  34      -        .weak   __fsr_init_value
  35      -
  36      -__fsr_init_value_ptr:
  37      -        .4byte  __fsr_init_value
  38      -        .type   __fsr_init_value_ptr,@object
  39      -        .size   __fsr_init_value_ptr,4
  40      -
  41   34  /*
  42   35   * The following table maps trap enable bits in __fsr_init_value
  43   36   * (after shifting right one bit):
  44   37   *
  45   38   * bit 0 - inexact trap
  46   39   * bit 1 - division trap
  47   40   * bit 2 - underflow trap
  48   41   * bit 3 - overflow trap
  49   42   * bit 4 - invalid trap
  50   43   *
↓ open down ↓ 36 lines elided ↑ open up ↑
  87   80          .byte   0b11010110
  88   81          .byte   0b11110010
  89   82          .byte   0b11010010
  90   83          .byte   0b11100110
  91   84          .byte   0b11000110
  92   85          .byte   0b11100010
  93   86          .byte   0b11000010
  94   87  
  95   88          .size   trap_table,32
  96   89  
  97      -        .section        .text
  98      -        .align  4
  99      -
 100      -        .globl  __fsr
 101      -        .type   __fsr,@function
 102      -__fsr:
       90 +ENTRY_NP(__fsr)
 103   91          pushl   %ebp
 104   92          movl    %esp,%ebp
 105   93          pushl   %edx
 106   94          pushl   %ecx
       95 +        pushl   %ebx
 107   96          subl    $4,%esp
 108   97  
 109      -        lea     __fsr_init_value_ptr, %ecx
 110      -        movl    (%ecx),%ecx             /* get the value set by CG */
       98 +        /* Setup PIC */
       99 +        call    9f
      100 +9:      popl    %ebx
      101 +        addl    $_GLOBAL_OFFSET_TABLE_ + [. - 9b], %ebx
      102 +
      103 +        movl    8(%ebp), %ecx           /* the value set by CG is passed in */
 111  104          shrl    $1,%ecx                 /* get rid of fns bit */
 112  105          cmpl    $0,%ecx                 /* if remaining bits are zero */
 113  106          je      3f                      /*   there's nothing to do */
 114  107  
 115  108          fstcw   0(%esp)                 /* store the control word */
 116  109  
 117  110          movl    %ecx,%edx
 118  111          andl    $0x1f,%edx              /* get the trap enable bits */
 119      -        movb    trap_table(%edx),%al
      112 +        movl    trap_table@GOT(%ebx), %eax
      113 +        addl    %eax,%edx
      114 +        movb    (%edx),%al
 120  115          andb    %al,0(%esp)     /* unmask the corresponding exceptions */
 121  116  
 122  117          testl   $0x200,%ecx             /* test denormal trap enable */
 123  118          jz      1f                      /* skip if zero */
 124  119  
 125  120          andb    $0xfd,0(%esp)   /* unmask denormal exception */
 126  121  
 127  122  1:
 128  123          movl    %ecx,%edx
 129  124          andl    $0x60,%edx              /* get the rounding direction */
↓ open down ↓ 14 lines elided ↑ open up ↑
 144  139          xorl    $0x180,%ecx             /* reverse bits */
 145  140          shll    $1,%ecx
 146  141          andw    $0xfcff,0(%esp)         /* update rounding precision */
 147  142          orw     %cx,0(%esp)
 148  143  
 149  144  1:
 150  145          fldcw   0(%esp)                 /* load the modified control word */
 151  146  
 152  147  3:
 153  148          addl    $4,%esp
      149 +        popl    %ebx
 154  150          popl    %ecx
 155  151          popl    %edx
 156  152          popl    %ebp
 157  153          ret
 158      -
 159      -        .size   __fsr,[.-__fsr]
      154 +SET_SIZE(__fsr)
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX