Wed, 31 Jan 2018 19:24:57 -0500
8189170: Add option to disable stack overflow checking in primordial thread for use with JNI_CreateJavaJVM
Reviewed-by: dcubed
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright 2012, 2013 SAP AG. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #include <stddef.h> |
aoqi@0 | 26 | |
aoqi@0 | 27 | // Header file to contain porting-relevant code which does not have a |
aoqi@0 | 28 | // home anywhere else and which can not go into os_<platform>.h because |
aoqi@0 | 29 | // that header is included inside the os class definition, hence all |
aoqi@0 | 30 | // its content is part of the os class. |
aoqi@0 | 31 | |
aoqi@0 | 32 | // Aix' own version of dladdr(). |
aoqi@0 | 33 | // This function tries to mimick dladdr(3) on Linux |
aoqi@0 | 34 | // (see http://linux.die.net/man/3/dladdr) |
aoqi@0 | 35 | // dladdr(3) is not POSIX but a GNU extension, and is not available on AIX. |
aoqi@0 | 36 | // |
aoqi@0 | 37 | // Differences between AIX dladdr and Linux dladdr: |
aoqi@0 | 38 | // |
aoqi@0 | 39 | // 1) Dl_info.dli_fbase: can never work, is disabled. |
aoqi@0 | 40 | // A loaded image on AIX is divided in multiple segments, at least two |
aoqi@0 | 41 | // (text and data) but potentially also far more. This is because the loader may |
aoqi@0 | 42 | // load each member into an own segment, as for instance happens with the libC.a |
aoqi@0 | 43 | // 2) Dl_info.dli_sname: This only works for code symbols (functions); for data, a |
aoqi@0 | 44 | // zero-length string is returned (""). |
aoqi@0 | 45 | // 3) Dl_info.dli_saddr: For code, this will return the entry point of the function, |
aoqi@0 | 46 | // not the function descriptor. |
aoqi@0 | 47 | |
aoqi@0 | 48 | typedef struct { |
aoqi@0 | 49 | const char *dli_fname; // file path of loaded library |
aoqi@0 | 50 | // void *dli_fbase; |
aoqi@0 | 51 | const char *dli_sname; // symbol name; "" if not known |
aoqi@0 | 52 | void *dli_saddr; // address of *entry* of function; not function descriptor; |
aoqi@0 | 53 | } Dl_info; |
aoqi@0 | 54 | |
aoqi@0 | 55 | // Note: we export this to use it inside J2se too |
aoqi@0 | 56 | #ifdef __cplusplus |
aoqi@0 | 57 | extern "C" |
aoqi@0 | 58 | #endif |
aoqi@0 | 59 | int dladdr(void *addr, Dl_info *info); |
aoqi@0 | 60 | |
aoqi@0 | 61 | |
aoqi@0 | 62 | // The semantics in this file are thus that codeptr_t is a *real code ptr*. |
aoqi@0 | 63 | // This means that any function taking codeptr_t as arguments will assume |
aoqi@0 | 64 | // a real codeptr and won't handle function descriptors (eg getFuncName), |
aoqi@0 | 65 | // whereas functions taking address as args will deal with function |
aoqi@0 | 66 | // descriptors (eg os::dll_address_to_library_name). |
aoqi@0 | 67 | typedef unsigned int* codeptr_t; |
aoqi@0 | 68 | |
aoqi@0 | 69 | // helper function - given a program counter, tries to locate the traceback table and |
aoqi@0 | 70 | // returns info from it (like, most importantly, function name, displacement of the |
aoqi@0 | 71 | // pc inside the function, and the traceback table itself. |
aoqi@0 | 72 | #ifdef __cplusplus |
aoqi@0 | 73 | extern "C" |
aoqi@0 | 74 | #endif |
aoqi@0 | 75 | int getFuncName( |
aoqi@0 | 76 | codeptr_t pc, // [in] program counter |
aoqi@0 | 77 | char* p_name, size_t namelen, // [out] optional: user provided buffer for the function name |
aoqi@0 | 78 | int* p_displacement, // [out] optional: displacement |
aoqi@0 | 79 | const struct tbtable** p_tb, // [out] optional: ptr to traceback table to get further information |
aoqi@0 | 80 | char* p_errmsg, size_t errmsglen // [out] optional: user provided buffer for error messages |
aoqi@0 | 81 | ); |