Retrieve source file names in binary executable or library
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Debugging using gdb or something like strace? See the thing is this is harder than it looks. The reason is that unless the maintainers in the source used descriptive functional names in their libraries and calls, or descriptive hard coded strings in the compiled binary there's no way to find source file names. However, a lot of programs you can find this kind of information. Learn how to use a disassembler (special program to view binary files) and you might find the information that you seek. A reverse engineering forum might be better able to help you with something like this though.
Quote:
Originally Posted by yince
Hello,
I would like to know how can I obtain source file names inside an executable or library using the debugging information.
If your executable hasn't been stripped, you can use the
nm -a <executable_name>
to dump all symbols in it, including source filenames. Source file names are debugging-only symbols, hence the -a switch. They will be somewhere at the end of the output.
If your executable hasn't been stripped, you can use the
nm -a <executable_name>
to dump all symbols in it, including source filenames. Source file names are debugging-only symbols, hence the -a switch. They will be somewhere at the end of the output.
Thanks,
nm -al <executable_name>
did the trick.
I also found:
objdump -dl <executable_name>
I don't know yet if I will get the same result with the two commands above but the first one is faster.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.