On 09 September 2006 16:34, mathieu lacage wrote: > The idea is to change the way the address of a global > variable is calculated: rather than merely access a memory > area directly or through the GOT, we need to add another > level of indirection. > > The simplest way to add another level of indirection is > to replace every declaration and definition of a static > variable by another static variable which would be an > array of the original variables: > > static int a; > void foo (void) > { > a = 1; > } > > would be transformed into: > > static int a[MAX_PROCESS_NUMBER]; > void foo (void) > { > a[process_id] = 1; > } > > Another solution would be to do something like this: > > extern void *magic_function (void *variable_uid); > > static int a; > void foo (void) > { > void *ptr = magic_function (&a); > int *pa = (int *)ptr; > *pa = 1; > } > > and then make the user provide magic_function at link time, > just like __cyg_profile_func_enter.
I think this would be a great feature to have, even if it did only work with simple globals and couldn't handle TLS. Disclaimer: I haven't thought it through thoroughly yet :) Nor am I sure whether the better solution might not be to just force all globals to be accessed via the GOT and allow multiple GOT pointers? That would also keep all the per-process data together, as opposed to grouping all the data for each individual object across all processes together in an array, which might be preferable. cheers, DaveK -- Can't think of a witty .sigline today....