Force export symbols on all x86 variants in libc.

For silvermont, the __popcountsi2 symbol does not get exported by libc.
But for atom, this symbol is exported. Since we already exported this symbol
for previous releases, it's better to just follow through and force
the export, but only for 32 bit. x86 64 bit will not export this symbol.

Bug: 17681440
Change-Id: I6c62245f0960910f64baaaf6d9d090bf3ea5f435
diff --git a/libc/arch-x86/bionic/libgcc_compat.c b/libc/arch-x86/bionic/libgcc_compat.c
new file mode 100644
index 0000000..c723263
--- /dev/null
+++ b/libc/arch-x86/bionic/libgcc_compat.c
@@ -0,0 +1,15 @@
+/* Generated by genlibgcc_compat.py */
+
+extern char __divdi3;
+extern char __moddi3;
+extern char __popcountsi2;
+extern char __udivdi3;
+extern char __umoddi3;
+
+void* __bionic_libgcc_compat_symbols[] = {
+    &__divdi3,
+    &__moddi3,
+    &__popcountsi2,
+    &__udivdi3,
+    &__umoddi3,
+};
diff --git a/libc/arch-x86/x86.mk b/libc/arch-x86/x86.mk
index a141548..2a0609d 100644
--- a/libc/arch-x86/x86.mk
+++ b/libc/arch-x86/x86.mk
@@ -25,6 +25,7 @@
 libc_bionic_src_files_x86 += \
     arch-x86/bionic/__bionic_clone.S \
     arch-x86/bionic/_exit_with_stack_teardown.S \
+    arch-x86/bionic/libgcc_compat.c \
     arch-x86/bionic/_setjmp.S \
     arch-x86/bionic/setjmp.S \
     arch-x86/bionic/__set_tls.c \
diff --git a/libc/tools/genlibgcc_compat.py b/libc/tools/genlibgcc_compat.py
index cb5c3b3..628bf92 100755
--- a/libc/tools/genlibgcc_compat.py
+++ b/libc/tools/genlibgcc_compat.py
@@ -76,9 +76,6 @@
 class Generator:
     def process(self):
         android_build_top_path = os.environ["ANDROID_BUILD_TOP"]
-        build_path =  android_build_top_path + "/bionic/libc"
-        file_name = "libgcc_compat.c"
-        file_path = build_path + "/arch-arm/bionic/" + file_name
 
         print "* ANDROID_BUILD_TOP=" + android_build_top_path
 
@@ -86,8 +83,12 @@
         arch = subprocess.check_output(["CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core make --no-print-directory -f build/core/config.mk dumpvar-TARGET_ARCH"],
                     cwd=android_build_top_path, shell=True).strip()
 
-        if arch != 'arm':
-            sys.exit("Error: Invalid TARGET_ARCH='" + arch + "' expecting 'arm'")
+        if arch != 'arm' and arch != 'x86':
+            sys.exit("Error: Invalid TARGET_ARCH='" + arch + "' expecting 'arm' or 'x86'")
+
+        build_path =  android_build_top_path + "/bionic/libc"
+        file_name = "libgcc_compat.c"
+        file_path = build_path + "/arch-" + arch + "/bionic/" + file_name
 
         build_output_file_path = tempfile.mkstemp()[1]