Skip to content

Commit

Permalink
build: disable non-PIC assembly when building for Android/x86
Browse files Browse the repository at this point in the history
This disables MMX/MMXEXT code for ffmpeg/postproc, and all assembly for
mpg123 and libass, if building for Android on x86 (32-bit).

It has performance implications but it avoids all TEXTRELs in the output,
which makes it possible to use W^X hardening techniques. The code can
probably be ported to be PIC-compatible in the future so that these can be
re-enabled, but even Gentoo Linux has no better solutions for this at the
moment.

Signed-off-by: Diego Elio Pettenò <[email protected]>
Signed-off-by: Jean-Baptiste Kempf <[email protected]>
  • Loading branch information
Flameeyes authored and jbkempf committed Dec 8, 2015
1 parent 475671e commit dd225ab
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
7 changes: 7 additions & 0 deletions contrib/src/ass/rules.mak
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ endif
ifdef HAVE_ANDROID
WITH_FONTCONFIG = 0
WITH_HARFBUZZ = 0
ifeq ($(ANDROID_ABI), x86)
WITH_ASS_ASM = 0
endif
else
ifdef HAVE_TIZEN
WITH_FONTCONFIG = 0
Expand Down Expand Up @@ -59,6 +62,10 @@ else
ASS_CONF += --disable-harfbuzz
endif

ifeq ($(WITH_ASS_ASM), 0)
ASS_CONF += --disable-asm
endif

ifdef WITH_OPTIMIZATION
ASS_CFLAGS += -O3
else
Expand Down
6 changes: 6 additions & 0 deletions contrib/src/ffmpeg/rules.mak
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ FFMPEGCONF += --target-os=linux --enable-pic

endif

ifdef HAVE_ANDROID
ifeq ($(ANDROID_ABI), x86)
FFMPEGCONF += --disable-mmx --disable-mmxext
endif
endif

# Windows
ifdef HAVE_WIN32
ifndef HAVE_MINGW_W64
Expand Down
10 changes: 9 additions & 1 deletion contrib/src/mpg123/rules.mak
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ ifeq ($(call need_pkg,"mpg123"),)
PKGS_FOUND += mpg123
endif

MPG123CONF = $(HOSTCONF)

ifdef HAVE_ANDROID
ifeq ($(ANDROID_ABI), x86)
MPG123CONF += --with-cpu=generic_fpu
endif
endif

$(TARBALLS)/mpg123-$(MPG123_VERSION).tar.bz2:
$(call download,$(MPG123_URL))

Expand All @@ -22,6 +30,6 @@ endif

.mpg123: mpg123
$(RECONF)
cd $< && $(HOSTVARS) ./configure $(HOSTCONF)
cd $< && $(HOSTVARS) ./configure $(MPG123CONF)
cd $< && $(MAKE) install
touch $@
6 changes: 6 additions & 0 deletions contrib/src/postproc/rules.mak
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ ifdef HAVE_LINUX
POSTPROCCONF += --target-os=linux --enable-pic
endif

ifdef HAVE_ANDROID
ifeq ($(ANDROID_ABI), x86)
POSTPROCCONF += --disable-mmx --disable-mmxext
endif
endif

# Windows
ifdef HAVE_WIN32
POSTPROCCONF += --target-os=mingw32
Expand Down

0 comments on commit dd225ab

Please sign in to comment.