Beispiel #1
0
SWIGEXPORT jlong JNICALL Java_org_jllvm_bindings_ObjectJNI_LLVMGetSymbols(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jlong jresult = 0 ;
  LLVMObjectFileRef arg1 = (LLVMObjectFileRef) 0 ;
  LLVMSymbolIteratorRef result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(LLVMObjectFileRef *)&jarg1; 
  result = (LLVMSymbolIteratorRef)LLVMGetSymbols(arg1);
  *(LLVMSymbolIteratorRef *)&jresult = result; 
  return jresult;
}
Beispiel #2
0
int object_list_symbols(void) {
  LLVMMemoryBufferRef MB;
  LLVMObjectFileRef O;
  LLVMSectionIteratorRef sect;
  LLVMSymbolIteratorRef sym;
  char *msg = NULL;

  if (LLVMCreateMemoryBufferWithSTDIN(&MB, &msg)) {
    fprintf(stderr, "Error reading file: %s\n", msg);
    exit(1);
  }

  O = LLVMCreateObjectFile(MB);
  if (!O) {
    fprintf(stderr, "Error reading object\n");
    exit(1);
  }

  sect = LLVMGetSections(O);
  sym = LLVMGetSymbols(O);
  while (!LLVMIsSymbolIteratorAtEnd(O, sym)) {

    LLVMMoveToContainingSection(sect, sym);
    printf("%s @0x%08" PRIx64 "/0x%08" PRIx64 " +%" PRIu64 " (%s)\n",
           LLVMGetSymbolName(sym), LLVMGetSymbolAddress(sym),
           LLVMGetSymbolFileOffset(sym), LLVMGetSymbolSize(sym),
           LLVMGetSectionName(sect));

    LLVMMoveToNextSymbol(sym);
  }

  LLVMDisposeSymbolIterator(sym);

  LLVMDisposeObjectFile(O);

  return 0;
}