Skip to content

二进制重排,Clang 插桩获取 APP 启动调用的函数符号

License

Notifications You must be signed in to change notification settings

huipengo/ClangTrace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClangTrace

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Build Settings:

在App 的 Target - Build Settings - Other C Flags Debug 增加 -fsanitize-coverage=func,trace-pc-guard

OC - Swift 混编,则在 Other Swift Flags Debug 增加 -sanitize-coverage=func-sanitize=undefined


Cocoapods 管理代码,用的是静态库的方式的话,那么可以通过hook来修改所有的pod库的编译选项;将以下内容拷贝到你的Podfile文件下面,执行 pod install --no-repo-update

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      macho_type = config.build_settings['MACH_O_TYPE']
      #if macho_type == 'staticlib'
        # 将依赖的pod项目的Other C Flags加上’-fsanitize-coverage=func,trace-pc-guard‘选项
        config.build_settings['OTHER_CFLAGS'] ||= ['$(inherited)', '-fsanitize-coverage=func,trace-pc-guard']
        config.build_settings['OTHER_SWIFT_FLAGS'] ||= ['$(inherited)', '-fsanitize-coverage=func,trace-pc-guard']
      #end
    end
  end
end

Requirements

iOS 9.0

Installation

ClangTrace is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ClangTrace', :git => 'https://github.com/huipengo/ClangTrace.git', :configurations => ['Debug']

会在 App 的沙盒的 tmp 目录下生成 trace.order 文件

Xcode 的连接器 ld 默认忽略 order file不存在的方法Other Linker Flags: Debug 添加 -order_file_statistics,会以 warning 的形式把这些没找到的符号打印在日志里

Author

huipeng, penghui_only@163.com

License

ClangTrace is available under the MIT license. See the LICENSE file for more info.

简书

iOS App启动优化 - 二进制重排

About

二进制重排,Clang 插桩获取 APP 启动调用的函数符号

Resources

License

Stars

Watchers

Forks

Packages

No packages published