美文网首页
iOS插庄 order

iOS插庄 order

作者: 紫色冰雨 | 来源:发表于2020-05-24 19:15 被阅读0次

二进制重排 

https://mp.weixin.qq.com/s/Drmmx5JtjG3UtTFksL6Q8Q

clang 官方文档

http://clang.llvm.org/docs/SanitizerCoverage.html

1 添加参数 

-fsanitize-coverage=trace-pc-guard

在编译时候 所有方法前面 插入 __sanitizer_cov_trace_pc_guard

oc 工程    只有func函数hook   -fsanitize-coverage=func,trace-pc-guard

swift 工程 的话    

-sanitize-coverage=func 

-sanitize=undefined

order生成后

生成  -fsanitize-coverage=func,trace-pc-guard 干掉

// trace-pc-guard-cb.cc

#include

#include<stdio.h>

#include

// This callback is inserted by the compiler as a module constructor

// into every DSO. 'start' and 'stop' correspond to the

// beginning and end of the section with the guards for the entire

// binary (executable or DSO). The callback will be called at least

// once per DSO and may be called multiple times with the same parameters.

extern "C" void __sanitizer_cov_trace_pc_guard_init(uint32_t *start,

                                                    uint32_t*stop) {

  static uint64_tN;  // Counter for the guards.

  if(start == stop || *start)return;  // Initialize only once.

  printf("INIT: %p %p\n", start, stop);

  for(uint32_t*x = start; x < stop; x++)

    *x = ++N;  // Guards should start from 1.

}

// This callback is inserted by the compiler on every edge in the

// control flow (some optimizations apply).

// Typically, the compiler will emit the code like this:

//    if(*guard)

//      __sanitizer_cov_trace_pc_guard(guard);

// But for large functions it will emit a simple call:

//    __sanitizer_cov_trace_pc_guard(guard);

extern "C" void __sanitizer_cov_trace_pc_guard(uint32_t *guard) {

  if (!*guard) return;  // Duplicate the guard check.

  // If you set *guard to 0 this code will not be called again for this edge.

  // Now you can get the PC and do whatever you want:

  //  store it somewhere or symbolize it and print right away.

  // The values of `*guard` are as you set them in

  // __sanitizer_cov_trace_pc_guard_init and so you can make them consecutive

  // and use them to dereference an array or a bit vector.

//  void *PC = __builtin_return_address(0);

  charPcDescr[1024];

  // This function is a part of the sanitizer run-time.

  // To use it, link with AddressSanitizer or other sanitizer.

//  __sanitizer_symbolize_pc(PC, "%p %F %L", PcDescr, sizeof(PcDescr));

  printf("guard: %p %x PC %s\n", guard, *guard, PcDescr);

}

相关文章

  • iOS插庄 order

    二进制重排 https://mp.weixin.qq.com/s/Drmmx5JtjG3UtTFksL6Q8Q c...

  • 记录一个低级错误

    order是mysql的关键字了,我用order做为表名,死活插不进去数据

  • 多次受阻万元大关,多看少做把握机会

    【今日骚话】 多次受阻万元大关,多看少做把握机会 要涨做多,狗庄插针,完了又涨又做多,狗庄又插针……说打脸就打脸,...

  • Xcode8和iOS10问题小结

    目录 回顾iOS8-SDK新特性iOS9-SDK新特性iOS10-SDK新特性 Xcode8新字体 Xcode8插...

  • mysql自定义排序

    场景 业务需要,优惠券列表要求按类型进行排序,但是,类型并不是顺序的,即order by是解决不了问题的 建表 插...

  • iOS动画插值

    插值 假如我们知道起点(start) 、终点(end)和持续的时间(duration), 假如匀速的话,很容易计算...

  • 启动优化3

    二进制重排 & clang插桩 注意:在iOS生产环境的app,在发生Page Fault进行重新加载时,iOS系...

  • 01 - LLVM Pass 实现 C函数 插桩

    01. llvm 在 iOS 插桩 网上我就搜到这一篇文章介绍使用 LLVM Pass 的方式,来实现函数插桩。 ...

  • 单身狗庄过节插针,高位做空钱包变鼓

    【今日骚话】 单身狗庄过节插针,高位做空钱包变鼓 首先得道个歉,昨天看涨结果给砸懵逼了,狗庄是个单身狗昨晚居然不是...

  • iOS 启动优化-生成 Order File

    启动优化-理论篇[https://www.jianshu.com/p/d724ebff917b]启动优化-二进制重...

网友评论

      本文标题:iOS插庄 order

      本文链接:https://www.haomeiwen.com/subject/zvljahtx.html