This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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]

Re: How to check at compilation time whether -msdata is set to eabi for PowerPC embedded targets


"R. Diez" <rdiezmail-gcc@yahoo.de> writes:

> 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?

The "section type conflict" error is about the type of the section,
yes.  You can get this kind of error if you want to put a modifiable
variable in a read-only section.  However, I don't know why you are
getting the error in this case.


> 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.

You would have to ask an EABI developer, I don't know.


> 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

As far as I can see there is no such preprocessor macro at present.  I
think it could be added to gcc/config/rs6000/rs6000-c.c, in
rs6000_cpu_cpp_builtins, by testing rs6000_sdata.

Ian


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