Ensure posix/init.c is included by the linker.

Change-Id: I24cec815f6a58a09483059bcc4d978568b305530
diff --git a/libipt/BUILD.gn b/libipt/BUILD.gn
index f2f069a..5641686 100644
--- a/libipt/BUILD.gn
+++ b/libipt/BUILD.gn
@@ -71,7 +71,9 @@
   if (is_linux) {
     sources += [
       "internal/include/posix/pt_section_posix.h",
-      "src/posix/init.c",
+      # IWBN to include init.c but we're building a static library,
+      # and thus it won't be brought in (nothing external references it).
+      #"src/posix/init.c",
       "src/posix/pt_cpuid.c",
       "src/posix/pt_section_posix.c",
     ]
@@ -96,5 +98,8 @@
     "PT_VERSION_MINOR=6",
     "PT_VERSION_BUILD=0",
     "PT_VERSION_EXT=\"\"",
+    # This is a workaround to ensure posix/init.c is brought in by the linker.
+    # See pt_ild.c.
+    "INCLUDE_EARLY_INIT",
   ]
 }
diff --git a/libipt/src/pt_ild.c b/libipt/src/pt_ild.c
index a864dff..94a885a 100644
--- a/libipt/src/pt_ild.c
+++ b/libipt/src/pt_ild.c
@@ -36,6 +36,14 @@
 
 #include <string.h>
 
+// If we're put in a static library, posix/init.c will not be brought in
+// and thus pt_ild_init will not be called. Rather than manually copy
+// the code into here we maintain the intent of init.c, and just ensure
+// it's brought in by the linker.
+#ifdef INCLUDE_EARLY_INIT
+#include "posix/init.c"
+#endif
+
 /* SET UP 3 TABLES */
 
 static uint8_t has_disp_regular[4][4][8];