3

this

en.wikipedia.org/wiki/Hot_swapping#cite_note-1

says that VS can do it with the help of its debugger. Does gdb provide a similar functionality ?

this is the closest i could find, but doesn't seem to be ready to be used:

http://www.aitdspace.gr/xmlui/handle/123456789/219

dlopen/dlsym/dlclose are also close, but will not work for -lmylib referenced libraries (reference count never gets to 0).

alternatives i've considered:

1) using -Wl,-wrap,foo and on __wrap_foo() { func = dlopen(); func(); }

2) making libfoo.so a shared library and when we need to hotswap we dlopen(RTLD_GLOBAL) to load the new code and provide updated symbols to the next call to foo();

1) doesn't work very well because it requires me to enumerate all the functions i want to hotswap, which are all of them.

2) doesn't work very well because when foo() is called, the new code is loaded, but foo has forever the reference to that symbol. calling dlopen multiple times make foo to be re evaluated.

4

3 回答 3

2

您可能对 Ksplice 感兴趣。这是一项源自 MIT 的技术,它允许将软件补丁应用到 Linux 内核而无需重新启动。这与应用安全更新最相关:

http://www.ksplice.com/paper

于 2010-10-20T00:10:26.087 回答
0

您当然可以破解自己的系统,在该系统中存储函数指针列表,并可以更改这些指针以指向您当时拥有 dlopen() 的任何库。

你是对的,没有任何简单的方法可以拦截对具有固定链接的例程的调用。您总是可以通过程序集跳转到另一个例程来破坏例程的开始,但这可能很危险(并且不是 C)。

也许一个在你的代码中很弱而在 dlopen()'d 库中很强大的符号会起作用?

在任何这些情况下,您都必须处理旧代码当前正在运行的情况。这也不容易,除非您的程序中有一些点,您知道要交换的库中没有线程。

于 2010-10-19T23:40:54.080 回答
0

我发现最接近的是 oracle developer studio 附带的 solari dbx,但是 dev studio 在 linux 和 solaris 中都使用 dbx,只有 solaris 版本支持“编辑并继续”或“热代码交换”

于 2018-04-04T01:41:40.150 回答