]> sipb.mit.edu Git - snippets/.git/commitdiff
programming: Sync gccrun and disasm from my locker (oops)
authorGeoffrey Thomas <geofft@mit.edu>
Tue, 21 Aug 2012 23:11:24 +0000 (16:11 -0700)
committerGeoffrey Thomas <geofft@mit.edu>
Tue, 21 Aug 2012 23:13:28 +0000 (16:13 -0700)
disasm gains a -o option to provide arguments to objdump. The argument
to -o gets interpreted by the shell, allowing multiple arguments to be
passed to objdump.

gccrun now passes parameters past the first to gcc, requiring you to
quote the code to be compiled. It also allows the wrapper to be
interpreted by the shell, allowing a wrapper with arguments.

programming/disasm
programming/gccrun

index 0531dc52110dbae41003c372343236047a79631a..ad014ebd3d017026a352f4b07e4211958c8c402e 100755 (executable)
@@ -1,6 +1,11 @@
 #!/bin/sh
 
+case "$1" in
+  -o) args="$2"
+      shift 2;;
+esac
+
 file=$(mktemp)
 echo "$*" | xxd -r -p > "$file"
-objdump -D -b binary -m i386 "$file" | tail -n +7
+objdump -D -b binary -m i386 $args "$file" | tail -n +7
 rm "$file"
index 55e6b680b23ac29dedf57b08346769f907379d21..52419311b470c43282c23e3aa336d57345cadc22 100755 (executable)
@@ -18,6 +18,8 @@ cat > "$f/command.c" << EOF
 #include <sys/mman.h>
 #include <sys/ptrace.h>
 #include <sys/syscall.h>
+#include <arpa/inet.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <stdio.h>
@@ -28,15 +30,16 @@ cat > "$f/command.c" << EOF
 int
 main(int argc, char *argv[], char *envp[])
 {
-       $@;
+       $1;
        return 0;
 }
 EOF
-if ! gcc -o "$f/command" "$f/command.c"; then
+shift
+if ! gcc -o "$f/command" "$f/command.c" $@; then
     exit 1
 fi
 if [ -n "$wrapper" ]; then
-    "$wrapper" "$f/command"
+    $wrapper "$f/command"
 else
     "$f/command"
 fi