失业在家写写lab练手,懒得配环境,参考这个仓库直接docker pull!非常方便,就是镜像有点大。
顺利写了data lab.然而bomb里用gdb run,我的电脑是m1 mac arm64,拉的镜像是amd64:

1
2
3
4
5
6
7
8
9
10
(gdb) run
Starting program: /home/csapp/project/bomb/bomb
warning: Error disabling address space randomization: Operation not permitted
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
[New LWP 352]
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
[LWP 352 exited]
[Inferior 1 (process 349) exited with code 0377]

报错了,怎么会是🤯
docker run加上--security-opt seccomp=unconfined,参考这里

再用gdb调试,还是报错。

1
2
3
4
5
(gdb) run
Starting program: /home/csapp/project/bomb/bomb
warning: Could not trace the inferior process.
warning: ptrace: Function not implemented
During startup program exited with code 127.

arm64的机器上跑amd64 ubuntu,qemu没法直接用gdb,可以参考qemu的GDB usage文档。我试了,没成功,container运行的时候就打开了qemu,不会,只能重新打个amd64的image。

修改Dockerfile
ARG arch_name=arm64
注意code-server的url需要更新到https://github.com/coder/code-server/releases/download/v4.8.1/code-server

这样就是arm64的环境了,然而还是报错

1
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory

装个libc6-amd64-cross就好了,参考这里,Dockerfile里加上

1
2
3
4
5
6
RUN apt-get install -y wget unzip
RUN apt-get install -y libc6-amd64-cross

RUN ln -s /usr/x86_64-linux-gnu/lib64/ /lib64

ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/lib64:/usr/x86_64-linux-gnu/lib"

虽然gdb还是会报错,不过终于能run起来了。搞了一天,docker build太慢了= =

1
warning: `/lib64/ld-linux-x86-64.so.2': Shared library architecture unknown is not compatible with target architecture aarch64.