Re: strtok, bus error
ben <[email protected]>
| Newsgroups | org.kernel.vger.linux-c-programming |
|---|---|
| Message-ID | <[email protected]> |
thank you for that precise explanation. objdump is now less cryptic to me... - ben Glynn Clements a écrit : > ben wrote: >> i don't know if it is a compiler feature (storage behavior into the DATA >> segment), or a linux kernel feature, or if it is specified in ANSI, but >> the second way leads to pointing to a _constant_ string. If someone can >> enlighten... > > ANSI C says that string literals "may" be read-only. On platforms with > memory protection they usually are read-only. > > On Linux, string literals are stored in the "rodata" segment, which is > read-only, and thus can be shared between all processes which are > using a given executable or shared library. > > You can list the segments which make up an executable or shared > library using "objdump -h" > [snipped] > > The main ones are text, rodata, data, and bss. > > The text segment holds code, and is read-only and executable (CODE > flag). > > The others hold static data: global variables, "static" local > variables, string literals, and intialisers for automatic > (non-"static" local) arrays. > > Read-only data (literals, initialisers, "const" variables) goes into > the rodata segment, which is read-only. > > Mutable variables with explicit initialisers go into the data segment. > > Mutable variables without initialisers (i.e. implicitly initialised to > zero) go into the bss segment. As the entire bss segment is initially > zero, it doesn't need to be stored in the file (this is indicated by > the lack of the CONTENTS, LOAD, and CODE/DATA flags). > > The other segments tend to be architecture-specific. -- To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html