verma wrote: > Hi all, > I have one question related to ld.so.1 stack cleanup. > in source code /rtld/common/util.c the following are written: > /* > *The stack layout is plateform specific,but all share the folowing stack > layout > * so stack cleanup also same. > */ > #if defined(sparc) || defined(i386) || defined(__amd64) > > /* > * Stack Cleanup. > * > * This function is invoked to 'remove' arguments that were passed in on the > * stack. This is most likely if ld.so.1 was invoked directly. In that case > * we want to remove ld.so.1 as well as it's arguments from the argv[] array. > * Which means we then need to slide everything above it on the stack down > * accordingly. > * > * While the stack layout is platform specific - it just so happens that x86, > * sparc, sparcv9, and amd64 all share the following initial stack layout. > static void > stack_cleanup(char **argv, char ***envp, auxv_t **auxv, int rmcnt) > { > } > > Could you please tell me is stack are same for all platforms or stacks varies > paltform to platform. > If stack are diffeerent the this function should be different for all > architecture. > I think ,this function is only required for stack cleanup when we invoke as > #./ld.so.1 ./test > > Thanks > > > This message posted from opensolaris.org > _______________________________________________ > tools-linking mailing list > tools-linking at opensolaris.org
Doesn't that comment answer your questions? Stacks are platform dependent, and can vary from platform to platform. It just so happens (a nice coincidence) that all of the platforms Solaris officially supports today happen to have the same common initial stack layout. There is no assurance that a new platform would be the same. If you were porting this code to a new platform, you'd have to study the architecture manual and ABI specification and see. It might well be that you have to implement stack_cleanup() differently for that system. Note that surrounding #if expression: #if defined(__sparc) || defined(__x86) ... stack_cleanup()... ... #else /* * Verify that the above routine is appropriate for any new platforms. */ #error unsupported architecture! #endif The code is written to intentionally error out if built on a platform we don't know about, to draw your attention to the issue. I believe you are right: This code is only used when ld.so.1 is used as the program to run. - Ali