Skip to content

Commit

Permalink
document overall idea of win_forwarder.c
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Aug 23, 2024
1 parent d2cad41 commit d0f09d1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions recipe/win_forwarder.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
#include <string.h>
#include <tchar.h>

// the idea here is as follows; this wrapper will be compiled and renamed into
// a file corresponding to the versioned binaries created in install_llvm.bat.
// For example, we'll have llc.exe and llc-19.exe, both under %LIBRARY_BIN%.
// To avoid security holes, we ensure that the wrapper can only call binaries
// in %LIBRARY_BIN%, otherwise we fail. For example:
// * user calls `llc -version`; argv[0] == "llc", argv[1] == "-version"
// * determine path of calling binary, i.e. %LIBRARY_BIN%\llc.exe
// * construct versioned path, i.e. %LIBRARY_BIN%\llc-19.exe
// * collect all other arguments & quote them, e.g. `"argv[1]" "argv[2]" ...`
// * invoke `%LIBRARY_BIN%\llc-19.exe "argv[1]" "argv[2]" ...`
// * collect return value from inner call and return the same from wrapper

int _tmain( int argc, TCHAR *argv[] )
{
STARTUPINFO si;
Expand Down

0 comments on commit d0f09d1

Please sign in to comment.