if a global or static C variable is not explicitly initialized, but implicitly initialized, is it in .data or .bss section?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Computer Systems: A Programmer's Perspective says about two sections in a ELF relocatable object file:



  • .data Initialized global and static C variables. Local C variables are maintained
    at run time on the stack and do not appear in either the .data or .bss
    sections.


  • .bss Uninitialized global and static C variables, along with any global or static
    variables that are initialized to zero. This section occupies no actual space
    in the object file; it is merely a placeholder. Object file formats distinguish
    between initialized and uninitialized variables for space efficiency: unini-
    tialized variables do not have to occupy any actual disk space in the object
    file. At run time, these variables are allocated in memory with an initial
    value of zero.


Do "initialized" and "unitiailized" in the quote mean explicitly or implicitly or either?



if a global or static C variable is not explicitly initialized, but implicitly initialized, is it in .data or .bss section?



Does it matter whether the global or static C variable is implicitly initialized to zero or nonzero?



Thanks.









share

























    up vote
    0
    down vote

    favorite












    Computer Systems: A Programmer's Perspective says about two sections in a ELF relocatable object file:



    • .data Initialized global and static C variables. Local C variables are maintained
      at run time on the stack and do not appear in either the .data or .bss
      sections.


    • .bss Uninitialized global and static C variables, along with any global or static
      variables that are initialized to zero. This section occupies no actual space
      in the object file; it is merely a placeholder. Object file formats distinguish
      between initialized and uninitialized variables for space efficiency: unini-
      tialized variables do not have to occupy any actual disk space in the object
      file. At run time, these variables are allocated in memory with an initial
      value of zero.


    Do "initialized" and "unitiailized" in the quote mean explicitly or implicitly or either?



    if a global or static C variable is not explicitly initialized, but implicitly initialized, is it in .data or .bss section?



    Does it matter whether the global or static C variable is implicitly initialized to zero or nonzero?



    Thanks.









    share























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Computer Systems: A Programmer's Perspective says about two sections in a ELF relocatable object file:



      • .data Initialized global and static C variables. Local C variables are maintained
        at run time on the stack and do not appear in either the .data or .bss
        sections.


      • .bss Uninitialized global and static C variables, along with any global or static
        variables that are initialized to zero. This section occupies no actual space
        in the object file; it is merely a placeholder. Object file formats distinguish
        between initialized and uninitialized variables for space efficiency: unini-
        tialized variables do not have to occupy any actual disk space in the object
        file. At run time, these variables are allocated in memory with an initial
        value of zero.


      Do "initialized" and "unitiailized" in the quote mean explicitly or implicitly or either?



      if a global or static C variable is not explicitly initialized, but implicitly initialized, is it in .data or .bss section?



      Does it matter whether the global or static C variable is implicitly initialized to zero or nonzero?



      Thanks.









      share













      Computer Systems: A Programmer's Perspective says about two sections in a ELF relocatable object file:



      • .data Initialized global and static C variables. Local C variables are maintained
        at run time on the stack and do not appear in either the .data or .bss
        sections.


      • .bss Uninitialized global and static C variables, along with any global or static
        variables that are initialized to zero. This section occupies no actual space
        in the object file; it is merely a placeholder. Object file formats distinguish
        between initialized and uninitialized variables for space efficiency: unini-
        tialized variables do not have to occupy any actual disk space in the object
        file. At run time, these variables are allocated in memory with an initial
        value of zero.


      Do "initialized" and "unitiailized" in the quote mean explicitly or implicitly or either?



      if a global or static C variable is not explicitly initialized, but implicitly initialized, is it in .data or .bss section?



      Does it matter whether the global or static C variable is implicitly initialized to zero or nonzero?



      Thanks.







      elf





      share












      share










      share



      share










      asked 2 mins ago









      Tim

      24.2k69233424




      24.2k69233424

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476895%2fif-a-global-or-static-c-variable-is-not-explicitly-initialized-but-implicitly-i%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476895%2fif-a-global-or-static-c-variable-is-not-explicitly-initialized-but-implicitly-i%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)