• Mans Rullgard's avatar
    x86: swscale: fix fragile memory accesses · 90540c2d
    Mans Rullgard authored
    To access data at multiple fixed offsets from a base address, this
    code uses a single "m" operand and code of the form "32%0", relying on
    the memory operand instantiation having no displacement, giving a final
    result of the form "32(%rax)".  If the compiler uses a register and
    displacement, e.g. "64(%rax)", the end result becomes "3264(%rax)",
    which obviously does not work.
    
    Replacing the "m" operands with "r" operands allows safe addition of a
    displacement.  In theory, multiple memory operands could use a shared
    base register with different index registers, "(%rax,%rbx)", potentially
    making more efficient use of registers.  In the cases at hand, no such
    sharing is possible since the addresses involved are entirely unrelated.
    
    After this change, the code somewhat rudely accesses memory without
    using a corresponding memory operand, which in some cases can lead to
    unwanted "optimisations" of surrounding code.  However, the original
    code also accesses memory not covered by a memory operand, so this is
    not adding any defect not already present.  It is also hightly unlikely
    that any such optimisations could be performed here since the memory
    locations in questions are not accessed elsewhere in the same functions.
    
    This fixes crashes with suncc.
    Signed-off-by: 's avatarMans Rullgard <mans@mansr.com>
    90540c2d
Name
Last commit
Last update
compat Loading commit data...
doc Loading commit data...
libavcodec Loading commit data...
libavdevice Loading commit data...
libavfilter Loading commit data...
libavformat Loading commit data...
libavresample Loading commit data...
libavutil Loading commit data...
libswscale Loading commit data...
presets Loading commit data...
tests Loading commit data...
tools Loading commit data...
.gitignore Loading commit data...
COPYING.GPLv2 Loading commit data...
COPYING.GPLv3 Loading commit data...
COPYING.LGPLv2.1 Loading commit data...
COPYING.LGPLv3 Loading commit data...
CREDITS Loading commit data...
Changelog Loading commit data...
Doxyfile Loading commit data...
INSTALL Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
README Loading commit data...
RELEASE Loading commit data...
arch.mak Loading commit data...
avconv.c Loading commit data...
avconv.h Loading commit data...
avconv_filter.c Loading commit data...
avconv_opt.c Loading commit data...
avplay.c Loading commit data...
avprobe.c Loading commit data...
avserver.c Loading commit data...
cmdutils.c Loading commit data...
cmdutils.h Loading commit data...
cmdutils_common_opts.h Loading commit data...
common.mak Loading commit data...
configure Loading commit data...
library.mak Loading commit data...
version.sh Loading commit data...