From: Florian Krohm Date: Wed, 30 Sep 2015 20:30:48 +0000 (+0000) Subject: Make sure no executable stack gets created. X-Git-Tag: svn/VALGRIND_3_12_0~331 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=193f88fad46be6a544202c5d2c943a96271a991d;p=thirdparty%2Fvalgrind.git Make sure no executable stack gets created. Explanation by Matthias Schwarzott: The linker will request an executable stack as soon as at least one object file, that is linked in, wants an executable stack. And the absence of the .section .note.GNU-stack."",@progbits is enough to tell the linker that an executable stack is needed. So even an empty asm-file must at least contain this statement to not force executable stacks on the whole executable. * Define a helper macro MARK_STACK_NO_EXEC that disables the executable stack. * Instantiate this macro unconditionally at the end of each asm file. Patch by Matthias Schwarzott . git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15692 --- diff --git a/coregrind/m_cpuid.S b/coregrind/m_cpuid.S index 48d6cf4915..9ba75ecc37 100644 --- a/coregrind/m_cpuid.S +++ b/coregrind/m_cpuid.S @@ -151,10 +151,8 @@ ret #endif -#if defined(VGP_x86_linux) || defined(VGP_amd64_linux) /* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",@progbits -#endif +MARK_STACK_NO_EXEC /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/coregrind/m_dispatch/dispatch-amd64-darwin.S b/coregrind/m_dispatch/dispatch-amd64-darwin.S index ee97ce33de..dd7f117041 100644 --- a/coregrind/m_dispatch/dispatch-amd64-darwin.S +++ b/coregrind/m_dispatch/dispatch-amd64-darwin.S @@ -29,9 +29,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_amd64_darwin) -#include "pub_core_basics_asm.h" #include "pub_core_dispatch_asm.h" #include "pub_core_transtab_asm.h" #include "libvex_guest_offsets.h" /* for OFFSET_amd64_RIP */ @@ -250,6 +251,9 @@ VG_(disp_cp_evcheck_fail): #endif // defined(VGP_amd64_darwin) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-amd64-linux.S b/coregrind/m_dispatch/dispatch-amd64-linux.S index 9d5d993213..bb7a0378c0 100644 --- a/coregrind/m_dispatch/dispatch-amd64-linux.S +++ b/coregrind/m_dispatch/dispatch-amd64-linux.S @@ -29,9 +29,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_amd64_linux) -#include "pub_core_basics_asm.h" #include "pub_core_dispatch_asm.h" #include "pub_core_transtab_asm.h" #include "libvex_guest_offsets.h" /* for OFFSET_amd64_RIP */ @@ -249,11 +250,11 @@ VG_(disp_cp_evcheck_fail): .size VG_(disp_run_translations), .-VG_(disp_run_translations) -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",@progbits - #endif // defined(VGP_amd64_linux) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-amd64-solaris.S b/coregrind/m_dispatch/dispatch-amd64-solaris.S index 5a3dd81f90..3750693480 100644 --- a/coregrind/m_dispatch/dispatch-amd64-solaris.S +++ b/coregrind/m_dispatch/dispatch-amd64-solaris.S @@ -29,9 +29,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_amd64_solaris) -#include "pub_core_basics_asm.h" #include "pub_core_dispatch_asm.h" #include "pub_core_transtab_asm.h" #include "libvex_guest_offsets.h" /* for OFFSET_amd64_RIP */ @@ -251,6 +252,9 @@ VG_(disp_cp_evcheck_fail): #endif // defined(VGP_amd64_solaris) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-arm-linux.S b/coregrind/m_dispatch/dispatch-arm-linux.S index 6c5a5fe7bf..c21e5e4fb4 100644 --- a/coregrind/m_dispatch/dispatch-arm-linux.S +++ b/coregrind/m_dispatch/dispatch-arm-linux.S @@ -29,10 +29,11 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_arm_linux) .fpu vfp -#include "pub_core_basics_asm.h" #include "pub_core_dispatch_asm.h" #include "pub_core_transtab_asm.h" #include "libvex_guest_offsets.h" /* for OFFSET_arm_R* */ @@ -206,11 +207,11 @@ VG_(disp_cp_evcheck_fail): .size VG_(disp_run_translations), .-VG_(disp_run_translations) -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",%progbits - #endif // defined(VGP_arm_linux) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end dispatch-arm-linux.S ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-arm64-linux.S b/coregrind/m_dispatch/dispatch-arm64-linux.S index a5443fb866..2e8e0cd9fa 100644 --- a/coregrind/m_dispatch/dispatch-arm64-linux.S +++ b/coregrind/m_dispatch/dispatch-arm64-linux.S @@ -29,9 +29,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_arm64_linux) -#include "pub_core_basics_asm.h" #include "pub_core_dispatch_asm.h" #include "pub_core_transtab_asm.h" #include "libvex_guest_offsets.h" /* for OFFSET_arm_R* */ @@ -231,11 +232,11 @@ VG_(disp_cp_evcheck_fail): .size VG_(disp_run_translations), .-VG_(disp_run_translations) -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",%progbits - #endif // defined(VGP_arm64_linux) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end dispatch-arm64-linux.S ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-mips32-linux.S b/coregrind/m_dispatch/dispatch-mips32-linux.S index 26b067d331..22b6b382aa 100644 --- a/coregrind/m_dispatch/dispatch-mips32-linux.S +++ b/coregrind/m_dispatch/dispatch-mips32-linux.S @@ -29,10 +29,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" #if defined(VGP_mips32_linux) -#include "pub_core_basics_asm.h" #include "pub_core_dispatch_asm.h" #include "pub_core_transtab_asm.h" #include "libvex_guest_offsets.h" /* for OFFSET_mips_PC */ @@ -235,11 +235,11 @@ VG_(disp_cp_evcheck_fail): .size VG_(disp_run_translations), .-VG_(disp_run_translations) +#endif // defined(VGP_mips32_linux) -/* Let the linker know we do not need an executable stack */ -.section .note.GNU-stack,"",@progbits +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC -#endif // defined(VGP_mips32_linux) /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-mips64-linux.S b/coregrind/m_dispatch/dispatch-mips64-linux.S index 8af39898f0..5e5afee060 100644 --- a/coregrind/m_dispatch/dispatch-mips64-linux.S +++ b/coregrind/m_dispatch/dispatch-mips64-linux.S @@ -29,10 +29,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" #if defined(VGP_mips64_linux) -#include "pub_core_basics_asm.h" #include "pub_core_dispatch_asm.h" #include "pub_core_transtab_asm.h" #include "libvex_guest_offsets.h" /* for OFFSET_mips_PC */ @@ -235,11 +235,11 @@ VG_(disp_cp_evcheck_fail): .size VG_(disp_run_translations), .-VG_(disp_run_translations) +#endif // defined(VGP_mips64_linux) -/* Let the linker know we do not need an executable stack */ -.section .note.GNU-stack,"",@progbits +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC -#endif // defined(VGP_mips64_linux) /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-ppc32-linux.S b/coregrind/m_dispatch/dispatch-ppc32-linux.S index 364326d0ed..0c9374f31d 100644 --- a/coregrind/m_dispatch/dispatch-ppc32-linux.S +++ b/coregrind/m_dispatch/dispatch-ppc32-linux.S @@ -28,10 +28,11 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_ppc32_linux) #include "config.h" -#include "pub_core_basics_asm.h" #include "pub_core_dispatch_asm.h" #include "pub_core_transtab_asm.h" #include "libvex_guest_offsets.h" /* for OFFSET_ppc32_CIA */ @@ -495,11 +496,11 @@ VG_(disp_cp_evcheck_fail): .size VG_(disp_run_translations), .-VG_(disp_run_translations) -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",@progbits - #endif // defined(VGP_ppc32_linux) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-ppc64be-linux.S b/coregrind/m_dispatch/dispatch-ppc64be-linux.S index 46dce2d74a..64e192a460 100644 --- a/coregrind/m_dispatch/dispatch-ppc64be-linux.S +++ b/coregrind/m_dispatch/dispatch-ppc64be-linux.S @@ -28,9 +28,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_ppc64be_linux) -#include "pub_core_basics_asm.h" #include "pub_core_dispatch_asm.h" #include "pub_core_transtab_asm.h" #include "libvex_guest_offsets.h" /* for OFFSET_ppc64_CIA */ @@ -527,11 +528,11 @@ VG_(disp_cp_evcheck_fail): .size .VG_(disp_run_translations), .-.VG_(disp_run_translations) -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",@progbits - #endif // defined(VGP_ppc64be_linux) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-ppc64le-linux.S b/coregrind/m_dispatch/dispatch-ppc64le-linux.S index 5da71a6ae5..177228341e 100644 --- a/coregrind/m_dispatch/dispatch-ppc64le-linux.S +++ b/coregrind/m_dispatch/dispatch-ppc64le-linux.S @@ -28,9 +28,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_ppc64le_linux) -#include "pub_core_basics_asm.h" #include "pub_core_dispatch_asm.h" #include "pub_core_transtab_asm.h" #include "libvex_guest_offsets.h" /* for OFFSET_ppc64_CIA */ @@ -620,11 +621,11 @@ VG_(disp_cp_evcheck_fail): .size .VG_(disp_run_translations), .-.VG_(disp_run_translations) -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",@progbits - #endif // defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-s390x-linux.S b/coregrind/m_dispatch/dispatch-s390x-linux.S index 30b2d13f5f..aec65ba405 100644 --- a/coregrind/m_dispatch/dispatch-s390x-linux.S +++ b/coregrind/m_dispatch/dispatch-s390x-linux.S @@ -267,11 +267,11 @@ VG_(disp_cp_evcheck_fail): .size VG_(disp_run_translations), .-VG_(disp_run_translations) -/* Let the linker know we don't need an executable stack */ - .section .note.GNU-stack,"",@progbits - #endif /* VGA_s390x */ +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end dispatch-s390x-linux.S ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-tilegx-linux.S b/coregrind/m_dispatch/dispatch-tilegx-linux.S index 8afa2b4d7b..b3114efce8 100644 --- a/coregrind/m_dispatch/dispatch-tilegx-linux.S +++ b/coregrind/m_dispatch/dispatch-tilegx-linux.S @@ -29,8 +29,9 @@ /* Contributed by Zhi-Gang Liu */ -#if defined(VGP_tilegx_linux) #include "pub_core_basics_asm.h" + +#if defined(VGP_tilegx_linux) #include "pub_core_dispatch_asm.h" #include "pub_core_transtab_asm.h" #include "libvex_guest_offsets.h" /* for OFFSET_tilegx_PC */ @@ -297,11 +298,11 @@ fast_lookup_failed: .size VG_(disp_run_translations), .-VG_(disp_run_translations) +#endif /* defined(VGP_tilegx_linux) */ - /* Let the linker know we do not need an executable stack */ - .section .note.GNU-stack,"",@progbits +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC -#endif /* defined(VGP_tilegx_linux) */ /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-x86-darwin.S b/coregrind/m_dispatch/dispatch-x86-darwin.S index e636baefd7..d5edbab9f5 100644 --- a/coregrind/m_dispatch/dispatch-x86-darwin.S +++ b/coregrind/m_dispatch/dispatch-x86-darwin.S @@ -29,9 +29,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_x86_darwin) -#include "pub_core_basics_asm.h" #include "pub_core_dispatch_asm.h" #include "pub_core_transtab_asm.h" #include "libvex_guest_offsets.h" /* for OFFSET_x86_EIP */ @@ -239,6 +240,9 @@ VG_(disp_cp_evcheck_fail): #endif // defined(VGP_x86_darwin) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-x86-linux.S b/coregrind/m_dispatch/dispatch-x86-linux.S index 9b93261960..6845911b31 100644 --- a/coregrind/m_dispatch/dispatch-x86-linux.S +++ b/coregrind/m_dispatch/dispatch-x86-linux.S @@ -29,9 +29,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_x86_linux) -#include "pub_core_basics_asm.h" #include "pub_core_dispatch_asm.h" #include "pub_core_transtab_asm.h" #include "libvex_guest_offsets.h" /* for OFFSET_x86_EIP */ @@ -240,11 +241,11 @@ VG_(disp_cp_evcheck_fail): .size VG_(disp_run_translations), .-VG_(disp_run_translations) -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",@progbits - #endif // defined(VGP_x86_linux) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_dispatch/dispatch-x86-solaris.S b/coregrind/m_dispatch/dispatch-x86-solaris.S index 3c7762b768..88f796c2a1 100644 --- a/coregrind/m_dispatch/dispatch-x86-solaris.S +++ b/coregrind/m_dispatch/dispatch-x86-solaris.S @@ -29,9 +29,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_x86_solaris) -#include "pub_core_basics_asm.h" #include "pub_core_dispatch_asm.h" #include "pub_core_transtab_asm.h" #include "libvex_guest_offsets.h" /* for OFFSET_x86_EIP */ @@ -242,6 +243,9 @@ VG_(disp_cp_evcheck_fail): #endif // defined(VGP_x86_solaris) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_mach/mach_traps-amd64-darwin.S b/coregrind/m_mach/mach_traps-amd64-darwin.S index 692fb52280..e5b393c947 100644 --- a/coregrind/m_mach/mach_traps-amd64-darwin.S +++ b/coregrind/m_mach/mach_traps-amd64-darwin.S @@ -27,6 +27,8 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_amd64_darwin) #include "vki/vki-scnums-darwin.h" @@ -134,6 +136,9 @@ _semaphore_wait_signal: #endif // defined(VGP_amd64_darwin) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_mach/mach_traps-x86-darwin.S b/coregrind/m_mach/mach_traps-x86-darwin.S index 0a23b9af92..5564060337 100644 --- a/coregrind/m_mach/mach_traps-x86-darwin.S +++ b/coregrind/m_mach/mach_traps-x86-darwin.S @@ -27,6 +27,8 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_x86_darwin) // DDD: should use __NR_ constants in here instead of the trap numbers @@ -124,6 +126,9 @@ _semaphore_wait_signal: #endif // defined(VGP_x86_darwin) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_syswrap/syscall-amd64-darwin.S b/coregrind/m_syswrap/syscall-amd64-darwin.S index d82ea164fa..6f1652b6ac 100644 --- a/coregrind/m_syswrap/syscall-amd64-darwin.S +++ b/coregrind/m_syswrap/syscall-amd64-darwin.S @@ -28,9 +28,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_amd64_darwin) -#include "pub_core_basics_asm.h" #include "pub_core_vkiscnums_asm.h" #include "libvex_guest_offsets.h" @@ -251,6 +252,9 @@ ML_(blksys_finished_UNIX): .quad MK_L_SCCLASS_N(UNIX,5) #endif // defined(VGP_amd64_darwin) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_syswrap/syscall-amd64-linux.S b/coregrind/m_syswrap/syscall-amd64-linux.S index e2c61b4e50..80cc75cfc7 100644 --- a/coregrind/m_syswrap/syscall-amd64-linux.S +++ b/coregrind/m_syswrap/syscall-amd64-linux.S @@ -28,9 +28,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_amd64_linux) -#include "pub_core_basics_asm.h" #include "pub_core_vkiscnums_asm.h" #include "libvex_guest_offsets.h" @@ -244,11 +245,11 @@ ML_(blksys_committed): .quad 4b ML_(blksys_finished): .quad 5b .previous -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",@progbits - #endif // defined(VGP_amd64_linux) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_syswrap/syscall-amd64-solaris.S b/coregrind/m_syswrap/syscall-amd64-solaris.S index a34cf9c586..e04503e11f 100644 --- a/coregrind/m_syswrap/syscall-amd64-solaris.S +++ b/coregrind/m_syswrap/syscall-amd64-solaris.S @@ -28,9 +28,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_amd64_solaris) -#include "pub_core_basics_asm.h" #include "pub_core_vkiscnums_asm.h" #include "libvex_guest_offsets.h" @@ -273,6 +274,9 @@ ML_(blksys_finished_DRET): .quad 4b #endif // defined(VGP_amd64_solaris) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_syswrap/syscall-arm-linux.S b/coregrind/m_syswrap/syscall-arm-linux.S index e2517db20b..9e020f946a 100644 --- a/coregrind/m_syswrap/syscall-arm-linux.S +++ b/coregrind/m_syswrap/syscall-arm-linux.S @@ -27,9 +27,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_arm_linux) -#include "pub_core_basics_asm.h" #include "pub_core_vkiscnums_asm.h" #include "libvex_guest_offsets.h" @@ -141,12 +142,10 @@ ML_(blksys_complete): .long 3b ML_(blksys_committed): .long 4b ML_(blksys_finished): .long 5b -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",%progbits - -.previous - #endif // defined(VGP_arm_linux) + +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/coregrind/m_syswrap/syscall-arm64-linux.S b/coregrind/m_syswrap/syscall-arm64-linux.S index 80839962a4..2306ade58e 100644 --- a/coregrind/m_syswrap/syscall-arm64-linux.S +++ b/coregrind/m_syswrap/syscall-arm64-linux.S @@ -28,9 +28,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_arm64_linux) -#include "pub_core_basics_asm.h" #include "pub_core_vkiscnums_asm.h" #include "libvex_guest_offsets.h" @@ -169,12 +170,10 @@ ML_(blksys_complete): .quad 3b ML_(blksys_committed): .quad 4b ML_(blksys_finished): .quad 5b -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",%progbits - -.previous - #endif // defined(VGP_arm_linux) + +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/coregrind/m_syswrap/syscall-mips32-linux.S b/coregrind/m_syswrap/syscall-mips32-linux.S index 9b14daa025..85459763bd 100644 --- a/coregrind/m_syswrap/syscall-mips32-linux.S +++ b/coregrind/m_syswrap/syscall-mips32-linux.S @@ -28,9 +28,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_mips32_linux) -#include "pub_core_basics_asm.h" #include "pub_core_vkiscnums_asm.h" #include "libvex_guest_offsets.h" @@ -202,14 +203,12 @@ ML_(blksys_restart): .long 2b ML_(blksys_complete): .long 3b ML_(blksys_committed): .long 4b ML_(blksys_finished): .long 5b -.previous -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",%progbits +#endif // defined(VGP_mips32_linux) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC -#endif // defined(VGP_mips32_linux) - /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_syswrap/syscall-mips64-linux.S b/coregrind/m_syswrap/syscall-mips64-linux.S index 32ccfede88..660087850f 100644 --- a/coregrind/m_syswrap/syscall-mips64-linux.S +++ b/coregrind/m_syswrap/syscall-mips64-linux.S @@ -28,9 +28,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_mips64_linux) -#include "pub_core_basics_asm.h" #include "pub_core_vkiscnums_asm.h" #include "libvex_guest_offsets.h" @@ -144,12 +145,12 @@ ML_(blksys_restart): .quad 2b ML_(blksys_complete): .quad 3b ML_(blksys_committed): .quad 4b ML_(blksys_finished): .quad 5b -.previous -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",%progbits #endif // defined(VGP_mips64_linux) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_syswrap/syscall-ppc32-linux.S b/coregrind/m_syswrap/syscall-ppc32-linux.S index 86946b46e0..6213922c7d 100644 --- a/coregrind/m_syswrap/syscall-ppc32-linux.S +++ b/coregrind/m_syswrap/syscall-ppc32-linux.S @@ -27,9 +27,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_ppc32_linux) -#include "pub_core_basics_asm.h" #include "pub_core_vkiscnums_asm.h" #include "libvex_guest_offsets.h" @@ -153,13 +154,11 @@ ML_(blksys_complete): .long 3b ML_(blksys_committed): .long 4b ML_(blksys_finished): .long 5b -.previous - -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",@progbits - #endif // defined(VGP_ppc32_linux) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_syswrap/syscall-ppc64be-linux.S b/coregrind/m_syswrap/syscall-ppc64be-linux.S index 0634abc558..9c42f3ebe9 100644 --- a/coregrind/m_syswrap/syscall-ppc64be-linux.S +++ b/coregrind/m_syswrap/syscall-ppc64be-linux.S @@ -27,9 +27,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_ppc64be_linux) -#include "pub_core_basics_asm.h" #include "pub_core_vkiscnums_asm.h" #include "libvex_guest_offsets.h" @@ -161,11 +162,10 @@ ML_(blksys_complete): .quad 3b ML_(blksys_committed): .quad 4b ML_(blksys_finished): .quad 5b +#endif // defined(VGP_ppc64be_linux) /* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",@progbits - -#endif // defined(VGP_ppc64be_linux) +MARK_STACK_NO_EXEC /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/coregrind/m_syswrap/syscall-ppc64le-linux.S b/coregrind/m_syswrap/syscall-ppc64le-linux.S index 8b61509179..b469cc4014 100644 --- a/coregrind/m_syswrap/syscall-ppc64le-linux.S +++ b/coregrind/m_syswrap/syscall-ppc64le-linux.S @@ -27,9 +27,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_ppc64le_linux) -#include "pub_core_basics_asm.h" #include "pub_core_vkiscnums_asm.h" #include "libvex_guest_offsets.h" @@ -178,11 +179,10 @@ ML_(blksys_complete): .quad 3b ML_(blksys_committed): .quad 4b ML_(blksys_finished): .quad 5b +#endif // defined(VGP_ppc64le_linux) /* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",@progbits - -#endif // defined(VGP_ppc64le_linux) +MARK_STACK_NO_EXEC /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/coregrind/m_syswrap/syscall-s390x-linux.S b/coregrind/m_syswrap/syscall-s390x-linux.S index 72231f2c87..b8a93813d5 100644 --- a/coregrind/m_syswrap/syscall-s390x-linux.S +++ b/coregrind/m_syswrap/syscall-s390x-linux.S @@ -162,11 +162,11 @@ ML_(blksys_committed): .quad 4b ML_(blksys_finished): .quad 5b .previous -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",@progbits - #endif /* VGA_s390x */ +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_syswrap/syscall-tilegx-linux.S b/coregrind/m_syswrap/syscall-tilegx-linux.S index 0bd3756abe..7be2f6a9ac 100644 --- a/coregrind/m_syswrap/syscall-tilegx-linux.S +++ b/coregrind/m_syswrap/syscall-tilegx-linux.S @@ -28,9 +28,10 @@ /* Contributed by Zhi-Gang Liu */ +#include "pub_core_basics_asm.h" + #if defined(VGP_tilegx_linux) -#include "pub_core_basics_asm.h" #include "pub_core_vkiscnums_asm.h" #include "libvex_guest_offsets.h" @@ -180,11 +181,12 @@ ML_(do_syscall_for_client_WRK): ML_(blksys_committed): .quad 4b ML_(blksys_finished): .quad 5b .previous - /* Let the linker know we don't need an executable stack */ - .section .note.GNU-stack,"",%progbits #endif /* defined(VGP_tilegx_linux) */ +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_syswrap/syscall-x86-darwin.S b/coregrind/m_syswrap/syscall-x86-darwin.S index 4f7bac7f0f..823c9b47ee 100644 --- a/coregrind/m_syswrap/syscall-x86-darwin.S +++ b/coregrind/m_syswrap/syscall-x86-darwin.S @@ -28,9 +28,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_x86_darwin) -#include "pub_core_basics_asm.h" #include "pub_core_vkiscnums_asm.h" #include "libvex_guest_offsets.h" @@ -248,7 +249,10 @@ ML_(blksys_committed_UNIX): .long MK_L_SCCLASS_N(UNIX,4) ML_(blksys_finished_UNIX): .long MK_L_SCCLASS_N(UNIX,5) #endif // defined(VGP_x86_darwin) - + +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_syswrap/syscall-x86-linux.S b/coregrind/m_syswrap/syscall-x86-linux.S index 30cb23e45d..e4c6a0a5d3 100644 --- a/coregrind/m_syswrap/syscall-x86-linux.S +++ b/coregrind/m_syswrap/syscall-x86-linux.S @@ -28,9 +28,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_x86_linux) -#include "pub_core_basics_asm.h" #include "pub_core_vkiscnums_asm.h" #include "libvex_guest_offsets.h" @@ -183,12 +184,12 @@ ML_(blksys_complete): .long 3b ML_(blksys_committed): .long 4b ML_(blksys_finished): .long 5b .previous - -/* Let the linker know we don't need an executable stack */ -.section .note.GNU-stack,"",@progbits #endif // defined(VGP_x86_linux) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_syswrap/syscall-x86-solaris.S b/coregrind/m_syswrap/syscall-x86-solaris.S index 654aa84347..c0df3d8ed7 100644 --- a/coregrind/m_syswrap/syscall-x86-solaris.S +++ b/coregrind/m_syswrap/syscall-x86-solaris.S @@ -28,9 +28,10 @@ The GNU General Public License is contained in the file COPYING. */ +#include "pub_core_basics_asm.h" + #if defined(VGP_x86_solaris) -#include "pub_core_basics_asm.h" #include "pub_core_vkiscnums_asm.h" #include "libvex_guest_offsets.h" @@ -270,6 +271,9 @@ ML_(blksys_finished_DRET): .long 4b #endif // defined(VGP_x86_solaris) +/* Let the linker know we don't need an executable stack */ +MARK_STACK_NO_EXEC + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_trampoline.S b/coregrind/m_trampoline.S index 5d46b1567c..cac2288996 100644 --- a/coregrind/m_trampoline.S +++ b/coregrind/m_trampoline.S @@ -1599,14 +1599,8 @@ VG_(trampoline_stuff_end): #endif #endif -#if defined(VGO_linux) /* Let the linker know we don't need an executable stack */ -# if defined(VGP_arm_linux) - .section .note.GNU-stack,"",%progbits -# else - .section .note.GNU-stack,"",@progbits -# endif -#endif +MARK_STACK_NO_EXEC /*--------------------------------------------------------------------*/ /*--- end ---*/ diff --git a/include/pub_tool_basics_asm.h b/include/pub_tool_basics_asm.h index becf918446..d73c91e939 100644 --- a/include/pub_tool_basics_asm.h +++ b/include/pub_tool_basics_asm.h @@ -58,6 +58,20 @@ # error Unknown OS #endif +/* Let the linker know we don't need an executable stack. + The call to MARK_STACK_NO_EXEC should be put unconditionally + at the end of all asm source files. +*/ +#if defined(VGO_linux) +# if defined(VGA_arm) +# define MARK_STACK_NO_EXEC .section .note.GNU-stack,"",%progbits +# else +# define MARK_STACK_NO_EXEC .section .note.GNU-stack,"",@progbits +# endif +#else +# define MARK_STACK_NO_EXEC +#endif + #endif /* __PUB_TOOL_BASICS_ASM_H */ /*--------------------------------------------------------------------*/