Last active
June 3, 2025 13:24
-
-
Save Na0ki/1f541bfb12956d5c56002f2bb40007a1 to your computer and use it in GitHub Desktop.
patchelfの挙動確認するのに使った色々
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| services: | |
| task: | |
| build: | |
| context: . | |
| dockerfile: Dockerfile.patchelfpoc | |
| tty: true | |
| stdin_open: true | |
| working_dir: /working_dir | |
| command: /bin/bash | |
| volumes: | |
| - ./src:/working_dir |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM debian:bookworm | |
| RUN apt-get update | |
| RUN apt-get install -y gcc g++ make software-properties-common curl wget vim patchelf file | |
| RUN apt-get clean && rm -rf /var/lib/apt/lists/* | |
| CMD ["/bin/bash"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void func(); | |
| int main() { | |
| func(); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| build: | |
| gcc -c -o main.o main.c | |
| gcc -fPIC -shared -o libmylib1.so mylib1.c | |
| gcc -fPIC -shared -o libmylib2.so mylib2.c | |
| gcc -o main main.c -L. -lmylib1 -Wl,-rpath,. | |
| link2: | |
| patchelf --add-needed ./libmylib2.so main | |
| read: | |
| readelf -d main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| void func(void) { | |
| printf("Hello World!\n"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| void func(void) { | |
| printf("Bye World!\n"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment