[llvm] 4669cc9 - [test][llvm-objcopy/mac] Fix invalid strip tests

Keith Smiley via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 7 20:06:53 PST 2022


Author: Keith Smiley
Date: 2022-02-07T20:01:48-08:00
New Revision: 4669cc93948e6d058812fc2f8f888dc478f09b33

URL: https://github.com/llvm/llvm-project/commit/4669cc93948e6d058812fc2f8f888dc478f09b33
DIFF: https://github.com/llvm/llvm-project/commit/4669cc93948e6d058812fc2f8f888dc478f09b33.diff

LOG: [test][llvm-objcopy/mac] Fix invalid strip tests

I discovered some of these tests had `cmp` statements that weren't
actually being run. I had also recently copied this broken setup for a
new test around chained fixups. Fixing this revealed that the binaries
did differ because of their code signature so I regenerated the fixture
here with this source:

```c
int main() {
   return 0;
}
```

Passing `-Wl,-no_adhoc_codesign` on my M1 machine to make sure it didn't
get any signature.

Differential Revision: https://reviews.llvm.org/D119203

Added: 
    

Modified: 
    llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-chained-fixups.yaml
    llvm/test/tools/llvm-objcopy/MachO/strip-all.test

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-chained-fixups.yaml b/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-chained-fixups.yaml
index 358716da1b87..c66b565253bf 100644
--- a/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-chained-fixups.yaml
+++ b/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-chained-fixups.yaml
@@ -4,8 +4,8 @@ FileHeader:
   cputype:         0x100000C
   cpusubtype:      0x0
   filetype:        0x2
-  ncmds:           16
-  sizeofcmds:      744
+  ncmds:           15
+  sizeofcmds:      728
   flags:           0x200085
   reserved:        0x0
 LoadCommands:
@@ -34,9 +34,9 @@ LoadCommands:
     Sections:
       - sectname:        __text
         segname:         __TEXT
-        addr:            0x100003F98
-        size:            24
-        offset:          0x3F98
+        addr:            0x100003FA4
+        size:            20
+        offset:          0x3FA4
         align:           2
         reloff:          0x0
         nreloc:          0
@@ -44,12 +44,12 @@ LoadCommands:
         reserved1:       0x0
         reserved2:       0x0
         reserved3:       0x0
-        content:         C0035FD6FF4300D100008052FF0F00B9FF430091C0035FD6
+        content:         FF4300D100008052FF0F00B9FF430091C0035FD6
       - sectname:        __unwind_info
         segname:         __TEXT
-        addr:            0x100003FB0
-        size:            80
-        offset:          0x3FB0
+        addr:            0x100003FB8
+        size:            72
+        offset:          0x3FB8
         align:           2
         reloff:          0x0
         nreloc:          0
@@ -57,14 +57,14 @@ LoadCommands:
         reserved1:       0x0
         reserved2:       0x0
         reserved3:       0x0
-        content:         010000001C000000000000001C000000000000001C00000002000000983F00003400000034000000B13F00000000000034000000030000000C0002001400020000000001040000000010000200000002
+        content:         010000001C000000000000001C000000000000001C00000002000000A43F00003400000034000000B93F00000000000034000000030000000C000100100001000000000000100002
   - cmd:             LC_SEGMENT_64
     cmdsize:         72
     segname:         __LINKEDIT
     vmaddr:          4294983680
     vmsize:          16384
     fileoff:         16384
-    filesize:        753
+    filesize:        176
     maxprot:         1
     initprot:        1
     nsects:          0
@@ -76,20 +76,20 @@ LoadCommands:
   - cmd:             LC_DYLD_EXPORTS_TRIE
     cmdsize:         16
     dataoff:         16440
-    datasize:        56
+    datasize:        48
   - cmd:             LC_SYMTAB
     cmdsize:         24
-    symoff:          16504
-    nsyms:           15
-    stroff:          16744
-    strsize:         120
+    symoff:          16496
+    nsyms:           2
+    stroff:          16528
+    strsize:         32
   - cmd:             LC_DYSYMTAB
     cmdsize:         80
     ilocalsym:       0
-    nlocalsym:       12
-    iextdefsym:      12
-    nextdefsym:      3
-    iundefsym:       15
+    nlocalsym:       0
+    iextdefsym:      0
+    nextdefsym:      2
+    iundefsym:       2
     nundefsym:       0
     tocoff:          0
     ntoc:            0
@@ -110,12 +110,12 @@ LoadCommands:
     ZeroPadBytes:    7
   - cmd:             LC_UUID
     cmdsize:         24
-    uuid:            F445529E-643C-3A38-8F59-AB64566BCAFF
+    uuid:            9F5977A4-F4EB-3BE2-BB19-E21B49454091
   - cmd:             LC_BUILD_VERSION
     cmdsize:         32
     platform:        1
     minos:           786432
-    sdk:             786432
+    sdk:             786688
     ntools:          1
     Tools:
       - tool:            3
@@ -125,7 +125,7 @@ LoadCommands:
     version:         0
   - cmd:             LC_MAIN
     cmdsize:         24
-    entryoff:        16284
+    entryoff:        16292
     stacksize:       0
   - cmd:             LC_LOAD_DYLIB
     cmdsize:         56
@@ -138,78 +138,14 @@ LoadCommands:
     ZeroPadBytes:    6
   - cmd:             LC_FUNCTION_STARTS
     cmdsize:         16
-    dataoff:         16496
+    dataoff:         16488
     datasize:        8
   - cmd:             LC_DATA_IN_CODE
     cmdsize:         16
-    dataoff:         16504
+    dataoff:         16496
     datasize:        0
-  - cmd:             LC_CODE_SIGNATURE
-    cmdsize:         16
-    dataoff:         16864
-    datasize:        273
 LinkEditData:
   NameList:
-    - n_strx:          33
-      n_type:          0x64
-      n_sect:          0
-      n_desc:          0
-      n_value:         0
-    - n_strx:          39
-      n_type:          0x64
-      n_sect:          0
-      n_desc:          0
-      n_value:         0
-    - n_strx:          46
-      n_type:          0x66
-      n_sect:          0
-      n_desc:          1
-      n_value:         1636754403
-    - n_strx:          1
-      n_type:          0x2E
-      n_sect:          1
-      n_desc:          0
-      n_value:         4294983576
-    - n_strx:          109
-      n_type:          0x24
-      n_sect:          1
-      n_desc:          0
-      n_value:         4294983576
-    - n_strx:          1
-      n_type:          0x24
-      n_sect:          0
-      n_desc:          0
-      n_value:         4
-    - n_strx:          1
-      n_type:          0x4E
-      n_sect:          1
-      n_desc:          0
-      n_value:         4
-    - n_strx:          1
-      n_type:          0x2E
-      n_sect:          1
-      n_desc:          0
-      n_value:         4294983580
-    - n_strx:          114
-      n_type:          0x24
-      n_sect:          1
-      n_desc:          0
-      n_value:         4294983580
-    - n_strx:          1
-      n_type:          0x24
-      n_sect:          0
-      n_desc:          0
-      n_value:         20
-    - n_strx:          1
-      n_type:          0x4E
-      n_sect:          1
-      n_desc:          0
-      n_value:         20
-    - n_strx:          1
-      n_type:          0x64
-      n_sect:          1
-      n_desc:          0
-      n_value:         0
     - n_strx:          2
       n_type:          0xF
       n_sect:          1
@@ -219,20 +155,13 @@ LinkEditData:
       n_type:          0xF
       n_sect:          1
       n_desc:          0
-      n_value:         4294983576
-    - n_strx:          27
-      n_type:          0xF
-      n_sect:          1
-      n_desc:          0
-      n_value:         4294983580
+      n_value:         4294983588
   StringTable:
     - ' '
     - __mh_execute_header
-    - _foo
-    - _main
-    - '/tmp/'
-    - main.c
-    - '/var/folders/gj/wf3swl0x215b2sq1qy84kzkm0000gn/T/main-e32fe7.o'
-    - _foo
     - _main
+    - ''
+    - ''
+    - ''
+    - ''
 ...

diff  --git a/llvm/test/tools/llvm-objcopy/MachO/strip-all.test b/llvm/test/tools/llvm-objcopy/MachO/strip-all.test
index d64ea0b9bbfb..5cea836b3ba2 100644
--- a/llvm/test/tools/llvm-objcopy/MachO/strip-all.test
+++ b/llvm/test/tools/llvm-objcopy/MachO/strip-all.test
@@ -24,23 +24,23 @@
 ## "llvm-strip --strip-all" and "llvm-objcopy --strip-all".
 # RUN: llvm-strip %t.exec -o %t2
 # RUN: llvm-strip --strip-all %t.exec -o %t3
-# cmp %t2 %t.exec.stripped
-# cmp %t3 %t.exec.stripped
+# RUN: cmp %t2 %t.exec.stripped
+# RUN: cmp %t3 %t.exec.stripped
 
 # RUN: llvm-strip %t.dwarf -o %t4
 # RUN: llvm-strip --strip-all %t.dwarf -o %t5
-# cmp %t4 %t.dwarf.stripped
-# cmp %t5 %t.dwarf.stripped
+# RUN: cmp %t4 %t.dwarf.stripped
+# RUN: cmp %t5 %t.dwarf.stripped
 
 # RUN: llvm-lipo %t.dwarf -create -output %t.dwarf.universal
 # RUN: llvm-strip %t.dwarf.universal -o %t.dwarf.universal.stripped
 # RUN: llvm-lipo %t.dwarf.universal.stripped -thin x86_64 -output %t6
 # RUN: cmp %t6 %t.dwarf.stripped
 
-# RUN: llvm-strip %t.exec -o %t7
-# RUN: llvm-strip --strip-all %t.exec -o %t8
-# cmp %t7 %t.fixups.stripped
-# cmp %t8 %t.fixups.stripped
+# RUN: llvm-strip %t.fixups -o %t7
+# RUN: llvm-strip --strip-all %t.fixups -o %t8
+# RUN: cmp %t7 %t.fixups.stripped
+# RUN: cmp %t8 %t.fixups.stripped
 
 ## Make sure that debug sections are removed.
 # DWARF:       Sections [


        


More information about the llvm-commits mailing list