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
# 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
// 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);