How to redirect the fopen to open a different file instead of specifed filename in the program binary given as input to gem5 simulator in SE mode

14 views
Skip to first unread message

gogineni kailashnath

unread,
Jul 21, 2021, 11:48:57 AM7/21/21
to gem5-...@gem5.org, gem5-g...@googlegroups.com
Hello,

I have a C code, which creates a file file.txt and prints the hello world content in the file.

#include<stdio.h>

    int main () {
       FILE *fp;
       char str[] = "Hello world";
    
       fp = fopen( "file.txt" , "w" );
       fwrite(str , 1 , sizeof(str) , fp );
    
       fclose(fp);
      
       return(0);
    }

This binary is compiled in a static form My question is that, since I'm using a gem5 simulator in syscall emulation mode. I'm working on linux system.

In the hardware level, since we only know the instructions, for example if the binary has to open file.txt, how can I redirect it to open a different file (say hello.txt, i.e., for any filename specified, it should just trigger hello.txt). Any help would be appreciated.

Reply all
Reply to author
Forward
0 new messages