[FFmpeg-devel] Cross-compiling arm assembler on OSX

Kvikant, Christian Scilla kvide
Fri Jan 30 12:30:07 CET 2009

Earlier Ronald S. Bultje wrote:
> It'd be nice if there was somehow a way to (cross-)compile the armv4l/ 
> directory on the Mac in some way, either by updating gas (haven't 
> tested) or by making the code somewhat more forgiving to early gas 
> version restrictions / bugs / etc.
> Ronald

Cross-compiling is certainly possible.

Apple's SDK uses an anno dazumal gas 1.38 with lots of mach-o specific
customization in binutils while linking is done with ld64. Saurik's approach
uses more recent cctools with patches for arm and ld_classic as linker.

Both tool chains choke on different stuff in the arm code, but to compile
ffmpeg with all the goodies enabled the following needs to be done with the
arm assembly:

1) Avoid uppercase
2) pop/push need to be rewritten in their canonical forms
3) Macro parameters need to be referred to as $0, $1 etc.
4) Manually define labels and if needed, define them global (or tweak
endfunc to do nothing)
5) Some replacements: e.g. use .long for .word
6) Verify stack alignment

Yonas has a patch in progress here: http://code.google.com/p/ffmpeg4iphone/

When using Saurik's assembler the adrl operation that Yonas asked about
translates into:

    add   ip, pc, 5f
    add   ip, ip, 0x600 (?)

But from a "commercial" point of view the main problem arises when building
shared libraries. While loading libavcodec.dyld on the iPhone the dyld
automagic rebasing stuff chokes on addressing. Removing "-read_only_relocs
suppress" when linking reveals the error:

ld: absolute addressing (perhaps -mdynamic-no-pic) used in _put_pixels16_arm
from libavcodec/arm/dsputil_arm_s.o not allowed in slidable image. Use
'-read_only_relocs suppress' to enable text relocs.

This same "error" is present in the mmx implementation for Darwin. See
MacPorts tickets #15156 and #15157

I've browsed through the disassembled code of my own compilation of
libavcodec and can't find any absolute address references. I suspect that
this has something to do with ARM32/Thumb differences though.

One option to just test the library would be to rebase while linking. The
rebase tool provided with the SDK responds with a bus error on mach-o arm
shared libraries. Go figure.


More information about the ffmpeg-devel mailing list