This patch is an improvement on the one posted here: Bug 528200 - media-libs/x265 - /usr/lib64/libx265.a has executable stack https://bugs.gentoo.org/528200 --- source/common/x86/x86inc.asm.orig 2017-11-28 22:21:40.000000000 -0500 +++ source/common/x86/x86inc.asm 2018-02-25 16:36:54.243966522 -0500 @@ -66,6 +66,15 @@ %endif %endif +%define FORMAT_ELF 0 +%ifidn __OUTPUT_FORMAT__,elf + %define FORMAT_ELF 1 +%elifidn __OUTPUT_FORMAT__,elf32 + %define FORMAT_ELF 1 +%elifidn __OUTPUT_FORMAT__,elf64 + %define FORMAT_ELF 1 +%endif + %ifdef PREFIX %define mangle(x) _ %+ x %else @@ -685,7 +694,7 @@ CAT_XDEFINE cglobaled_, %2, 1 %endif %xdefine current_function %2 - %ifidn __OUTPUT_FORMAT__,elf + %if FORMAT_ELF global %2:function %%VISIBILITY %else global %2 @@ -718,7 +727,7 @@ %macro const 1-2+ %xdefine %1 mangle(private_prefix %+ _ %+ %1) - %ifidn __OUTPUT_FORMAT__,elf + %if FORMAT_ELF global %1:data hidden %else global %1 @@ -729,7 +738,7 @@ ; This is needed for ELF, otherwise the GNU linker assumes the stack is ; executable by default. -%ifidn __OUTPUT_FORMAT__,elf +%if FORMAT_ELF [SECTION .note.GNU-stack noalloc noexec nowrite progbits] %endif