[uClinux-dev] relocs problems with arm

Tom Walsh tom at cyberiansoftware.com
Fri Nov 30 21:24:13 EST 2001


Fabrice Gautier wrote:
> 
> A quick update on the endianness problem for thebinary flat format.
> 
> I don't think there is anything like a "standard" for this format but as per
> this chunk of kernel code:
> 
> rp = (unsigned long *) calc_reloc(ntohl(reloc[i]), text_len);
> /* Get the pointer's value.  */
> addr = get_unaligned (rp);
> if (addr != 0) {
>   /* Do the relocation.  */
>   addr = calc_reloc (ntohl (addr), text_len);
>   /* Write back the relocated pointer.  */
>   put_unaligned (addr, rp);
> }
> 
> It seems that the kernel expect to have everything in network format (that
> is big endian if i got it right)

Nope, you don't have it right.  The calc_reloc is apparently making sure
that *it* doesn't run into an endian problem and is letting the ntohl
macro ensure a common format for the data it is processing.  The way
that the ntohl macro works on your particular processor implementation
is entirely despendant upon how you set it up.

e.g.  Some ARM processors are able to switch endian-ess, from big to
little, by throwing a bit selector, or from a pin state on power-up. It
is up to you to make sure that the kernel source code (such as ntohl)
reflects the endian-ess of your data / code.

If you don't know which end is up (big or little ;), why not contact the
technical people at the manufacturer that made your chip?!  You will
find the manufacturer eager to assist you in using their product in your
design.  After all, it *is* in their best interest.

Regards,

TomW

-- 
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------------------------------------------
This message resent by the uclinux-dev at uclinux.org list server http://www.uClinux.org/



More information about the uClinux-dev mailing list