PowerPC EABI issues with newlib

R. Diez rdiezmail-newlib@yahoo.de
Fri Jul 8 18:25:00 GMT 2011

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 . I've had two issues with newlib and I wanted to share the solutions with other newlib users.

The first problem is that specifying "--target=powerpc-unknown-eabi" ends up building with flag "-mno-eabi", although the opposite ("-meabi") is normally what one wants. The problem lies in newlib/configure.host , this is the code:

  powerpc*-*-eabi* | \
  powerpc*-*-elf* | \
  powerpc*-*-linux* | \
  powerpc*-*-rtem* | \
  powerpc*-*-sysv* | \
	newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES"

The second problem is that newlib fails to build 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

The problem lies in file newlib/libc/include/sys/config.h , this is the code:

/* 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")))

When using "-msdata=eabi", const variables should land in .sdata2, and not in .sdata . While variable _impure_ptr is not const, _global_impure_ptr is const and should not be placed in .sdata .

I'm not sure about the best way to fix this issue. Here is a question about it I posted to the GCC e-mail list and the answer to it:


In case those links break, the e-mail title was "How to check at compilation time whether -msdata is set to eabi for PowerPC embedded targets".

  R. Diez

More information about the Newlib mailing list