BITCODE DEMYSTIFIED

卷六十一 · 江陵柄政(简体全.docx 立即下载

A few months ago Apple announced a ‘new feature,’ called ‘Bitcode.’ In this article, I will try to answer the questions like what is Bitcode, what problems it aims to solve, what issues it introduces and so on.

What is Bitcode?

To answer this question let’s look at what compilers do for us. Here is a brief overview of compilation process:

  • Lexer: takes source code as an input and translates it into a stream of tokens;
  • Parser: takes stream of tokens as an input and translates it into an AST;
  • Semantic Analysis: takes an AST as an input, checks if a program is correct (method called with correct amount of parameters, method called on object actually exists and non-private, etc.), fills in ‘missing types’ (e.g.: let x = y, x has type of y) and passes AST to the next phase;
  • Code Generation: takes an AST as an input and emits some high-level IR (intermediate representation);
  • Optimization: takes IR, makes optimizations and emits IR which is potentially faster and/or smaller;
  • AsmPrinter: another code generation phase, it takes IR and emits assembly for particular CPU;
  • Assembler: takes assembly and converts it into an object code (stream of 0s and 1s);
  • Linker: usually programs refer to already compiled routines from other programs (e.g.: printf) to avoid recompilation of the same code over and over. Until this phase these links do not have correct addresses, they are just placeholders. Linker’s job is to resolve those placeholders so that they point to the correct addresses of their corresponding routines.

You can find more details here: The Compiler.

In the modern world these phases are split into two parts: compiler frontend (lexer, parser, semantic analysis, code generation) and compiler backend (optimization, asm printer, assembler, linker). This separation makes much sense for both language designers and hardware manufacturers. If you want to create a new programming language you ‘just’ need to implement a frontend, and you get all available optimizations and support of different CPUs for free. On the other hand, if you created a new chip, you ‘just’ need to extend the backend and you get all the available languages (frontends) support for your CPU.

Below you can see a picture that illustrates compilation process using Clang and LLVM:

This picture clearly demonstrates how communication between frontend and backend is done using IR, LLVM has it is own format, that can be encoded using LLVM bitstream file format - Bitcode.

Just to recall it explicitly - Bitcode is a bitstream representation of LLVM IR.

What problems Apple’s Bitcode aims to solve?

Again, we need to dive a bit deeper and look at how an OS runs programs. This description is not precise and is given just to illustrate the process. For more details I can recommend reading this article: How OS X Executes Applications.

OS X and iOS can run on different CPUs (i386, x86_64, arm, arm64, etc.), if you want to run a program on any OS X/iOS setup, then the program should contain object code for each platform. Here is how a binary might look like:

When you run a program, OS reads the ‘Table Of Contents’ and looks for a slice corresponding to the OS CPU. For instance, if you run operating system on x86_64, then OS will load object code for x86_64 into a memory and run the program.

What’s happening with other slices? Nothing, they just waste your disk space.

This is the problem Apple wants to solve: currently, all the apps on the AppStore contain object code for arm and arm64 CPUs. Moreover, third-party proprietary libraries or frameworks contain object code for i386, x86_64, arm and arm64, so you can use them to test the app on a device or simulator. (Can you imagine how many copies of Google Analytics for i386 you have in your pocket?)

UPD: I do not know why, but I was sure that final executable contains these slices as well (i386, x86_64, etc.), but it seems they are stripped during the build phase.

Apple did not give us that many details about how the Bitcode and App Thinning works, so let me assume how it may look:

When you submit an app (including Bitcode) Apple’s ‘BlackBox’ recompiles it for each supported platform and drops any ‘useless’ object code, so AppStore has a copy of the app for each CPU. When an end user wants to install the app - she installs the only version for the particular processor, without any unused stuff.

Bitcode might save up to 50% of disk space per program.

UPD: Of course, I do not take in count resources, it is just about binary itself. For instance, an app I am working on currently has size ~40 megabytes (including assets, xibs. fonts), a size of a binary itself is ~16 megabytes. I checked sizes of each slice: ~7MB for armv7 and 9MB for arm64, if we crop just one of them, it will decrease the size of the app by ~20%.

What problems do Bitcode introduce?

The idea of Bitcode and recompiling for each platform looks really great, and it is a huge improvement, though it has downsides as well: the biggest one is security.

To get the benefits of Bitcode, you should submit your app including Bitcode (surprisingly). If you use some proprietary third-party library, then it also should contain Bitcode, hence as a maintainer of a proprietary library, you should distribute the library with Bitcode.

To recall: Bitcode is just another form of LLVM IR.

LLVM IR

Let’s write some code to see LLVM IR in action.

// main.c
extern int printf(const char *fmt, ...);

int main() {
  printf("Hello World\n");
  return 0;
}

Run the following:

clang -S -emit-llvm main.c

And you’ll have main.ll containing IR:

@.str = private unnamed_addr constant [13 x i8] c"Hello World\0A\00", align 1

; Function Attrs: nounwind ssp uwtable
define i32 @main() #0 {
  %1 = alloca i32, align 4
  store i32 0, i32* %1
  %2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([13 x i8]* @.str, i32 0, i32 0))
  ret i32 0
}

declare i32 @printf(i8*, ...) #1

What can we see here? It is a bit more verbose than original C code, but it is still much more readable than assembler. Malefactors will be much happier to work with this representation, than with disassembled version of a binary (and they do not even have to pay for tools such Hopper or IDA).

How could malefactor get the IR?

iOS and OS X executables have their own format - Mach-O (read Parsing Mach-O files for more details). Mach-O file contains several segments such as Read-Only Data, Code, Symbol Table, etc. One of those sections contain xar archive with Bitcode:

It is really easy to retrieve it automatically, here I wrote a simple C program that does just that: bitcode_retriever. The workflow is pretty straightforward. Let’s assume that some_binary is a Mach-O file that contains object code for two CPUs (arm and x86_64), and each object code is built using two source files:

$ bitcode_retriever some_binary
arm.xar
x86_64.xar
$ xar -xvf arm.xar
1
2
$ llvm-dis 1 # outputs 1.ll
$ llvm-dis 2 # outputs 2.ll

Bitcode does not store any information about original filenames but uses numbers instead (1, 2, 3, etc.). Also, probably you do not have llvm-disinstalled/built on your machine, but you can easily obtain it, see this article for more details: Getting Started with Clang/LLVM on OS X.

Another potential issue (can’t confirm it) - Bitcode thingie works only for iOS 9, so if you submit your app to the AppStore and it includes Bitcode, then malefactor can get the whole IR from your app using iOS 7⁄8 and jailbroken device.

I know only one way to secure the IR - obfuscation. This task is not trivial itself, and it requires even much more efforts if you want to introduce this phase into your Xcode-Driven development flow.

Summary

  • Bitcode is a bitstream file format for LLVM IR
  • one of its goals is to decrease a size of an app by eliminating unused object code
  • malefactor can obtain your app or library, retrieve the IR from it and steal your ‘secret algorithm.’
战国BC298年世界历史地图矢量文件SHP格式.zip 本资源为《战国BC298年世界历史地图矢量文件SHP格式》压缩包,文件大小约 2.29 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。 立即下载

相关推荐

open-code-review · 自动化代码评审工具

Open Code Review 是一款 AI 驱动的代码审查 CLI 工具。它脱胎于阿里巴巴集团内部的官方 AI 代码审查助手——过去两年间,它已服务于数万名开发者,发现了数百万个代码缺陷。经过大规模生产环境的充分验证后,我们将其孵化为开源项目回馈社区。只需配置一个模型端点即可上手使用。 它读取 Git diff,通过具备工具调用能力的 Agent 将变更文件发送至可配置的 LLM,生成具有行级精度的结构化审查评论。该 Agent 可以读取完整文件内容、搜索代码库、检查其他变更文件以获取上下文,从而产出深度审查——而非仅停留在 diff 表面的浅层反馈。除了 diff 审查之外,ocr scan 还能对整个文件进行审查,适用于审计不熟悉的代码库或没有有意义 diff 的目录。

关于bitcode, 知道这些就够了

转载http://www.cocoachina.com/ios/20190108/26055.html 原文链接http://xelz.info/blog/2018/11/24/all-you-need-to-know-about-bitcode/ 0x00 前言 苹果在WWDC 2015大会上引入了bitcode,随后在Xcode7中添加了在二进制中嵌入bitcode(Ena...

chqj_163的专栏 9266

春秋BC537年世界历史地图矢量文件SHP格式.zip

本资源为《春秋BC537年世界历史地图矢量文件SHP格式》压缩包,文件大小约 1.86 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

仿真抓取EVCD文件的demo工程

仿真抓取EVCD文件的demo工程

春秋BC524年世界历史地图矢量文件SHP格式.zip

本资源为《春秋BC524年世界历史地图矢量文件SHP格式》压缩包,文件大小约 1.84 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

春秋BC765年世界历史地图矢量文件SHP格式.zip

本资源为《春秋BC765年世界历史地图矢量文件SHP格式》压缩包,文件大小约 26.64 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

AI大模型智慧工厂MDC项目规划方案.pptx

AI大模型智慧工厂MDC项目规划方案.pptx

ComfyUI/GIMM-VFI 低帧率视频补帧

文件编号:c0256 输入低帧率视频,用 GIMM-VFI 在相邻帧之间插帧,适合改善运动连贯性。实测将 12 fps 的 54 帧短片转为 24 fps、107 帧。 解压后将 c0256.json 导入 RunningHub 工作台。若在本地 ComfyUI 使用,请按已安装的节点和模型版本调整工作流。

复现基于量化状态反馈+非线性自适应神经控制的反馈系统(不确定MIMO)仿真(Matlab代码实现)

内容概要:本文围绕一种结合量化状态反馈与非线性自适应神经控制的先进控制策略,开展针对不确定多输入多输出(MIMO)反馈系统的仿真研究。该方法旨在应对系统中存在的建模不确定性与外部扰动,利用径向基函数(RBF)神经网络逼近未知非线性动态特性,并设计基于量化状态的自适应控制器,有效降低数据传输负担,提升系统在有限带宽条件下的鲁棒性与控制精度。研究严格基于李雅普诺夫稳定性理论完成控制器设计与收敛性证明,确保闭环系统所有信号一致最终有界。配套提供的Matlab代码实现了完整的仿真模型搭建、控制算法编程、参数调节、对比实验设置及结果可视化,涵盖状态响应曲线、控制输入、神经网络权重自适应过程等关键指标,便于用户复现并深入理解算法核心机制。; 适合人群:具备自动控制原理、非线性系统理论及Matlab/Simulink仿真基础的研究生、科研人员与控制工程领域的技术人员;特别适用于从事自适应控制、智能控制、鲁棒控制及MIMO系统设计等相关方向的研究与开发人员。; 使用场景及目标:① 学习并掌握基于神经网络的自适应控制在复杂不确定系统中的设计流程与实现方法;② 理解量化反馈机制在现代网络化控制系统中的应用价值及其对稳定性的保障途径;③ 借助完整可运行的Matlab代码复现高水平研究成果,支撑学术论文撰写、科研项目攻关或工程原型验证。; 阅读建议:建议读者结合经典自适应控制教材与相关IEEE Transactions级文献,重点钻研李雅普诺夫函数构造思路、神经网络逼近原理与权值更新律的设计逻辑,同时动手调试代码参数,观察不同量化密度与初始条件下系统性能的变化,以深化对理论与实践融合的理解。

降噪耳机主动降噪模拟:反相波抵消与延迟误差(Python 源码)

Python 源码:用反相波抵消模拟主动降噪(ANC),包含理想抵消、延迟误差与幅度误差的计算与验证,附完整运行结果与两张图(抵消前后波形、降噪量-频率曲线)。代码可直接运行复现,适合学习信号处理与声学降噪原理。

春秋BC611年世界历史地图矢量文件SHP格式.zip

本资源为《春秋BC611年世界历史地图矢量文件SHP格式》压缩包,文件大小约 1.83 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

ComfyUI/Qwen Image Edit 海边街巷线条水彩

文件编号:c0264 输入街巷照片与笔触、配色要求,生成线条水彩旅行速写。样例保留了蓝色自行车、薄荷绿百叶窗和远处海面。 解压后将 c0264.json 导入 RunningHub 工作台。若在本地 ComfyUI 使用,请按已安装的节点和模型版本调整工作流。

YOLO26算法工业金属板材黑划痕与孔洞目标检测+训练好的模型+634张数据集+pyqt可视化界面.zip

附训练好的 YOLO 权重与 PyQt 可视化检测界面,页面底部含可视化效果预览,毕设/课设开箱即用。 【数据集概况】 · 检测类别(中文):[黑划痕(BlackScratch), 孔洞(Hole)] · 总计:634 张 · 测试集:1 张 · 验证集:63 张 · 训练集:570 张 【训练曲线与评估图】 【模型训练配置】 参数 | 值 模型 | yolo26n 训练轮数 | 100 epochs 输入尺寸 | 640x640 批次大小 | 24 优化器 | auto 初始学习率 | 0.01 训练设备 【关键指标汇总】 训练了 54 个 epoch,最终轮指标: 指标 | 数值 mAP50 | **0.4370** mAP50-95 | 0.1245 Precision | 0.5408 Recall | 0.5383 train/box_loss | 1.3866 train/cls_loss | 0.9975 val/box_loss | 2.4797 val/cls_loss | 2.2340 【训练过程分析】 在训练初期,我注意到模型的表现确实出乎意料,loss(特别是box_loss和cls_loss)迅速下降,这表明模型在快速适应训练样本。但随着时间推移,曲线显得有些停滞,似乎在第40到第50个epoch之间出现了轻微的平台期。这种现象在box_loss上尤为明显,尽管整体趋势良好,但在后期却显得较为平缓,这可能意味着在提升精确度和召回率上有些力不从心。对于l1_loss来说,虽然下降速度稍慢,但整体趋势依然向好,模型在特征提取方面的改进也有所显现。整体来看,模型在训练后期表现较为稳定,mAP50和mAP50-95也保持了平稳的增长,这表明模型在泛化能力上表现良好,但遗憾的是,这种平稳的... 使用场景:毕业设计、课程设计、深度学习入门、工业场景落地验证。

尼日利亚国家石油公司油气运营分析数据集

本数据集以尼日利亚国家石油公司为业务蓝本,构建了一套覆盖2024年至2025年的多表关系型油气运营数据,完整呈现上游开采、原油出口、下游分销与管道完整性四个业务环节。数据采用星型与雪花模型设计,包含3张维度表与4张事实表:维度表记录主要合资与产品分成合同油田、炼厂与储运设施、国际原油买家;事实表逐周记录上游产量、伴生气与放空率、作业成本与停机原因,逐批记录原油出口提单、船名、提油量、官方售价与布伦特价差、货值与回款状态,逐月记录汽油、柴油、航煤与液化石油气等产品的分销量与收入,以及管道事件类型、严重程度、泄漏量、延误产量与修复时长。适用人群:能源行业研究人员、石油经济与贸易分析师、数据仓库与商业智能学习者、管理咨询顾问以及高校师生。使用场景:适合开展上游产量与停机因素分析、出口定价与营收测算、下游分销结构研究、管道风险评估等课题,更是练习SQL多表关联、维度建模与可视化仪表盘开发的优质素材。其他说明:数据为CSV格式,附带完整的数据字典与表结构说明,主键外键关系清晰,背景注释完善易读,可直接导入Python、R、Excel、PowerBI等工具使用,适合毕业设计、课程实训与企业内训,也便于练习从需求到看板的完整分析流程,建议先从维度表理解业务对象再接入事实表。

内网(极空间)搭建gitlab跳板机转发端口及域名配置

然后,回头尝试用内网地址+15022 clone,成功,用公网的ip+15222 clone失败,那就是定位到时nginx转发的问题了。首先想到的就是 git clone是通过ssh的22端口进行下载的,那就需要打通22端口,则又配置22端口的nginx转发。然后,我通过ssh命令,做一个端口转发,以实现内网穿透,将服务端口链接到跳板机上。然后穿透到阿里云服务器跳板机的端口,只能内网访问,需要用nginx做个转发,才能用公网ip进行访问。然后,如上,我的80端口,映射15080,22端口映射15022。

God丶Davide的博客 6093

告别抓包失败!保姆级配置:让Burp+Proxifier稳定抓取任意微信小程序

本文提供了一套完整的Burp+Proxifier配置方案,确保稳定抓取微信小程序数据。从环境准备、工具选型到Burp Suite深度配置和Proxifier精准设置,详细解决了证书安装、进程捕获和乱码解析等核心问题,帮助开发者告别抓包失败,提升调试效率。

weixin_28738165的博客 468
上一篇: iOS汇编教程:理解ARM
下一篇: OCS——史上最疯狂的iOS动态化方案
3行代码
博客等级 码龄16年 189粉丝 171原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值