diff options
author | Mans Rullgard <mans@mansr.com> | 2012-06-29 13:35:08 +0100 |
---|---|---|
committer | Mans Rullgard <mans@mansr.com> | 2012-07-01 11:25:06 +0100 |
commit | 62634158b7cd39ad1e330a87153a97bf3dc6f8de (patch) | |
tree | 3b5bb36649f0e08a5675c474b29200c5f0b155b7 /libavutil/arm/asm.S | |
parent | ceabc13f129cd6344b1eebdbe10119083fe5520e (diff) | |
download | ffmpeg-62634158b7cd39ad1e330a87153a97bf3dc6f8de.tar.gz |
ARM: generate position independent code to access data symbols
This creates proper position independent code when accessing
data symbols if CONFIG_PIC is set.
References to external symbols should now use the movrelx macro.
Some additional code changes are required since this macro may
need a register to hold the GOT pointer.
Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavutil/arm/asm.S')
-rw-r--r-- | libavutil/arm/asm.S | 73 |
1 files changed, 72 insertions, 1 deletions
diff --git a/libavutil/arm/asm.S b/libavutil/arm/asm.S index 6038a63a27..15081802c6 100644 --- a/libavutil/arm/asm.S +++ b/libavutil/arm/asm.S @@ -62,7 +62,14 @@ ELF .eabi_attribute 25, \val .endm .macro function name, export=0 + .set .Lpic_idx, 0 + .set .Lpic_gp, 0 .macro endfunc + .if .Lpic_idx + .altmacro + put_pic %(.Lpic_idx - 1) + .noaltmacro + .endif ELF .size \name, . - \name .endfunc .purgem endfunc @@ -106,8 +113,44 @@ ELF .size \name, . - \name #endif .endm +.macro put_pic num + put_pic_\num +.endm + +.macro do_def_pic num, val, label + .macro put_pic_\num + .if \num + .altmacro + put_pic %(\num - 1) + .noaltmacro + .endif +\label: .word \val + .purgem put_pic_\num + .endm +.endm + +.macro def_pic val, label + .altmacro + do_def_pic %.Lpic_idx, \val, \label + .noaltmacro + .set .Lpic_idx, .Lpic_idx + 1 +.endm + +.macro ldpic rd, val, indir=0 + ldr \rd, .Lpicoff\@ +.Lpic\@: + .if \indir + ldr \rd, [pc, \rd] + .else + add \rd, pc, \rd + .endif + def_pic \val - (.Lpic\@ + (8 >> CONFIG_THUMB)), .Lpicoff\@ +.endm + .macro movrel rd, val -#if HAVE_ARMV6T2 && !CONFIG_PIC && !defined(__APPLE__) +#if CONFIG_PIC + ldpic \rd, \val +#elif HAVE_ARMV6T2 && !defined(__APPLE__) movw \rd, #:lower16:\val movt \rd, #:upper16:\val #else @@ -115,6 +158,34 @@ ELF .size \name, . - \name #endif .endm +.macro movrelx rd, val, gp +#if CONFIG_PIC && defined(__ELF__) + .ifnb \gp + .if .Lpic_gp + .unreq gp + .endif + gp .req \gp + ldpic gp, _GLOBAL_OFFSET_TABLE_ + .elseif !.Lpic_gp + gp .req r12 + ldpic gp, _GLOBAL_OFFSET_TABLE_ + .endif + .set .Lpic_gp, 1 + ldr \rd, .Lpicoff\@ + ldr \rd, [gp, \rd] + def_pic \val(GOT), .Lpicoff\@ +#elif CONFIG_PIC && defined(__APPLE__) + ldpic \rd, .Lpic\@, indir=1 + .non_lazy_symbol_pointer +.Lpic\@: + .indirect_symbol \val + .word 0 + .text +#else + movrel \rd, \val +#endif +.endm + .macro ldr_pre rt, rn, rm:vararg A ldr \rt, [\rn, \rm]! T add \rn, \rn, \rm |