This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How can I rewrite _start(entry point) of main function


(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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]