Recover static library from executable
3
votes
1
answer
1673
views
I have an existing executable for which a small amount of source code has been lost. In particular, the executable uses a few functions from a static library, and the source code for that library is missing. I do have an older version of that library's code, but the executable uses three or four methods that aren't in the old version. I have a header file for the new version of the code, which includes prototypes of the missing functions, but the
.c
file containing the actual function definitions is missing.
Since the executable is statically linked, I wonder if there is a way to rebuild the static library by extracting the object code from it. I can find the symbols I need using nm
and objdump
, but I don't know if there's a way to extract those functions and re-package them into object files or a static library.
As an example, it looks something like this:
$ nm ./theApplication
001721dc T _missingFunction1
00171ed8 T _missingFunction2
$ objdump --disassemble-all ./theApplication
00171ed8 :
171ed8: 1a e5 f8 14 P2 = [P3 + 0x53e0];
001721dc :
1721dc: c5 04 [--SP] = (P5:5);
I'd like to pull missingFunction1()
and missingFunction2()
out into a static library or object files so I can link against them in other executables. Is that possible, and if so, how can it be done?
Asked by maldata
(165 rep)
Nov 28, 2019, 08:14 PM
Last activity: Mar 3, 2024, 06:26 AM
Last activity: Mar 3, 2024, 06:26 AM