| 1 | #include <unistd.h> |
| 2 | |
| 3 | int main(int argc, const char *argv[], const char *envp[]) { |
| 4 | if (argc == 2) { |
| 5 | // If we have two arguments the first is the path to this executable, |
| 6 | // the second is the path to the linux dynamic loader that we should |
| 7 | // exec with. We want to re-run this problem under the dynamic loader |
| 8 | // and make sure we can hit the breakpoint in the "else". |
| 9 | const char *interpreter = argv[1]; |
| 10 | const char *this_program = argv[0]; |
| 11 | const char *exec_argv[3] = {interpreter, this_program, nullptr}; |
| 12 | execve(path: interpreter, argv: (char *const *)exec_argv, envp: (char *const *)envp); |
| 13 | } |
| 14 | // Break here |
| 15 | return 0; |
| 16 | } |
| 17 | |