- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Our developers compile the exe rather than having a commit process do if for us. The exe contains a template function to return a version number. The binary then gets edited externly by our commit process once regression tests pass.
But on upgrading to 2016 the binary file no longer contains the template string in 64 bit version. I have optimization dissabled for the source for the template function and even used the volatile keyword to indicate to the compiler to do optimising.
Here is the code:
module getVersionStringMod implicit none contains function getVers() result(aString) character(:), allocatable :: aString integer i #ifndef DEBUG character(35), volatile :: buildVersion #endif allocate(character(20)::aString) #ifdef DEBUG aString(1:1) = 'D' aString(2:2) = 'E' aString(3:3) = 'B' aString(4:4) = 'U' aString(5:5) = 'G' do i = 6, 20 aString(i:i) = ' ' end do #else buildVersion = '$Revision:: 0.0 $'C do i = 1, 20 aString(i:i) = buildVersion(12+i:12+i) end do #endif end function end module
The external editor looks for string
'$Revision:: 0.0 $'
But instead the binary contains:
'$Revisio odd chars here I could not include in post n:: 0.0 $'
Does the compiler now do some deliberate obfuscation ?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Very interesting. What happens is that the compiler does the assignment in pieces with integer move instructions. The source string therefore doesn't have to be contiguous in the object file.
What you want instead is to use an initialization for buildVersion like so:
character(35), volatile :: buildVersion = '$Revision:: 0.0 $'C
This will keep it all in one piece.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page