Created
April 28, 2017 12:56
-
-
Save evsasse/0cd5592aa166891fea6e1407d1d87184 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
gcc -E hello.c -o hello.i | |
gcc -S hello.i -o hello.s | |
gcc -c hello.i -o hello.o | |
``.rodata`` => read-only data | |
objdump -h hello.o => headers | |
objdump -t hello.o => tabela de simbolos | |
objdump -r hello.o => entradas de relocacao | |
objdump -D hello.o => assemblt de todas as sessoes | |
objdump -s hello.o => dados | |
objdump -s -j .rodata hello.o => dados apenas do sessao .rodata | |
ld -o hello hello.o -lc => linka o programa, usando libc | |
ld -static -o hello -L `gcc -print-file-name=` /usr/lib/crt1.o /usr/lib/crti.o hello.o /usr/lib/crtn.o -lc -lgcc | |
find /usr/lib -name crt1.o | |
ld -static -o hello -L `gcc -print-file-name=` /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o hello.o /usr/lib/x86_64-linux-gnu/crtn.o -lc -lgcc | |
ld -static -o hello -L `gcc -print-file-name=` /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o hello.o /usr/lib/x86_64-linux-gnu/crtn.o --start-group -lc -lgcc -lgcc_eh --end-group | |
./hello | |
objdump -hrt hello | |
strip hello | |
objdump -hrt hello | |
readelf -h hello | |
gdb hello | |
p main | |
p _start | |
x/x 0x400830 | |
disassemble _start | |
b _start | |
info registers | |
rip => instruction pointer | |
cs => code segment | |
ss => stack segment | |
... | |
disasseble main | |
b main => breakpoint no main | |
b *0x01230123 => breakpoint no endereco | |
stepi => step instruction |
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 main(){ | |
printf("Hello world!\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment