https://sourceware.org/bugzilla/show_bug.cgi?id=27725
Bug ID: 27725 Summary: using -p in objcopy discards microseconds in destination timestamp Product: binutils Version: 2.34 Status: UNCONFIRMED Severity: normal Priority: P2 Component: binutils Assignee: unassigned at sourceware dot org Reporter: rhbroberg at yahoo dot com Target Milestone: --- It looks like the -p option to preserve timestamps only does it at the second level, not at the microsecond level. This causes issues in build systems which have target objects linked, and then objcopy'd, and the end timestamp is earlier than the original timestamp. If any compilation unit was built in the same second as the binary was linked, its timestamp will now be newer than the resulting binary, and a subsequent build will re-link the binary as it considers it to be out of date. Here is a simple example on a ubuntu-20.04 machine running binutils/2.34: rhb@ubuntu-20-04-01:/tmp$ ls -la --time-style=full-iso a.out -rwxrwxr-x 1 rhb rhb 17320 2021-04-13 18:58:04.829559663 +0000 a.out rhb@ubuntu-20-04-01:/tmp$ cp a.out a.out.withsymbols rhb@ubuntu-20-04-01:/tmp$ objcopy -p --only-keep-debug a.out a.out.debuginfo rhb@ubuntu-20-04-01:/tmp$ objcopy -p --strip-debug a.out rhb@ubuntu-20-04-01:/tmp$ objcopy -p --add-gnu-debuglink=a.out.debuginfo a.out rhb@ubuntu-20-04-01:/tmp$ ls -la --time-style=full-iso a.out* -rwxrwxr-x 1 rhb rhb 17320 2021-04-13 18:58:04.000000000 +0000 a.out -rwxrwxr-x 1 rhb rhb 5936 2021-04-13 18:58:04.000000000 +0000 a.out.debuginfo -rwxrwxr-x 1 rhb rhb 17320 2021-04-13 18:59:15.131891948 +0000 a.out.withsymbols rhb@ubuntu-20-04-01:/tmp$ rhb@ubuntu-20-04-01:/tmp$ apt list binutils Listing... Done binutils/focal-updates,focal-security,now 2.34-6ubuntu1.1 amd64 [installed,automatic] N: There is 1 additional version. Please use the '-a' switch to see it rhb@ubuntu-20-04-01:/tmp$ ----- Notice the timestamp of the created files have 0 as the microseconds timestamp. -- You are receiving this mail because: You are on the CC list for the bug.