# HG changeset patch # User cslag # Date 1483610849 -3600 # Node ID d5705f22629814f81f218130ff876385b81e545d # Parent 572aff0216277f97742ca35e5688bc52757905bf - added portasm support for adding .section .note.GNU-stack "hints" marking generated .o files from assembly files as not needing an executable stack * needed to be done manually in assembly files, in contrast to C translation units where gcc adds such hints automatically * this is for security, and better/easier integration of dyncall into other projects and builds, as dyncall doesn't need an executable stack * thanks to Thorsten Behrens for bringing this up to our intention and providing a first analysis * currently only done on Linux, but will be added across other platforms (where applicable) after some testing diff -r 572aff021627 -r d5705f226298 dyncall/dyncall_call_x64.S --- a/dyncall/dyncall_call_x64.S Thu Jan 05 10:35:12 2017 +0100 +++ b/dyncall/dyncall_call_x64.S Thu Jan 05 11:07:29 2017 +0100 @@ -145,3 +145,6 @@ END_ASM + +SECTION_NOTE_NXSTACK /* mark object as not needing execstack */ + diff -r 572aff021627 -r d5705f226298 dyncall/dyncall_call_x86.S --- a/dyncall/dyncall_call_x86.S Thu Jan 05 10:35:12 2017 +0100 +++ b/dyncall/dyncall_call_x86.S Thu Jan 05 11:07:29 2017 +0100 @@ -237,3 +237,6 @@ END_ASM + +SECTION_NOTE_NXSTACK /* mark object as not needing execstack */ + diff -r 572aff021627 -r d5705f226298 dyncallback/dyncall_callback_x64.S --- a/dyncallback/dyncall_callback_x64.S Thu Jan 05 10:35:12 2017 +0100 +++ b/dyncallback/dyncall_callback_x64.S Thu Jan 05 11:07:29 2017 +0100 @@ -178,3 +178,6 @@ END_ASM + +SECTION_NOTE_NXSTACK /* mark object as not needing execstack */ + diff -r 572aff021627 -r d5705f226298 dyncallback/dyncall_callback_x86.S --- a/dyncallback/dyncall_callback_x86.S Thu Jan 05 10:35:12 2017 +0100 +++ b/dyncallback/dyncall_callback_x86.S Thu Jan 05 11:07:29 2017 +0100 @@ -110,3 +110,6 @@ END_PROC(dcCallbackThunkEntry) END_ASM + +SECTION_NOTE_NXSTACK /* mark object as not needing execstack */ + diff -r 572aff021627 -r d5705f226298 portasm/portasm-x64.S --- a/portasm/portasm-x64.S Thu Jan 05 10:35:12 2017 +0100 +++ b/portasm/portasm-x64.S Thu Jan 05 11:07:29 2017 +0100 @@ -69,6 +69,8 @@ # define JNE(X) jne X # define CMP(A,B) cmp B,A # define LOCAL(X) X +/* @@@ check if masm support wanted/needed */ +# define SECTION_NOTE_NXSTACK #else /* GNU/SunPro Assembler AT&T Syntax */ .text @@ -152,5 +154,11 @@ # define FLDL(X) fldl X # define SET(K,V) .set K,V # define LOCAL(X) .X +/* @@@ extend following to probably *all* ELF targets - needs testing, though */ +# if defined(OS_Linux) +# define SECTION_NOTE_NXSTACK .section .note.GNU-stack,"",@progbits +# else +# define SECTION_NOTE_NXSTACK +# endif #endif diff -r 572aff021627 -r d5705f226298 portasm/portasm-x86.S --- a/portasm/portasm-x86.S Thu Jan 05 10:35:12 2017 +0100 +++ b/portasm/portasm-x86.S Thu Jan 05 11:07:29 2017 +0100 @@ -62,6 +62,8 @@ # define FLDS(OP) fld OP # define FLDL(OP) fld OP # define LOCAL(NAME) NAME +/* @@@ check if masm support wanted/needed */ +# define SECTION_NOTE_NXSTACK #else /* GNU/SunPro Assembler AT&T Syntax */ .text @@ -124,5 +126,11 @@ # define FLDL(X) fldl X # define ADD(A,B) add A,B # define LOCAL(X) .X +/* @@@ extend following to probably *all* ELF targets - needs testing, though */ +# if defined(OS_Linux) +# define SECTION_NOTE_NXSTACK .section .note.GNU-stack,"",@progbits +# else +# define SECTION_NOTE_NXSTACK +# endif #endif