#272: altivec specific code segfaults on ppc when compiled with --enable-pic -----------------------+---------------------- Reporter: kim | Owner: Type: defect | Status: open Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: ppc, PIC | Blocked By: Blocking: | Reproduced: 1 Analyzed: 0 | -----------------------+----------------------
Comment (by kim): Replying to [comment:7 reimar]: > Are you sure this isn't specific to your compiler version? > LLVM and possible also gcc made an ABI change that optimized the TOC register r2 away. > The current code thus can't work anymore. I think that's what is happening. However I'm using a fairly standard compiler (which I think is the default in any recent distro: gcc 4.5.x) Also tested with gcc 4.4.5 with the same results so I guess this change in gcc is quite old. However I came up with a proof of concept patch to load the address of local symbols in a pic friendly way. (I use the standard trick of computing the space between a fixed label and the symbol to be loaded and then add this to the adresss of the fixed label which is determined at runtime using a phony branch instruction). I've tested it on linux ppc 32bit and I'm now able to play the above sample without problems. {{{ diff --git a/libavcodec/ppc/asm.S b/libavcodec/ppc/asm.S index e372d53..30e0953 100644 --- a/libavcodec/ppc/asm.S +++ b/libavcodec/ppc/asm.S @@ -67,7 +67,11 @@ X(\name): .macro movrel rd, sym #if CONFIG_PIC - lwz \rd, \sym@got(r2) + bcl 20, 31, lab_pic_\@ +lab_pic_\@: + mflr \rd + addis \rd, \rd, (\sym - lab_pic_\@)@ha + addi \rd, \rd, (\sym - lab_pic_\@)@l #else lis \rd, \sym@ha la \rd, \sym@l(\rd) }}} -- Ticket URL: <https://avcodec.org/trac/ffmpeg/ticket/272#comment:8> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker _______________________________________________ FFmpeg-trac mailing list FFmpeg-trac@avcodec.org http://avcodec.org/mailman/listinfo/ffmpeg-trac