This is the mail archive of the libc-help@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] | |
On Wednesday 04 November 2009 17:11:28 Bharath Ramesh wrote:
> I am trying to access the arguments passed to an application in the
> constructor of a shared library. My aim is to prepend the arguments with
> certain arguments that I can strip off just before my constructor exits.
> This requires that I have access to the argument list passed to the
> application in the constructor. I would appreciate any help on this. I
> am sorry if this an incorrect mailing list to ask this question. I
> thought this might be good place to start off. I would appreciate if I
> am copied in the reply as I am not subscribed to this list.
$ cat test.c
#include <stdio.h>
extern char **environ;
foo(int argc, char **argv, char **env)
{ printf("%i, %p, %s, %p, %p\n", argc, argv, *argv, env, environ); }
__attribute__((section(".init_array"))) static void *foo_constructor = &foo;
main(){}
$ gcc test.c && ./a.out foo
2, 0xbfd877f4, ./a.out, 0xbfd87800, 0xbfd87800
maybe someone knows of an easier way to get a pointer into the init_array
section ...
-mike
Attachment:
signature.asc
Description: This is a digitally signed message part.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |