Re: Running Application Inside Application

From: Gilad Ben-Yossef
Date: Mon Nov 21 2011 - 09:29:03 EST


On Mon, Nov 21, 2011 at 2:54 PM, Xin Tong <xerox.time.tech@xxxxxxxxx> wrote:
>
> Your method looks interesting and neat. I have another question, is there a way for me to preload a .so and hijack the startup32 function so that it does not call main, instead it calls some functions within the preloaded .so ?
>

Donno, on your constructor, locate the symbol for main and plant a
jump or call instruction there to your function in the .so? this gets
real hairy real quick...

At any rate, it is not Linux kernel mailing list stuff. Try StackOverflow... :-)

Gilad

> Thanks
>
>
> Xin
>
> On Mon, Nov 21, 2011 at 1:41 AM, Gilad Ben-Yossef <gilad@xxxxxxxxxxxxx> wrote:
>>
>> On Mon, Nov 21, 2011 at 4:18 AM, Xin Tong <xerox.time.tech@xxxxxxxxx> wrote:
>>>
>>> I have applications that do not install signal handlers I need it to
>>> install. Therefore, I am thinking about having a light-weight run-time
>>> to load the application ELF file and install the needed signal handler
>>> in the run-time ? Is this doable ? What if it is not ELF-encoded ?
>>
>> There is a much easier way: create a dynamically linked library (let's call it libsig.so) with code like so:
>> int install_sig_handlers __attribute__((constructor)) {
>>    // Do what you need here
>> }
>> Then run your app like so:
>> LD_PRELOAD=/path/to/libsig.so /path/to/your/app
>> Unless your application is static and/or SUID the dynamic linker will load libsig.so into your app memory space and will run the constructor function where you can install signal handler at will
>> Gilad
>>
>>>
>>> Thanks
>>>
>>> Xin
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>> the body of a message to majordomo@xxxxxxxxxxxxxxx
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>> Please read the FAQ at  http://www.tux.org/lkml/
>>
>>
>>
>> --
>> Gilad Ben-Yossef
>> Chief Coffee Drinker
>> gilad@xxxxxxxxxxxxx
>> Israel Cell: +972-52-8260388
>> US Cell: +1-973-8260388
>> http://benyossef.com
>>
>> "Unfortunately, cache misses are an equal opportunity pain provider."
>> -- Mike Galbraith, LKML
>



--
Gilad Ben-Yossef
Chief Coffee Drinker
gilad@xxxxxxxxxxxxx
Israel Cell: +972-52-8260388
US Cell: +1-973-8260388
http://benyossef.com

"Unfortunately, cache misses are an equal opportunity pain provider."
-- Mike Galbraith, LKML
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/