Artifact bf5d669ef3750618ddced083c1afab4cd29f0172:


0000: 2f 2a 20 54 72 61 6d 70 6f 6c 69 6e 65 20 66 6f  /* Trampoline fo
0010: 72 20 69 33 38 36 20 43 50 55 20 2a 2f 0a 0a 2f  r i386 CPU */../
0020: 2a 0a 20 2a 20 43 6f 70 79 72 69 67 68 74 20 31  *. * Copyright 1
0030: 39 39 35 2d 31 39 39 39 20 42 72 75 6e 6f 20 48  995-1999 Bruno H
0040: 61 69 62 6c 65 2c 20 3c 62 72 75 6e 6f 40 63 6c  aible, <bruno@cl
0050: 69 73 70 2e 6f 72 67 3e 0a 20 2a 0a 20 2a 20 54  isp.org>. *. * T
0060: 68 69 73 20 69 73 20 66 72 65 65 20 73 6f 66 74  his is free soft
0070: 77 61 72 65 20 64 69 73 74 72 69 62 75 74 65 64  ware distributed
0080: 20 75 6e 64 65 72 20 74 68 65 20 47 4e 55 20 47   under the GNU G
0090: 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 20 4c 69  eneral Public Li
00a0: 63 65 6e 63 65 0a 20 2a 20 64 65 73 63 72 69 62  cence. * describ
00b0: 65 64 20 69 6e 20 74 68 65 20 66 69 6c 65 20 43  ed in the file C
00c0: 4f 50 59 49 4e 47 2e 20 43 6f 6e 74 61 63 74 20  OPYING. Contact 
00d0: 74 68 65 20 61 75 74 68 6f 72 20 69 66 20 79 6f  the author if yo
00e0: 75 20 64 6f 6e 27 74 20 68 61 76 65 20 74 68 69  u don't have thi
00f0: 73 0a 20 2a 20 6f 72 20 63 61 6e 27 74 20 6c 69  s. * or can't li
0100: 76 65 20 77 69 74 68 20 69 74 2e 20 54 68 65 72  ve with it. Ther
0110: 65 20 69 73 20 41 42 53 4f 4c 55 54 45 4c 59 20  e is ABSOLUTELY 
0120: 4e 4f 20 57 41 52 52 41 4e 54 59 2c 20 65 78 70  NO WARRANTY, exp
0130: 6c 69 63 69 74 20 6f 72 20 69 6d 70 6c 69 65 64  licit or implied
0140: 2c 0a 20 2a 20 6f 6e 20 74 68 69 73 20 73 6f 66  ,. * on this sof
0150: 74 77 61 72 65 2e 0a 20 2a 2f 0a 0a 2f 2a 20 41  tware.. */../* A
0160: 76 61 69 6c 61 62 6c 65 20 72 65 67 69 73 74 65  vailable registe
0170: 72 73 3a 20 25 65 61 78 2c 20 25 65 64 78 2c 20  rs: %eax, %edx, 
0180: 25 65 63 78 2e 20 2a 2f 0a 2f 2a 0a 20 2a 20 4f  %ecx. */./*. * O
0190: 6e 20 53 6f 6c 61 72 69 73 20 32 2e 36 2c 20 77  n Solaris 2.6, w
01a0: 68 65 6e 20 74 68 65 20 66 75 6e 63 74 69 6f 6e  hen the function
01b0: 20 62 65 69 6e 67 20 6a 75 6d 70 65 64 20 74 6f   being jumped to
01c0: 20 69 73 20 61 6e 20 65 78 74 65 72 6e 61 6c 20   is an external 
01d0: 73 79 6d 62 6f 6c 20 6f 66 0a 20 2a 20 61 20 73  symbol of. * a s
01e0: 68 61 72 65 64 20 6c 69 62 72 61 72 79 2c 20 74  hared library, t
01f0: 68 65 20 6a 75 6d 70 20 61 63 74 75 61 6c 6c 79  he jump actually
0200: 20 70 6f 69 6e 74 73 20 74 6f 20 61 6e 20 45 4c   points to an EL
0210: 46 20 69 6e 64 69 72 65 63 74 20 6a 75 6d 70 3a  F indirect jump:
0220: 0a 20 2a 20 20 20 6a 6d 70 20 2a 50 54 52 0a 20  . *   jmp *PTR. 
0230: 2a 20 77 68 65 72 65 20 50 54 52 20 69 6e 69 74  * where PTR init
0240: 69 61 6c 6c 79 20 63 6f 6e 74 61 69 6e 73 20 74  ially contains t
0250: 68 65 20 61 64 64 72 65 73 73 20 6f 66 20 73 6f  he address of so
0260: 6d 65 20 72 65 73 6f 6c 76 69 6e 67 20 72 6f 75  me resolving rou
0270: 74 69 6e 65 20 77 68 69 63 68 0a 20 2a 20 77 69  tine which. * wi
0280: 6c 6c 20 72 65 70 6c 61 63 65 20 74 68 65 20 50  ll replace the P
0290: 54 52 20 63 6f 6e 74 65 6e 74 73 20 77 69 74 68  TR contents with
02a0: 20 74 68 65 20 61 63 74 75 61 6c 20 63 6f 64 65   the actual code
02b0: 20 61 64 64 72 65 73 73 20 6f 66 20 74 68 65 20   address of the 
02c0: 66 75 6e 63 74 69 6f 6e 0a 20 2a 20 61 6e 64 20  function. * and 
02d0: 74 68 65 6e 20 6a 75 6d 70 20 74 6f 20 74 68 65  then jump to the
02e0: 20 66 75 6e 63 74 69 6f 6e 2e 0a 20 2a 20 55 6e   function.. * Un
02f0: 66 6f 72 74 75 6e 61 74 65 6c 79 2c 20 74 68 69  fortunately, thi
0300: 73 20 72 65 73 6f 6c 76 69 6e 67 20 72 6f 75 74  s resolving rout
0310: 69 6e 65 20 63 6c 6f 62 62 65 72 73 20 61 6c 6c  ine clobbers all
0320: 20 74 68 72 65 65 20 72 65 67 69 73 74 65 72 73   three registers
0330: 3a 0a 20 2a 20 25 65 61 78 2c 20 25 65 64 78 2c  :. * %eax, %edx,
0340: 20 25 65 63 78 2e 20 4d 75 73 74 20 70 61 73 73   %ecx. Must pass
0350: 20 74 68 65 20 61 64 64 69 74 69 6f 6e 61 6c 20   the additional 
0360: 64 61 74 61 20 76 69 61 20 74 68 65 20 73 74 61  data via the sta
0370: 63 6b 2e 0a 20 2a 20 41 20 73 69 6d 70 6c 65 20  ck.. * A simple 
0380: 22 70 75 73 68 6c 20 24 3c 64 61 74 61 3e 22 20  "pushl $<data>" 
0390: 69 73 20 6e 6f 74 20 73 75 66 66 69 63 69 65 6e  is not sufficien
03a0: 74 3a 20 69 74 20 63 61 75 73 65 73 20 74 72 6f  t: it causes tro
03b0: 75 62 6c 65 20 69 66 20 74 68 65 20 63 61 6c 6c  uble if the call
03c0: 65 64 0a 20 2a 20 66 75 6e 63 74 69 6f 6e 20 69  ed. * function i
03d0: 73 20 63 6f 6d 70 69 6c 65 64 20 77 69 74 68 20  s compiled with 
03e0: 2d 66 6f 6d 69 74 2d 66 72 61 6d 65 2d 70 6f 69  -fomit-frame-poi
03f0: 6e 74 65 72 2e 0a 20 2a 2f 0a 20 0a 2e 67 6c 6f  nter.. */. ..glo
0400: 62 6c 20 5f 74 72 61 6d 70 0a 5f 74 72 61 6d 70  bl _tramp._tramp
0410: 3a 0a 09 70 6f 70 6c 20 25 65 63 78 0a 09 70 75  :..popl %ecx..pu
0420: 73 68 6c 20 24 30 78 37 33 35 35 34 37 31 31 0a  shl $0x73554711.
0430: 09 70 75 73 68 6c 20 25 65 63 78 0a 09 6a 6d 70  .pushl %ecx..jmp
0440: 20 30 78 62 61 62 65 62 65 63 30 0a               0xbabebec0.