generated from Meekdai/Gmeek-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kylinholmes
committed
Aug 23, 2024
1 parent
c7e22e7
commit 379e3ba
Showing
7 changed files
with
317 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Kylin's :link: https://kylinholmes.github.io | ||
### :page_facing_up: [2](https://kylinholmes.github.io/tag.html) | ||
### :page_facing_up: [3](https://kylinholmes.github.io/tag.html) | ||
### :speech_balloon: 3 | ||
### :hibiscus: 2357 | ||
### :alarm_clock: 2024-08-12 12:48:23 | ||
### :hibiscus: 3015 | ||
### :alarm_clock: 2024-08-23 13:05:23 | ||
### Powered by :heart: [Gmeek](https://github.com/Meekdai/Gmeek) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
**ABI 大致包含以下内容** | ||
~~Todo: ~~ | ||
- [ ] 函数调用: | ||
- [ ] 数据类型布局: | ||
- [ ] 异常处理: | ||
- [ ] 内存管理: | ||
- [ ] 命名重整(Name Mangling): | ||
- [ ] 类型转换: | ||
- [ ] 线程机制: | ||
- [ ] 动态链接: | ||
|
||
|
||
## 函数调用 | ||
- 参数传递:规定了函数参数是如何传递的,包括参数的顺序、位置(寄存器或栈)等。 | ||
- 返回值处理:规定了函数返回值是如何处理的,包括返回值的类型、位置等。 | ||
- 调用约定(calling conventions):规定了函数调用前后栈的清理方式,例如 cdecl、fastcall、stdcall 等。 | ||
## 数据布局 | ||
- 结构体和联合体:规定了结构体和联合体成员的布局、对齐和大小。 | ||
- 数组和指针:规定了数组和指针类型的布局和行为。 | ||
## 异常处理 | ||
- 规定了异常抛出和捕获的方式,包括异常对象的表示和异常处理机制。 | ||
## 内存管理 | ||
- 规定了内存分配和释放的机制,如堆内存的分配和回收。 | ||
## 命名重整 | ||
- 规定了函数和类型的名称在二进制中的表示方式,以解决函数重载等问题。 | ||
## 类型转换 | ||
- 规定了类型转换的操作,如从一种类型到另一种类型的转换规则。 | ||
## 线程机制 | ||
- 规定了多线程环境下代码的安全性和同步机制。 | ||
## 动态链接 | ||
- 规定了动态链接库(DLL 或 SO 文件)的加载和使用方式。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"singlePage": [], "startSite": "", "filingNum": "", "onePageListNum": 20, "commentLabelColor": "#006b75", "yearColorList": ["#bc4c00", "#0969da", "#1f883d", "#A333D0"], "i18n": "CN", "themeMode": "manual", "dayTheme": "light_tritanopia", "nightTheme": "dark_tritanopia", "urlMode": "pinyin", "script": "", "style": "", "head": "", "indexScript": "", "indexStyle": "", "bottomText": "", "showPostSource": 1, "iconList": {}, "UTC": 8, "rssSplit": "sentence", "exlink": {}, "needComment": 1, "allHead": "", "title": "Kylin's", "subTitle": "Essay", "avatarUrl": "https://avatars.githubusercontent.com/u/45586871?v=4", "GMEEK_VERSION": "last", "postListJson": {"P1": {"htmlDir": "docs/post/This is a Title.html", "labels": ["documentation"], "postTitle": "This is a Title", "postUrl": "post/This%20is%20a%20Title.html", "postSourceUrl": "https://github.com/kylinholmes/kylinholmes.github.io/issues/1", "commentNum": 3, "wordCount": 19, "description": "# Head 1\r\nsome text\u3002", "top": 0, "createdAt": 1718985782, "style": "", "script": "", "head": "", "ogImage": "https://avatars.githubusercontent.com/u/45586871?v=4", "createdDate": "2024-06-22", "dateLabelColor": "#bc4c00"}, "P2": {"htmlDir": "docs/post/zai- Rust-zhong- -dong-tai-lian-jie-he-yun-xing-shi-jia-zai-dong-tai-ku.html", "labels": ["rust"], "postTitle": "\u5728 Rust\u4e2d \u52a8\u6001\u94fe\u63a5\u548c\u8fd0\u884c\u65f6\u52a0\u8f7d\u52a8\u6001\u5e93", "postUrl": "post/zai-%20Rust-zhong-%20-dong-tai-lian-jie-he-yun-xing-shi-jia-zai-dong-tai-ku.html", "postSourceUrl": "https://github.com/kylinholmes/kylinholmes.github.io/issues/2", "commentNum": 0, "wordCount": 2338, "description": "## \u52a8\u6001\u94fe\u63a5crate\r\n\r\n**\u5047\u8bbe\u52a8\u6001\u5e93\u662f impls**\r\n**\u9700\u8981\u94fe\u63a5\u5230 impls\u7684crate\u662fabi**\r\n\r\n```bash\r\n\u251c\u2500\u2500 abi # runtime loading library\r\n\u2502 \u251c\u2500\u2500 Cargo.toml # specifies dependent libraries to be used for dynamic linking\r\n\u2502 \u2514\u2500\u2500 src\r\n\u2502 \u251c\u2500\u2500 import.rs # import impls to this crate\r\n\u2502 \u251c\u2500\u2500 lib.rs # \r\n\u2502 \u2514\u2500\u2500 main.rs # test main: loading abi and binding interface\r\n\u251c\u2500\u2500 impls # dynamic link library \r\n\u2502 \u2514\u2500\u2500 src\r\n\u2502 \u2514\u2500\u2500 lib.rs # impls\r\n\u2514\u2500\u2500 README.md\r\n```\r\n\r\n`main` == loadl ibrary => `abi` == dynamic link ==> `impls`\r\n\r\n\u8bbe\u7f6elib\u7c7b\u578b\u4e3a`cdylib`\r\n```toml\r\n# impls/Cargo.toml\r\n[lib]\r\ncrate-type = ['cdylib']\r\n```\r\n\r\n\u5bfc\u51fa\u63a5\u53e3\r\n```rust\r\n// impls/src/lib.rs\r\n#[no_mangle]\r\npub extern 'C' fn add(left: usize, right: usize) -> usize {\r\n left + right\r\n}\r\n```\r\n\r\n\r\n\r\n\u8bbe\u7f6e\u4f9d\u8d56 \r\n```toml\r\n# abi/Cargo.toml\r\n[dependencies]\r\nimpls = { path = '../impls' }\r\n```\r\n\r\n\u63a5\u53e3\u5b9a\u4e49\r\n```rust\r\n#[link(name = 'impls')]\r\nextern 'C' {\r\n pub fn add(a :usize, b: usize) -> usize;\r\n}\r\n```\r\n\r\n\u8c03\u7528\u63a5\u53e3\r\n```rust\r\nprintln!('Add {}', add(1, 9));\r\n```\r\n\r\n## \u8fd0\u884c\u65f6\u52a0\u8f7d\u52a8\u6001\u5e93\r\n\u56e0\u4e3a\u662f\u8fd0\u884c\u65f6\u52a0\u8f7d\uff0c\u6240\u4ee5\u51fd\u6570\u7684\u63a5\u53e3\u4e0d\u9700\u8981\u5355\u72ec\u5b9a\u4e49\uff0c\u901a\u5e38\u662f\u7ed1\u5b9a\u5230\u51fd\u6570\u6307\u9488\u4e0a\r\n\r\n```toml\r\n# abi/Cargo.toml\r\n[dependencies]\r\nimpls = { path = '../impls' }\r\nlibloading = '0.8.5'\r\n```\r\n\r\n```rust\r\n// abi/src/main.rs\r\nuse libloading::{Library, Symbol};\r\n\r\nstatic DLL_HANDLE:Lazy<Library> = Lazy::new(|| {\r\n unsafe {\r\n let dll = std::env::args().nth(1).expect('No DLL provided');\r\n Library::new(dll).expect('Failed to load DLL')\r\n }\r\n});\r\n\r\n// \u5b9a\u4e49\u597d\u51fd\u6570\u6307\u9488\u7684\u7ed3\u6784\u4f53\r\n#[derive(Debug)]\r\nstruct Interface<'a> {\r\n add: Symbol<'a, extern 'C' fn(usize, usize) -> usize>,\r\n init: Symbol<'a, extern 'C' fn() -> ()>,\r\n}\r\n\r\n// \u52a0\u8f7d\u52a8\u6001\u5e93\u540e\uff0c\u7ed1\u5b9a\u51fd\u6570\u6307\u9488\r\nimpl <'a> Interface<'a> {\r\n fn new() -> Self {\r\n unsafe {\r\n let add: Symbol<extern 'C' fn(usize, usize) -> usize> = DLL_HANDLE.borrow().get(b'add').expect('Failed to load add');\r\n let init: Symbol<extern 'C' fn() -> ()> = DLL_HANDLE.borrow().get(b'init').expect('Failed to load init');\r\n Interface {\r\n add,\r\n init\r\n }\r\n }\r\n }\r\n}\r\n\r\nfn main() {\r\n let handle = Interface::new();\r\n (handle.init)();\r\n let result = (handle.add)(1, 9);\r\n println!('Result: {}', result);\r\n \r\n}\r\n\r\n```\r\n\r\n\r\n## Demo\r\n\u9879\u76ee\u5730\u5740 [Demo](https://github.com/kylinholmes/rs_dynamic_link)\u3002", "top": 0, "createdAt": 1723438079, "style": "", "script": "", "head": "", "ogImage": "https://avatars.githubusercontent.com/u/45586871?v=4", "createdDate": "2024-08-12", "dateLabelColor": "#bc4c00"}}, "singeListJson": {}, "labelColorDict": {"bug": "#d73a4a", "documentation": "#0075ca", "duplicate": "#cfd3d7", "enhancement": "#a2eeef", "good first issue": "#7057ff", "help wanted": "#008672", "invalid": "#e4e669", "question": "#d876e3", "rust": "#DA545B", "wontfix": "#ffffff"}, "displayTitle": "Kylin's", "faviconUrl": "https://avatars.githubusercontent.com/u/45586871?v=4", "ogImage": "https://avatars.githubusercontent.com/u/45586871?v=4", "primerCSS": "<link href='https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/Primer/21.0.7/primer.css' rel='stylesheet' />", "homeUrl": "https://kylinholmes.github.io", "prevUrl": "disabled", "nextUrl": "disabled"} | ||
{"singlePage": [], "startSite": "", "filingNum": "", "onePageListNum": 20, "commentLabelColor": "#006b75", "yearColorList": ["#bc4c00", "#0969da", "#1f883d", "#A333D0"], "i18n": "CN", "themeMode": "manual", "dayTheme": "light_tritanopia", "nightTheme": "dark_tritanopia", "urlMode": "pinyin", "script": "", "style": "", "head": "", "indexScript": "", "indexStyle": "", "bottomText": "", "showPostSource": 1, "iconList": {}, "UTC": 8, "rssSplit": "sentence", "exlink": {}, "needComment": 1, "allHead": "", "title": "Kylin's", "subTitle": "Essay", "avatarUrl": "https://avatars.githubusercontent.com/u/45586871?v=4", "GMEEK_VERSION": "last", "postListJson": {"P1": {"htmlDir": "docs/post/This is a Title.html", "labels": ["documentation"], "postTitle": "This is a Title", "postUrl": "post/This%20is%20a%20Title.html", "postSourceUrl": "https://github.com/kylinholmes/kylinholmes.github.io/issues/1", "commentNum": 3, "wordCount": 19, "description": "# Head 1\r\nsome text\u3002", "top": 0, "createdAt": 1718985782, "style": "", "script": "", "head": "", "ogImage": "https://avatars.githubusercontent.com/u/45586871?v=4", "createdDate": "2024-06-22", "dateLabelColor": "#bc4c00"}, "P2": {"htmlDir": "docs/post/zai- Rust-zhong- -dong-tai-lian-jie-he-yun-xing-shi-jia-zai-dong-tai-ku.html", "labels": ["rust"], "postTitle": "\u5728 Rust\u4e2d \u52a8\u6001\u94fe\u63a5\u548c\u8fd0\u884c\u65f6\u52a0\u8f7d\u52a8\u6001\u5e93", "postUrl": "post/zai-%20Rust-zhong-%20-dong-tai-lian-jie-he-yun-xing-shi-jia-zai-dong-tai-ku.html", "postSourceUrl": "https://github.com/kylinholmes/kylinholmes.github.io/issues/2", "commentNum": 0, "wordCount": 2338, "description": "## \u52a8\u6001\u94fe\u63a5crate\r\n\r\n**\u5047\u8bbe\u52a8\u6001\u5e93\u662f impls**\r\n**\u9700\u8981\u94fe\u63a5\u5230 impls\u7684crate\u662fabi**\r\n\r\n```bash\r\n\u251c\u2500\u2500 abi # runtime loading library\r\n\u2502 \u251c\u2500\u2500 Cargo.toml # specifies dependent libraries to be used for dynamic linking\r\n\u2502 \u2514\u2500\u2500 src\r\n\u2502 \u251c\u2500\u2500 import.rs # import impls to this crate\r\n\u2502 \u251c\u2500\u2500 lib.rs # \r\n\u2502 \u2514\u2500\u2500 main.rs # test main: loading abi and binding interface\r\n\u251c\u2500\u2500 impls # dynamic link library \r\n\u2502 \u2514\u2500\u2500 src\r\n\u2502 \u2514\u2500\u2500 lib.rs # impls\r\n\u2514\u2500\u2500 README.md\r\n```\r\n\r\n`main` == loadl ibrary => `abi` == dynamic link ==> `impls`\r\n\r\n\u8bbe\u7f6elib\u7c7b\u578b\u4e3a`cdylib`\r\n```toml\r\n# impls/Cargo.toml\r\n[lib]\r\ncrate-type = ['cdylib']\r\n```\r\n\r\n\u5bfc\u51fa\u63a5\u53e3\r\n```rust\r\n// impls/src/lib.rs\r\n#[no_mangle]\r\npub extern 'C' fn add(left: usize, right: usize) -> usize {\r\n left + right\r\n}\r\n```\r\n\r\n\r\n\r\n\u8bbe\u7f6e\u4f9d\u8d56 \r\n```toml\r\n# abi/Cargo.toml\r\n[dependencies]\r\nimpls = { path = '../impls' }\r\n```\r\n\r\n\u63a5\u53e3\u5b9a\u4e49\r\n```rust\r\n#[link(name = 'impls')]\r\nextern 'C' {\r\n pub fn add(a :usize, b: usize) -> usize;\r\n}\r\n```\r\n\r\n\u8c03\u7528\u63a5\u53e3\r\n```rust\r\nprintln!('Add {}', add(1, 9));\r\n```\r\n\r\n## \u8fd0\u884c\u65f6\u52a0\u8f7d\u52a8\u6001\u5e93\r\n\u56e0\u4e3a\u662f\u8fd0\u884c\u65f6\u52a0\u8f7d\uff0c\u6240\u4ee5\u51fd\u6570\u7684\u63a5\u53e3\u4e0d\u9700\u8981\u5355\u72ec\u5b9a\u4e49\uff0c\u901a\u5e38\u662f\u7ed1\u5b9a\u5230\u51fd\u6570\u6307\u9488\u4e0a\r\n\r\n```toml\r\n# abi/Cargo.toml\r\n[dependencies]\r\nimpls = { path = '../impls' }\r\nlibloading = '0.8.5'\r\n```\r\n\r\n```rust\r\n// abi/src/main.rs\r\nuse libloading::{Library, Symbol};\r\n\r\nstatic DLL_HANDLE:Lazy<Library> = Lazy::new(|| {\r\n unsafe {\r\n let dll = std::env::args().nth(1).expect('No DLL provided');\r\n Library::new(dll).expect('Failed to load DLL')\r\n }\r\n});\r\n\r\n// \u5b9a\u4e49\u597d\u51fd\u6570\u6307\u9488\u7684\u7ed3\u6784\u4f53\r\n#[derive(Debug)]\r\nstruct Interface<'a> {\r\n add: Symbol<'a, extern 'C' fn(usize, usize) -> usize>,\r\n init: Symbol<'a, extern 'C' fn() -> ()>,\r\n}\r\n\r\n// \u52a0\u8f7d\u52a8\u6001\u5e93\u540e\uff0c\u7ed1\u5b9a\u51fd\u6570\u6307\u9488\r\nimpl <'a> Interface<'a> {\r\n fn new() -> Self {\r\n unsafe {\r\n let add: Symbol<extern 'C' fn(usize, usize) -> usize> = DLL_HANDLE.borrow().get(b'add').expect('Failed to load add');\r\n let init: Symbol<extern 'C' fn() -> ()> = DLL_HANDLE.borrow().get(b'init').expect('Failed to load init');\r\n Interface {\r\n add,\r\n init\r\n }\r\n }\r\n }\r\n}\r\n\r\nfn main() {\r\n let handle = Interface::new();\r\n (handle.init)();\r\n let result = (handle.add)(1, 9);\r\n println!('Result: {}', result);\r\n \r\n}\r\n\r\n```\r\n\r\n\r\n## Demo\r\n\u9879\u76ee\u5730\u5740 [Demo](https://github.com/kylinholmes/rs_dynamic_link)\u3002", "top": 0, "createdAt": 1723438079, "style": "", "script": "", "head": "", "ogImage": "https://avatars.githubusercontent.com/u/45586871?v=4", "createdDate": "2024-08-12", "dateLabelColor": "#bc4c00"}, "P3": {"htmlDir": "docs/post/Application Binary Interface.html", "labels": ["Basic"], "postTitle": "Application Binary Interface", "postUrl": "post/Application%20Binary%20Interface.html", "postSourceUrl": "https://github.com/kylinholmes/kylinholmes.github.io/issues/3", "commentNum": 0, "wordCount": 658, "description": "\r\n**ABI \u5927\u81f4\u5305\u542b\u4ee5\u4e0b\u5185\u5bb9**\r\n~~Todo: ~~\r\n- [ ] \u51fd\u6570\u8c03\u7528\uff1a\r\n- [ ] \u6570\u636e\u7c7b\u578b\u5e03\u5c40\uff1a\r\n- [ ] \u5f02\u5e38\u5904\u7406\uff1a\r\n- [ ] \u5185\u5b58\u7ba1\u7406\uff1a\r\n- [ ] \u547d\u540d\u91cd\u6574\uff08Name Mangling\uff09\uff1a\r\n- [ ] \u7c7b\u578b\u8f6c\u6362\uff1a\r\n- [ ] \u7ebf\u7a0b\u673a\u5236\uff1a\r\n- [ ] \u52a8\u6001\u94fe\u63a5\uff1a\r\n\r\n \r\n## \u51fd\u6570\u8c03\u7528\r\n - \u53c2\u6570\u4f20\u9012\uff1a\u89c4\u5b9a\u4e86\u51fd\u6570\u53c2\u6570\u662f\u5982\u4f55\u4f20\u9012\u7684\uff0c\u5305\u62ec\u53c2\u6570\u7684\u987a\u5e8f\u3001\u4f4d\u7f6e\uff08\u5bc4\u5b58\u5668\u6216\u6808\uff09\u7b49\u3002", "top": 0, "createdAt": 1724384786, "style": "", "script": "", "head": "", "ogImage": "https://avatars.githubusercontent.com/u/45586871?v=4", "createdDate": "2024-08-23", "dateLabelColor": "#bc4c00"}}, "singeListJson": {}, "labelColorDict": {"Basic": "#2C00DF", "documentation": "#0075ca", "rust": "#DA545B"}, "displayTitle": "Kylin's", "faviconUrl": "https://avatars.githubusercontent.com/u/45586871?v=4", "ogImage": "https://avatars.githubusercontent.com/u/45586871?v=4", "primerCSS": "<link href='https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/Primer/21.0.7/primer.css' rel='stylesheet' />", "homeUrl": "https://kylinholmes.github.io", "prevUrl": "disabled", "nextUrl": "disabled"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.