24 if(libFileName ==
""){
return;}
25 void* library = dlopen(libFileName.c_str(), RTLD_LAZY | RTLD_GLOBAL);
27 std::cerr <<
"phoenix_listLibrarySymbol : library '"<<libFileName<<
"' not found" << std::endl;
30 struct link_map * map = NULL;
31 dlinfo(library, RTLD_DI_LINKMAP, &map);
33 Elf64_Sym * symtab =
nullptr;
34 char * strtab =
nullptr;
36 for(
auto section = map->l_ld; section->d_tag != DT_NULL; ++section){
37 if(section->d_tag == DT_SYMTAB){
38 symtab = (Elf64_Sym *)section->d_un.d_ptr;
40 if(section->d_tag == DT_STRTAB){
41 strtab = (
char*)section->d_un.d_ptr;
43 if(section->d_tag == DT_SYMENT){
44 symentries = section->d_un.d_val;
47 int size = strtab - (
char *)symtab;
48 for(
int k = 0; k < size / symentries; ++k){
49 auto sym = &symtab[k];
51 if(ELF64_ST_TYPE(symtab[k].st_info) == STT_FUNC){
53 auto str = &strtab[sym->st_name];
54 vecFunction.push_back(std::string(str));
67std::string
phoenix_mangleFunction(
const std::string & functionPrototype,
const std::string & extraInclude,
const std::string & compiler){
68 std::string command(
"echo \"#include <new>\\n#include <string>\\n"+extraInclude+
"\\n"+functionPrototype+
" {} \" | "+compiler+
" -x c++ -S - -o- | grep \"@function\" | cut -d ',' -f 1 | sed -e \"s/.type//g\" | sed -s \"s/ //g\" | sed -e \"s/\t//g\"");
69 FILE * fp = popen(command.c_str(),
"r");
71 std::cerr <<
"phoenix_mangleFunction : cannot get result of command '"<<command<<
"'" << std::endl;
74 std::string mangledFunction(
"");
79 char ch = (char)buffer;
80 if(ch !=
' ' && ch !=
'\t' && ch !=
'\n'){
81 mangledFunction += ch;
87 return mangledFunction;
std::string phoenix_mangleFunction(const std::string &functionPrototype, const std::string &extraInclude, const std::string &compiler)
Mangle the given function prototype.