Changeset f7ac09d for src/driver/as.cc
- Timestamp:
- Aug 2, 2018, 5:51:59 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 3537dd7
- Parents:
- 0a76d84
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/driver/as.cc
r0a76d84 rf7ac09d 10 10 // Created On : Wed Aug 1 10:49:42 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 2 1 6:18:14201813 // Update Count : 8412 // Last Modified On : Thu Aug 2 17:50:09 2018 13 // Update Count : 90 14 14 // 15 15 … … 38 38 off_t size = mystat.st_size; 39 39 40 if ( ftruncate( fd, size + 1 ) ) { perror( "ftruncate" ); exit( EXIT_FAILURE ); };41 42 40 char * start = (char *)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 ); 43 41 if ( start == (void *)-1 ) { perror( "mmap" ); exit( EXIT_FAILURE ); }; 44 42 45 char * cursor = strstr( start, ".Ldebug_info0:" ); // debug information ? 46 for ( int i = 0; i < 8; i += 1 ) { // move N (magic) lines forward 47 cursor = strstr( cursor, "\n" ) + 1; 48 } // for 49 cursor -= 2; // backup over "c\n" language value 50 if ( *(cursor - 1) != 'x' ) { fprintf( stderr, "invalid C language code\n" ); exit( EXIT_FAILURE ); }; 51 memmove( cursor + 2, cursor + 1, start + size - cursor - 1 ); // move text 1 character right 52 *(cursor) = '2'; // replace with CFA language value 53 *(cursor + 1) = '5'; 43 if ( char * cursor = strstr( start, ".Ldebug_info0:" ) ) { // debug information ? 44 // Expand file by one byte to hold 2 character Cforall language code. 45 if ( ftruncate( fd, size + 1 ) ) { perror( "ftruncate" ); exit( EXIT_FAILURE ); }; 54 46 55 if ( munmap( start, size ) ) { perror( "munmap" ); exit( EXIT_FAILURE ); }; 47 for ( int i = 0; i < 8; i += 1 ) { // move N (magic) lines forward 48 cursor = strstr( cursor, "\n" ) + 1; 49 } // for 50 51 cursor -= 2; // backup over "c\n" language value 52 if ( *(cursor - 1) != 'x' ) { fprintf( stderr, "invalid C language code\n" ); exit( EXIT_FAILURE ); }; 53 54 memmove( cursor + 2, cursor + 1, start + size - cursor - 1 ); // move remaining text 1 character right 55 56 *(cursor) = '2'; // replace C language value with CFA 57 *(cursor + 1) = '5'; 58 } // if 59 60 if ( munmap( start, size ) ) { perror( "munmap" ); exit( EXIT_FAILURE ); }; // update on disk 56 61 57 62 argv[0] = "as";
Note: See TracChangeset
for help on using the changeset viewer.