This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[RFC] Fix gcc section type conflict on _global_impure_ptr
- From: Kevin Cernekee <cernekee at gmail dot com>
- To: jjohnstn at redhat dot com, corinna at vinschen dot de
- Cc: newlib at sourceware dot org, gregory dot 0xf0 at gmail dot com
- Date: Fri, 17 Oct 2014 21:48:53 -0700
- Subject: [RFC] Fix gcc section type conflict on _global_impure_ptr
- Authentication-results: sourceware.org; auth=none
On architectures that use __ATTRIBUTE_IMPURE_PTR__ to put _impure_ptr
and _global_impure_ptr into a specific ELF section, gcc may complain
about adding a const variable to a writable section:
mips-linux-gcc -B/tmp/newlib-2.1.0/build/mips-none-elf/newlib/ -isystem /tmp/newlib-2.1.0/build/mips-none-elf/newlib/targ-include -isystem /tmp/newlib-2.1.0/newlib/libc/include -B/tmp/newlib-2.1.0/build/mips-none-elf/libgloss/mips -L/tmp/newlib-2.1.0/build/mips-none-elf/libgloss/libnosys -L/tmp/newlib-2.1.0/libgloss/mips -DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\" -DPACKAGE_VERSION=\"2.1.0\" -DPACKAGE_STRING=\"newlib\ 2.1.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -I. -I../../../../../newlib/libc/reent -DMISSING_SYSCALL_NAMES -fno-builtin -g -O2 -c -o lib_a-impure.o `test -f 'impure.c' || echo '../../../../../newlib/libc/reent/'`impure.c
In file included from /tmp/newlib-2.1.0/newlib/libc/include/reent.h:93:0,
from ../../../../../newlib/libc/reent/impure.c:1:
/tmp/newlib-2.1.0/newlib/libc/include/sys/reent.h:762:23: error: _impure_ptr causes a section type conflict with _global_impure_ptr
extern struct _reent *_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
^
/tmp/newlib-2.1.0/newlib/libc/include/sys/reent.h:763:30: note: '_global_impure_ptr' was declared here
extern struct _reent *_CONST _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
^
make[5]: *** [lib_a-impure.o] Error 1
make[5]: Leaving directory `/tmp/newlib-2.1.0/build/mips-none-elf/newlib/libc/reent'
Avoid this by dropping the _CONST modifier.
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
---
newlib/ChangeLog | 7 +++++++
newlib/libc/include/sys/reent.h | 2 +-
newlib/libc/machine/spu/impure.c | 2 +-
newlib/libc/reent/impure.c | 2 +-
4 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 1eb4ddc..aebc40b 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,10 @@
+2014-10-17 Kevin Cernekee <cernekee@gmail.com>
+
+ * newlib/libc/include/sys/reent.h (_global_impure_ptr): Remove _CONST
+ attribute to fix gcc section type conflict.
+ * newlib/libc/machine/spu/impure.c: Likewise.
+ * newlib/libc/reent/impure.c: Likewise.
+
2014-10-16 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libc/unix/getcwd.c (getcwd): Close directory also in case of an error.
diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reent.h
index ce5b3ed..292926b 100644
--- a/newlib/libc/include/sys/reent.h
+++ b/newlib/libc/include/sys/reent.h
@@ -760,7 +760,7 @@ struct _reent
#endif
extern struct _reent *_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
-extern struct _reent *_CONST _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
+extern struct _reent *_global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
void _reclaim_reent _PARAMS ((struct _reent *));
diff --git a/newlib/libc/machine/spu/impure.c b/newlib/libc/machine/spu/impure.c
index 5fbe0e5..69e0784 100644
--- a/newlib/libc/machine/spu/impure.c
+++ b/newlib/libc/machine/spu/impure.c
@@ -11,4 +11,4 @@
struct _reent __ATTRIBUTE_IMPURE_DATA__ _impure_data = _REENT_INIT(_impure_data);
struct _reent *__ATTRIBUTE_IMPURE_PTR__ _impure_ptr = &_impure_data;
-struct _reent *_CONST __ATTRIBUTE_IMPURE_PTR__ _global_impure_ptr = &_impure_data;
+struct _reent *__ATTRIBUTE_IMPURE_PTR__ _global_impure_ptr = &_impure_data;
diff --git a/newlib/libc/reent/impure.c b/newlib/libc/reent/impure.c
index f5918c8..13635a0 100644
--- a/newlib/libc/reent/impure.c
+++ b/newlib/libc/reent/impure.c
@@ -25,4 +25,4 @@ static struct _reent __ATTRIBUTE_IMPURE_DATA__ impure_data = _REENT_INIT (impure
extern struct _reent reent_data __attribute__ ((alias("impure_data")));
#endif
struct _reent *__ATTRIBUTE_IMPURE_PTR__ _impure_ptr = &impure_data;
-struct _reent *_CONST __ATTRIBUTE_IMPURE_PTR__ _global_impure_ptr = &impure_data;
+struct _reent *__ATTRIBUTE_IMPURE_PTR__ _global_impure_ptr = &impure_data;
--
2.1.1