[llvm-bugs] [Bug 41836] New: COFF obj2yaml -> yaml2obj round trip does the wrong thing with globals in .bss

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 10 14:05:12 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41836

            Bug ID: 41836
           Summary: COFF obj2yaml -> yaml2obj round trip does the wrong
                    thing with globals in .bss
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Object
          Assignee: unassignedbugs at nondot.org
          Reporter: rnk at google.com
                CC: llvm-bugs at lists.llvm.org

Seems related to https://bugs.llvm.org/show_bug.cgi?id=8338

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190510/8da32379/attachment.html>


More information about the llvm-bugs mailing list