You might be interested to read more about this not particularly difficult problem, known in general as "dynamic software updating". You can get a general overview on Wikipedia, but I'd recommend having a browse through the work of Michael Hicks and colleagues: https://www.cs.umd.edu/~mwh/papers/mwh-cat.html
They've worked on a number of iterations on this idea, of which these are probably the most interesting and relevant to C:
Comments
You might be interested to read more about this not particularly difficult problem, known in general as "dynamic software updating". You can get a general overview on Wikipedia, but I'd recommend having a browse through the work of Michael Hicks and colleagues: https://www.cs.umd.edu/~mwh/papers/mwh-cat.html
They've worked on a number of iterations on this idea, of which these are probably the most interesting and relevant to C:
Original DSU paper (2001): https://www.cs.umd.edu/~mwh/papers/HicksMN01a.html
Proteus (2005/2007): https://www.cs.umd.edu/~mwh/papers/StoyleHBSN06.html
Ginseng (2006): https://www.cs.umd.edu/~mwh/papers/neamtiu06dsu.html
Kitsune (2012): https://www.cs.umd.edu/~mwh/papers/hayden12kitsune.html
I'd caution you that "I've never done it, but it seems easy" is the first symptom of early stage Dunning-Kruger. Don't ignore the warning signs!