Questions tagged [data-segment]
54 questions
166
votes
6 answers
Why is the .bss segment required?
What I know is that global and static variables are stored in the .data segment, and uninitialized data are in the .bss segment. What I don't understand is why do we have dedicated segment for uninitialized variables? If an uninitialized variable…

Whoami
- 13,930
- 19
- 84
- 140
10
votes
4 answers
bss segment in C
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…

Vivek Maran
- 2,623
- 5
- 38
- 52
7
votes
1 answer
Why has the .bss segment not increased when variables are added?
Recently,I learned that the .bss segment stores uninitialized data. However, when I try a small program as below and use size(1) command in terminal, the .bss segment didn't change, even if I add some global variables. Do I misunderstand…

James Chu
- 73
- 4
6
votes
3 answers
What is c/c++ data segment and stack size?
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?

WhatIf
- 653
- 2
- 8
- 18
5
votes
0 answers
Get string length at declaration in assembly x86_64 in Linux
See the statements of string1 and string2 as well as their len1 and len2. The code is Assembly for x86_64 using GNU Assembler, passing parameters to invoke Linux x86_64 system calls. When I mov len1, %rdx it oddly generates a nonsense value…

Lourenco
- 2,772
- 2
- 15
- 21
5
votes
2 answers
NASM compiling x86_64 ASM label addresses off by 256 bytes in Mach-O when using multiple db declarations?
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…

Alexander O'Mara
- 58,688
- 18
- 163
- 171
5
votes
2 answers
why linux set the data-segment to __USER_DS at the prologue of exception handler
I'm trying to read Linux source code(2.6.11)
In the exception handler, at entry.s,
error_code:
movl $(__USER_DS), %ecx
movl %ecx, %ds
movl %ecx, %es
I don't know why loading user data segment here. Since it is supposed to be entering the exception…

Holmes
- 63
- 4
4
votes
1 answer
Strange behaviour of size utility
1st case:
#include
int main(void)
{
return 0;
}
Size output:
text data bss dec hex filename
1115 552 8 1675 68b ./a.out
2nd case:
#include
int global; // new line compared to…

Patrick
- 2,464
- 3
- 30
- 47
4
votes
2 answers
Are template variables thread safe? they're placed on data segment?
I'm playing with the new template variables feature from C++14 in order to get used to it (maybe is soon to do this 'cause it seems that some compilers didn't implement it completely).
Now I'm wondering where lies each instance of a template…

PaperBirdMaster
- 12,806
- 9
- 48
- 94
4
votes
1 answer
Is there a C++ equivalent (or equivalent technique) of Perl's __DATA__ segment?
is anyone aware of a C++ equivalent of Perl's __DATA__ segment? For anyone not familiar with Perl, the __DATA__ segment is an (optional) annotation towards the end of a Perl file; whatever comes after is considered the content of a (virtual) file…

tunnuz
- 23,338
- 31
- 90
- 128
3
votes
3 answers
Executable Ada code on the stack
I've just watched a talk on security considerations for railway systems from last year's 32C3.
At minute 25 the speaker briefly talks about Ada. Specifically he says:
Typical Ada implementations have a mechanism called "(tramp / trunk /
?)…

morido
- 1,027
- 7
- 24
3
votes
1 answer
Storing a vector in a DLL data segment
Information
The following warning:
LINK : warning LNK4039: section '.SHARED' specified with /SECTION option does not exist
always occur whenever I try to store a vector in a data segment of a dynamic link library in C++.
For an example:
#include…

XOR Bit
- 31
- 3
2
votes
1 answer
What does `Var2 DW Var1` mean in TurboShell/TurboAsm?
why does the following code compile perfectly?
Data Segment
Var1 Dw (any 4 digit hex value)
Var2 Dw Var1
Data Ends
what does the line "Var2 Dw Var1" even mean?
I thought that only an immediate value can go after the type defining .

user1020063
- 21
- 1
2
votes
4 answers
Can static storage (mostly data segment) cause segmentation fault?
static storage is decided at compilation time. However, consider the scenario where we have lot of lazy initialization in functions:
void foo ()
{
static int a[1000];
}
I am not discussing the coding practice here, but the technical aspect. As…

iammilind
- 68,093
- 33
- 169
- 336
2
votes
1 answer
Why data segment of C was separated as two sections?
All globally initialised values are stored in .data segment .i.e. initialised data segment and uninitialised values are stored in bss and compiler initialise those uninitialised values to zero automatically in bss. Then why data segment is separated…

RatheeshT
- 61
- 3