[llvm] [yaml2obj][XOFF] Update yaml2obj for XCOFF to create valid XCOFF files in more cases. (PR #77620)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 25 00:47:47 PST 2024


================
@@ -0,0 +1,156 @@
+## Case 1: an error is reported when FileOffsetToData is too small
+## RUN: not yaml2obj --docnum=1 %s -o %t 2>&1 | \
+## RUN:   FileCheck %s --check-prefix=ERROR1
+#
+# ERROR1: error: current file offset (60) is bigger than the specified FileOffsetToData for the .text section (48)
+--- !XCOFF
+FileHeader:
+  MagicNumber:     0x1DF
+  NumberOfSections: 1
+  CreationTime:    1705445558
+  OffsetToSymbolTable: 0x4E
+  AuxiliaryHeaderSize: 0
+  Flags:           0x0
+Sections:
+  - Name:            .text
+    Address:         0x0
+    Size:            0x8
+    FileOffsetToData: 0x30
+    FileOffsetToRelocations: 0x44
+    NumberOfRelocations: 0x1
+    Flags:           [ STYP_TEXT ]
+    SectionData:     '480000014E800020'
+    Relocations:
+      - Address:         0x0
+        Symbol:          0x0
+        Info:            0x99
+        Type:            0x1A
+Symbols:
+  - Name:            .bar
+    Value:           0x0
+    Section:         N_UNDEF
+    Type:            0x0
+    StorageClass:    C_EXT
+    NumberOfAuxEntries: 1
+    AuxEntries:
+      - Type:            AUX_CSECT
+        SymbolAlignmentAndType: 0
+        StorageMappingClass: XMC_PR
+        SectionOrLength: 0
+  - Name:            .foo
+    Value:           0x0
+    Section:         .text
+    Type:            0x0
+    StorageClass:    C_EXT
+    NumberOfAuxEntries: 1
+    AuxEntries:
+      - Type:            AUX_CSECT
+        SymbolAlignmentAndType: 17
+        StorageMappingClass: XMC_PR
+        SectionOrLength: 8
+StringTable:     {}
+...
+## Case 2: an error is reported when FileOffsetToRelocations is too small
----------------
jh7370 wrote:

Nit: Include a blank line after the YAML too.

https://github.com/llvm/llvm-project/pull/77620


More information about the llvm-commits mailing list