From 2804789be8640d5d4f0bd72e26c7ed1ff94e279e Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 15 Dec 2019 20:39:01 +0000 Subject: [PATCH] testsc: print the address of main(). As explained in the comment in the code, this makes it easier to map addresses in the log files back to addresses in the code, if the testsc image is built as a position-independent executable. --- testsc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/testsc.c b/testsc.c index 87f1e674..38edb8aa 100644 --- a/testsc.c +++ b/testsc.c @@ -1450,6 +1450,15 @@ int main(int argc, char **argv) if (is_dry_run) { printf("Dry run (DynamoRIO instrumentation not detected)\n"); } else { + /* Print the address of main() in this run. The idea is that + * if this image is compiled to be position-independent, then + * PC values in the logs won't match the ones you get if you + * disassemble the binary, so it'll be harder to match up the + * log messages to the code. But if you know the address of a + * fixed (and not inlined) function in both worlds, you can + * find out the offset between them. */ + printf("Live run, main = %p\n", (void *)main); + if (!outdir) { fprintf(stderr, "expected -O option\n"); return 1;