[llvm] r270158 - [yaml2obj] Removing debug code that scribbled 0xDEADBEEF

Chris Bieneman via llvm-commits llvm-commits at lists.llvm.org
Thu May 19 16:26:37 PDT 2016


Author: cbieneman
Date: Thu May 19 18:26:31 2016
New Revision: 270158

URL: http://llvm.org/viewvc/llvm-project?rev=270158&view=rev
Log:
[yaml2obj] Removing debug code that scribbled 0xDEADBEEF

Now that MachO load command fields are fully covered we can fill unaccounted for bytes with 0. That allows us to sparsely specify YAML to simplify tests.

Simplifying load_commands test accordingly.

Modified:
    llvm/trunk/test/ObjectYAML/MachO/load_commands.yaml
    llvm/trunk/tools/yaml2obj/yaml2macho.cpp

Modified: llvm/trunk/test/ObjectYAML/MachO/load_commands.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ObjectYAML/MachO/load_commands.yaml?rev=270158&r1=270157&r2=270158&view=diff
==============================================================================
--- llvm/trunk/test/ObjectYAML/MachO/load_commands.yaml (original)
+++ llvm/trunk/test/ObjectYAML/MachO/load_commands.yaml Thu May 19 18:26:31 2016
@@ -33,79 +33,6 @@ LoadCommands:
     initprot:        5
     nsects:          6
     flags:           0
-    Sections:        
-      - sectname:        __text
-        segname:         __TEXT
-        addr:            0x0000000100001160
-        size:            3099
-        offset:          0x00001160
-        align:           4
-        reloff:          0x00000000
-        nreloc:          0
-        flags:           0x80000400
-        reserved1:       0x00000000
-        reserved2:       0x00000000
-        reserved3:       0x00000000
-      - sectname:        __stubs
-        segname:         __TEXT
-        addr:            0x0000000100001D7C
-        size:            90
-        offset:          0x00001D7C
-        align:           1
-        reloff:          0x00000000
-        nreloc:          0
-        flags:           0x80000408
-        reserved1:       0x00000000
-        reserved2:       0x00000006
-        reserved3:       0x00000000
-      - sectname:        __stub_helper
-        segname:         __TEXT
-        addr:            0x0000000100001DD8
-        size:            166
-        offset:          0x00001DD8
-        align:           2
-        reloff:          0x00000000
-        nreloc:          0
-        flags:           0x80000400
-        reserved1:       0x00000000
-        reserved2:       0x00000000
-        reserved3:       0x00000000
-      - sectname:        __gcc_except_tab
-        segname:         __TEXT
-        addr:            0x0000000100001E80
-        size:            240
-        offset:          0x00001E80
-        align:           2
-        reloff:          0x00000000
-        nreloc:          0
-        flags:           0x00000000
-        reserved1:       0x00000000
-        reserved2:       0x00000000
-        reserved3:       0x00000000
-      - sectname:        __cstring
-        segname:         __TEXT
-        addr:            0x0000000100001F70
-        size:            15
-        offset:          0x00001F70
-        align:           0
-        reloff:          0x00000000
-        nreloc:          0
-        flags:           0x00000002
-        reserved1:       0x00000000
-        reserved2:       0x00000000
-        reserved3:       0x00000000
-      - sectname:        __unwind_info
-        segname:         __TEXT
-        addr:            0x0000000100001F80
-        size:            120
-        offset:          0x00001F80
-        align:           2
-        reloff:          0x00000000
-        nreloc:          0
-        flags:           0x00000000
-        reserved1:       0x00000000
-        reserved2:       0x00000000
-        reserved3:       0x00000000
   - cmd:             LC_SEGMENT_64
     cmdsize:         312
     segname:         __DATA
@@ -117,43 +44,6 @@ LoadCommands:
     initprot:        3
     nsects:          3
     flags:           0
-    Sections:        
-      - sectname:        __got
-        segname:         __DATA
-        addr:            0x0000000100002000
-        size:            24
-        offset:          0x00002000
-        align:           3
-        reloff:          0x00000000
-        nreloc:          0
-        flags:           0x00000006
-        reserved1:       0x0000000F
-        reserved2:       0x00000000
-        reserved3:       0x00000000
-      - sectname:        __nl_symbol_ptr
-        segname:         __DATA
-        addr:            0x0000000100002018
-        size:            16
-        offset:          0x00002018
-        align:           3
-        reloff:          0x00000000
-        nreloc:          0
-        flags:           0x00000006
-        reserved1:       0x00000012
-        reserved2:       0x00000000
-        reserved3:       0x00000000
-      - sectname:        __la_symbol_ptr
-        segname:         __DATA
-        addr:            0x0000000100002028
-        size:            120
-        offset:          0x00002028
-        align:           3
-        reloff:          0x00000000
-        nreloc:          0
-        flags:           0x00000007
-        reserved1:       0x00000014
-        reserved2:       0x00000000
-        reserved3:       0x00000000
   - cmd:             LC_SEGMENT_64
     cmdsize:         72
     segname:         __LINKEDIT

Modified: llvm/trunk/tools/yaml2obj/yaml2macho.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2macho.cpp?rev=270158&r1=270157&r2=270158&view=diff
==============================================================================
--- llvm/trunk/tools/yaml2obj/yaml2macho.cpp (original)
+++ llvm/trunk/tools/yaml2obj/yaml2macho.cpp Thu May 19 18:26:31 2016
@@ -182,13 +182,12 @@ Error MachOWriter::writeLoadCommands(raw
       BytesWritten += LC.ZeroPadBytes;
     }
 
+    // Fill remaining bytes with 0. This will only get hit in partially
+    // specified test cases.
     auto BytesRemaining = LC.Data.load_command_data.cmdsize - BytesWritten;
     if (BytesRemaining > 0) {
-      // TODO: Replace all this once the load command data is present in yaml.
-      // For now I fill with 0xDEADBEEF because it is easy to spot on a hex
-      // viewer.
       std::vector<uint32_t> FillData;
-      FillData.insert(FillData.begin(), BytesRemaining / 4 + 1, 0xDEADBEEFu);
+      FillData.insert(FillData.begin(), BytesRemaining, 0);
       OS.write(reinterpret_cast<char *>(FillData.data()), BytesRemaining);
     }
   }




More information about the llvm-commits mailing list