Maximum size of bss and data

I want to declare all the variables in my C program at compile time, for example, for example:

char cache[CACHE_SIZE];
char udp_ring[MAX_UDP_PACKET_SIZE*MAX_REQUESTS];
int  num_packets;
char error_codes[NUM_ERRORS][MAX_ERROR_STRING]= {
    {"Unknown user\n"},
    {"Wrong password\n"},
    ....
};

The question is, are there any restrictions on the size of variables in a C program when they go in the BSS or DATA segment? For example, if I declare CACHE_SIZE of 8 GB of RAM, will it work? Is there a difference for 32 bit or 64 bit? I plan to run the program on Linux, and there will be no restrictions in my RLIMIT_DATA configuration.

+5
source share
2 answers

You will be able to manage as much virtual memory as your kernel allows you to process processes: it will depend on the architecture.

, x86 ( x86-64) Linux 3 1 ( PAE ): 3 ( , , bss, , , ..)

​​ , : 8- 32- .

glibc (malloc,...), LD_PRELOAD, malloc/calloc/realloc/free ( sbrk()), .

+3

glibc, syscalls ( syscalls (2) man page). (, open (2), ( 2), (2)...). Glibc C . howto , libc, (, C asm). . _ syscall (2) man-. VDSO.

, mmap (2) munmap(2) syscalls. . Glibc malloc free.

, ( .data) ( .bss), : . : ELF .

, Glibc. C. , dietlibc.

+2

All Articles