data-segment

What is c/c++ data segment and stack size?

谁都会走 提交于 2019-12-12 12:25:00
问题 I read that it depends on the compiler and operating system architecture. How do I find out the data segment and stack max size on a Linux system using GCC as compiler? 回答1: Let me experiment with you: create file ``test.c'' like this: int main (void) { return 0; } Now compile it, specifying max stack size (just to easy lookup this number in map file and determine symbol name, refering to it): gcc test.c -o test.x -Wl,--stack=0x20000 -Wl,-Map=output.map Determining data size is simple: size

Why global variables are stored in heap?

。_饼干妹妹 提交于 2019-12-08 06:25:18
问题 Why in the following example the global variables are stored in the heap segment, instead of the data/bss segment? From the following output of the maps pseudo-file, the data/bss segment is the 3rd line. This is because it is read/write, and anonymous. The following 2 entries are the heap (as the label indicates). This is the output of the /proc//maps: 00400000-00405000 r-xp 00000000 08:02 17962770 myexec 00604000-00605000 r--p 00004000 08:02 17962770 myexec 00605000-00606000 rw-p 00005000 08

bss segment in C

泄露秘密 提交于 2019-11-27 21:36:37
In one of the answers to the question " Regarding the bss segment and data segment in Unix ", I see the explanation on bss as follows: Bss is special: .bss objects don't take any space in the object file, and by grouping all the symbols that are not specifically intialized together, they can be easily zeroed out at once. But when I use size on the object file, generated out of the code: #include <stdio.h> int uninit_global_var; int init_global_var=5; int main() { int local_var; return 0; } I have the following text data bss dec hex filename 1231 280 12 1523 5f3 a.out and see the bss growing

bss segment in C

痴心易碎 提交于 2019-11-27 04:31:41
问题 In one of the answers to the question "Regarding the bss segment and data segment in Unix", I see the explanation on bss as follows: Bss is special: .bss objects don't take any space in the object file, and by grouping all the symbols that are not specifically intialized together, they can be easily zeroed out at once. But when I use size on the object file, generated out of the code: #include <stdio.h> int uninit_global_var; int init_global_var=5; int main() { int local_var; return 0; } I

NASM compiling x86_64 ASM label addresses off by 256 bytes in Mach-O when using multiple db declarations?

我与影子孤独终老i 提交于 2019-11-26 17:17:25
问题 In short, when I have multiple db sections in my .data section, the compiled addresses/labels are off when compiled by NASM. In my testing they are off by 256 bytes in the resulting Mach-O binary. Software I am using: OS X 10.10.5 nasm NASM version 2.11.08, installed via Homebrew as required for x84_64 ASM gobjdump GNU objdump (GNU Binutils) 2.25.1, installed via Homebrew clang Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) What works: Take for example the following "hello