[PATCH, ARM] Don't use __thumb2__ to select _REENT_SMALL
Jeff Johnston
jjohnstn@redhat.com
Tue Jun 2 17:24:00 GMT 2009
Paul Brook wrote:
> On Tuesday 02 June 2009, Paul Brook wrote:
>
>>> Yes, this leaks out into user code -- at least it does for me. Try
>>> building the standard arm-eabi multilib tools and then running the gcc
>>> testsuite with -mcpu=cortex-a8 and -mthumb. Programs such as
>>> gcc.c-torture/exectute/fprintf-1.c will then fail.
>>>
>>> The definition of stdout is:
>>> #define stdout (_REENT->_stdout)
>>>
>> In my sources this field lives at the same location in both cases.
>>
>
> Further investigation indicates upstream newlib is missing the following
> patch.
>
> 2009-06-02 Paul Brook <paul@codesourcery.com>
>
> newlib/
> * libc/include/sys/reent.h (_reent): Adjust _REENT_SMALL to be binary
> compatible with normal layout
>
>
This would require changing the initialization macro in kind or else
there will be trouble. I'm not thrilled with leaving two gaps in the
struct for 16-bit platforms, but there are now 2 unused fields since
Corinna revamped locale support. If the unpaired int that is caused by
the errno move was put below and the unused fields were removed, I could
certainly live with that as the struct gets smaller and there is one
left-over int anyway. Might as well be errno.
That said, I agree with Richard's point. If the thumb2 flag is not a
proper check for a platform that requires a small reent struct, then it
shouldn't be used as such.
Perhaps a staggered approach can be used. Make the reent change now as
a stop-gap and work on changing the compiler so that a proper check can
be made for when reent small should really be used and a proper multilib
is created. For now, put a comment in that the thumb2 check is wrong
and needs to be changed.
Seem reasonable?
-- Jeff J.
> Index: newlib/libc/include/sys/reent.h
> ===================================================================
> --- newlib/libc/include/sys/reent.h (revision 159552)
> +++ newlib/libc/include/sys/reent.h (revision 159553)
> @@ -344,14 +344,15 @@ struct _misc_reent
> * ports with 16-bit int's but 32-bit pointers, align nicely. */
> struct _reent
> {
> + /* As an exception to the above put _errno first for binary
> + compatibility with non _REENT_SMALL targets. */
> + int _errno; /* local copy of errno */
>
> /* FILE is a big struct and may change over time. To try to achieve binary
> compatibility with future versions, put stdin,stdout,stderr here.
> These are pointers into member __sf defined below. */
> __FILE *_stdin, *_stdout, *_stderr; /* XXX */
>
> - int _errno; /* local copy of errno */
> -
> int _inc; /* used by tmpnam */
>
> char *_emergency;
>
>
More information about the Newlib
mailing list