I've been thinking about this for a while because I've observed that even really fundamental libraries like libc have a GOT/PLT, consisting of important functionality such as malloc() and its friends.
Is it even possible to create a shared library that has no GOT/PLT? Would such a library ever crop up in the wild, outside of an academic exercise? (If it helps, consider exclusively the x86 platform)
My gut tells me the answers to those questions are "no" and "yes" respectively, but I'm not 100% certain on either.
Is it possible that a .so file that just contains a list of C types won't have a GOT/PLT? Maybe, but I can't understand why that would occur in practice when you can just #include a .h file to do that!
I wound up finding an answer to the second part of the question, and it seems to be "no". I have just under 5500 .so files in my /lib directory, and I ran the following shell script, called
sotest.sh
:I then ran
./sotest.sh | grep "HAS NO PLT SECTION"
. I did have some results, but all were .a files and none were .so files.So, in practice, it doesn't seem like you will ever run across a .so file without a PLT/GOT in the wild. I'm still curious if it's possible in theory, but I found the answer to the practical side of my question, so I thought it could help others who were wondering the same thing!