Mercurial > hg > truffle
annotate agent/src/os/solaris/proc/saproc_audit.cpp @ 18149:c6086a18c9ce
Rename LIRGenerationResult.getFrameMap() to getFrameMapBuilder().
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Tue, 21 Oct 2014 16:28:40 +0200 |
parents | c18cbe5936b8 |
children |
rev | line source |
---|---|
892
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
892
diff
changeset
|
2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
892
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
4 * |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
8 * |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
13 * accompanied this code). |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
14 * |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
18 * |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
892
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
892
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
892
diff
changeset
|
21 * questions. |
892
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
22 * |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
23 */ |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
24 |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
25 #include <link.h> |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
26 #include <stdio.h> |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
27 #include <stdlib.h> |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
28 #include <string.h> |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
29 #include <sys/types.h> |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
30 #include <sys/stat.h> |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
31 #include <fcntl.h> |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
32 #include <limits.h> |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
33 #include <varargs.h> |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
34 |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
35 // This class sets up an interposer on open calls from libproc.so to |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
36 // support a pathmap facility in the SA. |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
37 |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
38 static uintptr_t* libproc_cookie; |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
39 static uintptr_t* libc_cookie; |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
40 static uintptr_t* libsaproc_cookie; |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
41 |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
42 |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
43 uint_t |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
44 la_version(uint_t version) |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
45 { |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
46 return (LAV_CURRENT); |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
47 } |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
48 |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
49 |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
50 uint_t |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
51 la_objopen(Link_map * lmp, Lmid_t lmid, uintptr_t * cookie) |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
52 { |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
53 if (strstr(lmp->l_name, "/libproc.so") != NULL) { |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
54 libproc_cookie = cookie; |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
55 return LA_FLG_BINDFROM; |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
56 } |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
57 if (strstr(lmp->l_name, "/libc.so") != NULL) { |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
58 libc_cookie = cookie; |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
59 return LA_FLG_BINDTO; |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
60 } |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
61 if (strstr(lmp->l_name, "/libsaproc.so") != NULL) { |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
62 libsaproc_cookie = cookie; |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
63 return LA_FLG_BINDTO | LA_FLG_BINDFROM; |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
64 } |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
65 return 0; |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
66 } |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
67 |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
68 |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
69 #if defined(_LP64) |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
70 uintptr_t |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
71 la_symbind64(Elf64_Sym *symp, uint_t symndx, uintptr_t *refcook, |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
72 uintptr_t *defcook, uint_t *sb_flags, const char *sym_name) |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
73 #else |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
74 uintptr_t |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
75 la_symbind32(Elf32_Sym *symp, uint_t symndx, uintptr_t *refcook, |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
76 uintptr_t *defcook, uint_t *sb_flags) |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
77 #endif |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
78 { |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
79 #if !defined(_LP64) |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
80 const char *sym_name = (const char *)symp->st_name; |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
81 #endif |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
82 if (strcmp(sym_name, "open") == 0 && refcook == libproc_cookie) { |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
83 // redirect all open calls from libproc.so through libsaproc_open which will |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
84 // try the alternate library locations first. |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
85 void* handle = dlmopen(LM_ID_BASE, "libsaproc.so", RTLD_NOLOAD); |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
86 if (handle == NULL) { |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
87 fprintf(stderr, "libsaproc_audit.so: didn't find libsaproc.so during linking\n"); |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
88 } else { |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
89 uintptr_t libsaproc_open = (uintptr_t)dlsym(handle, "libsaproc_open"); |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
90 if (libsaproc_open == 0) { |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
91 fprintf(stderr, "libsaproc_audit.so: didn't find libsaproc_open during linking\n"); |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
92 } else { |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
93 return libsaproc_open; |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
94 } |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
95 } |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
96 } |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
97 return symp->st_value; |
a94af87c3357
6861984: solaris version of libsaproc.so should support SA_ALTROOT directly
never
parents:
diff
changeset
|
98 } |