[PATCH, GOLD, AArch64] default stack not executable

Jim Wilson jim.wilson@linaro.org
Thu Sep 21 20:27:00 GMT 2017


For aarch64, ld.bfd makes the stack not executable when a GNU-stack note is
missing.  Note that elf_backend_default_execstack is 0 in bfd/elfnn-aarch64.c.

However, ld.gold makes the stack executable when a GNU-stack note is missing.
Note that is_default_stack_executable is true in gold/aarch64.cc.

This appears to be a bug in gold.  It also looks like 64-bit ppc gets this
wrong also, though I have not tested that.

The following patch fixes this for aarch64 by changing gold aarch64 to make
is_default_stack_executable false.  This was tested with a make check, and
there were no regressions.  It was also verified against a testcase using a
.s file with a missing GNU-stack note.

	gold/
	* aarch64.cc (Target_aarch64::aarch64_info): Set
	is_default_stack_executable to false.
---
 gold/aarch64.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gold/aarch64.cc b/gold/aarch64.cc
index a72e2c3..4c6e920 100644
--- a/gold/aarch64.cc
+++ b/gold/aarch64.cc
@@ -3523,7 +3523,7 @@ const Target::Target_info Target_aarch64<64, false>::aarch64_info =
   false,		// has_make_symbol
   false,		// has_resolve
   false,		// has_code_fill
-  true,			// is_default_stack_executable
+  false,		// is_default_stack_executable
   true,			// can_icf_inline_merge_sections
   '\0',			// wrap_char
   "/lib/ld.so.1",	// program interpreter
@@ -3551,7 +3551,7 @@ const Target::Target_info Target_aarch64<32, false>::aarch64_info =
   false,		// has_make_symbol
   false,		// has_resolve
   false,		// has_code_fill
-  true,			// is_default_stack_executable
+  false,		// is_default_stack_executable
   false,		// can_icf_inline_merge_sections
   '\0',			// wrap_char
   "/lib/ld.so.1",	// program interpreter
@@ -3579,7 +3579,7 @@ const Target::Target_info Target_aarch64<64, true>::aarch64_info =
   false,		// has_make_symbol
   false,		// has_resolve
   false,		// has_code_fill
-  true,			// is_default_stack_executable
+  false,		// is_default_stack_executable
   true,			// can_icf_inline_merge_sections
   '\0',			// wrap_char
   "/lib/ld.so.1",	// program interpreter
@@ -3607,7 +3607,7 @@ const Target::Target_info Target_aarch64<32, true>::aarch64_info =
   false,		// has_make_symbol
   false,		// has_resolve
   false,		// has_code_fill
-  true,			// is_default_stack_executable
+  false,		// is_default_stack_executable
   false,		// can_icf_inline_merge_sections
   '\0',			// wrap_char
   "/lib/ld.so.1",	// program interpreter
-- 
2.7.4



More information about the Binutils mailing list