Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Link Error -- Relocation Overflow [SOLVED]



My original message is at:

http://lists.apple.com/archives/Darwin-dev/2005/Jun/msg00120.html

and my followup is at:

http://lists.apple.com/archives/Darwin-dev/2005/Jul/msg00044.html

I ended up blowing a DTS incident and George Warner provided the help that led to a solution.

For the benefit of Googlers Of The Future, I'm providing a synopsis of what DTS suggested, and a description of what turned out to solve my problem.


What the error message means: the PowerPC unconditional branch is 24 bits and the conditional branches are 14 bits.


How to diagnose more fully: extract the .o from the .a file using the ar command, then run otool -rv on the .o file. Also run nm -n on the .o file to match up the symbols.

How to avoid the problem: using -mlong-branch can help.


In my case I had a conditional branch that was trying to branch over more than 14 bits, and this branch was in raw assembly code. (If it was in C code, then the -mlong-branch flag would probably have helped, but since it was in raw assembly the bne wasn't translated to avoid the 14-bit branch.)


Specifically, I had an inline assembly function that included code like this:

  1:
    ...
    bne 1

And the fix (!) was to change it to look like this:

  1:
    ...
    bne 1b

Adding the "b" is a compiler hint to branch backwards. Without the "b", it seems that it was trying to branch to a different invocation of this (inline) function, which was a long long ways away. With the "b" it branches backwards to the correct label.


Anyway, dunno if this is of interest to anyone, but if there's even a chance that this will help ease the next guy's frustration it'll be worth it.


--Bob

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.