Working Backwards: An Adventure With Objdump and Strace
I was trying to figure out how a specific Linux utility worked. I will call this utility "util". I don't want to name anything specific, just in case ;). The company that made this utility have an SDK, but for the life of me, I couldn't see a mention in their documentation about how I could use an API to mimic util's functionality.
I didn't have access to the source or project files, so I couldn't look using the regular means. After much thinking, I thought that maybe I could work through it backwards using objdump and strace.
As I had mentioned in one of my earlier posts, strace is a Linux tool that can show us the system calls that are used by an executable. I wondered if the functionality of util that I was interested in was being implemented using ioctl calls. It turns out that it wasn't, but the beginning of the strace output gave me an interesting lead. I noticed that util was using a specific shared object that was not part of gcc or anything usually Linux related. I decided to look at the symbols listing of this mysterious shared object, using objdump: "objdump -dR libmystery.so". I noticed that there were symbols being exported with very interesting names - names that related to the functionality that I was trying to figure out.
I googled the name of the shared object library that util was using. I saw a changelog talking about my mystery library, and the changelog description mentioned the functionality that I was interested in. I was getting closer! Now I needed to figure out how I could use this shared object library. It turns out, after much (like a lot of) digging in google, I found out that the company who made the utility had just recently released the API for what I needed. I was in luck! I found the header file for the API, and tested it out using a small program that linked with the mystery library (the same one that util was using) - it worked.
I found it really interesting that the SDK documentation that they had didn't mention this API at all. But, at least I got to learn how to use objdump.