Skip to content

Commit

Permalink
Merge pull request Homebrew#1460 from woodruffw/audit-ignore-weak-lin…
Browse files Browse the repository at this point in the history
…kage

os/mac: MachO.dynamically_linked_libraries filtering.
  • Loading branch information
MikeMcQuaid authored Nov 9, 2016
2 parents a7dc9e1 + 126c15d commit 1fb7d0f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Library/Homebrew/os/mac/linkage_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def check_dylibs
@keg.find do |file|
next if file.symlink? || file.directory?
next unless file.dylib? || file.mach_o_executable? || file.mach_o_bundle?
file.dynamically_linked_libraries.each do |dylib|

# weakly loaded dylibs may not actually exist on disk, so skip them
# when checking for broken linkage
file.dynamically_linked_libraries(except: :LC_LOAD_WEAK_DYLIB).each do |dylib|
@reverse_links[dylib] << file
if dylib.start_with? "@"
@variable_dylibs << dylib
Expand Down
8 changes: 5 additions & 3 deletions Library/Homebrew/os/mac/mach.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "vendor/macho/macho"
require "os/mac/architecture_list"

module MachO
module MachOShim
# @private
def macho
@macho ||= begin
Expand Down Expand Up @@ -51,8 +51,10 @@ def mach_data
end
end

def dynamically_linked_libraries
macho.linked_dylibs
def dynamically_linked_libraries(except: :none)
lcs = macho.dylib_load_commands.reject { |lc| lc.type == except }

lcs.map(&:name).map(&:to_s)
end

def dylib_id
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/os/mac/pathname.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "os/mac/mach"

class Pathname
include MachO
include MachOShim
end

0 comments on commit 1fb7d0f

Please sign in to comment.