os/mac: Allow MachO.dynamically_linked_libraries to be filtered by dylib type.

This allows us to filter out weak linkages during audits, preventing
a false error from occurring when the dylib cannot be found.
This commit is contained in:
William Woodruff 2016-11-07 19:37:52 -05:00
parent 7e09379669
commit 032ed07bce
No known key found for this signature in database
GPG Key ID: 85AE00C504833B3C
2 changed files with 8 additions and 3 deletions

View File

@ -23,7 +23,10 @@ class LinkageChecker
@keg.find do |file| @keg.find do |file|
next if file.symlink? || file.directory? next if file.symlink? || file.directory?
next unless file.dylib? || file.mach_o_executable? || file.mach_o_bundle? 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 @reverse_links[dylib] << file
if dylib.start_with? "@" if dylib.start_with? "@"
@variable_dylibs << dylib @variable_dylibs << dylib

View File

@ -51,8 +51,10 @@ module MachO
end end
end end
def dynamically_linked_libraries def dynamically_linked_libraries(except: :none)
macho.linked_dylibs lcs = macho.dylib_load_commands.reject { |lc| lc.type == except }
lcs.map(&:name).map(&:to_s)
end end
def dylib_id def dylib_id