What does .comm mean?

I just translated this program,

#include <stdio.h> int dam[1000][1000]; int main (int argc, const char * argv[]) { // insert code here... printf("Hello, World!\n"); return 0; } 

for assembly using gcc creation,

  .cstring LC0: .ascii "Hello, World!\0" .text .globl _main _main: pushl %ebp movl %esp, %ebp pushl %ebx subl $20, %esp call L3 "L00000000001$pb": L3: popl %ebx leal LC0-"L00000000001$pb"(%ebx), %eax movl %eax, (%esp) call L_puts$stub movl $0, %eax addl $20, %esp popl %ebx leave ret .comm _dam,1000000,5 .section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5 L_puts$stub: .indirect_symbol _puts hlt ; hlt ; hlt ; hlt ; hlt .subsections_via_symbols 

What does .comm mean? Does the dam use heap space, stack space, or data space?

+7
assembly gcc x86 gas
source share
2 answers

In the as manual:

.. comm declares a common character named character. When linking, a common character in one object file can be combined with a specific or common character of the same name in another object file. If ld does not see the definition for a character — only one or more common characters — then it will allocate the length of the bytes of uninitialized memory. length must be an absolute expression. If ld sees several common characters with the same name, and they are not all of the same size, it will allocate space using the largest size.

When using ELF, the .comm directive takes an optional third argument. This is the desired alignment character specified as a byte boundary (for example, alignment of 16 units that the least significant 4 bits of the address must be zero). alignment must be an absolute expression, and it must be a force of two. If ld allocates uninitialized memory for a common character, this will use alignment when placing the character. If alignment is not specified, how alignment will be set to the highest power of two is less than or equal to the size of the character, to a maximum of 16.

+10
source share

.comm name, size, alignment

The .comm directive allocates memory in a data section. The repository is referenced by the identifier name. Size is measured in bytes and must be a positive integer. The name cannot be predefined. Alignment is optional. If alignment is specified, the name address is aligned to multiple alignment.

Source: https://docs.oracle.com/cd/E26502_01/html/E28388/eoiyg.html

+1
source share

All Articles