Rafael EspĂndola
2006-Dec-18 21:14 UTC
[LLVMdev] [patch] emit .weak for zero initialized weak variables
> I'm not sure this is right. C code like this: > > int X; > > should compile to a .comm directive, not a .weak directive, right?right. According to GCC, "int x" should compile to ".comm x", but "int x __attribute__((weak))" should compile to --------------- .weak x x: .zero 4 --------------- It looks like we have a bug in llvm-gcc, both C codes compile to -------------------------- %x = weak global int 0 --------------------------> -ChrisBest Regards, Rafael
Chris Lattner
2006-Dec-19 06:46 UTC
[LLVMdev] [patch] emit .weak for zero initialized weak variables
On Mon, 18 Dec 2006, [UTF-8] Rafael Esp?ndola wrote:>> I'm not sure this is right. C code like this: >> >> int X; >> >> should compile to a .comm directive, not a .weak directive, right? > > right. > > According to GCC, "int x" should compile to ".comm x", but "int x > __attribute__((weak))" should compile to > --------------- > .weak x > x: > .zero 4 > --------------- > > It looks like we have a bug in llvm-gcc, both C codes compile to > -------------------------- > %x = weak global int 0 > --------------------------Is there a semantic difference between the two? Just because GCC compiles them to different things, it doesn't mean they do different things... -Chris -- http://nondot.org/sabre/ http://llvm.org/
Rafael EspĂndola
2006-Dec-26 16:47 UTC
[LLVMdev] [patch] emit .weak for zero initialized weak variables
> Is there a semantic difference between the two? Just because GCC compiles > them to different things, it doesn't mean they do different things...Sorry for the long delay... On a x86 box I am able to use both declarations interchangeably. There is a problem if we have both a declaration and an use on the same file: We must print a ".weak" because of the use, but if we printed a ".comm" for the declaration, the assembler will reject the file: Error: symbol `a' can not be both weak and common Best Regards, Rafael
Possibly Parallel Threads
- [LLVMdev] [patch] emit .weak for zero initialized weak variables
- [LLVMdev] [patch] emit .weak for zero initialized weak variables
- [LLVMdev] [patch] emit .weak for zero initialized weak variables
- [LLVMdev] [patch] emit .weak for zero initialized weak variables
- [lld] elf linker creates undefined empty symbol