Last active
August 11, 2023 04:18
-
-
Save justinian/ed2b2b850051135a51a3d38888935f20 to your computer and use it in GitHub Desktop.
Clang and _GLOBAL_OFFSET_TABLE_
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
| unsigned long SOME_GLOBAL = 123; |
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
| extern unsigned long _GLOBAL_OFFSET_TABLE_ []; | |
| extern unsigned long SOME_GLOBAL; | |
| int main() { | |
| auto foo1 = reinterpret_cast<unsigned long*>(&_GLOBAL_OFFSET_TABLE_); | |
| auto foo2 = reinterpret_cast<unsigned long*>( _GLOBAL_OFFSET_TABLE_); | |
| auto bar1 = &SOME_GLOBAL; | |
| auto bar2 = reinterpret_cast<unsigned long*>(SOME_GLOBAL); | |
| 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
| #CC = /home/justin/.local/lib/jsix/toolchains/llvm-13/bin/clang++ | |
| #LD = /home/justin/.local/lib/jsix/toolchains/llvm-13/bin/ld.lld | |
| #CC = g++ | |
| #LD = ld | |
| #CC = clang++-13 | |
| #LD = clang++-13 | |
| #LD = ld.lld-13 | |
| CC = clang++-16 | |
| LD = ld.lld-16 | |
| got: foo.o bar.o | |
| ${LD} -pie -o $@ $^ | |
| %.o: %.cpp | |
| ${CC} -c -g -fpie -o $@ $^ | |
| dump: got | |
| ${CC} --version | |
| objdump -M intel -DS -j .text $^ | |
| clean: | |
| -rm *.o got | |
| .PHONY: rip clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment