Beispiel #1
0
int object_list_sections(void) {
  LLVMMemoryBufferRef MB;
  LLVMObjectFileRef O;
  LLVMSectionIteratorRef sect;
  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);
  while (!LLVMIsSectionIteratorAtEnd(O, sect)) {
    printf("'%s': @0x%08" PRIx64 " +%" PRIu64 "\n", LLVMGetSectionName(sect),
           LLVMGetSectionAddress(sect), LLVMGetSectionSize(sect));

    LLVMMoveToNextSection(sect);
  }

  LLVMDisposeSectionIterator(sect);

  LLVMDisposeObjectFile(O);

  return 0;
}
Beispiel #2
0
SWIGEXPORT jlong JNICALL Java_org_jllvm_bindings_ObjectJNI_LLVMGetSectionSize(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jlong jresult = 0 ;
  LLVMSectionIteratorRef arg1 = (LLVMSectionIteratorRef) 0 ;
  uint64_t result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(LLVMSectionIteratorRef *)&jarg1; 
  result = LLVMGetSectionSize(arg1);
  {
    uint64_t * resultptr = (uint64_t *) malloc(sizeof(uint64_t));
    memmove(resultptr, &result, sizeof(uint64_t));
    *(uint64_t **)&jresult = resultptr;
  }
  return jresult;
}
Beispiel #3
0
LLVMPY_GetSectionSize(LLVMSectionIteratorRef SI)
{
  return LLVMGetSectionSize(SI);
}