Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5963555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:16:26+00:00 2026-05-22T19:16:26+00:00

In the virtual memory concept, where does C compilers store immediate strings? Example: char

  • 0

In the virtual memory concept, where does C compilers store immediate strings? Example:

char *str = "Immediate string";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:16:27+00:00Added an answer on May 22, 2026 at 7:16 pm

    gcc at least handles the following four cases differently:

    char *globalstr = "immediate global string";
    char globalbuf[] = "immediate global array of chars";
    int main(int argc, char* argv[]) {
        char *str = "immediate string";
        char buf[] = "immediate array of chars";
        return 0;
    }
    

    Local variable char *str and global variable char *str are stored into the .rodata section:

    $ readelf --hex-dump=.rodata foo
    
    Hex dump of section '.rodata':
      0x00400688 01000200 696d6d65 64696174 6520676c ....immediate gl
      0x00400698 6f62616c 20737472 696e6700 696d6d65 obal string.imme
      0x004006a8 64696174 65207374 72696e67 00       diate string.
    

    The storage for local variable char buf[] is allocated on the stack at runtime, and initialized via instructions in the .text section:

    $ readelf --hex-dump=.text foo
    
    Hex dump of section '.text':
    ...
      0x00400510 00000048 85c07408 bf480e60 00c9ffe0 ...H..t..H.`....
      0x00400520 c9c39090 554889e5 4883ec50 897dbc48 ....UH..H..P.}.H
      0x00400530 8975b064 488b0425 28000000 488945f8 .u.dH..%(...H.E.
      0x00400540 31c048c7 45c8a406 4000c745 d0696d6d 1.H.E...@..E.imm
      0x00400550 65c745d4 64696174 c745d865 206172c7 e.E.diat.E.e ar.
      0x00400560 45dc7261 7920c745 e06f6620 63c745e4 E.ray .E.of c.E.
      0x00400570 68617273 c645e800 b8000000 00488b55 hars.E.......H.U
      0x00400580 f8644833 14252800 00007405 e897feff .dH3.%(...t.....
    ...
    

    The global variable char buf[] is stored in the .data section:

    $ readelf --hex-dump=.data foo
    
    Hex dump of section '.data':
      0x00601020 00000000 00000000 00000000 00000000 ................
      0x00601030 00000000 00000000 00000000 00000000 ................
      0x00601040 8c064000 00000000 00000000 00000000 ..@.............
      0x00601050 00000000 00000000 00000000 00000000 ................
      0x00601060 696d6d65 64696174 6520676c 6f62616c immediate global
      0x00601070 20617272 6179206f 66206368 61727300  array of chars.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Virtual memory is a good concept currently used by modern operating systems. But I
Most of the literature on Virtual Memory point out that the as a Application
I'm debugging an out-of-memory exception. When I get the exception, the virtual bytes performance
How does a virtual machine generate native machine code on the fly and execute
Virtual memory was introduced to help run more programs with limited memory. But in
Virtual memory is well-supported by modern hardware, but application-level memory allocation is still all
I have virtual memory size set to 756 MB on windows xp. but when
I am trying to get a deeper understanding of the virtual memory manager of
Consider a virtual memory system with a 38-bit virtual byte address, 1KB pages and
Malloc allocates memory from one of the virtual memory regions of the process called

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.