Skip to content

Commit

Permalink
Create pages.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Laity000 committed Mar 16, 2024
1 parent 89d5c7b commit 893d443
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Deploy Sphinx documentation to Pages

on:
push:
branches: [main] # branch to trigger deployment

jobs:
pages:
runs-on: ubuntu-20.04
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
id-token: write
steps:
- id: deployment
uses: sphinx-notes/pages@v3
with:
documentation_path: ./source
requirements_path: ./requirements.txt

Binary file added png/image_llvm_ir_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions source/llvm/vtable.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#! https://zhuanlan.zhihu.com/p/687308019
# c++ vtable in llvm ir


Expand Down Expand Up @@ -85,7 +86,7 @@ llvm ir在这里可以看到: https://godbolt.org/z/3jz34Y8a6
单继承的例子这里不再介绍了。通过`多重继承`都可以了解。
##多重继承的vtable in llvm ir格式
## 多重继承的vtable in llvm ir格式
```c++
@vtable for Mother = linkonce_odr dso_local unnamed_addr constant { [4 x ptr] } { [4 x ptr] [
Expand Down Expand Up @@ -140,7 +141,7 @@ llvm ir在这里可以看到: https://godbolt.org/z/3jz34Y8a6
- vtable是一个指针类型的数组,当有多重继承,子类是多维数组,比如`Child``[5 x ptr], [3 x ptr]`。里面的内容编译器已经帮我们填好了。
- 第一个成员是`offset_to_top`
- 第二个成员是`typeinfo`
- 后面依次是函数地址,相同虚函数的偏移是固定的。这样当**通过基类指针或引用调用虚函数时**不管哪个实际类型,编译无脑加偏移就好了
- 后面依次是函数地址,相同虚函数的偏移是固定的。这样当**通过基类指针或引用调用虚函数时**不管哪个实际类型,编译器无脑加偏移就好了

我们着重看下新出现的两个成员:

Expand Down Expand Up @@ -349,6 +350,7 @@ Child::FatherFoo() 里的代码指令是写死的,即对于成员变量的偏
而 Mother 和 Child 合用一个虚指针,所以就不会有这种问题。

[thunk在c++还有其他含义](https://stackoverflow.com/questions/2641489/what-is-a-thunk)

[ virtual thunk and a non virtual thunk. ](https://reverseengineering.stackexchange.com/questions/4543/what-is-a-non-virtual-thunk)

### 子类指针调用子类虚方法
Expand Down

0 comments on commit 893d443

Please sign in to comment.