# Debian のlibc, libstdc++にdebug symbolをつける方法
## libc
https://ftp.tsukuba.wide.ad.jp/Linux/debian/pool/main/g/glibc から`libc-dbg`を取ってくる
以下`libc6-dbg_2.36-9+deb12u13_amd64.deb`を例にとる
1. 展開する
```sh
ar x libc6-dbg_2.36-9+deb12u13_amd64.deb
tar -xvf data.tar.xz
```
2. BuildIDを取ってくる
```
$ file libc.so.6
libc.so.6: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=6196744a316dbd57c0fd8968df1680aac482cec4, for GNU/Linux 3.2.0, stripped
```
今回は`6196744a316dbd57c0fd8968df1680aac482cec4`
3. unstripする
```
mv usr/lib/debug/.build-id/61/96744a316dbd57c0fd8968df1680aac482cec4.debug .
eu-unstrip libc.so.6 96744a316dbd57c0fd8968df1680aac482cec4.debug
mv 96744a316dbd57c0fd8968df1680aac482cec4.debug libc.so.6.unstrip
```
4. `cannot find matching section for`といわれたら
```
set debug-file-directory ./usr/lib/debug/.build-id/
set substitute-path ../../../../src/ /path/to/gcc/
```
## libstdc++
`strings libstdc++.so.6`をして以下の文字列を探す
```
{"type":"deb","os":"debian","name":"gcc-14","version":"14.2.0-19","architecture":"amd64"}
```
見つけたら以下から`libstdc++6-14-dbg_14.2.0-19_amd64.deb`とかをダウンロードする
https://ftp.tsukuba.wide.ad.jp/Linux/debian/pool/main/g/gcc-14
libcのように展開して`usr/lib/x86_64-linux-gnu/debug/libstdc++.so.6`を取ってくる
## libgcc
http://deb.debian.org/debian-debug/pool/main/g/gcc-14/libgcc-s1-dbgsym_14.2.0-19_amd64.deb からdebを取ってくる
```
set substitute-path ../../../src/ /home/rona/me/ctf/gcc/
```