Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
seccamp2018でセルフホストCコンパイラをつくった
Search
Ushitora Anqou
September 22, 2018
Programming
8
5.3k
seccamp2018でセルフホストCコンパイラをつくった
セキュリティ・キャンプ全国大会2018でセルフホストCコンパイラをつくりました。キャンプが終わった後にアセンブラとリンカと標準ライブラリを作りました。
Ushitora Anqou
September 22, 2018
Tweet
Share
More Decks by Ushitora Anqou
See All by Ushitora Anqou
Oblivious Online Monitoring for Safety LTL Specification via Fully Homomorphic Encryption
anqou
1
850
F*でプログラムの正しさを証明する
anqou
1
1.1k
「自作CPUでサイゼリヤ問題」を支える技術
anqou
2
320
ぼくのかんがえたさいきょうのマリオAI
anqou
1
530
10ステップで作るお手軽インタプリタ開発
anqou
3
990
Other Decks in Programming
See All in Programming
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
130
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
Haze - Real time background blurring
chrisbanes
1
510
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
100
Kaigi on Railsに初参加したら、その日にLT登壇が決定した件について
tama50505
0
100
ドメインイベント増えすぎ問題
h0r15h0
2
340
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
190
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
800
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
270
Security_for_introducing_eBPF
kentatada
0
110
モバイルアプリにおける自動テストの導入戦略
ostk0069
0
110
CSC305 Lecture 26
javiergs
PRO
0
140
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Adopting Sorbet at Scale
ufuk
73
9.1k
Become a Pro
speakerdeck
PRO
26
5k
A Tale of Four Properties
chriscoyier
157
23k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Mobile First: as difficult as doing things right
swwweet
222
9k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
170
Documentation Writing (for coders)
carmenintech
66
4.5k
Side Projects
sachag
452
42k
A Philosophy of Restraint
colly
203
16k
Navigating Team Friction
lara
183
15k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Transcript
#seccamp2018 Ͱηϧϑϗε τ C ίϯύΠϥΛͭͬͨ͘ ࠡ ᲒᲶ @ushitora anqou 1
ͲΜͳͻͱ ࠡ ᲒᲶʢ͏͠ͱΒ ͋Μ͜͏ʣ • Twitter: @ushitora anqou • ීஈ
C++Ͱ༡ΜͩΓ༡ΕͨΓɻ • constexpr Ͱ NN ͱ͔ॻ͖·ͨ͠ɻ GitHub ʹ͋ΔͷͰελʔ͍ͩ͘͞ɻ • Kernel VM Θ͔Γ·ͤΜɻษڧ͠ ·͢ɻ 2
seccamp ͬͯͳʹ ηΩϡϦςΟɾΩϟϯϓશࠃେձ 2018 • 8 ݄ 14 ʙ18
@౦ژதࢢ • IPA ओ࠵ͷ߹॓ܗࣜͷษڧձ • ʮY-II C ίϯύΠϥΛࣗ࡞ͯ͠ΈΑ ͏ʂʯθϛʹࢀՃ • ߨࢣ Rui ͞Μͱ hikalium ͞Μ 3
Y-II ͷඪ 4
ఔ Day N Δ͜ͱ Day 1 ։ձࣜͱ͔ʢ։ൃͳ͠ʣ Day 2 ։ൃ
Day 3 ։ൃ Day 4 ։ൃ Day 5 ดձࣜͱ͔ʢ։ൃͳ͠ʣ 7 ݄ͷ಄͔Βࣄલֶशͱͯ͠։ൃΛ࢝ΊΔɻ 5
Day 0
Day 0 ηϧϑϗετͰ͖ͨ 6
͓͡͞Μͳʹͨ͠ͷ ηϧϑϗετͷ x86-64 ͚ C ίϯύΠϥ aqcc Λॻ͍ͨɻ • System
V AMD64 ABI ४ڌɻ • C ϓϩάϥϜΛಡΈࠐΈΞηϯϒϦΛ ग़ྗɻ 7
ηϧϑϗετ ࣗࣗΛίϯύΠϧͰ͖Δɻ • aqcc C ݴޠͰॻ͔Ε͍ͯΔɻ • aqcc
C ݴޠίϯύΠϥͰ͋Δɻ • Ώ͑ʹ aqcc aqcc ͰίϯύΠϧͰ ͖Δɻ 8
ηϧϑϗετ seccamp ࠷ऴ·Ͱʹ 6 ਓத 3 ਓ͕ୡɻ 9
ͭ͘Γ͔ͨ 10
ͭ͘Γ͔ͨ Δ͚ͩ 10
ͭ͘Γ͔ͨ 11
ͭ͘Γ͔ͨ • ೖྗจࣈྻΛτʔΫϯྻʹׂ͢Δɻ 11
ͭ͘Γ͔ͨ • ೖྗจࣈྻΛτʔΫϯྻʹׂ͢Δɻ • τʔΫϯྻΛղऍ͠நߏจ ʢASTʣʹ͢Δɻ 11
ͭ͘Γ͔ͨ • ೖྗจࣈྻΛτʔΫϯྻʹׂ͢Δɻ • τʔΫϯྻΛղऍ͠நߏจ ʢASTʣʹ͢Δɻ • ҙຯղੳΛߦ͍ AST ΛŢœŕͱ͢Δɻ
11
ͭ͘Γ͔ͨ • ೖྗจࣈྻΛτʔΫϯྻʹׂ͢Δɻ • τʔΫϯྻΛղऍ͠நߏจ ʢASTʣʹ͢Δɻ • ҙຯղੳΛߦ͍ AST ΛŢœŕͱ͢Δɻ
• Ţœŕͱͳͬͨ AST ΛݩʹΞηϯϒϦΛ ੜ͢Δɻ 11
ͭ͘Γ͔ͨ • ೖྗจࣈྻΛτʔΫϯྻʹׂ͢Δɻ • τʔΫϯྻΛղऍ͠நߏจ ʢASTʣʹ͢Δɻ • ҙຯղੳΛߦ͍ AST ΛŢœŕͱ͢Δɻ
• Ţœŕͱͳͬͨ AST ΛݩʹΞηϯϒϦΛ ੜ͢Δɻ • ੜͨ͠ΞηϯϒϦΛ͍͍ײ͡ʹ࠷ద Խ͢Δɻ 11
ͭΒ͔ͬͨͱ͜Ζ • ΞηϯϒϦ͕͔Βͳ͍ɻ • ΞηϯϒϦΛॻ͘ͷॳΊͯɻ • lea ͬͯͳʹɻ • C
ͷݴޠ༷͕͔Βͳ͍ɻ • C ͷݴޠ༷ΛಡΉͷʢ΄΅ʣॳΊͯɻ • ൚֦ுͬͯͳʹɻ 12
C ݴޠ༷ͷ͕͜͜ΩϞ͍ʂ • ϙΠϯλ͕ΩϞ͍ʂ • int* p, q; ͷ q
int • ؔએݴ͕ΩϞ͍ʂ • int foo(); ͱ int foo(){...} ͱ int foo; ͷ۠ผɻ • ՄมҾ͕ΩϞ͍ʂ • va list ͱ͔ va start() ͱ͔ɻ • va list ͷఆٛͱ͔ͬͯ·͢ʁ 13
ଓɾC ݴޠ༷ͷ͕͜͜ΩϞ͍ʂ • switch ͕ΩϞ͍ʂ • if-else ͱ͍͏ΑΓ࣮࣭ goto switch
(1) { int a = 2; case 3: 1; int b = 5; break; case 1: a = 1; b = 0; default: printf("%d␣%d", a, b); // 1 0 } 14
ଓʑɾC ݴޠ༷ͷ͕͜͜ΩϞ͍ʂ • ߏମఆ͕ٛΩϞ͍ʂ • ߏମఆٛ int type-specifier ͳͷ
Ͱಉ͡ͱ͜Ζʹॻ͚Δɻ struct hogehoge { int piyopiyo; } foobar (); int foobar (); 15
ଓʑɾC ݴޠ༷ͷ͕͜͜ΩϞ͍ʂ • ߏମఆ͕ٛΩϞ͍ʂ • ߏମఆٛ int type-specifier ͳͷ
Ͱಉ͡ͱ͜Ζʹॻ͚Δɻ struct hogehoge { int piyopiyo; }; int; 15
ΠϯΫϦϝϯλϧͳ։ൃ • 1 ݸΛฦ͢ʮΓ΅ͯ C ίϯύΠ ϥʯ͔Βελʔτɻ • ঃʑʹػೳΛ͢ɻҰؾʹ࡞Βͳ͍ɻ
• Rui ͞ΜͷςΩετ Slackɾhangout Ͱॿ͚͍͍ͯͨͩͨɻ 16
DAY 2 17
DAY 2 Δ͜ͱ͕ͳ͍ 17
ͳʹΛ͠Α͏͔ ίʔυੜͷํࣜΛม͑Α͏ɻ • ελοΫϚγϯ • ݱঢ়ͷ࣮ɻ • ϨδελϚγϯ • ͬͪ͜ʹ͍ͨ͠ɻ
18
ελοΫϚγϯ • શͯͷ໋ྩελοΫΛհͯ͠ૢ࡞Λ ͢Δɻ • ελοΫϝϞϦ্ʹ͋ΔͷͰ͍ɻ 19
ϨδελϚγϯ • શͯͷ໋ྩϨδελΛհͯ͠ૢ࡞Λ ͢Δɻ • Ϩδελ CPU ʹ͋ΔͷͰ͍ɻ 20
Ͳ͏Δͷ ͑ΔϨδελ • ؔͷҾʹ͏Ϩδελγϑτԋ ࢉͳͲɺಛघͳ༻్ͰΘΕΔϨδε λΛආ͚Δɻ • r10, r11, r12,
r13, r14, r15 ͕ ͑Δɻ 21
ϨδελϚγϯͷͭ͘Γ͔ͨ • ॲཧͷ࢝·ΓͱऴΘΓͰ push, pop ͢ΔΘΓʹɺϨδελ͔ΒใΛ ҾͬுͬͨΓऔ͖ͬͯͨΓ͢Δɻ • AST ͷ༿ϊʔυ͔Βίʔυੜ͢Δͱ
͖ʹɺσʔλΛ֨ೲͨ͠ϨδελΛ ʹฦ͢ɻ 22
None
DAY 3 ϨδελϚγϯʹͳͬͨ 23
ŰƅŲŔŖŵƃţͷܭଌ ϨδελϚγϯͷ aqcc (2142d05) ͷιʔ είʔυΛશͯ࿈݁͠ɺ͜ΕΛίϯύΠϧ ͢Δ࣌ؒΛ perf ίϚϯυͰଌఆ͢Δɻ 24
ŰƅŲŔŖŵƃţ ελοΫϚγϯ (85ee93c) • gcc -O2 0.09287 ± 0.00187 seconds
• aqcc 0.40217 ± 0.00277 seconds 4.3 ഒ 25
ŰƅŲŔŖŵƃţ ϨδελϚγϯ (2142d05) • gcc -O2 0.090094 ± 0.000310 seconds
• aqcc 0.21281 ± 0.00286 seconds 2.3 ഒ 26
ͭΒ͔ͬͨͱ͜Ζ σόοά͕ͱʹ͔ͭ͘Β͍ɻ • gcc ͰͷιʔείϯύΠϧͰ͖Δɻ • ίϯύΠϧͨ͠ίϯύΠϥͰͷιʔε ίϯύΠϧ͕Ͱ͖ͳ͍ɻ 27
ͭΒ͔ͬͨͱ͜Ζ 28
ͭΒ͔ͬͨͱ͜Ζ 29
ͭΒ͔ͬͨͱ͜Ζ • σόοάใ͕ͳ͍ʂ • མ͍ͪͯΔͱ͜Ζʹόά͕͋ΔΘ͚ ͡Όͳ͍ʂ 29
ͭΒ͔ͬͨͱ͜Ζ ؒҧ͍͑ͯͨͷɺϨδελୀආͰͨ͠ɻ • ؔݺͼग़࣌͠ʹอଘ͖͢Ϩδελ ΛҰͭΕ͍ͯͨɻ • ΘΓͱΈΜͳܦݧ͢Δಓɻ 30
ŰƅŲŔŖŵƃţʢ࠶ܝʣ ϨδελϚγϯ (2142d05) • gcc -O2 0.090094 ± 0.000310 seconds
• aqcc 0.21281 ± 0.00286 seconds 2.3 ഒ 31
2.3 ⇒ 2 ഒʹ͍ͨ͠ʂ ग़ྗ͢ΔΞηϯϒϦΛ࠷దԽ͢Δɻ ४උ • ग़ྗίʔυΛه߸ʢstruct Codeʣʹ ஔ͖͑Δɻ
• ͦΕ·ͰจࣈྻͰѻ͍ͬͯͨɻ • େྔʹॻ͖͑Δ͖ॴ͕͋Δɻ • ͱͯͭΒ͍ɻ 32
2.3 ⇒ 2 ഒʹ͍ͨ͠ʂ ग़ྗ͢ΔΞηϯϒϦΛ࠷దԽ͢Δɻ • ఆΈࠐΈ • a =
1 + 5 * 8 + 1; =⇒ a = 42; • AST Λ෦తʹΠϯλϓϦτ͢Ε ྑ͍ɻ 32
ଓɾ࠷దԽ • dead code elimination ҙຯͷͳ͍ίʔυੜ͠ͳ͍Α͏ʹ ͢Δɻ • propagation mov
(%rax), %r11 =⇒ mov -8(%rbp), %r11 Έ߹Θ͍͍ͤͯײ͡ʹ࠷దԽ͢Δɻ 33
݁Ռ 34
݁Ռ όάͬͨ 34
݁Ռ όάͬͨ seccamp ऴྃ 34
ؼΓͷ৽װઢ propagation ͷࡍʹϨδελͷґଘؔΛม ߋ͢Δ͜ͱΛΕ͍ͯͨɻ 35
ଓଓɾ࠷దԽ • ؔͷதͰ͍ͬͯΔϨδελ͚ͩΛ ୀආ͢Δ • r12, r13, r14, r15
callee-saved. • ؔ಄Ͱ push ͠ऴΘΓͰ pop. • શͯΛอଘ͢Δͱ͕͔͔࣌ؒΔɻ • ॻ͖͑Δͷ͚ͩͰྑ͍ɻ 36
ŰƅŲŔŖŵƃţ ࠷దԽͨ͠ aqcc(4fcc2d3) 37
ŰƅŲŔŖŵƃţ ࠷దԽͨ͠ aqcc(4fcc2d3) • gcc -O2 0.13015 ± 0.00126 seconds
• aqcc 0.24342 ± 0.00108 seconds 1.87 ഒ 37
Φν͕ͳ͍ 38
aqcc ͰίϯύΠϧ test.c ΛίϯύΠϧ͍ͨ͠ɻ % ./aqcc test.c > test.s •
ίϯύΠϧ 39
aqcc ͰίϯύΠϧ test.c ΛίϯύΠϧ͍ͨ͠ɻ % ./aqcc test.c > test.s •
ίϯύΠϧ % gcc -c test.s -o test.o • Ξηϯϒϧ % gcc test.o -o test all.o • ϦϯΫ 39
વͷؼ݁ 40
વͷؼ݁ ͦ͏ͩ ΞηϯϒϥΛ ͭ͘Ζ͏ 40
None
None
Ξηϯϒϥ
Ξηϯϒϥͭͬͨ͘ 43
Ξηϯϒϥͷͭ͘Γ͔ͨ 44
Ξηϯϒϥͷͭ͘Γ͔ͨ Δ͚ͩ 44
Ξηϯϒϥͱ ΞηϯϒϦΛΦϒδΣΫτϑΝΠϧʹม ͢Δɻ • χʔϞχοΫΛΦϖίʔυʹม ͢Δɻ • ඞཁͳγϯϘϧใͳͲΛ·ͱΊͯ ELF ʹ͢Δɻ
45
MOV ໋ྩ mov %eax, %edx 46
MOV ໋ྩ mov %eax, %edx =⇒ 89 c2 Opcode Instruction
89 /r MOV r/m32,r32 46
MOV ໋ྩ mov %eax, %edx =⇒ 89 c2 Opcode Instruction
89 /r MOV r/m32,r32 7 6 5 4 3 2 1 0 ModR/M mod reg r/m 1 1 0 0 0 0 1 0 46
MOV ໋ྩ mov %rax, %rdx 47
MOV ໋ྩ mov %rax, %rdx =⇒ 48 89 c2 Opcode
Instruction REX.W + 89 /r MOV r/m64,r64 47
MOV ໋ྩ mov %rax, %rdx =⇒ 48 89 c2 Opcode
Instruction REX.W + 89 /r MOV r/m64,r64 7 6 5 4 3 2 1 0 REX Prefix 0 1 0 0 W R X B 0 1 0 0 1 0 0 0 47
MOV ໋ྩ mov %r8, %r10 48
MOV ໋ྩ mov %r8, %r10 =⇒ 4d 89 c2 Opcode
Instruction REX.W + 89 /r MOV r/m64,r64 48
MOV ໋ྩ mov %r8, %r10 =⇒ 4d 89 c2 Opcode
Instruction REX.W + 89 /r MOV r/m64,r64 7 6 5 4 3 2 1 0 REX Prefix 0 1 0 0 W R X B 0 1 0 0 1 1 0 1 48
MOV ໋ྩ mov %eax, (%rdx) 49
MOV ໋ྩ mov %eax, (%rdx) =⇒ 89 02 7 6
5 4 3 2 1 0 ModR/M mod reg r/m 0 0 0 0 0 0 1 0 49
MOV ໋ྩ mov %eax, -4(%rdx) =⇒ 89 42 fc 7
6 5 4 3 2 1 0 ModR/M mod reg r/m 0 1 0 0 0 0 1 0 50
MOV ໋ྩ mov %eax, -4(%rbp) =⇒ 89 45 fc 7
6 5 4 3 2 1 0 ModR/M mod reg r/m 0 1 0 0 0 1 0 1 51
MOV ໋ྩ mov %eax, (%rbp) =⇒ 89 45 00 7
6 5 4 3 2 1 0 ModR/M mod reg r/m 0 1 0 0 0 1 0 1 52
MOV ໋ྩ mov %eax, -4(%rip) =⇒ 89 05 fc ff
ff ff 7 6 5 4 3 2 1 0 ModR/M mod reg r/m 0 0 0 0 0 1 0 1 53
·ͱΊ inst mod r/m code (%rdx) 00 010 89 02
-4(%rdx) 01 010 89 42 fc -4(%rbp) 01 101 89 45 fc (%rbp) 01 101 89 45 00 -4(%rip) 00 101 89 05 fc ff ff ff ͱͯͭΒ͍ɻ 54
MOV ໋ྩ mov %eax, -400(%r11) 55
MOV ໋ྩ mov %eax, -400(%r11) =⇒ 41 89 83 70
fe ff ff 7 6 5 4 3 2 1 0 ModR/M mod reg r/m 1 0 0 0 0 0 1 1 55
MOV ໋ྩ mov %eax, -400(%r11) =⇒ 41 89 83 70
fe ff ff mov %eax, -400(%r12) 56
MOV ໋ྩ mov %eax, -400(%r11) =⇒ 41 89 83 70
fe ff ff mov %eax, -400(%r12) =⇒ 41 89 84 24 70 fe ff ff 56
MOV ໋ྩ mov %eax, -400(%r11) =⇒ 41 89 83 70
fe ff ff mov %eax, -400(%r12) =⇒ 41 89 84 24 70 fe ff ff 7 6 5 4 3 2 1 0 SIB scale index base 0 0 1 0 0 1 0 0 56
MOV ໋ྩ mov %eax, -400(%r12) =⇒ 41 89 84 24
70 fe ff ff scale = 20 = 1 index = %rsp base = %r12 disp = -400 ͜ͷͱ͖ scale × index + base + disp 57
MOV ໋ྩ mov %eax, -400(%r12) =⇒ 41 89 84 24
70 fe ff ff scale = 20 = 1 index = %rsp base = %r12 disp = -400 ͜ͷͱ͖ scale × index + base + disp ͨͩ͠ index = %rsp =⇒ scale = 0 57
݁ہ n(%r12) ͷͱ͖ʹ 24 ΛຒΊࠐΊ͍͍ɻ if (mod == 2 &&
rm == 4) emit_byte(modrm(0, 4, 4)); ίϝϯτ͕ඞཁ 58
// ͜ͷߦΛফ͢ͱམͪΔɻ ΧʔΰɾΧϧτɾϓϩάϥϛϯάͱ ࣮ࡍͷతʹʹཱͨͳ͍ίʔυϓϩάϥϜ ߏΛّࣜతʹؚΊ͓ͯ͘ϓϩάϥϛϯάͷελ ΠϧͰ͋Δɻ(Wikipedia ΑΓൈਮ) 59
// ͜ͷߦΛফ͢ͱམͪΔɻ ΧʔΰɾΧϧτɾϓϩάϥϛϯάͱ ࣮ࡍͷతʹʹཱͨͳ͍ίʔυϓϩάϥϜ ߏΛّࣜతʹؚΊ͓ͯ͘ϓϩάϥϛϯάͷελ ΠϧͰ͋Δɻ(Wikipedia ΑΓൈਮ) // ... //
That ’s why this line is needed. // NOT CARGO CULT PROGRAMMING !! if (mod == 2 && rm == 4) emit_byte(modrm(0, 4, 4)); 59
ΞηϯϒϥͭΒ͍ • ELF ͔ΒΜɻ • gas Λײͤ͡͞Δίʔυɻ • aqcc ʹ
long ͕ແ͍ɻ emit qword( 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00); gas ͷग़ྗʰϦϯΧɾϩʔμ࣮ફ։ൃς ΫχοΫʱΛͱʹௐɻ 60
aqcc ͰίϯύΠϧʢ࠶ܝʣ test.c ΛίϯύΠϧ͍ͨ͠ɻ % ./aqcc test.c > test.s •
ίϯύΠϧ % gcc -c test.s -o test.o • Ξηϯϒϧ % gcc test.o -o test all.o • ϦϯΫ 61
aqcc ͰίϯύΠϧ test.c ΛίϯύΠϧ͍ͨ͠ɻ % ./aqcc test.c test.o • ίϯύΠϧ&Ξηϯϒϧ
% gcc test.o -o test all.o • ϦϯΫ 62
ࣗ໌ͳ༠ಋ 63
ࣗ໌ͳ༠ಋ ͦ͏ͩ ϦϯΧΛ ͭ͘Ζ͏ 63
None
None
ϦϯΧͭͬͨ͘ 66
ϦϯΧͭͬͨ͘ C ඪ४ϥΠϒϥϦ࡞ͬͨɻ 66
None
ͳʹͬͨͷ ϦϯΧΛॻ͖͔ͨͬͨɻ • ϦϯΧͷσβΠϯʰϦϯΧɾϩʔμ ࣮ફ։ൃςΫχοΫʱΛ͞Βʹ؆୯ʹ ͨ͠ͷɻ • glibc Α͘Θ͔ΒΜɻ •
aqcc Ͱ༻͢Δඪ४ϥΠϒϥϦؔ ߴʑ༗ݶݸɻ=⇒ Δ͚ͩ 68
malloc(3) Λ࣮ aqcc malloc() ͢Δ͕ free() ͠ͳ͍ɻ 69
malloc(3) Λ࣮ aqcc malloc() ͢Δ͕ free() ͠ͳ͍ɻ char *p
= brk (0); int size = 0x32000000; char *q = brk(p + size ); ... if (malloc_remaining_size < size) return NULL; 69
aqcc ͷϝϞϦޮ • ίϯύΠϧ͚ͩͳΒແɻ • ϦϯΫ͚ͩͳΒແɻ (e.g., lld) • ίϯύΠϧɾΞηϯϒϧɾϦϯΫͩͱ
ϝϞϦΛ৯ͬͯͭΒ͍ɻ Ͳ͏͢Δʁ 70
ݴྶ.in 71
໊ݴ ϗϯϞϊͷϓϩάϥϚͰ͋Γ·ͤΜ ͔Βɺ͚ͬͭࣄͰ͢ΑɻϗϯϞϊͷϓ ϩάϥϚɺ ʮಈ͍ͯΔΑ͏ʹݟ͑Δ͚Ͳɺ ϝϞϦϦʔΫͩΒ͚͡Όͳ͍͔ɻ͢ඞཁ ͕͋Δ͔ͶʯͳΜͯݴ͏Ͱ͠ΐ͏ʁ ͳΒɺ10 ϦΫΤετ͝ͱʹ
Apache Λ࠶ى ಈ͠·͢Ͷɻ 72
໊ݴ ϗϯϞϊͷϓϩάϥϚͰ͋Γ·ͤΜ ͔Βɺ͚ͬͭࣄͰ͢ΑɻϗϯϞϊͷϓ ϩάϥϚɺ ʮಈ͍ͯΔΑ͏ʹݟ͑Δ͚Ͳɺ ϝϞϦϦʔΫͩΒ͚͡Όͳ͍͔ɻ͢ඞཁ ͕͋Δ͔ͶʯͳΜͯݴ͏Ͱ͠ΐ͏ʁ ͳΒɺ10 ϦΫΤετ͝ͱʹ
Apache Λ࠶ى ಈ͠·͢Ͷɻ ʕʕ ϥεϚεɾϥʔυϑ (PHP ։ൃऀ) 72
ػೳΛׂ • ./aqcc cs main.c main.s ίϯύΠϧ • ./aqcc so
main.s main.o Ξηϯϒϧ • ./aqcc oe main.o main.exe ϦϯΫ खͰଧͭͷগʑ໘ɻ 73
γΣϧεΫϦϓτΛॻ͘ • ./aqcc main.c -o main.exe =⇒ ݸผͷػೳΛదٓݺͿɻ gcc ͬΆ͔͚͘Δʂ
74
·ͱΊ 75
·ͱΊ • ίϯύΠϥ =⇒ Δ͚ͩ 75
·ͱΊ • ίϯύΠϥ =⇒ Δ͚ͩ • Ξηϯϒϥ =⇒ Δ͚ͩ 75
·ͱΊ • ίϯύΠϥ =⇒ Δ͚ͩ • Ξηϯϒϥ =⇒ Δ͚ͩ •
ϦϯΧ =⇒ Δ͚ͩ 75
·ͱΊ • ίϯύΠϥ =⇒ Δ͚ͩ • Ξηϯϒϥ =⇒ Δ͚ͩ •
ϦϯΧ =⇒ Δ͚ͩ • ඪ४ϥΠϒϥϦ =⇒ Δ͚ͩ 75
·ͱΊ • ίϯύΠϥ =⇒ Δ͚ͩ • Ξηϯϒϥ =⇒ Δ͚ͩ •
ϦϯΧ =⇒ Δ͚ͩ • ඪ४ϥΠϒϥϦ =⇒ Δ͚ͩ ʊਓਓਓਓਓਓਓਓਓਓਓਓਓʊ ʼɹΔ͚ͩπʔϧνΣΠϯɹʻ ʉ Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y ʉ 75
͝ਗ਼ௌ ͋Γ͕ͱ͏͟͝ ͍·ͨ͠ɻ 76
ࢀߟจݙ • ʮ௨৴༻ޠͷجૅࣝʯ https://www.wdic.org/ • ʰϦϯΧɾϩʔμ࣮ફ։ൃςΫχοΫʱ ࡔҪ ߂྄ɺCQ ग़൛ࣾɺ2010 •
ݴྶ.in http://www.kotodama.in/ 77
ࢀߟจݙ • IntelR ⃝ 64 and IA-32 Architectures Software Developer
Manuals https://software.intel.com/ en-us/articles/intel-sdm • N1548 Committee Draft December 2, 2010 ISO/IEC 9899:201x http://www.open-std.org/jtc1/ sc22/wg14/www/docs/n1548.pdf 78