This is the mail archive of the mailing list for the newlib project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Fix gcc section type conflict on _global_impure_ptr

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 <>
 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  <>
+	* 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  <>
 	* 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
 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")));
 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;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]