changeset 166:d5705f226298

- 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
author cslag
date Thu, 05 Jan 2017 11:07:29 +0100
parents 572aff021627
children da1d79ed3436
files dyncall/dyncall_call_x64.S dyncall/dyncall_call_x86.S dyncallback/dyncall_callback_x64.S dyncallback/dyncall_callback_x86.S portasm/portasm-x64.S portasm/portasm-x86.S
diffstat 6 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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 */
+
--- 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 */
+
--- 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 */
+
--- 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 */
+
--- 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
 
--- 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