This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
How to check at compilation time whether -msdata is set to eabi for PowerPC embedded targets
- From: "R. Diez" <rdiezmail-gcc at yahoo dot de>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 7 Jul 2011 15:22:48 +0100 (BST)
- Subject: How to check at compilation time whether -msdata is set to eabi for PowerPC embedded targets
- Reply-to: rdiezmail-gcc at yahoo dot de
Hi there:
I am building a GCC 4.5.3 cross-compiler for an embedded PowerPC target, together with binutils-2.21 and newlib 1.19.0, and I cannot compile newlib with switch -msdata=eabi . There are 2 related error messages:
1) newlib-1.19.0/newlib/libc/reent/impure.c:28:48: error: _global_impure_ptr causes a section type conflict
2) /tmp/ccteCPAo.s:2630: Warning: setting incorrect section attributes for .sdata2
It turns out that newlib wants to decide itself where to place the global variables _impure_ptr and _global_impure_ptr. If I do not set -msdata at all, or set it to -msdata=sysv , then both of these variables should land in section .sdata , and that's also what newlib specifies in this way:
[newlib-1.19.0/newlib/libc/include/sys/config.h]
/* For the PowerPC eabi, force the _impure_ptr to be in .sdata */
#if defined(__PPC__)
#if defined(_CALL_SYSV)
#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata")))
#endif
There is agreement, so compilation works. The trouble is, if you specify -msdata=eabi , GCC would normally place _global_impure_ptr in .sdata2, because that variable is declared as 'const'. But newlib insists on placing it in .sdata with the above construction. There is disagreement, therefore the build fails.
Before I report this issue to the newlib developers, or try somehow to fix it myself, there are a few things I would like to clarify here:
1) I thought with __attribute__((__section__(".sdata"))) one can decide where a variable lands. I guess there are restrictions on the type of section, or is there some other kind of problem here?
2) Does it make any sense that newlib wants to decide where a particular variable lands? I though GCC would always automatically get it right.
3) How can I check at compilation time whether -msdata is set to eabi? Symbol __PPC__ is defined for the PowerPC, and symbol _CALL_SYSV is not properly documented, but I guess it gets defined by -meabi . Does GCC need a new symbol for the current -msdata type? With such a symbol, I could write code like this:
#if defined(_PPC_MSDATA_EABI)
#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata2")))
#else
#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata")))
#endif
Please copy me on the answer, as I'm not subscribed to this list.
Many thanks,
R. Diez