From ad03eb635da06d362480a2bd4125283ef077885c Mon Sep 17 00:00:00 2001 From: Geoffrey Thomas Date: Tue, 21 Aug 2012 16:11:24 -0700 Subject: [PATCH] programming: Sync gccrun and disasm from my locker (oops) 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 | 7 ++++++- programming/gccrun | 9 ++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/programming/disasm b/programming/disasm index 0531dc5..ad014eb 100755 --- a/programming/disasm +++ b/programming/disasm @@ -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" diff --git a/programming/gccrun b/programming/gccrun index 55e6b68..5241931 100755 --- a/programming/gccrun +++ b/programming/gccrun @@ -18,6 +18,8 @@ cat > "$f/command.c" << EOF #include #include #include +#include +#include #include #include #include @@ -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 -- 2.44.0