diff --git a/backend/PrintAsm.ml b/backend/PrintAsm.ml
index 514f3d32fec807f719cf9927241c887aeb92e9ed..18bedd4f5031294c713ed3649c81cae16639dd52 100644
--- a/backend/PrintAsm.ml
+++ b/backend/PrintAsm.ml
@@ -210,6 +210,7 @@ let print_program oc p =
   List.iter (Printer.print_globdef oc) p.prog_defs;
   Target.print_epilogue oc;
   Printer.print_ais_annot oc;
+  print_nonexec_stack_note oc;
   if !Clflags.option_g then
     begin
       let atom_to_s s =
diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml
index 0bcc94cd4546f9e52c935f15132fed5224245545..8ee8e2caccf685b3e6d8a3a1ec230e4cc0f7ac92 100644
--- a/backend/PrintAsmaux.ml
+++ b/backend/PrintAsmaux.ml
@@ -355,3 +355,12 @@ let macos_mergeable_string_section sz =
   | 0 | 2 | 4 -> ".const"
   | 1 -> ".cstring"
   | _ -> assert false
+
+(** Marking the stack as non executable *)
+
+let print_nonexec_stack_note oc =
+  match Configuration.system with
+  | "linux" | "bsd" ->
+      output_string oc "\n\t.section .note.GNU-stack,\"\",%progbits\n"
+  | _ ->
+      ()
diff --git a/runtime/aarch64/sysdeps.h b/runtime/aarch64/sysdeps.h
index b098cf1c448a936a183f13314b2479e64afb1319..4f050fbe8337d530d0683cb1ec84f48b36cf3704 100644
--- a/runtime/aarch64/sysdeps.h
+++ b/runtime/aarch64/sysdeps.h
@@ -63,3 +63,7 @@ f:
 	.type f, @function; .size f, . - f
 
 #endif
+
+#if defined(SYS_linux) || defined(SYS_bsd)
+	.section .note.GNU-stack,"",%progbits
+#endif
diff --git a/runtime/arm/sysdeps.h b/runtime/arm/sysdeps.h
index 0c873f951d9225c850cc809a370c93688e821458..0906fa19a6b5ab90cafa96b311b0c2bd70121502 100644
--- a/runtime/arm/sysdeps.h
+++ b/runtime/arm/sysdeps.h
@@ -138,3 +138,7 @@ f:
 #define Reg3HI r7
 #define Reg3LO r6
 #endif
+
+#if defined(SYS_linux) || defined(SYS_bsd)
+	.section .note.GNU-stack,"",%progbits
+#endif
diff --git a/runtime/riscV/sysdeps.h b/runtime/riscV/sysdeps.h
index b95ca1b17651e758793cb3c2bae21e71e272b486..ca081dcafddbb28bfdcae43b92b72ae22a44410f 100644
--- a/runtime/riscV/sysdeps.h
+++ b/runtime/riscV/sysdeps.h
@@ -61,3 +61,6 @@ f:
 
 #endif
 
+#if defined(SYS_linux) || defined(SYS_bsd)
+	.section .note.GNU-stack,"",%progbits
+#endif
diff --git a/runtime/x86_32/sysdeps.h b/runtime/x86_32/sysdeps.h
index 973bbe2f9fd5a73dd7a3455d3dcc22e24bc2cb65..c22ed7701d7aa8de89227da959af58d766587fa9 100644
--- a/runtime/x86_32/sysdeps.h
+++ b/runtime/x86_32/sysdeps.h
@@ -36,6 +36,8 @@
 
 #if defined(SYS_linux) || defined(SYS_bsd)
 
+	.section .note.GNU-stack,"",%progbits
+
 #define GLOB(x) x
 #define FUNCTION(f) \
 	.text; \
diff --git a/runtime/x86_64/sysdeps.h b/runtime/x86_64/sysdeps.h
index 9031d5d07bfcc83524b5cdae8712647f4a814204..26fc7456c5126ca50d8b6cd4b8f72d4ba28e8425 100644
--- a/runtime/x86_64/sysdeps.h
+++ b/runtime/x86_64/sysdeps.h
@@ -36,6 +36,8 @@
 
 #if defined(SYS_linux) || defined(SYS_bsd)
 
+	.section .note.GNU-stack,"",%progbits
+
 #define GLOB(x) x
 #define FUNCTION(f) \
 	.text; \