[英]Extract statically linked libraries from an executable
I'm not sure if this is even possible, but given an executable file (foo.exe), with has many libraries which has been linked statically. 我不确定这是否可行,但给定一个可执行文件(foo.exe),有许多已静态链接的库。
Is there any software that extract from this file the .lib ( or .a ) that lay inside the executable ? 是否有任何软件从该文件中提取可执行文件中的.lib(或.a)?
Thanks. 谢谢。
Incredibly unlikely since, typically, you don't get the entire contents of the library injected into your executable. 不可思议的是,通常情况下,您不会将库的全部内容注入到可执行文件中。
You only get enough to satisfy all the undefined symbols. 您只能满足所有未定义的符号。 This may actually only be a small proportion of the library.
这实际上可能只是图书馆的一小部分。 A library generally consists of a set of object files of which only those that are required are linked into your executable.
库通常由一组目标文件组成,只有那些目标文件才链接到您的可执行文件中。
For example, if the only thing you called in the C runtime library was exit()
, you would be very unlikely to have the printf()
family of functions in your executable. 例如,如果您在C运行时库中调用的唯一东西是
exit()
,那么您的可执行文件中不太可能有printf()
系列函数。
If you linked with the object files directly, you may have a chance, since they would be included whether used or not (unless your linker is a smart one). 如果直接链接到目标文件,则可能有机会,因为无论是否使用它们都将被包括在内(除非您的链接器是智能链接器)。
But even that would be a Herculean task as there may be no information in the executable as to what code sections came from specific object files. 但即使这样也是一项艰巨的任务,因为可执行文件中可能没有关于哪些代码段来自特定目标文件的信息。 It's potentially doable but, if there's another way, I'd be looking at that first.
这可能是可行的,但是,如果有另一种方式,我会先看一下。
Let me clarify the typical process: 让我澄清一下典型的过程:
ao
, bo
, co
and do
contain the functions a()
, b()
, c()
and d()
respectively. ao
, bo
, co
和do
包含函数a()
, b()
, c()
和d()
。 They are all added to the abcd.a
archive. abcd.a
存档。 b()
calls c()
. b()
调用c()
的事实。 a()
and b()
and you compile it then link it with the abcd.a
library. a()
和b()
的abcd.a
,然后编译它然后用abcd.a
库链接它。 ao
and bo
out of the library and into your executable, satisfying the need for a()
and b()
but introducing a need for c()
, because b()
needs it. ao
和bo
拖出库并进入你的可执行文件,满足了对a()
和b()
的需要,但引入了对c()
b()
需求,因为b()
需要它。 co
out of the library and into your executable, satisfying the need for c()
. co
拖出库并进入可执行文件,满足c()
的需要。 Now all undefined symbols are satisfied, the executable is done and dusted, you can run it when ready. At no stage in that process was do
dragged into your executable so you have zero hope of getting it out. 在该过程的任何阶段
do
拖入你的可执行文件,所以你必须为零希望得到它的。
Update: Re the "if there's another way, I'd be looking at that first" comment I made above, you have just stated in a comment to one of the other answers that you have the source code that made the libraries you want extracted. 更新:重新“如果有另一种方式,我将首先看一下”我在上面做出的评论,你刚刚在其他答案的评论中说明你有源代码使你想要提取的库。 I need to ask: why can you not rebuild the libraries with that source?
我需要问一下:为什么你不能用这个源重建库? That seems to me a much easier solution than trying to recreate the libraries from a morass of executable code.
在我看来,这比尝试从可执行代码的混乱中重新创建库要容易得多。
Imagine having 10 books in language you don't understand, without covers, title pages, page numbers and chapters. 想象一下,有10本你不懂的语言书,没有封面,标题页,页码和章节。 Some of the books can be incomplete.
有些书可能不完整。 All pages are shuffled together so it is impossible to find out where is the beginning and end of each book.(each page is a function call) Now try to find page 123 of book 5 (let's say it is mentioned above function Exit()).
所有页面都被混合在一起,因此无法找出每本书的开头和结尾。(每个页面都是一个函数调用)现在尝试查找第5册的第123页(比如上面提到的函数Exit() )。
Well, IT IS possible... 嗯,有可能......
It seems like you're asking for a decompiler. 好像你要求反编译器。 Such tools are difficult to use (probably impossible for mildly sophisticated C++) and if there is any other way of solving your problem, including taking a couple months to rewrite the libraries, I'd recommend that course of action.
这些工具很难使用(对于稍微复杂的C ++来说可能是不可能的),如果有任何其他方法可以解决您的问题,包括花几个月时间重写库,我建议采取行动。
Like pax pointed out, even if you did use a decompiler, you would only get the library functions that the executable called. 就像pax指出的那样,即使您使用了反编译器,您也只能获得可执行文件所调用的库函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.