Skip to content

Commit fff8aa3

Browse files
authored
Merge pull request #40 from byeongkeunahn/main
Shorten the generated code with `./release-rs.sh --features short`
2 parents 2a2663a + a3dadbc commit fff8aa3

37 files changed

+873
-145
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"arch": "x86_64",
3+
"cpu": "x86-64",
4+
"crt-objects-fallback": "false",
5+
"crt-static-respected": true,
6+
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
7+
"dynamic-linking": true,
8+
"eh-frame-header": false,
9+
"env": "gnu",
10+
"has-rpath": true,
11+
"has-thread-local": true,
12+
"is-builtin": false,
13+
"linker-flavor": "gnu-cc",
14+
"llvm-target": "x86_64-unknown-linux-gnu",
15+
"max-atomic-width": 64,
16+
"os": "linux",
17+
"plt-by-default": false,
18+
"position-independent-executables": true,
19+
"pre-link-args": {
20+
"gnu-cc": [
21+
"-m64"
22+
],
23+
"gnu-lld-cc": [
24+
"-m64"
25+
]
26+
},
27+
"relro-level": "off",
28+
"stack-probes": {
29+
"kind": "none"
30+
},
31+
"static-position-independent-executables": true,
32+
"supported-sanitizers": [
33+
"address",
34+
"cfi",
35+
"leak",
36+
"memory",
37+
"thread",
38+
"safestack"
39+
],
40+
"supported-split-debuginfo": [
41+
"packed",
42+
"unpacked",
43+
"off"
44+
],
45+
"supports-xray": true,
46+
"target-family": [
47+
"unix"
48+
],
49+
"target-pointer-width": "64"
50+
}

.github/workflows/build-linux.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
with:
2929
toolchain: nightly
3030
target: ${{ matrix.target }}
31-
profile: minimal
31+
profile: default
3232
override: true
3333
components: clippy
3434
- name: Install node.js
@@ -39,6 +39,7 @@ jobs:
3939
run: |
4040
sudo apt update
4141
sudo apt install gcc-multilib nasm
42+
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
4243
- name: Clippy
4344
run: cargo clippy
4445
env:
@@ -53,15 +54,27 @@ jobs:
5354
run: |
5455
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release.sh C 64 ./src/solution.rs ./tests/boj_1000.in ./tests/boj_1000.out
5556
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release.sh C 64 ./tests/boj_1001.rs ./tests/boj_1001.in ./tests/boj_1001.out
57+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release.sh C 64 ./tests/boj_2587.rs ./tests/boj_2587.in ./tests/boj_2587.out
5658
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release.sh C 64 ./tests/boj_2751.rs ./tests/boj_2751.in.zip ./tests/boj_2751.out.zip
5759
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release.sh C 64 ./tests/boj_3745.rs ./tests/boj_3745.in ./tests/boj_3745.out
5860
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release.sh C 64 ./tests/boj_14939.rs ./tests/boj_14939.in ./tests/boj_14939.out
5961
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release.sh C 64 ./tests/reloc.rs ./tests/reloc.in ./tests/reloc.out
62+
- name: Check C (x86_64) - short
63+
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }}
64+
run: |
65+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./.github/workflows/release-short.sh C 64 ./src/solution.rs ./tests/boj_1000.in ./tests/boj_1000.out
66+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./.github/workflows/release-short.sh C 64 ./tests/boj_1001.rs ./tests/boj_1001.in ./tests/boj_1001.out
67+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./.github/workflows/release-short.sh C 64 ./tests/boj_2587.rs ./tests/boj_2587.in ./tests/boj_2587.out
68+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./.github/workflows/release-short.sh C 64 ./tests/boj_2751.rs ./tests/boj_2751.in.zip ./tests/boj_2751.out.zip
69+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./.github/workflows/release-short.sh C 64 ./tests/boj_3745.rs ./tests/boj_3745.in ./tests/boj_3745.out
70+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./.github/workflows/release-short.sh C 64 ./tests/boj_14939.rs ./tests/boj_14939.in ./tests/boj_14939.out
71+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./.github/workflows/release-short.sh C 64 ./tests/reloc.rs ./tests/reloc.in ./tests/reloc.out
6072
- name: Check C (x86)
6173
if: ${{ matrix.target == 'i686-unknown-linux-gnu' }}
6274
run: |
6375
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-32bit.sh C 32 ./src/solution.rs ./tests/boj_1000.in ./tests/boj_1000.out
6476
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-32bit.sh C 32 ./tests/boj_1001.rs ./tests/boj_1001.in ./tests/boj_1001.out
77+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-32bit.sh C 32 ./tests/boj_2587.rs ./tests/boj_2587.in ./tests/boj_2587.out
6578
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-32bit.sh C 32 ./tests/boj_2751.rs ./tests/boj_2751.in.zip ./tests/boj_2751.out.zip
6679
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-32bit.sh C 32 ./tests/boj_3745.rs ./tests/boj_3745.in ./tests/boj_3745.out
6780
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-32bit.sh C 32 ./tests/boj_14939.rs ./tests/boj_14939.in ./tests/boj_14939.out
@@ -71,15 +84,27 @@ jobs:
7184
run: |
7285
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-rs.sh Rust 64 ./src/solution.rs ./tests/boj_1000.in ./tests/boj_1000.out
7386
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-rs.sh Rust 64 ./tests/boj_1001.rs ./tests/boj_1001.in ./tests/boj_1001.out
87+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-rs.sh Rust 64 ./tests/boj_2587.rs ./tests/boj_2587.in ./tests/boj_2587.out
7488
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-rs.sh Rust 64 ./tests/boj_2751.rs ./tests/boj_2751.in.zip ./tests/boj_2751.out.zip
7589
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-rs.sh Rust 64 ./tests/boj_3745.rs ./tests/boj_3745.in ./tests/boj_3745.out
7690
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-rs.sh Rust 64 ./tests/boj_14939.rs ./tests/boj_14939.in ./tests/boj_14939.out
7791
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-rs.sh Rust 64 ./tests/reloc.rs ./tests/reloc.in ./tests/reloc.out
92+
- name: Check Rust (x86_64) - short
93+
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }}
94+
run: |
95+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./.github/workflows/release-rs-short.sh Rust 64 ./src/solution.rs ./tests/boj_1000.in ./tests/boj_1000.out
96+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./.github/workflows/release-rs-short.sh Rust 64 ./tests/boj_1001.rs ./tests/boj_1001.in ./tests/boj_1001.out
97+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./.github/workflows/release-rs-short.sh Rust 64 ./tests/boj_2587.rs ./tests/boj_2587.in ./tests/boj_2587.out
98+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./.github/workflows/release-rs-short.sh Rust 64 ./tests/boj_2751.rs ./tests/boj_2751.in.zip ./tests/boj_2751.out.zip
99+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./.github/workflows/release-rs-short.sh Rust 64 ./tests/boj_3745.rs ./tests/boj_3745.in ./tests/boj_3745.out
100+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./.github/workflows/release-rs-short.sh Rust 64 ./tests/boj_14939.rs ./tests/boj_14939.in ./tests/boj_14939.out
101+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./.github/workflows/release-rs-short.sh Rust 64 ./tests/reloc.rs ./tests/reloc.in ./tests/reloc.out
78102
- name: Check wasm32
79103
if: ${{ matrix.target == 'wasm32-unknown-unknown' }}
80104
run: |
81105
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-wasm32.sh JavaScript 32 ./src/solution.rs ./tests/boj_1000.in ./tests/boj_1000.out
82106
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-wasm32.sh JavaScript 32 ./tests/boj_1001.rs ./tests/boj_1001.in ./tests/boj_1001.out
107+
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-wasm32.sh JavaScript 32 ./tests/boj_2587.rs ./tests/boj_2587.in ./tests/boj_2587.out
83108
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-wasm32.sh JavaScript 32 ./tests/boj_2751.rs ./tests/boj_2751.in.zip ./tests/boj_2751.out.zip
84109
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-wasm32.sh JavaScript 32 ./tests/boj_3745.rs ./tests/boj_3745.in ./tests/boj_3745.out
85110
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-wasm32.sh JavaScript 32 ./tests/boj_14939.rs ./tests/boj_14939.in ./tests/boj_14939.out

.github/workflows/build-windows.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ jobs:
5555
run: |
5656
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows.cmd C 64 .\src\solution.rs .\tests\boj_1000.in .\tests\boj_1000.out
5757
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows.cmd C 64 .\tests\boj_1001.rs .\tests\boj_1001.in .\tests\boj_1001.out
58+
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows.cmd C 64 .\tests\boj_2587.rs .\tests\boj_2587.in .\tests\boj_2587.out
5859
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows.cmd C 64 .\tests\boj_2751.rs .\tests\boj_2751.in.zip .\tests\boj_2751.out.zip
5960
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows.cmd C 64 .\tests\boj_3745.rs .\tests\boj_3745.in .\tests\boj_3745.out
6061
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows.cmd C 64 .\tests\boj_14939.rs .\tests\boj_14939.in .\tests\boj_14939.out
@@ -64,6 +65,7 @@ jobs:
6465
run: |
6566
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows-rs.cmd Rust 64 .\src\solution.rs .\tests\boj_1000.in .\tests\boj_1000.out
6667
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows-rs.cmd Rust 64 .\tests\boj_1001.rs .\tests\boj_1001.in .\tests\boj_1001.out
68+
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows-rs.cmd Rust 64 .\tests\boj_2587.rs .\tests\boj_2587.in .\tests\boj_2587.out
6769
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows-rs.cmd Rust 64 .\tests\boj_2751.rs .\tests\boj_2751.in.zip .\tests\boj_2751.out.zip
6870
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows-rs.cmd Rust 64 .\tests\boj_3745.rs .\tests\boj_3745.in .\tests\boj_3745.out
6971
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows-rs.cmd Rust 64 .\tests\boj_14939.rs .\tests\boj_14939.in .\tests\boj_14939.out
@@ -73,6 +75,7 @@ jobs:
7375
run: |
7476
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-wasm32.cmd JavaScript 32 .\src\solution.rs .\tests\boj_1000.in .\tests\boj_1000.out
7577
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-wasm32.cmd JavaScript 32 .\tests\boj_1001.rs .\tests\boj_1001.in .\tests\boj_1001.out
78+
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-wasm32.cmd JavaScript 32 .\tests\boj_2587.rs .\tests\boj_2587.in .\tests\boj_2587.out
7679
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-wasm32.cmd JavaScript 32 .\tests\boj_2751.rs .\tests\boj_2751.in.zip .\tests\boj_2751.out.zip
7780
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-wasm32.cmd JavaScript 32 .\tests\boj_3745.rs .\tests\boj_3745.in .\tests\boj_3745.out
7881
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-wasm32.cmd JavaScript 32 .\tests\boj_14939.rs .\tests\boj_14939.in .\tests\boj_14939.out

.github/workflows/release-rs-short.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./release-rs.sh --features short

.github/workflows/release-short.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./release.sh --features short

.vscode/tasks.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
"$rustc"
2828
],
2929
},
30+
{
31+
"label": "build-release-amd64-short-submit",
32+
"type": "shell",
33+
"command": "mkdir -p ./target/x86_64-unknown-linux-gnu-short/release; ./release.sh --features short > ./target/x86_64-unknown-linux-gnu-short/release/loader.c; code --reuse-window ./target/x86_64-unknown-linux-gnu-short/release/loader.c",
34+
"problemMatcher": [
35+
"$rustc"
36+
],
37+
},
3038
{
3139
"label": "build-release-amd64-rs-submit",
3240
"type": "shell",
@@ -35,6 +43,14 @@
3543
"$rustc"
3644
],
3745
},
46+
{
47+
"label": "build-release-amd64-rs-short-submit",
48+
"type": "shell",
49+
"command": "mkdir -p ./target/x86_64-unknown-linux-gnu-short/release; ./release-rs.sh --features short > ./target/x86_64-unknown-linux-gnu-short/release/loader.rs; code --reuse-window ./target/x86_64-unknown-linux-gnu-short/release/loader.rs",
50+
"problemMatcher": [
51+
"$rustc"
52+
],
53+
},
3854
{
3955
"label": "build-release-i686-submit",
4056
"type": "shell",

Cargo.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,21 @@ bench = false
2424
path = "src/bin/basm-submit.rs"
2525

2626
[dependencies]
27-
compiler_builtins = { version = "0.1.101", features = ["mem"] }
2827
libm = "0.2.7"
2928
ryu = "1.0"
3029

30+
[target.x86_64-pc-windows-msvc.dependencies]
31+
compiler_builtins = { version = "0.1.103", features = ["mem"] }
32+
[target.x86_64-unknown-linux-gnu.dependencies]
33+
compiler_builtins = { version = "0.1.103", features = ["mem"] }
34+
[target.i686-unknown-linux-gnu.dependencies]
35+
compiler_builtins = { version = "0.1.103", features = ["mem"] }
36+
[target.wasm32-unknown-unknown.dependencies]
37+
compiler_builtins = { version = "0.1.103", features = ["mem"] }
38+
39+
[features]
40+
short = []
41+
3142
[profile.dev]
3243
panic = "abort"
3344

build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn main() {
1818
link_args_basm.push("/EMITPOGOPHASEINFO");
1919
link_args_basm_submit.push("/ALIGN:128");
2020
},
21-
"x86_64-unknown-linux-gnu" | "i686-unknown-linux-gnu" => {
21+
"x86_64-unknown-linux-gnu" | "x86_64-unknown-linux-gnu-short" | "i686-unknown-linux-gnu" => {
2222
link_args_basm.push("-nostartfiles");
2323
link_args_basm.push("-nostdlib");
2424
link_args_basm.push("-static-pie");
@@ -27,12 +27,12 @@ fn main() {
2727
link_args_basm.push("-fno-unwind-tables");
2828
link_args_basm.push("-fno-stack-protector");
2929
link_args_basm.push("-fno-plt");
30-
if target == "x86_64-unknown-linux-gnu" {
31-
link_args_basm.push("-Wl,--build-id=none,--gc-sections,--no-eh-frame-hdr,-z,norelro");
32-
} else {
30+
if target == "i686-unknown-linux-gnu" {
3331
// Prevent linker from putting data into text, which is non-writable and hence not relocatable.
3432
// This prevents the hack for getting the _DYNAMIC symbol in the entrypoint.
3533
link_args_basm.push("-Wl,--build-id=none,--gc-sections,--no-eh-frame-hdr,-z,norelro,-z,notext");
34+
} else {
35+
link_args_basm.push("-Wl,--build-id=none,--gc-sections,--no-eh-frame-hdr,-z,norelro");
3636
}
3737
link_args_basm_submit.push("-Wl,-z,max-page-size=128");
3838
},

release-html.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
>&2 echo "Building project for target wasm32-unknown-unknown, language JavaScript, build mode Release"
22
cargo +nightly build --target wasm32-unknown-unknown --bin=basm-submit --release "$@"
3-
python scripts/wasm-gen.py scripts/wasm-template.html
3+
python3 scripts/wasm-gen.py scripts/wasm-template.html

release-wasm32.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
>&2 echo "Building project for target wasm32-unknown-unknown, language JavaScript, build mode Release"
22
cargo +nightly build --target wasm32-unknown-unknown --bin=basm-submit --release "$@"
3-
python scripts/wasm-gen.py scripts/wasm-template.js
3+
python3 scripts/wasm-gen.py scripts/wasm-template.js

scripts/base91.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
1-
def encode(x):
1+
def encode(x_in, use_rle=False):
2+
sharp_insertion_points = []
3+
if use_rle:
4+
current_bits, current_bytes, i = 0, 0, 0
5+
x = bytearray()
6+
while i < len(x_in):
7+
current_bits += 13
8+
while current_bytes < current_bits // 8:
9+
if i >= len(x_in):
10+
break
11+
x.append(x_in[i])
12+
current_bytes += 1
13+
i += 1
14+
if len(x) > 0 and x[-1] == 0:
15+
zeros_cnt = 1
16+
while i - 1 + zeros_cnt < len(x_in) and zeros_cnt < 256 and x_in[i - 1 + zeros_cnt] == 0:
17+
zeros_cnt += 1
18+
if zeros_cnt >= 2:
19+
x.pop()
20+
x.append(zeros_cnt - 1)
21+
sharp_insertion_points.append((current_bits // 13 * 2) + len(sharp_insertion_points))
22+
i += zeros_cnt - 1
23+
sharp_insertion_points = list(reversed(sharp_insertion_points))
24+
else:
25+
x = x_in
26+
227
out = []
328
i = 0
429
cnt5, stack5 = 0, []
@@ -21,11 +46,14 @@ def encode(x):
2146
if bits < 13:
2247
stack5.append((pos, bits))
2348
cnt5 -= 8
24-
ret = bytearray(2 * len(out) + 1)
25-
for i in range(len(out)):
26-
ret[2 * i + 0] = 0x24 + (out[i] % 91)
27-
ret[2 * i + 1] = 0x24 + (out[i] // 91)
28-
ret[-1] = ord('!')
49+
ret = bytearray()
50+
for pack in out:
51+
ret.append(0x24 + (pack % 91))
52+
ret.append(0x24 + (pack // 91))
53+
if len(sharp_insertion_points) > 0 and len(ret) == sharp_insertion_points[-1]:
54+
ret.append(ord(b'#'))
55+
sharp_insertion_points.pop()
56+
ret.append(ord(b'!'))
2957
return bytes(ret)
3058

3159
if __name__ == '__main__':

scripts/static-pie-elf2bin.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,28 @@ def load_elf64(elf):
160160
continue # since bytearray is zero-initialized
161161

162162
dst_off, src_off, cnt = sh_dict['sh_addr'], sh_dict['sh_offset'], sh_dict['sh_size']
163-
memory_bin[dst_off:dst_off+cnt] = elf[src_off:src_off+cnt]
163+
blob = elf[src_off:src_off+cnt]
164+
165+
if sh_dict['sh_type'] == SHT_DYNAMIC:
166+
# Trim the DYNAMIC section, leaving only relocation-related entries
167+
# 16 == sizeof(Elf64_Dyn)
168+
dst = 0
169+
for src in range(0, len(blob), 16):
170+
# Included entries:
171+
# DT_PLTRELSZ = 2, DT_RELA = 7, DT_RELASZ = 8, DT_RELAENT = 9,
172+
# DT_REL = 17, DT_RELSZ = 18, DT_RELENT = 19, DT_PLTREL = 20,
173+
# DT_TEXT_REL = 22, DT_JMPREL = 23.
174+
#
175+
# Note: DT_RELACOUNT = 0x6fff_fff9 and DT_RELCOUNT = 0x6fff_fffa
176+
# are not included since they are redundant since
177+
# DT_RELACOUNT = DT_RELASZ/DT_RELAENT and
178+
# DT_RELCOUNT = DT_RELSZ/DT_RELENT.
179+
if b2i(blob[src:src+8]) in [2, 7, 8, 9, 17, 18, 19, 20, 22, 23]:
180+
blob[dst:dst+16] = blob[src:src+16]
181+
dst += 16
182+
blob[dst:] = bytearray(len(blob[dst:])) # fill remaining part with zeros
183+
184+
memory_bin[dst_off:dst_off+cnt] = blob
164185

165186
entrypoint_offset = b2i(elf[24:32])
166187
return memory_bin, pos_begin, entrypoint_offset

0 commit comments

Comments
 (0)