Re: SOLVED OT - C compiler, assignement on double-declared variable with different types

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jesus Sanchez
Date: Saturday, April 10, 2010 - 10:14 pm

El 11/04/2010 6:14, Jesus Sanchez escribis:

OK, doing a deep search I found this (think that my
  foo variable is the symbol the quote talks about):

------------------------------------------------------------------

.comm declares a common symbol named symbol. When linking, a common 
symbol in one object file may be merged with a defined or common symbol 
of the same name in another object file. If ld does not see a definition 
for the symbol--just one or more common symbols--then it will allocate 
length bytes of uninitialized memory. length must be an absolute 
expression. If ld sees multiple common symbols with the same name, and 
they do not all have 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 of the symbol, specified as a byte 
boundary (for example, an alignment of 16 means that the least 
significant 4 bits of the address should be zero). The alignment must be 
an absolute expression, and it must be a power of two. If ld allocates 
uninitialized memory for the common symbol, it will use the alignment 
when placing the symbol. If no alignment is specified, as will set the 
alignment to the largest power of two less than or equal to the size of 
the symbol, up to a maximum of 16.


seen on: 
http://stackoverflow.com/questions/501105/gcc-generated-assembly-comm
---------------------------------------------------------------------

so regarding my question, ld will use the largest memory space found as 
a .comm foo,
  so no harm at all with this mistake :D

thanks for your time anyway.
-J
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: SOLVED OT - C compiler, assignement on double-declared ..., Jesus Sanchez, (Sat Apr 10, 10:14 pm)
Re: SOLVED OT - C compiler, assignement on double-declared ..., patrick keshishian, (Sat Apr 10, 10:49 pm)
Re: SOLVED OT - C compiler, assignement on double-declared ..., patrick keshishian, (Sun Apr 11, 12:06 am)
Re: OT - C compiler, assignement on double-declared variab ..., patrick keshishian, (Sun Apr 11, 12:27 pm)