[cgl_discussion] Re: [PATCH i386] Live Patching Function on 2.6.11.7

Corey Minyard minyard at mvista.com
Mon May 9 20:18:41 PDT 2005


Takashi Ikebe wrote:

> Corey, can I ask some questions?
>
> Corey Minyard wrote:
>
>> Takashi Ikebe wrote:
>>
>>> Hello, Andrew
>>> Sorry for late reply.
>>> I don't know montavista's implementation, but it seems some 
>>> modifications to legacy application are needed(as long as it is 
>>> implemented as library...).
>>
>>
>>
>> No modifications are needed.  You can pre-load a shared library to do 
>> this.
>>
>
> Well, would you tell us how you implement this if possible?
> I think there are need some momentums to get the execution privilege 
> from process's main context( such as signal handler, invoke thread and 
> listen socket) to load the patch module dynamically.
> How your implementation get the execution privilege without changing 
> exiting code?

You *really* need to understand how the dynamic loader works.  But you 
can create a library with an init section that runs when the library is 
loaded.  If the library is pre-loaded, then it will run before the 
application.

>
>>> And there is no open-sourced implementation yet.
>>
>>
>>
>> That is true.
>>
>>> I think only the way to realize user space implementation without 
>>> zero modification on legacy application is using ptrace function.
>>
>>
>>
>> You are wrong.  I have implemented this.  Two times, in fact.  Look 
>> at LD_PRELOAD in the ld.so man page.
>>
>> I guess if the application was statically linked you couldn't do this 
>> without linking it in (no modifications to the application would be 
>> required, just a new library on the link step), but that seems unlikely.
>>
>
> The majority of programs uses static link to their own sub-routine, In 
> addition to that, the main important routine sometimes written in same 
> file of main() routine. They needs modifications....
> Can not to patch the symbols which linked as static is hard restriction.
> We think to patch to symbols even if they are statically linked is 
> essential.

That's not what I said.  You can patch static symbols.  You cannot 
preload a dynamic library in an executable that is statically linked 
(gcc -static *.o).  However, you can still statically link the patcher 
in and have it start in an init section.

As I said before, this is not easy and requires a deep understanding of 
how the system works.  The same is true of a ptrace-based one, BTW, but 
it is not as obvious at first.

-Corey



More information about the cgl_discussion mailing list