Last active
July 7, 2024 01:36
-
-
Save user202729/f5077701ed789d2cc50ea11d0ae998d5 to your computer and use it in GitHub Desktop.
This file contains 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
/a.o | |
/b.o | |
/c.o | |
/program |
This file contains 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
inline int f() { | |
asm( | |
".weak abc\n" | |
"abc: nop\n" | |
".pushsection CUSTOM, \"aw\"\n" | |
".quad abc\n" | |
".quad 0x0123456789abcdef\n" | |
".popsection" | |
); | |
return 1; | |
} | |
int g() { return f(); } |
This file contains 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
inline int f() { | |
asm( | |
".weak abc\n" | |
"abc: nop\n" | |
".pushsection CUSTOM, \"aw\"\n" | |
".quad abc\n" | |
".quad 0x0123456789abcdef\n" | |
".popsection" | |
); | |
return 1; | |
} | |
int h() { return f(); } |
This file contains 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
#!/bin/bash | |
set -e -x | |
g++ -fPIC a.cpp -c -o a.o | |
g++ -fPIC b.cpp -c -o b.o | |
ld -relocatable a.o b.o -o c.o | |
g++ main.cpp c.o -o program | |
./program | |
exit | |
objdump -D --reloc c.o | |
objdump -D --reloc a.o |
This file contains 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> | |
int g(); | |
int h(); | |
int main(){ | |
printf("%d %d\n", g(), h()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment