1
0
mirror of https://github.com/golang/go synced 2024-11-26 08:58:09 -07:00

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

Fixes #5392.

R=iant, r
CC=golang-dev
https://golang.org/cl/9119043
This commit is contained in:
Shenghou Ma 2013-05-03 16:33:21 +08:00
parent 7cc0581f86
commit e0db7fae87
4 changed files with 18 additions and 1 deletions

View File

@ -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']) {

View File

@ -40,3 +40,6 @@ EXT(__stack_chk_fail_local):
1:
jmp 1b
#ifdef __ELF__
.section .note.GNU-stack,"",@progbits
#endif

View File

@ -42,3 +42,7 @@ EXT(crosscall_amd64):
popq %rbp
popq %rbx
ret
#ifdef __ELF__
.section .note.GNU-stack,"",@progbits
#endif

View File

@ -34,3 +34,6 @@ EXT(__stack_chk_fail_local):
1:
b 1b
#ifdef __ELF__
.section .note.GNU-stack,"",@progbits
#endif