简体   繁体   中英

Is it possible to re-initialize a static library?

In our iOS app we use a closed source statically linked library ( foo.a + header files).

The library keeps its own internal state, most likely in global variables. And unfortunately, after a while, the library sometimes ends up in an erroneous state. When this happens, it basically becomes unusable — returning error codes from all its API functions.

My question: is it possible to re-initialize a static library from within an iOS app? The library does not hold any file handles or any other system resources (as far as I know), so supposedly it would be safe to re-initialize it.

In other words (I realize this sounds more and more crazy), is there a way to figure out what memory region the library keeps its global variables in, and then zero out that memory region?

No, and zeroing out that region even if it existed wouldn't "reinitialize" the library. It would just as likely put it into an invalid state. A static library is linked directly into your executable; it doesn't have a separate memory region (it's almost exactly the same as if you compiled the source yourself as part of your project). You need to work with the provider to fix their library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM