1/* 2 * Copyright (c) 2012, 2013 SAP SE. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 26// Loadlib_aix.cpp contains support code for analysing the memory 27// layout of loaded binaries in ones own process space. 28// 29// It is needed, among other things, to provide dladdr(3), which is 30// missing on AIX. 31 32#ifndef OS_AIX_VM_LOADLIB_AIX_HPP 33#define OS_AIX_VM_LOADLIB_AIX_HPP 34 35#include <stddef.h> 36 37class outputStream; 38 39// Struct holds information about a single loaded library module. 40// Note that on AIX, a single library can be spread over multiple 41// uintptr_t ranges on a module base, eg. 42// libC.a(shr3_64.o) or libC.a(shrcore_64.o). 43 44// Note: all pointers to strings (path, member) point to strings which are immortal. 45struct loaded_module_t { 46 47 // Points to the full path of the lodaed module, e.g. 48 // "/usr/lib/libC.a". 49 const char* path; 50 51 // Host library name without path 52 const char* shortname; 53 54 // Points to the object file (AIX specific stuff) 55 // e.g "shrcore_64.o". 56 const char* member; 57 58 // Text area from, to 59 const void* text; 60 size_t text_len; 61 62 // Data area from, to 63 const void* data; 64 size_t data_len; 65 66 // True if this module is part of the vm. 67 bool is_in_vm; 68 69}; 70 71// This class is a singleton holding a map of all loaded binaries 72// in the AIX process space. 73class LoadedLibraries 74// : AllStatic (including allocation.hpp just for AllStatic is overkill.) 75{ 76 77 public: 78 79 // Rebuild the internal module table. If an error occurs, internal module 80 // table remains untouched. 81 static bool reload(); 82 83 // Check whether the given address points into the text segment of a 84 // loaded module. Return true if this is the case. 85 // Optionally, information about the module is returned (info) 86 static bool find_for_text_address ( 87 const void* p, 88 loaded_module_t* info // Optional, leave NULL if not needed. 89 ); 90 91 // Check whether the given address points into the data segment of a 92 // loaded module. Return true if this is the case. 93 // Optionally, information about the module is returned (info) 94 static bool find_for_data_address ( 95 const void* p, 96 loaded_module_t* info // Optional, leave NULL if not needed. 97 ); 98 99 // Output debug info 100 static void print(outputStream* os); 101 102}; 103 104#endif // OS_AIX_VM_LOADLIB_AIX_HPP 105