[llvm-commits] CVS: llvm/lib/Reoptimizer/Inst/mkexcl/mkexcl.cpp

Joel Stanley jstanley at cs.uiuc.edu
Sun May 4 14:55:01 PDT 2003


Changes in directory llvm/lib/Reoptimizer/Inst/mkexcl:

mkexcl.cpp updated: 1.2 -> 1.3

---
Log message:

Bugfixes to ELF reader, redesigned slightly to handle archive files properly.



---
Diffs of the changes:

Index: llvm/lib/Reoptimizer/Inst/mkexcl/mkexcl.cpp
diff -u llvm/lib/Reoptimizer/Inst/mkexcl/mkexcl.cpp:1.2 llvm/lib/Reoptimizer/Inst/mkexcl/mkexcl.cpp:1.3
--- llvm/lib/Reoptimizer/Inst/mkexcl/mkexcl.cpp:1.2	Wed Apr 30 17:42:36 2003
+++ llvm/lib/Reoptimizer/Inst/mkexcl/mkexcl.cpp	Sun May  4 15:01:30 2003
@@ -3,7 +3,7 @@
 //       date: Wed Apr 30 17:19:23 CDT 2003
 //     fileid: mkexcl.cpp
 //    purpose: Provides the 'mkexcl' command-line utility.  This utility reads the input
-//    ELF files and dumps a C++ file to stdout that, when compiled, populates a vector
+//    ELF files and dumps a C++ file to stdout that, when compiled, populates a set
 //    with the symbol names contained in the object files.  This command-line utility is
 //    intended to work as part of the build process for the Reoptimizer-based performance
 //    instrumentation binary editing library.
@@ -11,8 +11,77 @@
 #include <iostream>
 #include "llvm/Reoptimizer/Inst/ElfReader.h"
 
+#if 0
+#include <ar.h> // test
+#include <stdio.h> // test
+#include <sys/types.h> // test
+#include <sys/stat.h> //test 
+#include <fcntl.h>// test
+#include <unistd.h> //test
+#endif
+
+using std::cerr;
+using std::endl;
+
+// SparcV9 word width is 4 bytes
+#define INST_WIDTH 4
+
 int main(int argc, char** argv) 
 {
-    std::cerr << "yeah" << std::endl;
+    if(argc > 1) {
+        std::string funcName;
+        std::pair<uint64_t, uint64_t> range;
+
+        for(int i = 1; i < argc; ++i) {
+            cerr << argv[i] << " contains the following symbols:" << endl;
+
+            ElfReader reader(argv[i]);
+            while(reader.findNextSymbol(funcName, range, INST_WIDTH)) {
+                cerr << funcName << endl;
+            }
+        }
+    }
+    else 
+        cerr << "Usage: " << argv[0] << " [ELF Object File]..." << endl;
+    
     return 0;
 }
+
+#if 0
+// Test -- assume that this is an archive file
+int fd = open(argv[i], O_RDONLY);
+assert(fd);
+
+char magicString[SARMAG];
+unsigned rdcnt = read(fd, magicString, SARMAG);
+assert(rdcnt == SARMAG);
+
+cerr << "magic string is " << magicString << endl;
+
+struct ar_hdr arhdr;
+rdcnt = read(fd, &arhdr, sizeof(struct ar_hdr));
+assert(rdcnt == sizeof(struct ar_hdr));
+
+cerr << "ar_name is: " << arhdr.ar_name << endl << endl;
+cerr << "===" << endl;
+cerr << "ar_size is: " << arhdr.ar_size << endl << endl;
+            
+// End test
+
+#endif
+
+
+#if 0
+
+/* Read until the connection goes away or we get the amount of data we want */
+while(byte_count < msg_size && (n = read(socket_fd, buffy, BUF_SIZE - 1)) > 0) 
+{
+
+    byte_count += n;
+
+    buffy[n] = '\0';
+
+    fputs(buffy, stdout);
+    
+}
+#endif





More information about the llvm-commits mailing list