Disable executable stack for the linker note, fixing #703 (again)
authorEdward Z. Yang <ezyang@mit.edu>
Tue, 9 Jul 2013 07:01:43 +0000 (00:01 -0700)
committerEdward Z. Yang <ezyang@mit.edu>
Tue, 9 Jul 2013 07:34:35 +0000 (00:34 -0700)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
compiler/main/DriverPipeline.hs

index 67377e6..26425ae 100644 (file)
@@ -1640,7 +1640,17 @@ mkNoteObjsToLinkIntoBinary dflags dep_packages = do
                                    text elfSectionNote,
                                    text "\n",
 
-          text "\t.ascii \"", info', text "\"\n" ]
+          text "\t.ascii \"", info', text "\"\n",
+
+          -- ALL generated assembly must have this section to disable
+          -- executable stacks.  See also
+          -- compiler/nativeGen/AsmCodeGen.lhs for another instance
+          -- where we need to do this.
+          (if platformHasGnuNonexecStack (targetPlatform dflags)
+           then text ".section .note.GNU-stack,\"\",@progbits\n"
+           else empty)
+
+           ]
           where
             info' = text $ escape info