I am working on an Android project that has a native ".so" file embedded in an apk. Whenever we need to release a bug fix we are now releasing a new apk file with ".so" which has the fix. But this is a huge file and is not efficient.
我正在开发一个Android项目,其中包含一个嵌入在apk中的原生“.so”文件。每当我们需要发布错误修复时,我们现在发布一个带有“.so”的新apk文件,其中包含修复程序。但这是一个巨大的文件,效率不高。
So my question is, is it possible to update the ".so" inside the ".apk" with only the relevant ".o" files that have changed? Meaning keeping the rest of the ".so" file the same, can we just update only those ".o" files that changed? Similar to how some systems push their bug fixes.
所以我的问题是,是否可以更新“.apk”中的“.so”,只更改相关的“.o”文件?意味着保持“.so”文件的其余部分相同,我们只能更新那些改变的“.o”文件吗?类似于某些系统如何推动其错误修复。
1 个解决方案
#1
1
Updating parts of dynamic library (.so
) is not possible. It's not like a static library (.a
), which is, essentially, just a plain archive with object files. A dynamic library is more like a usual executable and can be thought of as just a program with no main
. In fact, shared libraries are usually compiled as PIC and overall, if one part of the library changes, all other parts should be updated.
无法更新动态库(.so)的各个部分。它不像静态库(.a),它本质上只是一个带有目标文件的普通存档。动态库更像是通常的可执行文件,可以被认为只是一个没有main的程序。事实上,共享库通常被编译为PIC和整体,如果库的一部分发生更改,则应更新所有其他部分。
Say, there's one more instruction in the code of some function a
, which is followed by functions b
and c
. Then addresses of b
and c
should be increased by size of the instruction which got added to a
. Then all call sites of b
and c
inside this dynamic library should be updated with new addresses.
比方说,在某个函数a的代码中还有一个指令,其后是函数b和c。然后,b和c的地址应该增加到添加到a的指令的大小。然后,应使用新地址更新此动态库中所有b和c的调用站点。
That said, it could be done in theory, but the cost of implementation is much higher than profit from it.
也就是说,它可以在理论上完成,但实施成本远远高于它的利润。
#1
1
Updating parts of dynamic library (.so
) is not possible. It's not like a static library (.a
), which is, essentially, just a plain archive with object files. A dynamic library is more like a usual executable and can be thought of as just a program with no main
. In fact, shared libraries are usually compiled as PIC and overall, if one part of the library changes, all other parts should be updated.
无法更新动态库(.so)的各个部分。它不像静态库(.a),它本质上只是一个带有目标文件的普通存档。动态库更像是通常的可执行文件,可以被认为只是一个没有main的程序。事实上,共享库通常被编译为PIC和整体,如果库的一部分发生更改,则应更新所有其他部分。
Say, there's one more instruction in the code of some function a
, which is followed by functions b
and c
. Then addresses of b
and c
should be increased by size of the instruction which got added to a
. Then all call sites of b
and c
inside this dynamic library should be updated with new addresses.
比方说,在某个函数a的代码中还有一个指令,其后是函数b和c。然后,b和c的地址应该增加到添加到a的指令的大小。然后,应使用新地址更新此动态库中所有b和c的调用站点。
That said, it could be done in theory, but the cost of implementation is much higher than profit from it.
也就是说,它可以在理论上完成,但实施成本远远高于它的利润。