相変わらずmips系ってば….

TOPPERS/HRPカーネルのリンクをしようとすると .sdata がなんたらというエラーが出るようになった.
カーネル/アプリ側では -G 0 オプションを明示しているので,たぶん newlib をリンクしたことによる弊害だろう.
GCC側に toppers.h を付け加えて再ビルド.

diff --git a/gcc/config/mips/toppers.h b/gcc/config/mips/toppers.h
new file mode 100644
index 0000000..bb01f5f
--- /dev/null
+++ b/gcc/config/mips/toppers.h
@@ -0,0 +1,13 @@
+/* Specify predefined symbols in preprocessor.  */
+
+#define TARGET_OS_CPP_BUILTINS()       \
+do {                                   \
+  builtin_define ("__toppers__");      \
+} while (0)
+
+/* No sdata.
+ * The TOPPERS BSPs expect -G0
+ */
+#undef MIPS_DEFAULT_GVALUE
+#define MIPS_DEFAULT_GVALUE 0
+

だがしかし, .sdata 関連のエラーが止まらない.なんで?

原因

下記のパッチでうまく行ったらしい.

diff --git a/newlib/libc/include/sys/config.h b/newlib/libc/include/sys/config.h
index 0dfac08..87dd4c2 100644
--- a/newlib/libc/include/sys/config.h
+++ b/newlib/libc/include/sys/config.h
@@ -109,7 +109,7 @@
 #endif
 #endif
 
-#if defined(__mips__) && !defined(__rtems__)
+#if defined(__mips__) && !(defined(__rtems__) || defined(__toppers__))
 #define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata")))
 #endif

わかんねーよ,こんなところに原因があるなんてっ.

特定のdefineで切り分けるのではなく,configure で上手いことできたりしないのかなぁ….