[llvm] e16713d - Remove extraneous characters when printing the timestamp for an XCOFF object file.
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 3 10:19:32 PST 2023
Author: zhijian
Date: 2023-03-03T13:18:58-05:00
New Revision: e16713d8772bf77d1a41c65cb69ee93e6bd47798
URL: https://github.com/llvm/llvm-project/commit/e16713d8772bf77d1a41c65cb69ee93e6bd47798
DIFF: https://github.com/llvm/llvm-project/commit/e16713d8772bf77d1a41c65cb69ee93e6bd47798.diff
LOG: Remove extraneous characters when printing the timestamp for an XCOFF object file.
Summary:
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.
Summit the patch on behalf of Stephen Peckham.
Reviewers: James Henderson, Digger Lin
Differential Revision: https://reviews.llvm.org/D144281
Added:
Modified:
llvm/test/tools/llvm-readobj/XCOFF/file-header.test
llvm/tools/llvm-readobj/XCOFFDumper.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-readobj/XCOFF/file-header.test b/llvm/test/tools/llvm-readobj/XCOFF/file-header.test
index b7727dcf1d78a..8cbd84749fd48 100644
--- a/llvm/test/tools/llvm-readobj/XCOFF/file-header.test
+++ b/llvm/test/tools/llvm-readobj/XCOFF/file-header.test
@@ -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 (0x1)
# FILEHEADER32-NEXT: SymbolTableOffset: 0x3C
# FILEHEADER32-NEXT: SymbolTableEntries: 1
# FILEHEADER32-NEXT: OptionalHeaderSize: 0x0
diff --git a/llvm/tools/llvm-readobj/XCOFFDumper.cpp b/llvm/tools/llvm-readobj/XCOFFDumper.cpp
index 56f672b3c5aa5..8f4e55be2d915 100644
--- a/llvm/tools/llvm-readobj/XCOFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/XCOFFDumper.cpp
@@ -98,10 +98,11 @@ void XCOFFDumper::printFileHeaders() {
// 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] = {};
+
+ size_t BytesFormatted =
+ strftime(FormattedTime, sizeof(FormattedTime), "%F %T", gmtime(&TimeDate));
+ if (BytesFormatted)
W.printHex("TimeStamp", FormattedTime, TimeStamp);
else
W.printHex("Timestamp", TimeStamp);
More information about the llvm-commits
mailing list