Skip to content

Instantly share code, notes, and snippets.

View davidbalbert's full-sized avatar

David Albert davidbalbert

View GitHub Profile
@davidbalbert
davidbalbert / loadcommands.patch
Created December 3, 2012 19:58
GDB 7.5.1 OS X 10.8 Mach-O fixes
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 29ebba4..e44cf6d 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -3666,6 +3666,48 @@ bfd_mach_o_read_encryption_info (bfd *abfd, bfd_mach_o_load_command *command)
return TRUE;
}
+static bfd_boolean
+bfd_mach_o_read_main (bfd *abfd, bfd_mach_o_load_command *command)
@davidbalbert
davidbalbert / output
Created November 23, 2012 20:07
GDB 7.5 branch on OS X 10.8.2 load command errors
$ gdb/gdb /tmp/gdbtest/hello
GNU gdb (GDB) 7.5.0.20121123-cvs
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin12.2.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
@davidbalbert
davidbalbert / after_patch
Created November 20, 2012 19:09
BFD test results
$ make check
make check-recursive
Making check in doc
make[4]: Nothing to be done for `check'.
Making check in po
file=`echo ../../../bfd/po/da | sed 's,.*/,,'`.gmo \
&& rm -f $file && PATH=../src:$PATH : -o $file ../../../bfd/po/da.po
file=`echo ../../../bfd/po/es | sed 's,.*/,,'`.gmo \
&& rm -f $file && PATH=../src:$PATH : -o $file ../../../bfd/po/es.po
file=`echo ../../../bfd/po/fi | sed 's,.*/,,'`.gmo \
@davidbalbert
davidbalbert / README.md
Created September 12, 2012 16:41
Clang code generation

When I compile hello.c with: clang -g -O0 hello.c -o hello, and disassemble it in GDB, I get the contents of hello.s.

The line that confuses me is . It seems that when optimizations are off, clang saves unused return values on the stack. is saving the return value of printf even though hello.c doesn't do anything with it at all. I assume there's a reason for this. Why does it happen?

ganymede:~/Development/ruby [trunk]$ brew link --verbose apple-gcc42
Linking /usr/local/Cellar/apple-gcc42/4.2.1-5666.3... ln -s ../Cellar/apple-gcc42/4.2.1-5666.3/bin/i686-apple-darwin11-gfortran-4.2.1 i686-apple-darwin11-gfortran-4.2.1
ln -s ../Cellar/apple-gcc42/4.2.1-5666.3/bin/i686-apple-darwin11-gcc-4.2.1 i686-apple-darwin11-gcc-4.2.1
ln -s ../Cellar/apple-gcc42/4.2.1-5666.3/bin/i686-apple-darwin11-g++-4.2.1 i686-apple-darwin11-g++-4.2.1
ln -s ../Cellar/apple-gcc42/4.2.1-5666.3/bin/i686-apple-darwin11-cpp-4.2.1 i686-apple-darwin11-cpp-4.2.1
ln -s ../Cellar/apple-gcc42/4.2.1-5666.3/bin/gfortran-4.2 gfortran-4.2
ln -s ../Cellar/apple-gcc42/4.2.1-5666.3/bin/gfortran gfortran
ln -s ../Cellar/apple-gcc42/4.2.1-5666.3/bin/gcov-4.2 gcov-4.2
ln -s ../Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 gcc-4.2
ln -s ../Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2 g++-4.2
class Polygon
@@sides = nil
def self.sides
@@sides
end
def self.count
@@count
end
tell application "Terminal"
activate
tell application "System Events" to keystroke "n" using command down
end tell
#!/bin/sh
make clean
make distclean
rm -rf ./build
set -e
autoconf || exit 125
(./configure --prefix=`pwd`/build/ && make && make install) || exit 125
@davidbalbert
davidbalbert / bug.rb
Created June 22, 2012 16:29
Ruby inner method visibility bug
def foo
def bar
end
end
foo
p Object.instance_methods(false)
p Object.private_instance_methods(false)
require 'hello'
require 'goodbye'