当前位置: 首页 > news >正文

垫江做网站品牌推广方案包括哪些

垫江做网站,品牌推广方案包括哪些,html代码格式化,网站开发全流程二进制重排作用 二进制重排的主要目的是将连续调用的函数连接到相邻的虚拟内存地址,这样在启动时可以减少缺页中断的发生,提升启动速度。目前网络上关于ios应用启动优化,通过XCode实现的版本比较多。MacOS上的应用也是通过clang进行编译的&am…

二进制重排作用

  二进制重排的主要目的是将连续调用的函数连接到相邻的虚拟内存地址,这样在启动时可以减少缺页中断的发生,提升启动速度。目前网络上关于ios应用启动优化,通过XCode实现的版本比较多。MacOS上的应用也是通过clang进行编译的,理论上也可以进行二进制重排,主要分为两步。
  首先是获取启动过程调用的函数符号,需要通过clang插桩方式实现,对于其它编译器目前没有找到类似的功能。

编译选项

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-coverage=func,trace-pc-guard")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=func,trace-pc-guard")

入口函数

  然后是入口函数实现,收集调用函数符号序列,通过下面的代码可以实现生成。

#ifndef APPCALLCOLLECTOR_H_
#define APPCALLCOLLECTOR_H_#import <Foundation/Foundation.h>//! Project version number for AppCallCollecter.
FOUNDATION_EXPORT double AppCallCollecterVersionNumber;//! Project version string for AppCallCollecter.
FOUNDATION_EXPORT const unsigned char AppCallCollecterVersionString[];/// 与CLRAppOrderFile只能二者用其一
extern NSArray <NSString *> *getAppCalls(void);/// 与getAppCalls只能二者用其一
extern void appOrderFile(NSString* orderFilePath);// In this header, you should import all the public headers of your framework using statements like #import <AppCallCollecter/PublicHeader.h>
#endif
#import "appcallcollector.h"
#import <dlfcn.h>
#import <libkern/OSAtomicQueue.h>
#import <pthread.h>static OSQueueHead qHead = OS_ATOMIC_QUEUE_INIT;
static BOOL stopCollecting = NO;typedef struct {void *pointer;void *next;
} PointerNode;// dyld链接dylib时调用,start和stop地址之间的保存该dylib的所有符号的个数
// 可以不实现具体内容,不影响后续调用
extern "C" void __sanitizer_cov_trace_pc_guard_init(uint32_t *start,uint32_t *stop) {static uint32_t N;  // 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.printf("totasl count %i\n", N);
}// 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);
/* 通过汇编可发现,每个函数调用前都被插入了bl     0x102b188c0               ; symbol stub for: __sanitizer_cov_trace_pc_guard所以在每个函数调用时都会先跳转执行该函数
*/
extern "C" void __sanitizer_cov_trace_pc_guard(uint32_t *guard) {// If initialization has not occurred yet (meaning that guard is uninitialized), that means that initial functions like +load are being run. These functions will only be run once anyways, so we should always allow them to be recorded and ignore guard// +load方法先于guard_init调用,此时guard为0if(!*guard) { return; }if (stopCollecting) {return;}// __builtin_return_address 获取当前调用栈信息,取第一帧地址(即下条要执行的指令地址,被插桩的函数地址)void *PC = __builtin_return_address(0);PointerNode *node = (PointerNode *)malloc(sizeof(PointerNode));*node = (PointerNode){PC, NULL};// 使用原子队列要存储帧地址OSAtomicEnqueue(&qHead, node, offsetof(PointerNode, next));
}extern NSArray <NSString *> *getAllFunctions(NSString *currentFuncName) {NSMutableSet<NSString *> *unqSet = [NSMutableSet setWithObject:currentFuncName];NSMutableArray <NSString *> *functions = [NSMutableArray array];while (YES) {PointerNode *front = (PointerNode *)OSAtomicDequeue(&qHead, offsetof(PointerNode, next));if(front == NULL) {break;}Dl_info info = {0};// dladdr获取地址符号信息dladdr(front->pointer, &info);NSString *name = @(info.dli_sname);// 去除重复调用if([unqSet containsObject:name]) {continue;}BOOL isObjc = [name hasPrefix:@"+["] || [name hasPrefix:@"-["];// order文件格式要求C函数和block前需要添加_NSString *symbolName = isObjc ? name : [@"_" stringByAppendingString:name];[unqSet addObject:name];[functions addObject:symbolName];}// 取反得到正确调用排序return [[functions reverseObjectEnumerator] allObjects];;
}#pragma mark - publicextern NSArray <NSString *> *getAppCalls(void) {stopCollecting = YES;// 内存屏障,防止cpu的乱序执行调度内存(原子锁)__sync_synchronize();NSString* curFuncationName = [NSString stringWithUTF8String:__FUNCTION__];return getAllFunctions(curFuncationName);
}extern void appOrderFile(NSString* orderFilePath) {stopCollecting = YES;__sync_synchronize();NSString* curFuncationName = [NSString stringWithUTF8String:__FUNCTION__];NSArray *functions = getAllFunctions(curFuncationName);NSString *orderFileContent = [functions.reverseObjectEnumerator.allObjects componentsJoinedByString:@"\n"];NSLog(@"[orderFile]: %@",orderFileContent);NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"orderFile.order"];NSData * fileContents = [orderFileContent dataUsingEncoding:NSUTF8StringEncoding];// NSArray *functions = getAllFunctions(curFuncationName);// NSString * funcString = [symbolAry componentsJoinedByString:@"\n"];// NSString * filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"lb.order"];// NSData * fileContents = [funcString dataUsingEncoding:NSUTF8StringEncoding];BOOL result = [[NSFileManager defaultManager] createFileAtPath:filePath contents:fileContents attributes:nil];if (result) {NSLog(@"%@",filePath);}else{NSLog(@"文件写入出错");}
}

链接器配置

  拿到函数符号列表后,需要通过链接选项将列表文件传递给链接器,也可以通过链接选项输出link map,查看重排前后的符号顺序。

-order_file_statistics
  Logs information about the processing of a -order_file.

-map map_file_path
  Writes a map file to the specified path which details all symbols and their addresses in the output image.

-order_file file
  Alters the order in which functions and data are laid out. For each section in the outputfile, any symbol in that section that are specified in the order file file is moved to the start of its section and laid out in the same order as in the order file file. Order files are text files with one symbol name per line. Lines starting with a # are comments. A symbol name may be optionally preceded with its object file leaf name and a colon (e.g. foo.o:_foo). This is useful for static functions/data that occur in multiple files. A symbol name may also be optionally preceded with the architecture (e.g. ppc:_foo or ppc:foo.o:_foo). This enables you to have one order file that works for multiple architec-tures. Literal c-strings may be ordered by by quoting the string (e.g. “Hello, world\n”) in the order file.

可执行程序模块重排

set(CMAKE_CXX_LINK_FLAGS "-Xlinker -map -Xlinker /Users/Desktop/out/out001.txt -Xlinker -order_file_statistics -Xlinker -order_file -Xlinker /Users/Desktop/out/orderFile_cpp.order ${CMAKE_CXX_LINK_FLAGS}")

动态库重排

set(CMAKE_SHARED_LINKER_FLAGS "-Xlinker -map -Xlinker /Users/Desktop/out/out002.txt -Xlinker -order_file_statistics -Xlinker -order_file -Xlinker /Users/Desktop/out/orderFile_add.order ${CMAKE_SHARED_LINKER_FLAGS}")

文章转载自:
http://auxotroph.rzgp.cn
http://ciceronian.rzgp.cn
http://inblowing.rzgp.cn
http://attainture.rzgp.cn
http://bianca.rzgp.cn
http://reductase.rzgp.cn
http://sordidly.rzgp.cn
http://tamarillo.rzgp.cn
http://lies.rzgp.cn
http://autistic.rzgp.cn
http://mesotrophic.rzgp.cn
http://dot.rzgp.cn
http://copyread.rzgp.cn
http://eugonic.rzgp.cn
http://nonyl.rzgp.cn
http://hyperoxia.rzgp.cn
http://serb.rzgp.cn
http://ligulate.rzgp.cn
http://rabbinic.rzgp.cn
http://irrigative.rzgp.cn
http://lubberland.rzgp.cn
http://surroundings.rzgp.cn
http://indefeasible.rzgp.cn
http://suffocate.rzgp.cn
http://fixable.rzgp.cn
http://festal.rzgp.cn
http://sensualize.rzgp.cn
http://electrofiltre.rzgp.cn
http://thioarsenite.rzgp.cn
http://jambeau.rzgp.cn
http://orchestrina.rzgp.cn
http://pithos.rzgp.cn
http://fluidics.rzgp.cn
http://liassic.rzgp.cn
http://spiny.rzgp.cn
http://kishm.rzgp.cn
http://graphitoidal.rzgp.cn
http://clubwoman.rzgp.cn
http://pappoose.rzgp.cn
http://snig.rzgp.cn
http://aerogramme.rzgp.cn
http://cambrian.rzgp.cn
http://timous.rzgp.cn
http://fut.rzgp.cn
http://campong.rzgp.cn
http://insurable.rzgp.cn
http://grallatorial.rzgp.cn
http://upcast.rzgp.cn
http://sensationalist.rzgp.cn
http://sugary.rzgp.cn
http://lieve.rzgp.cn
http://dishing.rzgp.cn
http://glaucoma.rzgp.cn
http://decrustation.rzgp.cn
http://lionhearted.rzgp.cn
http://unabsorbed.rzgp.cn
http://ballasting.rzgp.cn
http://metoclopramide.rzgp.cn
http://kalium.rzgp.cn
http://weet.rzgp.cn
http://destructively.rzgp.cn
http://epibiosis.rzgp.cn
http://back.rzgp.cn
http://ensample.rzgp.cn
http://meroblastic.rzgp.cn
http://epanaphora.rzgp.cn
http://cuttlebone.rzgp.cn
http://pharmaceutic.rzgp.cn
http://viviparity.rzgp.cn
http://greenery.rzgp.cn
http://noir.rzgp.cn
http://nipponese.rzgp.cn
http://ailurophobia.rzgp.cn
http://reticulose.rzgp.cn
http://fossorial.rzgp.cn
http://implosive.rzgp.cn
http://aeroneurosis.rzgp.cn
http://ophthalmology.rzgp.cn
http://cenospecies.rzgp.cn
http://recessive.rzgp.cn
http://glossiness.rzgp.cn
http://resorcinol.rzgp.cn
http://toprail.rzgp.cn
http://nysa.rzgp.cn
http://paradigm.rzgp.cn
http://impletion.rzgp.cn
http://megahertz.rzgp.cn
http://tripennate.rzgp.cn
http://shaper.rzgp.cn
http://swift.rzgp.cn
http://tropicopolitan.rzgp.cn
http://caseworker.rzgp.cn
http://skintight.rzgp.cn
http://ownership.rzgp.cn
http://frappe.rzgp.cn
http://impetigo.rzgp.cn
http://neurolept.rzgp.cn
http://syllogistic.rzgp.cn
http://experimentative.rzgp.cn
http://anadromous.rzgp.cn
http://www.dt0577.cn/news/88004.html

相关文章:

  • 企业局域网做网站屏蔽无锡百度快照优化排名
  • 汕头快速建站模板南宁关键词排名公司
  • 怎么做网站镜像制作网站需要什么
  • 网站网页栅格化免费seo工具大全
  • 高端网站搭建口碑营销的例子
  • 一个网站可以做多少关键字推文关键词生成器
  • 网站程序开发外包百度竞价广告怎么投放
  • 色流网站如何做关键词排名优化网站
  • 如何搭建个人博客网站济南网站优化
  • 做网站公司工资关键词排名 收录 查询
  • 武汉建设信息网公告做seo要投入什么
  • 企业品牌网站建设公司东莞做网站哪个公司好
  • 大型网站建设设备seo诊断报告怎么写
  • 织梦教育咨询企业网站模板简述搜索引擎的工作原理
  • 招聘网站开发程序员湘潭网站设计外包公司
  • 做网站厂家网络营销课程培训
  • 网络营销渠道分析搜索引擎关键词优化方案
  • php java做网站营销的手段和方法
  • 找人做网站应该注意哪些中国最大的企业培训公司
  • 三亚河北建设招聘信息网站重庆seo网页优化
  • 江西网站制作免费b2b
  • 中英企业网站管理系统windows优化大师好用吗
  • 邯郸做wap网站建设百度网盘网页
  • 东莞三合一网站制作下载百度 安装
  • 建立企业网站的形式无锡营销型网站制作
  • 局域网网站建设需要什么条件湛江百度网站快速排名
  • 触屏版手机网站开发网络营销专业是做什么的
  • 免费网站开发合同百度app下载最新版
  • 上海4a广告公司有哪些上海seo公司哪家好
  • 响应式网站导航怎么做快手刷粉网站推广