Austin Schuh | dace2a6 | 2020-08-18 10:56:48 -0700 | [diff] [blame] | 1 | divert(-1) |
| 2 | dnl Copyright 2007, 2011, 2012, 2014 Free Software Foundation, Inc. |
| 3 | |
| 4 | dnl This file is part of the GNU MP Library. |
| 5 | dnl |
| 6 | dnl The GNU MP Library is free software; you can redistribute it and/or modify |
| 7 | dnl it under the terms of either: |
| 8 | dnl |
| 9 | dnl * the GNU Lesser General Public License as published by the Free |
| 10 | dnl Software Foundation; either version 3 of the License, or (at your |
| 11 | dnl option) any later version. |
| 12 | dnl |
| 13 | dnl or |
| 14 | dnl |
| 15 | dnl * the GNU General Public License as published by the Free Software |
| 16 | dnl Foundation; either version 2 of the License, or (at your option) any |
| 17 | dnl later version. |
| 18 | dnl |
| 19 | dnl or both in parallel, as here. |
| 20 | dnl |
| 21 | dnl The GNU MP Library is distributed in the hope that it will be useful, but |
| 22 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 23 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 24 | dnl for more details. |
| 25 | dnl |
| 26 | dnl You should have received copies of the GNU General Public License and the |
| 27 | dnl GNU Lesser General Public License along with the GNU MP Library. If not, |
| 28 | dnl see https://www.gnu.org/licenses/. |
| 29 | |
| 30 | define(`DARWIN') |
| 31 | |
| 32 | |
| 33 | dnl Usage LEA(symbol,reg) |
| 34 | dnl Usage LEAL(symbol_local_to_file,reg) |
| 35 | dnl |
| 36 | dnl We maintain lists of stuff to append in load_eip and darwin_bd. The |
| 37 | dnl `index' stuff is needed to suppress repeated definitions. To avoid |
| 38 | dnl getting fooled by "var" and "var1", we add 'bol ' (the end of |
| 39 | dnl 'indirect_symbol') at the beginning and and a newline at the end. This |
| 40 | dnl might be a bit fragile. |
| 41 | |
| 42 | define(`LEA', |
| 43 | m4_assert_numargs(2) |
| 44 | `ifdef(`PIC',` |
| 45 | ifelse(index(defn(`load_eip'), `$2'),-1, |
| 46 | `m4append(`load_eip', |
| 47 | ` TEXT |
| 48 | ALIGN(16) |
| 49 | L(movl_eip_`'substr($2,1)): |
| 50 | movl (%esp), $2 |
| 51 | ret_internal |
| 52 | ')') |
| 53 | ifelse(index(defn(`darwin_bd'), `bol $1 |
| 54 | '),-1, |
| 55 | `m4append(`darwin_bd', |
| 56 | ` .section __IMPORT,__pointers,non_lazy_symbol_pointers |
| 57 | L($1`'$non_lazy_ptr): |
| 58 | .indirect_symbol $1 |
| 59 | .long 0 |
| 60 | ')') |
| 61 | call L(movl_eip_`'substr($2,1)) |
| 62 | movl L($1`'$non_lazy_ptr)-.($2), $2 |
| 63 | ',` |
| 64 | movl `$'$1, $2 |
| 65 | ')') |
| 66 | |
| 67 | define(`LEAL', |
| 68 | m4_assert_numargs(2) |
| 69 | `ifdef(`PIC',` |
| 70 | ifelse(index(defn(`load_eip'), `$2'),-1, |
| 71 | `m4append(`load_eip', |
| 72 | ` TEXT |
| 73 | ALIGN(16) |
| 74 | L(movl_eip_`'substr($2,1)): |
| 75 | movl (%esp), $2 |
| 76 | ret_internal |
| 77 | ')') |
| 78 | call L(movl_eip_`'substr($2,1)) |
| 79 | leal $1-.($2), $2 |
| 80 | ',` |
| 81 | movl `$'$1, $2 |
| 82 | ')') |
| 83 | |
| 84 | |
| 85 | dnl ASM_END |
| 86 | |
| 87 | define(`ASM_END',`load_eip`'darwin_bd') |
| 88 | |
| 89 | define(`load_eip', `') dnl updated in LEA |
| 90 | define(`darwin_bd', `') dnl updated in LEA |
| 91 | |
| 92 | |
| 93 | dnl Usage: CALL(funcname) |
| 94 | dnl |
| 95 | |
| 96 | define(`CALL', |
| 97 | m4_assert_numargs(1) |
| 98 | `call GSYM_PREFIX`'$1') |
| 99 | |
| 100 | undefine(`PIC_WITH_EBX') |
| 101 | |
| 102 | divert`'dnl |