njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Redirections, etc. pub_tool_redir.h ---*/ |
| 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
sewardj | b3a1e4b | 2015-08-21 11:32:26 +0000 | [diff] [blame] | 10 | Copyright (C) 2000-2015 Julian Seward |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 11 | jseward@acm.org |
| 12 | |
| 13 | This program is free software; you can redistribute it and/or |
| 14 | modify it under the terms of the GNU General Public License as |
| 15 | published by the Free Software Foundation; either version 2 of the |
| 16 | License, or (at your option) any later version. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, but |
| 19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; if not, write to the Free Software |
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 26 | 02111-1307, USA. |
| 27 | |
| 28 | The GNU General Public License is contained in the file COPYING. |
| 29 | */ |
| 30 | |
njn | 4a164d0 | 2005-06-18 18:49:40 +0000 | [diff] [blame] | 31 | #ifndef __PUB_TOOL_REDIR_H |
| 32 | #define __PUB_TOOL_REDIR_H |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 33 | |
sewardj | 731f9cf | 2011-09-21 08:43:08 +0000 | [diff] [blame] | 34 | #include "config.h" /* DARWIN_VERS */ |
Elliott Hughes | a0664b9 | 2017-04-18 17:46:52 -0700 | [diff] [blame^] | 35 | #include "pub_tool_basics.h" // Bool and HChar |
sewardj | 731f9cf | 2011-09-21 08:43:08 +0000 | [diff] [blame] | 36 | |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 37 | /* The following macros facilitate function replacement and wrapping. |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 38 | |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 39 | Function wrapping and function replacement are similar but not |
| 40 | identical. |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 41 | |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 42 | A replacement for some function F simply diverts all calls to F |
| 43 | to the stated replacement. There is no way to get back to F itself |
| 44 | from the replacement. |
| 45 | |
| 46 | A wrapper for a function F causes all calls to F to instead go to |
| 47 | the wrapper. However, from inside the wrapper, it is possible |
| 48 | (with some difficulty) to get to F itself. |
| 49 | |
| 50 | You may notice that replacement is a special case of wrapping, in |
| 51 | which the call to the original is omitted. For implementation |
| 52 | reasons, though, it is important to use the following macros |
| 53 | correctly: in particular, if you want to write a replacement, make |
| 54 | sure you use the VG_REPLACE_FN_ macros and not the VG_WRAP_FN_ |
| 55 | macros. |
| 56 | |
sewardj | 9604484 | 2011-08-18 13:09:55 +0000 | [diff] [blame] | 57 | Finally there is the concept of prioritised behavioural equivalence |
| 58 | tags. A tag is a 5-digit decimal number (00000 to 99999) encoded |
| 59 | in the name. The top 4 digits are the equivalence class number, |
| 60 | and the last digit is a priority. |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 61 | |
sewardj | 9604484 | 2011-08-18 13:09:55 +0000 | [diff] [blame] | 62 | When processing redirections at library load time, if the set of |
| 63 | available specifications yields more than one replacement or |
| 64 | wrapper function for a given address, the system will try to |
| 65 | resolve the situation by examining the tags on the |
| 66 | replacements/wrappers. |
| 67 | |
| 68 | If two replacement/wrapper functions have the same tag and |
| 69 | priority, then the redirection machinery will assume they have |
| 70 | identical behaviour and can choose between them arbitrarily. If |
| 71 | they have the same tag but different priorities, then the one with |
| 72 | higher priority will be chosen. If neither case holds, then the |
| 73 | redirection is ambiguous and the system will ignore one of them |
| 74 | arbitrarily, but print a warning when running at -v or above. |
| 75 | |
| 76 | The tag is mandatory and must comprise 5 decimal digits. The tag |
| 77 | 00000 is special and means "does not have behaviour identical to any |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 78 | other replacement/wrapper function". Hence if you wish to write a |
| 79 | wrap/replacement function that is not subject to the above |
sewardj | 9604484 | 2011-08-18 13:09:55 +0000 | [diff] [blame] | 80 | resolution rules, use 00000 for the tag. Tags 00001 through 00009 |
| 81 | may not be used for any purpose. |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 82 | |
| 83 | |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 84 | Replacement |
| 85 | ~~~~~~~~~~~ |
| 86 | To write a replacement function, do this: |
| 87 | |
| 88 | ret_type |
| 89 | VG_REPLACE_FUNCTION_ZU(zEncodedSoname,fnname) ( .. args .. ) |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 90 | { |
| 91 | ... body ... |
| 92 | } |
| 93 | |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 94 | zEncodedSoname should be a Z-encoded soname (see below for |
| 95 | Z-encoding details) and fnname should be an unencoded fn name. A |
sewardj | 9604484 | 2011-08-18 13:09:55 +0000 | [diff] [blame] | 96 | default-safe equivalence tag of 00000 is assumed (see comments |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 97 | above). The resulting name is |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 98 | |
sewardj | 9604484 | 2011-08-18 13:09:55 +0000 | [diff] [blame] | 99 | _vgr00000ZU_zEncodedSoname_fnname |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 100 | |
sewardj | 9604484 | 2011-08-18 13:09:55 +0000 | [diff] [blame] | 101 | The "_vgr00000ZU_" is a prefix that gets discarded upon decoding. |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 102 | It identifies this function as a replacement and specifies its |
| 103 | equivalence tag. |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 104 | |
| 105 | It is also possible to write |
| 106 | |
| 107 | ret_type |
| 108 | VG_REPLACE_FUNCTION_ZZ(zEncodedSoname,zEncodedFnname) ( .. args .. ) |
| 109 | { |
| 110 | ... body ... |
| 111 | } |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 112 | |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 113 | which means precisely the same, but the function name is also |
| 114 | Z-encoded. This can sometimes be necessary. In this case the |
| 115 | resulting function name is |
| 116 | |
sewardj | 9604484 | 2011-08-18 13:09:55 +0000 | [diff] [blame] | 117 | _vgr00000ZZ_zEncodedSoname_zEncodedFnname |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 118 | |
| 119 | When it sees this either such name, the core's symbol-table reading |
| 120 | machinery and redirection machinery first Z-decode the soname and |
| 121 | if necessary the fnname. They are encoded so that they may include |
| 122 | arbitrary characters, and in particular they may contain '*', which |
| 123 | acts as a wildcard. |
| 124 | |
| 125 | They then will conspire to cause calls to any function matching |
| 126 | 'fnname' in any object whose soname matches 'soname' to actually be |
| 127 | routed to this function. This is used in Valgrind to define dozens |
| 128 | of replacements of malloc, free, etc. |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 129 | |
| 130 | The soname must be a Z-encoded bit of text because sonames can |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 131 | contain dots etc which are not valid symbol names. The function |
| 132 | name may or may not be Z-encoded: to include wildcards it has to be, |
| 133 | but Z-encoding C++ function names which are themselves already mangled |
| 134 | using Zs in some way is tedious and error prone, so the _ZU variant |
| 135 | allows them not to be Z-encoded. |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 136 | |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 137 | Note that the soname "NONE" is specially interpreted to match any |
| 138 | shared object which doesn't have a soname. |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 139 | |
| 140 | Note also that the replacement function should probably (must be?) in |
| 141 | client space, so it runs on the simulated CPU. So it must be in |
njn | 7b4e5ba | 2005-08-25 22:53:57 +0000 | [diff] [blame] | 142 | either vgpreload_<tool>.so or vgpreload_core.so. It also only works |
| 143 | with functions in shared objects, I think. |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 144 | |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 145 | It is important that the Z-encoded names contain no unencoded |
| 146 | underscores, since the intercept-handlers in m_redir.c detect the |
| 147 | end of the soname by looking for the first trailing underscore. |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 148 | |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 149 | To write function names which explicitly state the equivalence class |
| 150 | tag, use |
sewardj | 9604484 | 2011-08-18 13:09:55 +0000 | [diff] [blame] | 151 | VG_REPLACE_FUNCTION_EZU(5-digit-tag,zEncodedSoname,fnname) |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 152 | or |
sewardj | 9604484 | 2011-08-18 13:09:55 +0000 | [diff] [blame] | 153 | VG_REPLACE_FUNCTION_EZZ(5-digit-tag,zEncodedSoname,zEncodedFnname) |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 154 | |
sewardj | 9604484 | 2011-08-18 13:09:55 +0000 | [diff] [blame] | 155 | As per comments above, the tag must be a 5 digit decimal number, |
| 156 | padded with leading zeroes, in the range 00010 to 99999 inclusive. |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 157 | |
| 158 | |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 159 | Wrapping |
| 160 | ~~~~~~~~ |
| 161 | This is identical to replacement, except that you should use the |
| 162 | macro names |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 163 | |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 164 | VG_WRAP_FUNCTION_ZU |
| 165 | VG_WRAP_FUNCTION_ZZ |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 166 | VG_WRAP_FUNCTION_EZU |
| 167 | VG_WRAP_FUNCTION_EZZ |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 168 | |
| 169 | instead. |
| 170 | |
| 171 | Z-encoding |
| 172 | ~~~~~~~~~~ |
| 173 | Z-encoding details: the scheme is like GHC's. It is just about |
| 174 | readable enough to make a preprocessor unnecessary. First the |
| 175 | "_vgrZU_" or "_vgrZZ_" prefix is added, and then the following |
| 176 | characters are transformed. |
| 177 | |
| 178 | * --> Za (asterisk) |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 179 | : --> Zc (colon) |
| 180 | . --> Zd (dot) |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 181 | - --> Zh (hyphen) |
sewardj | 578b171 | 2009-07-26 19:41:07 +0000 | [diff] [blame] | 182 | + --> Zp (plus) |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 183 | (space) --> Zs (space) |
sewardj | 578b171 | 2009-07-26 19:41:07 +0000 | [diff] [blame] | 184 | _ --> Zu (underscore) |
sewardj | 6b9cc87 | 2006-10-17 01:39:30 +0000 | [diff] [blame] | 185 | @ --> ZA (at) |
sewardj | 578b171 | 2009-07-26 19:41:07 +0000 | [diff] [blame] | 186 | $ --> ZD (dollar) |
sewardj | 6b9cc87 | 2006-10-17 01:39:30 +0000 | [diff] [blame] | 187 | ( --> ZL (left) |
| 188 | ) --> ZR (right) |
sewardj | 578b171 | 2009-07-26 19:41:07 +0000 | [diff] [blame] | 189 | Z --> ZZ (Z) |
sewardj | 8eb8bab | 2015-07-21 14:44:28 +0000 | [diff] [blame] | 190 | / --> ZS (slash) |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 191 | |
| 192 | Everything else is left unchanged. |
| 193 | */ |
| 194 | |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 195 | /* If you change these, the code in VG_(maybe_Z_demangle) needs to be |
| 196 | changed accordingly. NOTE: duplicates |
| 197 | I_{WRAP,REPLACE}_SONAME_FNNAME_Z{U,Z} in valgrind.h. */ |
| 198 | |
sewardj | 6b9cc87 | 2006-10-17 01:39:30 +0000 | [diff] [blame] | 199 | /* Use an extra level of macroisation so as to ensure the soname/fnname |
| 200 | args are fully macro-expanded before pasting them together. */ |
| 201 | #define VG_CONCAT4(_aa,_bb,_cc,_dd) _aa##_bb##_cc##_dd |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 202 | |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 203 | #define VG_CONCAT6(_aa,_bb,_cc,_dd,_ee,_ff) _aa##_bb##_cc##_dd##_ee##_ff |
sewardj | 6b9cc87 | 2006-10-17 01:39:30 +0000 | [diff] [blame] | 204 | |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 205 | /* The 4 basic macros. */ |
| 206 | #define VG_REPLACE_FUNCTION_EZU(_eclasstag,_soname,_fnname) \ |
| 207 | VG_CONCAT6(_vgr,_eclasstag,ZU_,_soname,_,_fnname) |
| 208 | |
| 209 | #define VG_REPLACE_FUNCTION_EZZ(_eclasstag,_soname,_fnname) \ |
| 210 | VG_CONCAT6(_vgr,_eclasstag,ZZ_,_soname,_,_fnname) |
| 211 | |
| 212 | #define VG_WRAP_FUNCTION_EZU(_eclasstag,_soname,_fnname) \ |
| 213 | VG_CONCAT6(_vgw,_eclasstag,ZU_,_soname,_,_fnname) |
| 214 | |
| 215 | #define VG_WRAP_FUNCTION_EZZ(_eclasstag,_soname,_fnname) \ |
| 216 | VG_CONCAT6(_vgw,_eclasstag,ZZ_,_soname,_,_fnname) |
| 217 | |
| 218 | /* Convenience macros defined in terms of the above 4. */ |
| 219 | #define VG_REPLACE_FUNCTION_ZU(_soname,_fnname) \ |
sewardj | 9604484 | 2011-08-18 13:09:55 +0000 | [diff] [blame] | 220 | VG_CONCAT6(_vgr,00000,ZU_,_soname,_,_fnname) |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 221 | |
| 222 | #define VG_REPLACE_FUNCTION_ZZ(_soname,_fnname) \ |
sewardj | 9604484 | 2011-08-18 13:09:55 +0000 | [diff] [blame] | 223 | VG_CONCAT6(_vgr,00000,ZZ_,_soname,_,_fnname) |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 224 | |
| 225 | #define VG_WRAP_FUNCTION_ZU(_soname,_fnname) \ |
sewardj | 9604484 | 2011-08-18 13:09:55 +0000 | [diff] [blame] | 226 | VG_CONCAT6(_vgw,00000,ZU_,_soname,_,_fnname) |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 227 | |
| 228 | #define VG_WRAP_FUNCTION_ZZ(_soname,_fnname) \ |
sewardj | 9604484 | 2011-08-18 13:09:55 +0000 | [diff] [blame] | 229 | VG_CONCAT6(_vgw,00000,ZZ_,_soname,_,_fnname) |
sewardj | 85cf900 | 2011-08-16 09:54:00 +0000 | [diff] [blame] | 230 | |
sewardj | 6b9cc87 | 2006-10-17 01:39:30 +0000 | [diff] [blame] | 231 | |
njn | e615466 | 2009-02-10 04:23:41 +0000 | [diff] [blame] | 232 | /* --------- Some handy Z-encoded names. --------- */ |
| 233 | |
njn | b4cfbc4 | 2009-05-04 04:20:02 +0000 | [diff] [blame] | 234 | // Nb: ALL THESE NAMES MUST BEGIN WITH "VG_Z_". Why? If we applied |
| 235 | // conditional compilation inconsistently we could accidentally use an |
| 236 | // undefined constant like VG_Z_LIBC_DOT_A, resulting in a bogus Z-encoded |
| 237 | // name like "_vgrZU_VG_Z_LIBC_DOT_A_foo". This can't be detected at |
| 238 | // compile-time, because both the constant's name and its value are |
| 239 | // identifiers. However, by always using "VG_Z_" as a prefix, we can do a |
| 240 | // run-time check and abort if any name has "VG_Z_" in it, because that |
| 241 | // indicates that the constant has been used without being defined. |
| 242 | |
njn | e615466 | 2009-02-10 04:23:41 +0000 | [diff] [blame] | 243 | /* --- Soname of the standard C library. --- */ |
| 244 | |
sewardj | 8eb8bab | 2015-07-21 14:44:28 +0000 | [diff] [blame] | 245 | #if defined(VGO_linux) || defined(VGO_solaris) |
njn | e615466 | 2009-02-10 04:23:41 +0000 | [diff] [blame] | 246 | # define VG_Z_LIBC_SONAME libcZdsoZa // libc.so* |
sewardj | 731f9cf | 2011-09-21 08:43:08 +0000 | [diff] [blame] | 247 | |
| 248 | #elif defined(VGO_darwin) && (DARWIN_VERS <= DARWIN_10_6) |
njn | f76d27a | 2009-05-28 01:53:07 +0000 | [diff] [blame] | 249 | # define VG_Z_LIBC_SONAME libSystemZdZaZddylib // libSystem.*.dylib |
sewardj | 731f9cf | 2011-09-21 08:43:08 +0000 | [diff] [blame] | 250 | |
sewardj | 34ffca6 | 2014-06-21 09:37:46 +0000 | [diff] [blame] | 251 | #elif defined(VGO_darwin) && (DARWIN_VERS == DARWIN_10_7 \ |
| 252 | || DARWIN_VERS == DARWIN_10_8) |
sewardj | 731f9cf | 2011-09-21 08:43:08 +0000 | [diff] [blame] | 253 | # define VG_Z_LIBC_SONAME libsystemZucZaZddylib // libsystem_c*.dylib |
sewardj | 34ffca6 | 2014-06-21 09:37:46 +0000 | [diff] [blame] | 254 | /* Note that the idea of a single name for the C library falls |
| 255 | apart on more recent Darwins (10.8 and later) since the |
| 256 | functionality (malloc, free, str*) is split between |
| 257 | libsystem_c.dylib, libsystem_malloc.dylib and |
| 258 | libsystem_platform.dylib. This makes VG_Z_LIBC_SONAME somewhat useless |
| 259 | at least inside vg_replace_strmem.c, and that hardwires some dylib |
| 260 | names directly, for OSX 10.9. */ |
sewardj | 731f9cf | 2011-09-21 08:43:08 +0000 | [diff] [blame] | 261 | |
sewardj | ec66ad5 | 2014-06-20 11:48:38 +0000 | [diff] [blame] | 262 | #elif defined(VGO_darwin) && (DARWIN_VERS >= DARWIN_10_9) |
sewardj | 34ffca6 | 2014-06-21 09:37:46 +0000 | [diff] [blame] | 263 | # define VG_Z_LIBC_SONAME libsystemZumallocZddylib // libsystem_malloc.dylib |
sewardj | ec66ad5 | 2014-06-20 11:48:38 +0000 | [diff] [blame] | 264 | |
njn | e615466 | 2009-02-10 04:23:41 +0000 | [diff] [blame] | 265 | #else |
| 266 | # error "Unknown platform" |
sewardj | 731f9cf | 2011-09-21 08:43:08 +0000 | [diff] [blame] | 267 | |
njn | e615466 | 2009-02-10 04:23:41 +0000 | [diff] [blame] | 268 | #endif |
| 269 | |
| 270 | /* --- Soname of the GNU C++ library. --- */ |
| 271 | |
njn | b4cfbc4 | 2009-05-04 04:20:02 +0000 | [diff] [blame] | 272 | // Valid on all platforms(?) |
njn | e615466 | 2009-02-10 04:23:41 +0000 | [diff] [blame] | 273 | #define VG_Z_LIBSTDCXX_SONAME libstdcZpZpZa // libstdc++* |
| 274 | |
njn | 5f5ef2a | 2009-05-11 08:01:09 +0000 | [diff] [blame] | 275 | /* --- Soname of the pthreads library. --- */ |
| 276 | |
sewardj | 6e9de46 | 2011-06-28 07:25:29 +0000 | [diff] [blame] | 277 | #if defined(VGO_linux) |
njn | 5f5ef2a | 2009-05-11 08:01:09 +0000 | [diff] [blame] | 278 | # define VG_Z_LIBPTHREAD_SONAME libpthreadZdsoZd0 // libpthread.so.0 |
njn | f76d27a | 2009-05-28 01:53:07 +0000 | [diff] [blame] | 279 | #elif defined(VGO_darwin) |
| 280 | # define VG_Z_LIBPTHREAD_SONAME libSystemZdZaZddylib // libSystem.*.dylib |
sewardj | 8eb8bab | 2015-07-21 14:44:28 +0000 | [diff] [blame] | 281 | #elif defined(VGO_solaris) |
| 282 | # define VG_Z_LIBPTHREAD_SONAME libpthreadZdsoZd1 // libpthread.so.1 |
njn | 5f5ef2a | 2009-05-11 08:01:09 +0000 | [diff] [blame] | 283 | #else |
| 284 | # error "Unknown platform" |
| 285 | #endif |
| 286 | |
sewardj | a0eee32 | 2009-07-31 08:46:35 +0000 | [diff] [blame] | 287 | /* --- Sonames for Linux ELF linkers, plus unencoded versions. --- */ |
njn | e615466 | 2009-02-10 04:23:41 +0000 | [diff] [blame] | 288 | |
njn | b4cfbc4 | 2009-05-04 04:20:02 +0000 | [diff] [blame] | 289 | #if defined(VGO_linux) |
sewardj | a0eee32 | 2009-07-31 08:46:35 +0000 | [diff] [blame] | 290 | |
sewardj | 651cfa4 | 2010-01-11 13:02:19 +0000 | [diff] [blame] | 291 | #define VG_Z_LD_LINUX_SO_3 ldZhlinuxZdsoZd3 // ld-linux.so.3 |
| 292 | #define VG_U_LD_LINUX_SO_3 "ld-linux.so.3" |
| 293 | |
njn | e615466 | 2009-02-10 04:23:41 +0000 | [diff] [blame] | 294 | #define VG_Z_LD_LINUX_SO_2 ldZhlinuxZdsoZd2 // ld-linux.so.2 |
sewardj | a0eee32 | 2009-07-31 08:46:35 +0000 | [diff] [blame] | 295 | #define VG_U_LD_LINUX_SO_2 "ld-linux.so.2" |
| 296 | |
sewardj | 34ffca6 | 2014-06-21 09:37:46 +0000 | [diff] [blame] | 297 | #define VG_Z_LD_LINUX_X86_64_SO_2 ldZhlinuxZhx86Zh64ZdsoZd2 |
| 298 | // ld-linux-x86-64.so.2 |
sewardj | a0eee32 | 2009-07-31 08:46:35 +0000 | [diff] [blame] | 299 | #define VG_U_LD_LINUX_X86_64_SO_2 "ld-linux-x86-64.so.2" |
| 300 | |
njn | e615466 | 2009-02-10 04:23:41 +0000 | [diff] [blame] | 301 | #define VG_Z_LD64_SO_1 ld64ZdsoZd1 // ld64.so.1 |
sewardj | a0eee32 | 2009-07-31 08:46:35 +0000 | [diff] [blame] | 302 | #define VG_U_LD64_SO_1 "ld64.so.1" |
carll | 582d582 | 2014-08-07 23:35:54 +0000 | [diff] [blame] | 303 | #define VG_U_LD64_SO_2 "ld64.so.2" // PPC LE loader |
sewardj | a0eee32 | 2009-07-31 08:46:35 +0000 | [diff] [blame] | 304 | |
njn | e615466 | 2009-02-10 04:23:41 +0000 | [diff] [blame] | 305 | #define VG_Z_LD_SO_1 ldZdsoZd1 // ld.so.1 |
sewardj | a0eee32 | 2009-07-31 08:46:35 +0000 | [diff] [blame] | 306 | #define VG_U_LD_SO_1 "ld.so.1" |
| 307 | |
sewardj | dcd9051 | 2014-08-30 19:21:48 +0000 | [diff] [blame] | 308 | #define VG_U_LD_LINUX_AARCH64_SO_1 "ld-linux-aarch64.so.1" |
mjw | 4fa7108 | 2014-09-01 15:29:55 +0000 | [diff] [blame] | 309 | #define VG_U_LD_LINUX_ARMHF_SO_3 "ld-linux-armhf.so.3" |
sewardj | dcd9051 | 2014-08-30 19:21:48 +0000 | [diff] [blame] | 310 | |
njn | b4cfbc4 | 2009-05-04 04:20:02 +0000 | [diff] [blame] | 311 | #endif |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 312 | |
njn | f76d27a | 2009-05-28 01:53:07 +0000 | [diff] [blame] | 313 | /* --- Executable name for Darwin Mach-O linker. --- */ |
| 314 | |
| 315 | #if defined(VGO_darwin) |
sewardj | a0eee32 | 2009-07-31 08:46:35 +0000 | [diff] [blame] | 316 | |
njn | f76d27a | 2009-05-28 01:53:07 +0000 | [diff] [blame] | 317 | #define VG_Z_DYLD dyld // dyld |
sewardj | a0eee32 | 2009-07-31 08:46:35 +0000 | [diff] [blame] | 318 | #define VG_U_DYLD "dyld" |
| 319 | |
njn | f76d27a | 2009-05-28 01:53:07 +0000 | [diff] [blame] | 320 | #endif |
| 321 | |
sewardj | 8eb8bab | 2015-07-21 14:44:28 +0000 | [diff] [blame] | 322 | /* --- Soname for Solaris run-time linker. --- */ |
| 323 | // Note: run-time linker contains absolute pathname in the SONAME. |
| 324 | |
| 325 | #if defined(VGO_solaris) |
| 326 | |
| 327 | #if defined(VGP_x86_solaris) |
| 328 | # define VG_Z_LD_SO_1 ZSlibZSldZdsoZd1 // /lib/ld.so.1 |
| 329 | # define VG_U_LD_SO_1 "/lib/ld.so.1" |
| 330 | #elif defined(VGP_amd64_solaris) |
| 331 | # define VG_Z_LD_SO_1 ZSlibZSamd64ZSldZdsoZd1 // /lib/amd64/ld.so.1 |
| 332 | # define VG_U_LD_SO_1 "/lib/amd64/ld.so.1" |
| 333 | #else |
| 334 | # error "Unknown platform" |
| 335 | #endif |
| 336 | |
| 337 | /* --- Soname for Solaris libumem allocation interposition. --- */ |
| 338 | |
| 339 | #define VG_Z_LIBUMEM_SO_1 libumemZdsoZd1 // libumem.so.1 |
| 340 | #define VG_U_LIBUMEM_SO_1 "libumem.so.1" |
| 341 | |
| 342 | #endif |
njn | f76d27a | 2009-05-28 01:53:07 +0000 | [diff] [blame] | 343 | |
philippe | 1e470b5 | 2012-05-11 19:33:46 +0000 | [diff] [blame] | 344 | // Prefix for synonym soname synonym handling |
| 345 | #define VG_SO_SYN(name) VgSoSyn##name |
| 346 | #define VG_SO_SYN_PREFIX "VgSoSyn" |
| 347 | #define VG_SO_SYN_PREFIX_LEN 7 |
| 348 | |
Elliott Hughes | a0664b9 | 2017-04-18 17:46:52 -0700 | [diff] [blame^] | 349 | // Special soname synonym place holder for the malloc symbols that can |
| 350 | // be replaced using --soname-synonyms. Otherwise will match all |
| 351 | // public symbols in any shared library/executable. |
| 352 | #define SO_SYN_MALLOC VG_SO_SYN(somalloc) |
| 353 | #define SO_SYN_MALLOC_NAME "VgSoSynsomalloc" |
| 354 | |
| 355 | Bool VG_(is_soname_ld_so) (const HChar *soname); |
| 356 | |
njn | 4a164d0 | 2005-06-18 18:49:40 +0000 | [diff] [blame] | 357 | #endif // __PUB_TOOL_REDIR_H |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 358 | |
| 359 | /*--------------------------------------------------------------------*/ |
| 360 | /*--- end ---*/ |
| 361 | /*--------------------------------------------------------------------*/ |