浏览代码

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.
Bobby Bingham 11 年之前
父节点
当前提交
611eabd489
共有 2 个文件被更改,包括 7 次插入1 次删除
  1. 3 0
      arch/sh/crt_arch.h
  2. 4 1
      arch/sh/src/__fpsrc_values.c

+ 3 - 0
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 };

+ 4 - 1
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 };
+