or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing
xxxxxxxxxx
用1500 行建構可自我編譯的 C 編譯器 - 翁敏維
歡迎來到 https://hackmd.io/c/COSCUP2018 共筆
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →點擊本頁上方的 開始用 Markdown 一起寫筆記!
手機版請點選上方 按鈕展開議程列表。
投影片
Agenda
Purpose
可以自我編譯的編譯器代表在編譯自己的過程中
可以不需要借助其他的toolchain,
但要完成這樣的編譯器並不是一件容易的事情…
(尤其是只需要1500行)
AMaCC 辦到了
究竟AMaCC怎麼樣用不到1500 行辦到?
讓我們看下去…
Introduce AMaCC
Who implements AMaCC
由成功大學師生黃敬群(jserv)、陳建霖、梁穎睿等人開發的self-compiling的C語言編譯器
What is AMaCC
amacc.c
所編譯出來的執行檔可用來編譯amacc.c
, 後者產生出來的執行檔一樣具備編譯amacc.c
的能力dlsym(0, "open")
預備知識
self-host?
為什麼需要self-host?
假如有一個語言X,
他的compiler不能編譯X語言, 那要怎麼驗證compiler?
但是語言X的第一個compiler產生之前,
要怎麼編譯出語言X的第一個compiler?
這個就是 bootstrapping problem
有三種方法:
IR (Intermediate representation)
What is IR?
為什麼IR很重要?
AMaCC在IR這件事上是怎麼處理的?
ELF header
Program header
Section header
Segment, section
Program header
PT_LOAD
PT_INTERP
PT_DYNAMIC
Section header
Segment, Section
Relocation
What is reloc_imm for?
0xeb000000是怎麼來的?
將offset計算成address的計算方式
A:addend
T:
P:address of the place being relocated
Output of AMaCC
Overview source code of AMaCC
Reference
ARM Architecture
ARMv7-A and ARMv7-R edition
tags:
COSCUP2018
source
AMaCC
ARMv7-a
Encoding A1
ELF
arm
armv7-a
dynamic linker