Remove caching of the target machine and initialization of the
[oota-llvm.git] / tools / llvm-c-test / object.c
index c94e3af3b07368b9a10f54774c0017044d45c362..a5421d9066d5e62abbf7d76947361c873bdea65d 100644 (file)
@@ -20,6 +20,7 @@
 int object_list_sections(void) {
   LLVMMemoryBufferRef MB;
   LLVMObjectFileRef O;
+  LLVMSectionIteratorRef sect;
   char *msg = NULL;
 
   if (LLVMCreateMemoryBufferWithSTDIN(&MB, &msg)) {
@@ -33,7 +34,7 @@ int object_list_sections(void) {
     exit(1);
   }
 
-  LLVMSectionIteratorRef sect = LLVMGetSections(O);
+  sect = LLVMGetSections(O);
   while (!LLVMIsSectionIteratorAtEnd(O, sect)) {
     printf("'%s': @0x%08" PRIx64 " +%" PRIu64 "\n", LLVMGetSectionName(sect),
            LLVMGetSectionAddress(sect), LLVMGetSectionSize(sect));
@@ -51,6 +52,8 @@ int object_list_sections(void) {
 int object_list_symbols(void) {
   LLVMMemoryBufferRef MB;
   LLVMObjectFileRef O;
+  LLVMSectionIteratorRef sect;
+  LLVMSymbolIteratorRef sym;
   char *msg = NULL;
 
   if (LLVMCreateMemoryBufferWithSTDIN(&MB, &msg)) {
@@ -64,14 +67,13 @@ int object_list_symbols(void) {
     exit(1);
   }
 
-  LLVMSectionIteratorRef sect = LLVMGetSections(O);
-  LLVMSymbolIteratorRef sym = LLVMGetSymbols(O);
+  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),
+    printf("%s @0x%08" PRIx64 " +%" PRIu64 " (%s)\n", LLVMGetSymbolName(sym),
+           LLVMGetSymbolAddress(sym), LLVMGetSymbolSize(sym),
            LLVMGetSectionName(sect));
 
     LLVMMoveToNextSymbol(sym);