[PATCH] D144281: Update output for timestamp with llvm-readobj on XCOFF files.
Stephen Peckham via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 17 10:11:28 PST 2023
stephenpeckham created this revision.
stephenpeckham added reviewers: DiggerLin, jhenderson, MaskRay.
Herald added a project: All.
stephenpeckham requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The llvm-readobj prints extra characters for the timestamp when --file-headers is used with an XCOFF file. This change updates the format string used to print the time. In addition, the timestamp is printed in the local timezone, and a thread-safe call is used to convert the time.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D144281
Files:
llvm/test/tools/llvm-readobj/XCOFF/file-header.test
llvm/tools/llvm-readobj/XCOFFDumper.cpp
Index: llvm/tools/llvm-readobj/XCOFFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/XCOFFDumper.cpp
+++ llvm/tools/llvm-readobj/XCOFFDumper.cpp
@@ -98,10 +98,12 @@
// tests will let us know.
time_t TimeDate = TimeStamp;
- char FormattedTime[21] = {};
- size_t BytesWritten =
- strftime(FormattedTime, 21, "%Y-%m-%dT%H:%M:%SZ", gmtime(&TimeDate));
- if (BytesWritten)
+ char FormattedTime[80] = {};
+ struct tm local_tm;
+ size_t BytesFormatted =
+ strftime(FormattedTime, sizeof(FormattedTime), "%F %T %Z",
+ localtime_r(&TimeDate, &local_tm));
+ if (BytesFormatted)
W.printHex("TimeStamp", FormattedTime, TimeStamp);
else
W.printHex("Timestamp", TimeStamp);
Index: llvm/test/tools/llvm-readobj/XCOFF/file-header.test
===================================================================
--- llvm/test/tools/llvm-readobj/XCOFF/file-header.test
+++ llvm/test/tools/llvm-readobj/XCOFF/file-header.test
@@ -1,7 +1,7 @@
## This is a general test for the --file-header option.
# RUN: yaml2obj %s -o %t1
-# RUN: llvm-readobj %t1 --file-header | \
+# RUN: TZ=GMT llvm-readobj %t1 --file-header | \
# RUN: FileCheck %s --strict-whitespace --match-full-lines --check-prefix=FILEHEADER32
# FILEHEADER32:Format: aixcoff-rs6000
@@ -10,7 +10,7 @@
# FILEHEADER32-NEXT:FileHeader {
# FILEHEADER32-NEXT: Magic: 0x1DF
# FILEHEADER32-NEXT: NumberOfSections: 1
-# FILEHEADER32-NEXT: TimeStamp: 1970-01-01T00:00:01Z (0x1)
+# FILEHEADER32-NEXT: TimeStamp: 1970-01-01 00:00:01 GMT (0x1)
# FILEHEADER32-NEXT: SymbolTableOffset: 0x3C
# FILEHEADER32-NEXT: SymbolTableEntries: 1
# FILEHEADER32-NEXT: OptionalHeaderSize: 0x0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144281.498426.patch
Type: text/x-patch
Size: 1765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230217/098f6a6f/attachment.bin>
More information about the llvm-commits
mailing list