xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/strip-preserve-mtime.test (revision 1562e4552cd1b3d2eadd956c966f8a60e928b8ca)
1## Note: ls -l prints the modified timestamp
2
3## Preserve dates when stripping to an output file.
4# RUN: yaml2obj %s -o %t.1.o
5# RUN: touch -m -t 199705050555.55 %t.1.o
6# RUN: llvm-strip -p %t.1.o -o %t-preserved.1.o
7# RUN: ls -l %t-preserved.1.o | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME
8# Check that the stripped output is in fact a valid object file.
9# RUN: llvm-readobj %t-preserved.1.o
10
11## Preserve dates available via objcopy interface as well.
12# RUN: yaml2obj %s -o %t.2.o
13# RUN: touch -m -t 199705050555.55 %t.2.o
14# RUN: llvm-objcopy -p %t.2.o %t-preserved.2.o
15# RUN: ls -l %t-preserved.2.o | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME
16# RUN: llvm-readobj %t-preserved.2.o
17
18## Preserve dates when stripping in place.
19# RUN: yaml2obj %s -o %t.3.o
20# RUN: touch -m -t 199705050555.55 %t.3.o
21# RUN: llvm-strip -p %t.3.o
22# RUN: ls -l %t.3.o | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME
23# RUN: llvm-readobj %t.3.o
24
25## Without -p set, don't preserve dates.
26# RUN: yaml2obj %s -o %t.4.o
27# RUN: touch -m -t 199705050555.55 %t.4.o
28# RUN: llvm-strip %t.4.o
29# RUN: ls -l %t.4.o | FileCheck %s --check-prefix=CHECK-NO-PRESERVE-MTIME
30# RUN: llvm-readobj %t.4.o
31
32## Preserve dates in archives.
33# RUN: yaml2obj %s -o %t.5.o
34# RUN: rm -f %t.a
35# RUN: llvm-ar cr %t.a %t.5.o
36# RUN: touch -m -t 199705050555.55 %t.a
37# RUN: llvm-strip -p %t.a
38# RUN: ls -l %t.a | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME
39# RUN: llvm-readobj %t.a
40
41## Preserve dates in split DWO files.
42# RUN: cp %p/Inputs/dwarf.dwo %t-input.dwo
43# RUN: touch -m -t 199705050555.55 %t-input.dwo
44# RUN: llvm-objcopy -p --split-dwo=%t-dwo %t-input.dwo %t-nondwo
45# RUN: ls -l %t-dwo | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME
46# RUN: llvm-readobj %t-dwo
47# RUN: ls -l %t-nondwo | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME
48# RUN: llvm-readobj %t-nondwo
49
50## --preserve-dates and -p are aliases.
51# RUN: llvm-strip --preserve-dates %t.1.o -o %t-preserved.1.alias.o
52# RUN: ls -l %t-preserved.1.alias.o | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME
53# RUN: cmp %t-preserved.1.alias.o %t-preserved.1.o
54# RUN: llvm-objcopy --preserve-dates %t.2.o %t-preserved.2.alias.o
55# RUN: ls -l %t-preserved.2.alias.o | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME
56# RUN: cmp %t-preserved.2.o %t-preserved.2.alias.o
57
58# CHECK-PRESERVE-MTIME:        {{[[:space:]]1997}}
59# CHECK-NO-PRESERVE-MTIME-NOT: {{[[:space:]]1997}}
60
61!ELF
62FileHeader:
63  Class:           ELFCLASS64
64  Data:            ELFDATA2LSB
65  Type:            ET_REL
66  Machine:         EM_X86_64
67Sections:
68  - Name:            .text
69    Type:            SHT_PROGBITS
70    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
71