From: ben <brouits@free.fr>
To: linux-c-programming@vger.kernel.org
Subject: Re: strtok, bus error
Date: Tue, 17 Feb 2009 22:05:13 +0100 [thread overview]
Message-ID: <499B2689.4070404@free.fr> (raw)
In-Reply-To: <18843.6873.192794.250251@cerise.gclements.plus.com>
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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2009-02-17 21:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-17 2:52 strtok, bus error Fundu
2009-02-17 3:57 ` Bryan Christ
2009-02-17 6:31 ` Fundu
2009-02-17 4:04 ` ben
2009-02-17 20:15 ` Glynn Clements
2009-02-17 21:05 ` ben [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=499B2689.4070404@free.fr \
--to=brouits@free.fr \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.