Skip to content

Commit

Permalink
使用 opt 优化 LLVM IR,定制 clang 实现函数名加密
Browse files Browse the repository at this point in the history
  • Loading branch information
CYRUS-STUDIO committed Nov 25, 2024
1 parent e2348e7 commit ae5d81c
Show file tree
Hide file tree
Showing 15 changed files with 2,043 additions and 140 deletions.

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@
<h1>CYRUS STUDIO</h1>
<ul class="posts-list">

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/%E4%BD%BF%E7%94%A8-opt-%E4%BC%98%E5%8C%96-llvm-ir%E5%AE%9A%E5%88%B6-clang-%E5%AE%9E%E7%8E%B0%E5%87%BD%E6%95%B0%E5%90%8D%E5%8A%A0%E5%AF%86/">使用 opt 优化 LLVM IR,定制 clang 实现函数名加密</a>
<span class="posts-list-item-description">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-calendar">
<title>calendar</title>
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
Nov 26, 2024
<span class="posts-list-item-separator">-</span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-clock">
<title>clock</title>
<circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline>
</svg>
9 min read
</span>
</li>

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/%E7%BC%96%E8%AF%91-llvm-%E6%BA%90%E7%A0%81%E4%BD%BF%E7%94%A8-clion-%E8%B0%83%E8%AF%95-clang/">编译 LLVM 源码,使用 Clion 调试 clang</a>
<span class="posts-list-item-description">
Expand Down Expand Up @@ -207,23 +224,6 @@ <h1>CYRUS STUDIO</h1>
</span>
</li>

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/%E4%BD%BF%E7%94%A8-frida-%E5%AE%9A%E4%BD%8D-jni-%E6%96%B9%E6%B3%95%E5%86%85%E5%AD%98%E5%9C%B0%E5%9D%80/">使用 Frida 定位 JNI 方法内存地址</a>
<span class="posts-list-item-description">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-calendar">
<title>calendar</title>
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
Oct 29, 2024
<span class="posts-list-item-separator">-</span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-clock">
<title>clock</title>
<circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline>
</svg>
5 min read
</span>
</li>

</ul>


Expand Down
9 changes: 8 additions & 1 deletion public/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
<description>Recent content on CYRUS STUDIO</description>
<generator>Hugo</generator>
<language>zh-cn</language>
<lastBuildDate>Sun, 24 Nov 2024 23:00:44 +0800</lastBuildDate>
<lastBuildDate>Tue, 26 Nov 2024 03:23:42 +0800</lastBuildDate>
<atom:link href="https://cyrus-studio.github.io/blog/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>使用 opt 优化 LLVM IR,定制 clang 实现函数名加密</title>
<link>https://cyrus-studio.github.io/blog/posts/%E4%BD%BF%E7%94%A8-opt-%E4%BC%98%E5%8C%96-llvm-ir%E5%AE%9A%E5%88%B6-clang-%E5%AE%9E%E7%8E%B0%E5%87%BD%E6%95%B0%E5%90%8D%E5%8A%A0%E5%AF%86/</link>
<pubDate>Tue, 26 Nov 2024 03:23:42 +0800</pubDate>
<guid>https://cyrus-studio.github.io/blog/posts/%E4%BD%BF%E7%94%A8-opt-%E4%BC%98%E5%8C%96-llvm-ir%E5%AE%9A%E5%88%B6-clang-%E5%AE%9E%E7%8E%B0%E5%87%BD%E6%95%B0%E5%90%8D%E5%8A%A0%E5%AF%86/</guid>
<description>版权归作者所有,如有转发,请注明文章出处:https://cyrus-studio.github.io/blog/&#xA;1. LLVM IR LLVM IR(Intermediate Representation) 是 LLVM 编译框架中的一种中间表示形式,它是一种面向低级的中间代码,是 LLVM 架构的核心部分。LLVM IR 既可以用作 LLVM 编译器的输入,也可以用作输出,供其他编译器或工具链使用。&#xA;LLVM IR 的两种存储形式:&#xA;LLVM IR 语言(文本形式,扩展名 .ll):可读的 LLVM IR 代码。&#xA;LLVM 位码(Bitcode,扩展名 .bc):二进制形式的 LLVM IR,主要用于高效存储和传输。&#xA;LLVM IR 是平台无关的,可以跨不同的硬件架构进行移植。&#xA;LLVM IR 语言参考手册:https://llvm.org/docs/LangRef.html&#xA;1.1 将 C 文件转换为 LLVM IR 生成文本形式的 LLVM IR(.ll 文件)&#xA;clang -S -emit-llvm hello.c -o hello.ll 以 hello.ll 为例,生成的内容大概如下&#xA;; Function Attrs: noinline nounwind optnone uwtable&#xD;; 这行注释了函数的属性&#xD;; - noinline: 该函数不会被内联(inline)。&#xD;; - nounwind: 该函数不会引发异常(不会 unwind stack)。&#xD;; - optnone: 编译器不会对此函数进行任何优化。&#xD;; - uwtable: 该函数有一个可用的异常处理表(unwind table)。&#xD;define dso_local i32 @main() #0 {&#xD;; define: 定义一个函数。&#xD;; dso_local: 该函数在本地动态库中可见(仅限于当前编译单元)。&#xD;; i32: 返回类型为 32 位整数。&#xD;; @main: 函数名为 &amp;#39;main&amp;#39;。&#xD;; #0: 函数使用属性组 0 中定义的属性(即上面注释的那一行)。&#xD;entry:&#xD;; entry: 函数的入口基本块(Basic Block)的标签。&#xD;%retval = alloca i32, align 4&#xD;; alloca: 在栈上分配内存。这里分配了一个 32 位整数(i32)。&#xD;; align 4: 分配的内存对齐到 4 字节边界。&#xD;; %retval: 变量的名称(SSA 变量),用于存储 main 函数的返回值。&#xD;store i32 0, ptr %retval, align 4&#xD;; store: 将一个值存储到内存地址中。&#xD;; i32 0: 要存储的值是 32 位整数 0(即 main 函数的返回值)。&#xD;; ptr %retval: 存储的位置是之前分配的栈变量 %retval。&#xD;; align 4: 存储操作按 4 字节对齐。&#xD;%call = call i32 (ptr, .</description>
</item>
<item>
<title>编译 LLVM 源码,使用 Clion 调试 clang</title>
<link>https://cyrus-studio.github.io/blog/posts/%E7%BC%96%E8%AF%91-llvm-%E6%BA%90%E7%A0%81%E4%BD%BF%E7%94%A8-clion-%E8%B0%83%E8%AF%95-clang/</link>
Expand Down
34 changes: 17 additions & 17 deletions public/page/2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@
<h1>CYRUS STUDIO</h1>
<ul class="posts-list">

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/%E4%BD%BF%E7%94%A8-frida-%E5%AE%9A%E4%BD%8D-jni-%E6%96%B9%E6%B3%95%E5%86%85%E5%AD%98%E5%9C%B0%E5%9D%80/">使用 Frida 定位 JNI 方法内存地址</a>
<span class="posts-list-item-description">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-calendar">
<title>calendar</title>
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
Oct 29, 2024
<span class="posts-list-item-separator">-</span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-clock">
<title>clock</title>
<circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline>
</svg>
5 min read
</span>
</li>

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/frida%E8%84%9A%E6%9C%AC%E8%87%AA%E5%8A%A8%E5%8C%96%E5%AF%BB%E5%9D%80jni%E6%96%B9%E6%B3%95/">frida脚本,自动化寻址JNI方法</a>
<span class="posts-list-item-description">
Expand Down Expand Up @@ -207,23 +224,6 @@ <h1>CYRUS STUDIO</h1>
</span>
</li>

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/%E5%B8%B8%E8%A7%81%E7%9A%84-256-%E6%9D%A1-dalvik-%E5%AD%97%E8%8A%82%E7%A0%81%E6%8C%87%E4%BB%A4/">常见的 256 条 Dalvik 字节码指令</a>
<span class="posts-list-item-description">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-calendar">
<title>calendar</title>
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
Oct 5, 2024
<span class="posts-list-item-separator">-</span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-clock">
<title>clock</title>
<circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline>
</svg>
3 min read
</span>
</li>

</ul>


Expand Down
34 changes: 17 additions & 17 deletions public/page/3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@
<h1>CYRUS STUDIO</h1>
<ul class="posts-list">

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/%E5%B8%B8%E8%A7%81%E7%9A%84-256-%E6%9D%A1-dalvik-%E5%AD%97%E8%8A%82%E7%A0%81%E6%8C%87%E4%BB%A4/">常见的 256 条 Dalvik 字节码指令</a>
<span class="posts-list-item-description">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-calendar">
<title>calendar</title>
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
Oct 5, 2024
<span class="posts-list-item-separator">-</span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-clock">
<title>clock</title>
<circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline>
</svg>
3 min read
</span>
</li>

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/%E4%BD%BF%E7%94%A8ida-pro%E5%8A%A8%E6%80%81%E8%B0%83%E8%AF%95android-app/">使用IDA Pro动态调试Android APP</a>
<span class="posts-list-item-description">
Expand Down Expand Up @@ -207,23 +224,6 @@ <h1>CYRUS STUDIO</h1>
</span>
</li>

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/lineageos%E6%BA%90%E7%A0%81%E4%B8%8B%E8%BD%BD%E5%92%8C%E7%BC%96%E8%AF%91xiaomi-mi-6xwayne/">LineageOS源码下载和编译(Xiaomi Mi 6X,wayne)</a>
<span class="posts-list-item-description">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-calendar">
<title>calendar</title>
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
Sep 15, 2024
<span class="posts-list-item-separator">-</span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-clock">
<title>clock</title>
<circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline>
</svg>
6 min read
</span>
</li>

</ul>


Expand Down
34 changes: 17 additions & 17 deletions public/page/4/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@
<h1>CYRUS STUDIO</h1>
<ul class="posts-list">

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/lineageos%E6%BA%90%E7%A0%81%E4%B8%8B%E8%BD%BD%E5%92%8C%E7%BC%96%E8%AF%91xiaomi-mi-6xwayne/">LineageOS源码下载和编译(Xiaomi Mi 6X,wayne)</a>
<span class="posts-list-item-description">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-calendar">
<title>calendar</title>
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
Sep 15, 2024
<span class="posts-list-item-separator">-</span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-clock">
<title>clock</title>
<circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline>
</svg>
6 min read
</span>
</li>

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/lineageos%E5%88%B7%E6%9C%BA%E6%95%99%E7%A8%8B/">LineageOS刷机教程</a>
<span class="posts-list-item-description">
Expand Down Expand Up @@ -207,23 +224,6 @@ <h1>CYRUS STUDIO</h1>
</span>
</li>

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/0%E6%88%90%E6%9C%AC%E9%80%9A%E8%BF%87hugo%E5%92%8Cgithub-pages%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A2/">0成本通过Hugo和GitHub Pages搭建博客</a>
<span class="posts-list-item-description">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-calendar">
<title>calendar</title>
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
Aug 11, 2024
<span class="posts-list-item-separator">-</span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-clock">
<title>clock</title>
<circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline>
</svg>
3 min read
</span>
</li>

</ul>


Expand Down
17 changes: 17 additions & 0 deletions public/page/5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@
<h1>CYRUS STUDIO</h1>
<ul class="posts-list">

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/0%E6%88%90%E6%9C%AC%E9%80%9A%E8%BF%87hugo%E5%92%8Cgithub-pages%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A2/">0成本通过Hugo和GitHub Pages搭建博客</a>
<span class="posts-list-item-description">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-calendar">
<title>calendar</title>
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
Aug 11, 2024
<span class="posts-list-item-separator">-</span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-clock">
<title>clock</title>
<circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline>
</svg>
3 min read
</span>
</li>

</ul>


Expand Down
40 changes: 23 additions & 17 deletions public/posts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@
<h1>Posts</h1>
<ul class="posts-list">

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/%E4%BD%BF%E7%94%A8-opt-%E4%BC%98%E5%8C%96-llvm-ir%E5%AE%9A%E5%88%B6-clang-%E5%AE%9E%E7%8E%B0%E5%87%BD%E6%95%B0%E5%90%8D%E5%8A%A0%E5%AF%86/">使用 opt 优化 LLVM IR,定制 clang 实现函数名加密</a>
<span class="posts-list-item-description">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-calendar">
<title>calendar</title>
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
Nov 26, 2024
<span class="posts-list-item-separator">-</span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-clock">
<title>clock</title>
<circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline>
</svg>
9 min read
</span>
</li>

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/%E7%BC%96%E8%AF%91-llvm-%E6%BA%90%E7%A0%81%E4%BD%BF%E7%94%A8-clion-%E8%B0%83%E8%AF%95-clang/">编译 LLVM 源码,使用 Clion 调试 clang</a>
<span class="posts-list-item-description">
Expand Down Expand Up @@ -207,23 +224,6 @@ <h1>Posts</h1>
</span>
</li>

<li class="posts-list-item">
<a class="posts-list-item-title" href="https://cyrus-studio.github.io/blog/posts/%E4%BD%BF%E7%94%A8-frida-%E5%AE%9A%E4%BD%8D-jni-%E6%96%B9%E6%B3%95%E5%86%85%E5%AD%98%E5%9C%B0%E5%9D%80/">使用 Frida 定位 JNI 方法内存地址</a>
<span class="posts-list-item-description">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-calendar">
<title>calendar</title>
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
Oct 29, 2024
<span class="posts-list-item-separator">-</span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-clock">
<title>clock</title>
<circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline>
</svg>
5 min read
</span>
</li>

</ul>


Expand Down Expand Up @@ -254,6 +254,12 @@ <h1>Posts</h1>
</a>
</li>

<li class="page-item">
<a class="page-link" href="/blog/posts/page/5/">
5
</a>
</li>


<li class="page-item">
<a class="page-link" href="/blog/posts/page/2/">
Expand Down
Loading

0 comments on commit ae5d81c

Please sign in to comment.