* Re: How can I rewrite _start(entry point) of main function
[not found] <8a22e151-7038-264f-0c61-555cc0312feb@gmail.com>
@ 2020-01-19 4:32 ` Siddhesh Poyarekar
2020-01-19 5:05 ` Jason Yang
0 siblings, 1 reply; 2+ messages in thread
From: Siddhesh Poyarekar @ 2020-01-19 4:32 UTC (permalink / raw)
To: Jason Yang, libc-alpha, libc-help
(redirecting to libc-help)
On 18/01/20 8:35 pm, Jason Yang wrote:
> Dear developers:
>
> I have a demand that changing the argv array passed to main function
> after execve syscall. I knew that _start or even __libc_start_main are
> called before user's main function is called. Can I use LD_PRELOAD
> tricks to overwrite _start or any other functions in order for the
> modifications of argv before user's main function is called?
>
>
> Thanks so much! Looking forward your responses!
You can use constructors to run code before main() executes. Basically
implement a function with __attribute__((constructor)):
https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Function-Attributes.html
Siddhesh
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How can I rewrite _start(entry point) of main function
2020-01-19 4:32 ` How can I rewrite _start(entry point) of main function Siddhesh Poyarekar
@ 2020-01-19 5:05 ` Jason Yang
0 siblings, 0 replies; 2+ messages in thread
From: Jason Yang @ 2020-01-19 5:05 UTC (permalink / raw)
To: Siddhesh Poyarekar, libc-alpha, libc-help
Dear Siddhesh Poyarekar,
Thanks so much for your help.
My case is a different one.
I use execve to run an executable, but I could not modify argv0 passed
to main function(I use ld.so as the first arg), after execve is called,
I do not have chance to modify argv0 passed to main function any more,
so I want to find a cut point between execve and real main function to
give me a chance of changing the value of argv0.
I expect to use ld_preload trick to trap or overwrite some functions in
order to change values. Can I do that?
On 2020/01/19 13:31, Siddhesh Poyarekar wrote:
> (redirecting to libc-help)
>
> On 18/01/20 8:35 pm, Jason Yang wrote:
>> Dear developers:
>>
>> I have a demand that changing the argv array passed to main function
>> after execve syscall. I knew that _start or even __libc_start_main are
>> called before user's main function is called. Can I use LD_PRELOAD
>> tricks to overwrite _start or any other functions in order for the
>> modifications of argv before user's main function is called?
>>
>>
>> Thanks so much! Looking forward your responses!
> You can use constructors to run code before main() executes. Basically
> implement a function with __attribute__((constructor)):
>
> https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Function-Attributes.html
>
> Siddhesh
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-01-19 5:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <8a22e151-7038-264f-0c61-555cc0312feb@gmail.com>
2020-01-19 4:32 ` How can I rewrite _start(entry point) of main function Siddhesh Poyarekar
2020-01-19 5:05 ` Jason Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).