This is the mail archive of the gcc@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]

Re: 3.0.1 Freeze



> #define PTRRELOC(x)     ((typeof(x))((unsigned long)(x) + offset))
> #define RELOC(x)        (*PTRRELOC(&(x)))
> offset = get_reloc_offfset();
> strcpy(dest, RELOC("test"));
>
> I  don't see anything illegal/undefined/unportable about that code, just
> plain C pointer arithmetic to implement a poor mans relocation in  early
> boot  code.

Ah.  So, ignoring the non-standard `typeof', you have cast a pointer to
an integer, added another integer, and cast back to a pointer.  That
is (I checked) implementation-defined behavior, but the sensible
definition is that it do what you think.

So, I am now convinced that this optimization is too aggressive.  I
will simply remove it.

Thank you,

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com


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