Files
Kevin Thomas 6a9090915b Initial commit
2026-07-06 21:23:12 -04:00

74 lines
3.5 KiB
XML

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
<style>
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
.dim{font:20px 'Courier New',monospace;fill:#888}
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
.badge{stroke:#00ff41;rx:14}
</style>
<rect class="bg" width="1200" height="800"/>
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
<text class="title" x="600" y="52" text-anchor="middle">Struct Flattening</text>
<text class="dim" x="600" y="88" text-anchor="middle">How Compilers Transform Structs</text>
<!-- C Level -->
<rect class="pnl" x="30" y="110" width="555" height="220" rx="8"/>
<text class="sub" x="50" y="150">C Code (High Level)</text>
<rect x="50" y="168" width="515" height="140" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
<text class="cyn" x="70" y="198">gpio_init(leds.led1_pin);</text>
<text class="dim" x="70" y="225">// leds.led1_pin = 16</text>
<text class="cyn" x="70" y="258">gpio_init(leds.led2_pin);</text>
<text class="dim" x="70" y="285">// leds.led2_pin = 17</text>
<!-- Assembly Level -->
<rect class="pnl" x="615" y="110" width="555" height="220" rx="8"/>
<text class="sub" x="635" y="150">Assembly (Flattened)</text>
<rect x="635" y="168" width="515" height="140" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
<text class="grn" x="655" y="198">movs r0, #0x10</text>
<text class="dim" x="900" y="198">// 16</text>
<text class="txt" x="655" y="225">bl gpio_init</text>
<text class="grn" x="655" y="258">movs r0, #0x11</text>
<text class="dim" x="900" y="258">// 17</text>
<text class="txt" x="655" y="285">bl gpio_init</text>
<!-- The Key Insight -->
<rect class="pnl" x="30" y="350" width="1140" height="130" rx="8"/>
<text class="sub" x="50" y="390">The Key Insight</text>
<text class="red" x="50" y="425">Struct abstraction DISAPPEARS</text>
<text class="txt" x="520" y="425">at assembly level</text>
<text class="dim" x="50" y="455">You see individual values (16, 17, 18) not struct names</text>
<!-- Struct Member Mapping -->
<rect class="pnl" x="30" y="500" width="1140" height="260" rx="8"/>
<text class="sub" x="50" y="540">Struct Member Mapping</text>
<text class="amb" x="50" y="575">Assembly</text>
<text class="amb" x="280" y="575">Struct Member</text>
<text class="amb" x="560" y="575">Physical</text>
<text class="amb" x="800" y="575">NEC Code</text>
<line x1="50" y1="585" x2="1140" y2="585" stroke="#1a1a2e" stroke-width="1"/>
<text class="grn" x="50" y="615">0x10 (16)</text>
<text class="txt" x="280" y="615">led1_pin</text>
<text class="red" x="560" y="615">Red LED</text>
<text class="cyn" x="800" y="615">0x0C</text>
<text class="grn" x="50" y="645">0x11 (17)</text>
<text class="txt" x="280" y="645">led2_pin</text>
<text class="grn" x="560" y="645">Green LED</text>
<text class="cyn" x="800" y="645">0x18</text>
<text class="grn" x="50" y="675">0x12 (18)</text>
<text class="txt" x="280" y="675">led3_pin</text>
<text class="amb" x="560" y="675">Yellow LED</text>
<text class="cyn" x="800" y="675">0x5E</text>
<text class="dim" x="50" y="710">Sequential values (16,17,18) reveal the struct pattern</text>
<text class="dim" x="50" y="735">Recognize patterns to reconstruct original structs in Ghidra</text>
</svg>