linker: add LD_SHOW_AUXV support.
Yes, `od -t d8 /proc/self/auxv` is clever:
```
$ adb shell od -t d8 /proc/self/auxv
0000000 33 488593047552
0000020 51 4720
0000040 16 1155071
0000060 6 4096
0000100 17 100
0000120 3 375971917888
0000140 4 56
0000160 5 12
0000200 7 488593051648
0000220 8 0
0000240 9 375972184064
0000260 11 0
0000300 12 0
0000320 13 0
0000340 14 0
0000360 23 0
0000400 25 549220780840
0000420 26 0
0000440 31 549220786153
0000460 15 549220780856
0000500 0 0
0000520
$
```
But this is a lot easier to read:
```
$ adb shell LD_SHOW_AUXV=1 date
AT_SYSINFO_EHDR 0x7065010000
AT_MINSIGSTKSZ 4720
AT_HWCAP 0b100011001111111111111
AT_PAGESZ 4096
AT_CLKTCK 100
AT_PHDR 0x5c79d60040
AT_PHENT 56
AT_PHNUM 12
AT_BASE 0x7065011000
AT_FLAGS 0
AT_ENTRY 0x5c79da1000
AT_UID 0
AT_EUID 0
AT_GID 0
AT_EGID 0
AT_SECURE 0
AT_RANDOM 0x7ff814eb98
AT_HWCAP2 0
AT_EXECFN "/system/bin/date"
AT_PLATFORM "aarch64"
Tue Aug 22 20:43:22 GMT 2023
```
Test: adb shell LD_SHOW_AUXV=1 date
Change-Id: I51c4e8cbb799eb1dc360c9417cc6f82bebdcda73
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index 8a20670..5a33a63 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -32,6 +32,7 @@
#include <sys/auxv.h>
#include "linker.h"
+#include "linker_auxv.h"
#include "linker_cfi.h"
#include "linker_debug.h"
#include "linker_debuggerd.h"
@@ -324,12 +325,14 @@
g_linker_logger.ResetState();
- // Get a few environment variables.
+ // Enable debugging logs?
const char* LD_DEBUG = getenv("LD_DEBUG");
if (LD_DEBUG != nullptr) {
g_ld_debug_verbosity = atoi(LD_DEBUG);
}
+ if (getenv("LD_SHOW_AUXV") != nullptr) ld_show_auxv(args.auxv);
+
#if defined(__LP64__)
INFO("[ Android dynamic linker (64-bit) ]");
#else