/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#ifdef __APPLE__
#include "decoder_machO.hpp"
#include <cxxabi.h>
int status;
char* result;
// Don't pass buf to __cxa_demangle. In case of the 'buf' is too small,
// __cxa_demangle will call system "realloc" for additional memory, which
// call c library's free
return true;
}
return false;
}
return false;
}
// iterate through symbol table trying to match our offset
struct nlist_64 *last_nlist = cur_nlist; // no size stored in an entry, so keep previously seen nlist
if (addr_relative == this_value) {
break;
} else if (addr_relative > this_value) {
// gone past it, use previously seen nlist:
break;
}
}
if (found_strx == 0) {
return false;
}
// write the offset:
// lookup found_strx in the string table
char * symname = mach_find_in_stringtable((char*) ((uintptr_t)mach_base + stroff), strsize, found_strx);
if (symname) {
return true;
}
return false;
}
// possibly verify it is a mach_header, use magic number.
// commands begin immediately after the header.
return pos;
}
}
return NULL;
}
if (strx_wanted == 0) {
return NULL;
}
// find the first string, skip over the space char
// (or the four zero bytes we see e.g. in libclient)
if (*strtab == ' ') {
strtab++;
if (*strtab != 0) {
return NULL;
}
strtab++;
} else {
return NULL;
}
strtab+=4;
}
// read the real strings starting at index 1
while (strtab < strtab_end) {
if (cur_strx == strx_wanted) {
return strtab;
}
// find start of next string
while (*strtab != 0) {
strtab++;
}
strtab++; // skip the terminating zero
cur_strx++;
}
return NULL;
}
#endif