<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - COFF obj2yaml -> yaml2obj round trip does the wrong thing with globals in .bss"
   href="https://bugs.llvm.org/show_bug.cgi?id=41836">41836</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>COFF obj2yaml -> yaml2obj round trip does the wrong thing with globals in .bss
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Object
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rnk@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Seems related to <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - MC-COFF: section.bss always has .size as 0"
   href="show_bug.cgi?id=8338">https://bugs.llvm.org/show_bug.cgi?id=8338</a>

Specifically, SizeOfRawData for .bss sections is not preserved, it is zeroed
out. LLD currently contains a lot of yaml input test cases with accidentally
zero-sized globals in .bss because of this.

Consider:
$ cat bss.s
.bss
.global gv_bss
gv_bss:
.long 0

$ llvm-mc bss.s -o bss.obj -filetype=obj

$ obj2yaml bss.obj | yaml2obj -o bss2.obj

$ llvm-readobj -sections bss.obj > bss1.txt

$ llvm-readobj -sections bss2.obj > bss2.txt

$ diff -u bss1.txt bss2.txt
--- bss1.txt    2019-05-10 14:00:19.121866800 -0700
+++ bss2.txt    2019-05-10 14:00:22.056197400 -0700
@@ -1,5 +1,5 @@

-File: bss.obj
+File: bss2.obj
 Format: COFF-x86-64
 Arch: x86_64
 AddressSize: 64bit
@@ -10,7 +10,7 @@
     VirtualSize: 0x0
     VirtualAddress: 0x0
     RawDataSize: 0
-    PointerToRawData: 0x8C
+    PointerToRawData: 0x0
     PointerToRelocations: 0x0
     PointerToLineNumbers: 0x0
     RelocationCount: 0
@@ -28,7 +28,7 @@
     VirtualSize: 0x0
     VirtualAddress: 0x0
     RawDataSize: 0
-    PointerToRawData: 0x8C
+    PointerToRawData: 0x0
     PointerToRelocations: 0x0
     PointerToLineNumbers: 0x0
     RelocationCount: 0
@@ -45,7 +45,7 @@
     Name: .bss (2E 62 73 73 00 00 00 00)
     VirtualSize: 0x0
     VirtualAddress: 0x0
-    RawDataSize: 4
+    RawDataSize: 0
     PointerToRawData: 0x0
     PointerToRelocations: 0x0
     PointerToLineNumbers: 0x0

The .data and .text differences are mostly meaningless, I think. Reducing the
size of the .bss section is an issue because it changes the meaning of the
object pretty significantly: globals in .bss get smaller.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>