* Running Application Inside Application
@ 2011-11-21 2:18 Xin Tong
2011-11-21 3:25 ` Cong Wang
[not found] ` <CAOtvUMeHu_88Tye6CMaHpRwYY_vuz=9hE48DsJz0ARhMHYju-w@mail.gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: Xin Tong @ 2011-11-21 2:18 UTC (permalink / raw)
To: linux-kernel
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 ?
Thanks
Xin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Running Application Inside Application
2011-11-21 2:18 Running Application Inside Application Xin Tong
@ 2011-11-21 3:25 ` Cong Wang
2011-11-21 11:05 ` Bernd Petrovitsch
[not found] ` <CAOtvUMeHu_88Tye6CMaHpRwYY_vuz=9hE48DsJz0ARhMHYju-w@mail.gmail.com>
1 sibling, 1 reply; 4+ messages in thread
From: Cong Wang @ 2011-11-21 3:25 UTC (permalink / raw)
To: Xin Tong; +Cc: linux-kernel
On Mon, Nov 21, 2011 at 10:18 AM, Xin Tong <xerox.time.tech@gmail.com> 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 ?
>
If you want to exec*() to load the ELF, no, the signal handlers will be
cleared after exec*(), as the entire .text will be replaced by the new ELF file.
So, you probably have to parse and load the ELF file by yourself.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Running Application Inside Application
2011-11-21 3:25 ` Cong Wang
@ 2011-11-21 11:05 ` Bernd Petrovitsch
0 siblings, 0 replies; 4+ messages in thread
From: Bernd Petrovitsch @ 2011-11-21 11:05 UTC (permalink / raw)
To: Cong Wang; +Cc: Xin Tong, linux-kernel
On Mon, 2011-11-21 at 11:25 +0800, Cong Wang wrote:
> On Mon, Nov 21, 2011 at 10:18 AM, Xin Tong <xerox.time.tech@gmail.com> 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 ?
>
> If you want to exec*() to load the ELF, no, the signal handlers will be
It is in general so - not only für ELF.
> cleared after exec*(), as the entire .text will be replaced by the new ELF file.
>
> So, you probably have to parse and load the ELF file by yourself.
Hmmm, if these (obviously broken) applications use dynamic linking, one
could probably use a preload library.
Never tried that though .....
Bernd
--
Bernd Petrovitsch Email : bernd@petrovitsch.priv.at
LUGA : http://www.luga.at
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Running Application Inside Application
[not found] ` <CALKntY1i+NHE6HuDMME+WuAVmWG=tHuV=RsK9B3VnpVgcSJiRg@mail.gmail.com>
@ 2011-11-21 14:28 ` Gilad Ben-Yossef
0 siblings, 0 replies; 4+ messages in thread
From: Gilad Ben-Yossef @ 2011-11-21 14:28 UTC (permalink / raw)
To: Xin Tong; +Cc: linux-kernel
On Mon, Nov 21, 2011 at 2:54 PM, Xin Tong <xerox.time.tech@gmail.com> 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@benyossef.com> wrote:
>>
>> On Mon, Nov 21, 2011 at 4:18 AM, Xin Tong <xerox.time.tech@gmail.com> 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@vger.kernel.org
>>> 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@benyossef.com
>> 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@benyossef.com
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-11-21 14:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-21 2:18 Running Application Inside Application Xin Tong
2011-11-21 3:25 ` Cong Wang
2011-11-21 11:05 ` Bernd Petrovitsch
[not found] ` <CAOtvUMeHu_88Tye6CMaHpRwYY_vuz=9hE48DsJz0ARhMHYju-w@mail.gmail.com>
[not found] ` <CALKntY1i+NHE6HuDMME+WuAVmWG=tHuV=RsK9B3VnpVgcSJiRg@mail.gmail.com>
2011-11-21 14:28 ` Gilad Ben-Yossef
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®