[LLVMbugs] [Bug 8354] New: MC-COFF: Don't emit local storage with .bss$linkonce

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Oct 11 10:19:46 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=8354

           Summary: MC-COFF: Don't emit local storage with .bss$linkonce
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: geek4civic at gmail.com
                CC: llvmbugs at cs.uiuc.edu


.bss$linkonce_foobar would be unified by linker.
static and anonymous variables should not emitted to linkonce.


//////// foo.cc
int foo;
static int bar;

namespace {
  int qux;
  static int quux;
}

void fooset(int a0, int a1, int a2, int a3)
{
  foo = a0;
  bar = a1;
  qux = a2;
  quux = a3;
}

int fooget()
{
  return foo + bar + qux + quux;
}

//////// bar.cc
extern int foo;
static int bar;

namespace {
  int qux;
  static int quux;
}

void barset(int a0, int a1, int a2, int a3)
{
  foo = a0;
  bar = a1;
  qux = a2;
  quux = a3;
}

int barget()
{
  return foo + bar + qux + quux;
}

========

$ clang++ -O3 -S -emit-llvm foo.cc -o foo.ll
(snip)
@foo = global i32 0, align 4
@_ZL3bar = internal global i32 0, align 4
@_ZN12_GLOBAL__N_13quxE = internal global i32 0, align 4
@_ZN12_GLOBAL__N_1L4quuxE = internal global i32 0, align 4

$ clang++ -O3 -S -emit-llvm bar.cc -o bar.ll
(snip)
@foo = external global i32
@_ZL3bar = internal global i32 0, align 4
@_ZN12_GLOBAL__N_13quxE = internal global i32 0, align 4
@_ZN12_GLOBAL__N_1L4quuxE = internal global i32 0, align 4

========

$ llc -filetype=obj foo.ll
$ llc -filetype=obj bar.ll
$ ld foo.o bar.o -o foobar.exe

$ objdump -h foobar.exe
Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         000000a8  00401000  00401000  00000400  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         00000004  00402000  00402000  00000600  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          0000000c  00403000  00403000  00000000  2**2
                  ALLOC
  3 .idata        00000014  00404000  00404000  00000800  2**2
                  CONTENTS, ALLOC, LOAD, DATA

!!! size of .bss should be 0x18(4 * 6)!

$ nm -n --demangle foobar.exe

00402000 D _data_start__
00402000 D foo
00402004 D _data_end__
00403000 B _bss_start__
00403000 B _bss_end__
00403000 b .bss$linkonce__ZL3bar
00403000 b bar
00403004 b .bss$linkonce__ZN12_GLOBAL__N_13quxE
00403004 b (anonymous namespace)::qux
00403008 b .bss$linkonce__ZN12_GLOBAL__N_1L4quuxE
00403008 b (anonymous namespace)::quux

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list