// The following two kinds of variables require static storage, // i.e. `data` or `bss` section in the final executable. // // 1. global variables // 2. local static variables // // The particular section depends on its initial value: // initialized with non-zero value -- data segment // uninitialized -- bss segment
// .data // static int64_t x = 1; // int64_t x = 1;
// One can study the placement use `size`, something like: // // $ clang tmp.c && size a.out // // ## Case 0 ## (baseline) // // text data bss dec hex filename // 1334 544 8 1886 75e a.out // // ## Case 1 ## // global & initialized with non-zero -- data segment increase by 8 // // text data bss dec hex filename // 1334 552 8 1894 766 a.out // // ## Case 2 ## // global & uninitialized -- bss segment increase by 8 // // text data bss dec hex filename // 1334 544 16 1894 766 a.out // // ## Case 3 ## // local & initialized with non-zero -- data segment increase by 8 // // text data bss dec hex filename // 1334 552 8 1894 766 a.out // // ## Case 4 ## // local & uninitialized -- bss segment increase by 8 // // text data bss dec hex filename // 1334 544 16 1894 766 a.out