diff options
| author | Jack Nagel | 2014-10-10 19:21:46 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-10-10 19:22:11 -0500 |
| commit | 01397d17f78e64a4869c1657819f5b1d061ee2ce (patch) | |
| tree | c0a7cdd911712875eb314bf95c1bbcd20c283ae7 /Library | |
| parent | 8cc5aabfcf2a5ae8413ec7222b971c18daa69697 (diff) | |
| download | brew-01397d17f78e64a4869c1657819f5b1d061ee2ce.tar.bz2 | |
Don't raise in mach_data so the debugger doesn't catch it
Closes Homebrew/homebrew#33088.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/mach.rb | 85 |
1 files changed, 43 insertions, 42 deletions
diff --git a/Library/Homebrew/mach.rb b/Library/Homebrew/mach.rb index 8da667acd..de38d296b 100644 --- a/Library/Homebrew/mach.rb +++ b/Library/Homebrew/mach.rb @@ -53,51 +53,52 @@ module MachO # /usr/include/mach-o/fat.h def mach_data - @mach_data ||= begin - offsets = [] - mach_data = [] - - header = read(8).unpack("N2") - case header[0] - when 0xcafebabe # universal - header[1].times do |i| - # header[1] is the number of struct fat_arch in the file. - # Each struct fat_arch is 20 bytes, and the 'offset' member - # begins 8 bytes into the struct, with an additional 8 byte - # offset due to the struct fat_header at the beginning of - # the file. - offsets << read(4, 20*i + 16).unpack("N")[0] - end - when 0xcefaedfe, 0xcffaedfe, 0xfeedface, 0xfeedfacf # Single arch - offsets << 0 - when 0x7f454c46 # ELF - mach_data << { :arch => :x86_64, :type => :executable } - else - raise "Not a Mach-O binary." + @mach_data ||= _mach_data + end + + def _mach_data + offsets = [] + mach_data = [] + + header = read(8).unpack("N2") + case header[0] + when 0xcafebabe # universal + header[1].times do |i| + # header[1] is the number of struct fat_arch in the file. + # Each struct fat_arch is 20 bytes, and the 'offset' member + # begins 8 bytes into the struct, with an additional 8 byte + # offset due to the struct fat_header at the beginning of + # the file. + offsets << read(4, 20*i + 16).unpack("N")[0] end + when 0xcefaedfe, 0xcffaedfe, 0xfeedface, 0xfeedfacf # Single arch + offsets << 0 + when 0x7f454c46 # ELF + mach_data << { :arch => :x86_64, :type => :executable } + else + return [] + end - offsets.each do |offset| - arch = case read(8, offset).unpack("N2") - when [0xcefaedfe, 0x07000000] then :i386 - when [0xcffaedfe, 0x07000001] then :x86_64 - when [0xfeedface, 0x00000012] then :ppc7400 - when [0xfeedfacf, 0x01000012] then :ppc64 - else :dunno - end - - type = case read(4, offset + 12).unpack("N")[0] - when 0x00000002, 0x02000000 then :executable - when 0x00000006, 0x06000000 then :dylib - when 0x00000008, 0x08000000 then :bundle - else :dunno - end - - mach_data << { :arch => arch, :type => type } - end - mach_data - rescue - [] + offsets.each do |offset| + arch = case read(8, offset).unpack("N2") + when [0xcefaedfe, 0x07000000] then :i386 + when [0xcffaedfe, 0x07000001] then :x86_64 + when [0xfeedface, 0x00000012] then :ppc7400 + when [0xfeedfacf, 0x01000012] then :ppc64 + else :dunno + end + + type = case read(4, offset + 12).unpack("N")[0] + when 0x00000002, 0x02000000 then :executable + when 0x00000006, 0x06000000 then :dylib + when 0x00000008, 0x08000000 then :bundle + else :dunno + end + + mach_data << { :arch => arch, :type => type } end + + mach_data end def archs |
