about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2014-03-16 16:17:28 -0500
committerBobby Bingham <koorogi@koorogi.info>2014-03-16 16:17:28 -0500
commit611eabd489ce4eab3a70c410f363774bbcbbd3e9 (patch)
treed98e2665a754e93077c537d9263e927a44b7aee7
parent2b47a7aff24bbfbe7ba89fc6d542acc9f5493ae2 (diff)
downloadmusl-611eabd489ce4eab3a70c410f363774bbcbbd3e9.tar.gz
musl-611eabd489ce4eab3a70c410f363774bbcbbd3e9.tar.xz
musl-611eabd489ce4eab3a70c410f363774bbcbbd3e9.zip
superh: fix dynamic linking of __fpscr_values
Applications ended up with copy relocations for this array, which
resulted in libc's references to this array pointing to the
application's copy.  The dynamic linker, however, can require this array
before the application is relocated, and therefore before the
application's copy of this array is initialized.  This resulted in
garbage being loaded into FPSCR before executing main, which violated
the ABI.

We fix this by putting the array in crt1 and making the libc copy
private.  This prevents libc's reference to the array from pointing to
an uninitialized copy in the application.
-rw-r--r--arch/sh/crt_arch.h3
-rw-r--r--arch/sh/src/__fpsrc_values.c5
2 files changed, 7 insertions, 1 deletions
diff --git a/arch/sh/crt_arch.h b/arch/sh/crt_arch.h
index a69d1c9f..5fd39fc6 100644
--- a/arch/sh/crt_arch.h
+++ b/arch/sh/crt_arch.h
@@ -7,3 +7,6 @@ _start: \n\
 	bsr __cstart \n\
 	nop \n\
 ");
+
+/* used by gcc for switching the FPU between single and double precision */
+const unsigned long __fpscr_values[2] = { 0, 0x80000 };
diff --git a/arch/sh/src/__fpsrc_values.c b/arch/sh/src/__fpsrc_values.c
index 56056617..64b458f9 100644
--- a/arch/sh/src/__fpsrc_values.c
+++ b/arch/sh/src/__fpsrc_values.c
@@ -1,2 +1,5 @@
+#include "libc.h"
+
 /* used by gcc for switching the FPU between single and double precision */
-const unsigned long __fpscr_values[2] = { 0, 0x80000 };
+const unsigned long __fpscr_values[2] ATTR_LIBC_VISIBILITY = { 0, 0x80000 };
+