Skip to content

Commit

Permalink
os/mac: Allow MachO.dynamically_linked_libraries to be filtered by dy…
Browse files Browse the repository at this point in the history
…lib type.

This allows us to filter out weak linkages during audits, preventing
a false error from occurring when the dylib cannot be found.
  • Loading branch information
woodruffw committed Nov 9, 2016
1 parent 7e09379 commit 032ed07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 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
6 changes: 4 additions & 2 deletions Library/Homebrew/os/mac/mach.rb
Original file line number Diff line number Diff line change
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

0 comments on commit 032ed07

Please sign in to comment.