This is the mail archive of the gcc-patches@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: don't assume pointer cast to unsigned long is a valid initializer


Alexandre Oliva <aoliva at redhat dot com> writes:
> That said, the fact that the test points out an actual bug in the
> mips64-elf and the h8300-elf ports [...]

Sorry for not letting this thread die, but do you really think
it's a bug in the mips64-elf port?  To quote the test case again:

    extern void _text;
    static unsigned long x = (unsigned long) &_text - 0x10000000L - 1;

Suppose _text = 0x80100000 (a typical value for embedded programs
running in kseg0).  Since mips pointers sign extend, we have:

    (unsigned long) &_text = 0xffffffff80100000L

so if the value was calculated at run time, we'd have:

    (unsigned long) &_text - 0x10000000L - 1 = 0xffffffff700fffffL

Geoff seems to be suggesting that we use R_MIPS_64 for this value,
but the ELF32 R_MIPS_64 is a sign-extending 32-bit relocation, not
a full 64-bit relocation.  So if we emit:

x:      .dword _text - 0x10000001

we'd actually end up with x being initialised to 0x00000000700fffff.
To make the test case work, we'd need to have some other relocation
and (I guess) a new assembler directive to emit it.  It hardly seems
worth the effort.

IMO, 20010327-1.c should be unsupported for MIPS if sizeof (void *)
!= sizeof (long).

Richard


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