V8 学习笔记 0x00

Findkey Lv2

docker

先写 dockerfile

1
2
3
4
5
6
7
8
9
10
11
12
FROM ubuntu:22.04

RUN apt-get update && apt-get install -y \
git python3 python3-pip curl wget unzip clang cmake ninja-build \
build-essential pkg-config gnupg lsb-release vim gdb

ENV DEPOT_TOOLS=/opt/depot_tools
ENV PATH="$DEPOT_TOOLS:$PATH"

RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $DEPOT_TOOLS

WORKDIR /work

构建

1
docker build -t v8 .

挂载

1
2
3
4
5
6
7
docker run -it \
-v ./V8:/work \
-w /work \
--name finder \
--hostname work \
v8 \
bash

构建V8

来到工作目录,拉取源码

1
fetch v8

debug 构建

1
2
3
cd v8
tools/dev/v8gen.py x64.debug
ninja -C out.gn/x64.debug -j2 d8

如果对电脑性能有信心,可以把 -j2 参数改成 -j4 或者直接去掉。

no_pc 构建

debug 还是太麻烦了,指针压缩也可以暂时关掉

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cd v8
gn gen out/x64.release.no_pc --args='target_os = "linux"
target_cpu = "x64"
is_component_build = false
is_debug = false
v8_monolithic = true
v8_use_external_startup_data = false
symbol_level = 2
v8_enable_i18n_support= false
v8_enable_pointer_compression = false
v8_enable_backtrace = true
v8_enable_disassembler = true
v8_enable_object_print = true
v8_enable_verify_heap = true'
ninja -C out/x64.release.no_pc -j4 d8

gdb 配置

修改 .gdbinit

1
2
echo "source /home/key/Work/Pwn/Knowledges/V8/v8/tools/gdbinit" >> ~/.gdbinit
echo "source /home/key/Work/Pwn/Knowledges/V8/v8/tools/gdb-v8-support.py" >> ~/.gdbinit
  • Title: V8 学习笔记 0x00
  • Author: Findkey
  • Created at : 2026-04-20 20:35:05
  • Updated at : 2026-04-20 20:42:55
  • Link: https://find-key.github.io/2026/04/20/v8-learn-0/
  • License: This work is licensed under CC BY-NC-SA 4.0.