<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 8/5/2013 11:06 PM, Rui Ueyama wrote:<br>
    </div>
    <blockquote
cite="mid:CAJENXgvWN6=3W-JQs1EtwPV26XDy4Yc0ZYc49Wn_atMLAX7OcA@mail.gmail.com"
      type="cite">
      <pre wrap="">On Mon, Aug 5, 2013 at 8:58 PM, Shankar Easwaran <a class="moz-txt-link-rfc2396E" href="mailto:shankare@codeaurora.org"><shankare@codeaurora.org></a>wrote:

</pre>
      <blockquote type="cite">
        <pre wrap="">Isnt this supposed to be meant for common symbols ?
</pre>
      </blockquote>
      <pre wrap="">

I guess it's the correct terminology, but I don't know much about it. Is
this different from atoms for BSS?
</pre>
    </blockquote>
    This is the definition for ELF common symbols (extracted from Ian's
    blog) :-<br>
    <br>
    <span style="color: rgb(51, 51, 51); font-family: 'Lucida Grande',
      'Lucida Sans Unicode', Verdana, Arial, sans-serif; font-size:
      12px; font-style: normal; font-variant: normal; font-weight:
      normal; letter-spacing: normal; line-height: 18.71875px; orphans:
      auto; text-align: left; text-indent: 0px; text-transform: none;
      white-space: normal; widows: auto; word-spacing: 0px;
      -webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
      255); display: inline !important; float: none;">A section index of<span
        class="Apple-converted-space"> </span></span><code
      style="font-family: monospace; color: rgb(102, 102, 102);
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: 18.71875px; orphans: auto;
      text-align: left; text-indent: 0px; text-transform: none;
      white-space: normal; widows: auto; word-spacing: 0px;
      -webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
      255);">SHN_COMMON</code><span style="color: rgb(51, 51, 51);
      font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana,
      Arial, sans-serif; font-size: 12px; font-style: normal;
      font-variant: normal; font-weight: normal; letter-spacing: normal;
      line-height: 18.71875px; orphans: auto; text-align: left;
      text-indent: 0px; text-transform: none; white-space: normal;
      widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;
      background-color: rgb(255, 255, 255); display: inline !important;
      float: none;"><span class="Apple-converted-space"> </span>(</span><code
      style="font-family: monospace; color: rgb(102, 102, 102);
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: 18.71875px; orphans: auto;
      text-align: left; text-indent: 0px; text-transform: none;
      white-space: normal; widows: auto; word-spacing: 0px;
      -webkit-text-stroke-width: 0px; background-color: rgb(255, 255,
      255);">0xfff2</code><span style="color: rgb(51, 51, 51);
      font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana,
      Arial, sans-serif; font-size: 12px; font-style: normal;
      font-variant: normal; font-weight: normal; letter-spacing: normal;
      line-height: 18.71875px; orphans: auto; text-align: left;
      text-indent: 0px; text-transform: none; white-space: normal;
      widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;
      background-color: rgb(255, 255, 255); display: inline !important;
      float: none;">) indicates a common symbol. Common symbols were
      invented to handle Fortran common blocks, and they are also often
      used for uninitialized global variables in C. A common symbol has
      unusual semantics. Common symbols have a value of zero, but set
      the size field to the desired size. If one object file has a
      common symbol and another has a definition, the common symbol is
      treated as an undefined reference. If there is no definition for a
      common symbol, the program linker acts as though it saw a
      definition initialized to zero of the appropriate size. Two object
      files may have common symbols of different sizes, in which case
      the program linker will use the largest size. I</span><br>
    <blockquote
cite="mid:CAJENXgvWN6=3W-JQs1EtwPV26XDy4Yc0ZYc49Wn_atMLAX7OcA@mail.gmail.com"
      type="cite">
      <pre wrap="">

</pre>
      <blockquote type="cite">
        <pre wrap="">
On 8/2/2013 12:25 AM, Rui Ueyama wrote:

</pre>
        <blockquote type="cite">
          <pre wrap="">Author: ruiu
Date: Fri Aug  2 00:25:31 2013
New Revision: 187645

URL: <a class="moz-txt-link-freetext" href="http://llvm.org/viewvc/llvm-**project?rev=187645&view=rev">http://llvm.org/viewvc/llvm-**project?rev=187645&view=rev</a><a class="moz-txt-link-rfc2396E" href="http://llvm.org/viewvc/llvm-project?rev=187645&view=rev"><http://llvm.org/viewvc/llvm-project?rev=187645&view=rev></a>
Log:
[PECOFF] A symbol with symbol with section number 0 and non-zero value
represents a BSS atom.

Added:
     lld/trunk/test/pecoff/Inputs/**bss-undef.obj.yaml
     lld/trunk/test/pecoff/bss-**undef.test
Modified:
     lld/trunk/lib/ReaderWriter/**PECOFF/ReaderCOFF.cpp

Modified: lld/trunk/lib/ReaderWriter/**PECOFF/ReaderCOFF.cpp
URL: <a class="moz-txt-link-freetext" href="http://llvm.org/viewvc/llvm-**project/lld/trunk/lib/**">http://llvm.org/viewvc/llvm-**project/lld/trunk/lib/**</a>
ReaderWriter/PECOFF/**ReaderCOFF.cpp?rev=187645&r1=**
187644&r2=187645&view=diff<a class="moz-txt-link-rfc2396E" href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=187645&r1=187644&r2=187645&view=diff"><http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=187645&r1=187644&r2=187645&view=diff></a>
==============================**==============================**
==================
--- lld/trunk/lib/ReaderWriter/**PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/**PECOFF/ReaderCOFF.cpp Fri Aug  2
00:25:31 2013
@@ -161,6 +161,20 @@ private:
      // Filter non-defined atoms, and group defined atoms by its section.
      SectionToSymbolsT definedSymbols;
      for (const coff_symbol *sym : symbols) {
+      // A symbol with section number 0 and non-zero value represents an
+      // uninitialized data. I don't understand why there are two ways
to define
+      // an uninitialized data symbol (.bss and this way), but that's
how COFF
+      // works.
+      if (sym->SectionNumber == llvm::COFF::IMAGE_SYM_**UNDEFINED &&
+          sym->Value > 0) {
+        StringRef name = _symbolName[sym];
+        uint32_t size = sym->Value;
+        auto *atom = new (_alloc) COFFBSSAtom(*this, name, sym, size, 0);
+        result.push_back(atom);
+        continue;
+      }
+
+      // Skip if it's not for defined atom.
        if (sym->SectionNumber == llvm::COFF::IMAGE_SYM_ABSOLUTE ||
            sym->SectionNumber == llvm::COFF::IMAGE_SYM_**UNDEFINED)
          continue;

Added: lld/trunk/test/pecoff/Inputs/**bss-undef.obj.yaml
URL: <a class="moz-txt-link-freetext" href="http://llvm.org/viewvc/llvm-**project/lld/trunk/test/pecoff/**">http://llvm.org/viewvc/llvm-**project/lld/trunk/test/pecoff/**</a>
Inputs/bss-undef.obj.yaml?rev=**187645&view=auto<a class="moz-txt-link-rfc2396E" href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/bss-undef.obj.yaml?rev=187645&view=auto"><http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/bss-undef.obj.yaml?rev=187645&view=auto></a>
==============================**==============================**
==================
--- lld/trunk/test/pecoff/Inputs/**bss-undef.obj.yaml (added)
+++ lld/trunk/test/pecoff/Inputs/**bss-undef.obj.yaml Fri Aug  2
00:25:31 2013
@@ -0,0 +1,43 @@
+---
+header:
+  Machine:         IMAGE_FILE_MACHINE_I386
+  Characteristics: [  ]
+sections:
+  - Name:            .text
+    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE,
IMAGE_SCN_MEM_READ ]
+    Alignment:       4
+    SectionData:     ""
+  - Name:            .data
+    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_**DATA,
IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
+    Alignment:       4
+    SectionData:     03000000
+symbols:
+  - Name:            .text
+    Value:           0
+    SectionNumber:   1
+    SimpleType:      IMAGE_SYM_TYPE_NULL
+    ComplexType:     IMAGE_SYM_DTYPE_NULL
+    StorageClass:    IMAGE_SYM_CLASS_STATIC
+    NumberOfAuxSymbols: 1
+    AuxiliaryData:   000000000000000000000000000000**000000
+  - Name:            .data
+    Value:           0
+    SectionNumber:   2
+    SimpleType:      IMAGE_SYM_TYPE_NULL
+    ComplexType:     IMAGE_SYM_DTYPE_NULL
+    StorageClass:    IMAGE_SYM_CLASS_STATIC
+    NumberOfAuxSymbols: 1
+    AuxiliaryData:   040000000000000000000000000000**000000
+  - Name:            _bssdata1
+    Value:           4
+    SectionNumber:   0
+    SimpleType:      IMAGE_SYM_TYPE_NULL
+    ComplexType:     IMAGE_SYM_DTYPE_NULL
+    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
+  - Name:            _bssdata2
+    Value:           4
+    SectionNumber:   0
+    SimpleType:      IMAGE_SYM_TYPE_NULL
+    ComplexType:     IMAGE_SYM_DTYPE_NULL
+    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
+...

Added: lld/trunk/test/pecoff/bss-**undef.test
URL: <a class="moz-txt-link-freetext" href="http://llvm.org/viewvc/llvm-**project/lld/trunk/test/pecoff/**">http://llvm.org/viewvc/llvm-**project/lld/trunk/test/pecoff/**</a>
bss-undef.test?rev=187645&**view=auto<a class="moz-txt-link-rfc2396E" href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/bss-undef.test?rev=187645&view=auto"><http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/bss-undef.test?rev=187645&view=auto></a>
==============================**==============================**
==================
--- lld/trunk/test/pecoff/bss-**undef.test (added)
+++ lld/trunk/test/pecoff/bss-**undef.test Fri Aug  2 00:25:31 2013
@@ -0,0 +1,22 @@
+# RUN: yaml2obj %p/Inputs/bss-undef.obj.yaml > %t.obj
+#
+# RUN: lld -flavor link /out:%t /subsystem:console /force -- %t.obj \
+# RUN:    && llvm-readobj -sections %t | FileCheck %s
+
+CHECK:       Section {
+CHECK:         Number: 2
+CHECK-NEXT:    Name: .bss
+CHECK-NEXT:    VirtualSize: 0x0
+CHECK-NEXT:    VirtualAddress: 0x2000
+CHECK-NEXT:    RawDataSize: 512
+CHECK-NEXT:    PointerToRawData: 0x0
+CHECK-NEXT:    PointerToRelocations: 0x0
+CHECK-NEXT:    PointerToLineNumbers: 0x0
+CHECK-NEXT:    RelocationCount: 0
+CHECK-NEXT:    LineNumberCount: 0
+CHECK-NEXT:    Characteristics [
+CHECK-NEXT:      IMAGE_SCN_CNT_UNINITIALIZED_**DATA
+CHECK-NEXT:      IMAGE_SCN_MEM_READ
+CHECK-NEXT:      IMAGE_SCN_MEM_WRITE
+CHECK-NEXT:    ]
+CHECK-NEXT:  }


______________________________**_________________
llvm-commits mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/**mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/**mailman/listinfo/llvm-commits</a><a class="moz-txt-link-rfc2396E" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits"><http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits></a>



</pre>
        </blockquote>
        <pre wrap="">
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted
by the Linux Foundation


</pre>
      </blockquote>
      <pre wrap="">
</pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation</pre>
  </body>
</html>