long@uicsgva.csg.uiuc.edu (03/18/90)
I would like to know the data segment layout of a C program on Unix (Sun OS). For the following example, I found some extra variables were inserted before the first global variables (marked as ? in the following figure). /* --- example.c ---*/ +----------+ int a = 0; | text | int b[32]; +----------+ <- etext | ? | main() +----------+ { | a | ... +----------+ <- edata } | b | +----------+ <- end | | Now my questions are: does anyone know what they are? Does they vary from program to program? Thank you very much. junsheng long
henry@utzoo.uucp (Henry Spencer) (03/18/90)
In article <3300001@uicsgva.csg.uiuc.edu> long@uicsgva.csg.uiuc.edu writes: >I would like to know the data segment layout of a C program >on Unix (Sun OS). For the following example, I found some extra >variables were inserted before the first global variables ... >Now my questions are: does anyone know what they are? >Does they vary from program to program? They probably include things like string constants, tables the compiler generates for switch statements, variables used by run-time startup machinery, etc. There is potentially quite a bit going on below the surface, varying from program to program, compiler to compiler, and release to release. -- MSDOS, abbrev: Maybe SomeDay | Henry Spencer at U of Toronto Zoology an Operating System. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu