I want to get the address of _GLOBAL_OFFSET_TABLE_ in my program. One way is to use the nm command in Linux, maybe redirect the output to a file and parse that file to get address of _GLOBAL_OFFSET_TABLE_. However, that method seems to be quite inefficient. What are some more efficient methods of doing it?
相关问题
- Multiple sockets for clients to connect to
- Is shmid returned by shmget() unique across proces
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- how to get running process information in java?
This appears to work:
It gives:
However,
nm
thinks different:If you use assembly language, you can get
_GLOBAL_OFFSET_TABLE_
address withoutget_pc_thunk
.It is tricky way. :)
Here is the sample code :
This is available because
.got
section is adjacent to the<.got.plt>
Therefore the symbol
HEREIS
and_GLOBAL_OFFSET_TABLE_
locate at same address.PS. You can check it works with objdump.