Commit e0db7fae authored by Shenghou Ma's avatar Shenghou Ma

cmd/ld: add .note.GNU-stack section for external linking

Fixes #5392.

R=iant, r
CC=golang-dev
https://golang.org/cl/9119043
parent 7cc0581f
......@@ -930,6 +930,8 @@ doelf(void)
addstring(shstrtab, ".rel.noptrdata");
addstring(shstrtab, ".rel.data");
}
// add a .note.GNU-stack section to mark the stack as non-executable
addstring(shstrtab, ".note.GNU-stack");
}
if(!debug['s']) {
......@@ -1403,6 +1405,11 @@ elfobj:
elfshreloc(sect);
for(sect=segdata.sect; sect!=nil; sect=sect->next)
elfshreloc(sect);
// add a .note.GNU-stack section to mark the stack as non-executable
sh = elfshname(".note.GNU-stack");
sh->type = SHT_PROGBITS;
sh->addralign = 1;
sh->flags = 0;
}
if(!debug['s']) {
......
......@@ -40,3 +40,6 @@ EXT(__stack_chk_fail_local):
1:
jmp 1b
#ifdef __ELF__
.section .note.GNU-stack,"",@progbits
#endif
......@@ -42,3 +42,7 @@ EXT(crosscall_amd64):
popq %rbp
popq %rbx
ret
#ifdef __ELF__
.section .note.GNU-stack,"",@progbits
#endif
......@@ -34,3 +34,6 @@ EXT(__stack_chk_fail_local):
1:
b 1b
#ifdef __ELF__
.section .note.GNU-stack,"",@progbits
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment