Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add demo on GOT (and PLT) analysis #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add demo on GOT (and PLT) analysis #1

wants to merge 1 commit into from

Conversation

razvand
Copy link
Owner

@razvand razvand commented Nov 29, 2020

There are two source code files (main.c and basket.c), a header file (basket.h) and a Makefile. The bascket.c file will be compiled into a shared library (libbasket.so). The main.c will be compiled and linked against the shared library, resulting in an executable main. We investigate the resulting files: the main executable and the libbasket.so library.

We used nm, objdump and readelf for static analysis and GDB for dynamic analysis.

@razvand razvand self-assigned this Nov 29, 2020
got-plt/README.md Outdated Show resolved Hide resolved
got-plt/README.md Outdated Show resolved Hide resolved
got-plt/README.md Outdated Show resolved Hide resolved
got-plt/README.md Outdated Show resolved Hide resolved
got-plt/README.md Outdated Show resolved Hide resolved
got-plt/README.md Outdated Show resolved Hide resolved
got-plt/README.md Outdated Show resolved Hide resolved
got-plt/README.md Outdated Show resolved Hide resolved
got-plt/README.md Outdated Show resolved Hide resolved
got-plt/README.md Outdated Show resolved Hide resolved
got-plt/README.md Outdated Show resolved Hide resolved
got-plt/README.md Outdated Show resolved Hide resolved
Starting program: /home/razvan/projects/snippets.git/got-plt/nostdlib/main

Temporary breakpoint 1, 0x0000555555554395 in main ()
(gdb) maint info sections

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this command displays something and it's confusing because here it looks like it shouldn't display anything
tbh, I would remove it; or if you want to present both options, add the output for both

391: 55 push rbp
392: 48 89 e5 mov rbp,rsp
395: e8 d6 ff ff ff call 370 <flowers@plt>
39a: e8 d1 ff ff ff call 370 <flowers@plt>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basket.c doesn't disassemble into this, there is only one flower() call in the main function

0x0000555555554391 <+0>: push rbp
0x0000555555554392 <+1>: mov rbp,rsp
0x0000555555554395 <+4>: call 0x555555554370 <flowers@plt>
=> 0x000055555555439a <+9>: call 0x555555554370 <flowers@plt>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing as above

### Nice to Know

The lazy binding feature of the loader can be disabled by using the `-z now` linker option.
In that case, function addresses will be resolved at load time, and the `.got.plt` entries will be populated from the start with the actual addresses.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/start/beginning so there is no confusion with the start method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants