1
0
mirror of https://github.com/golang/go synced 2024-11-22 14:24:45 -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,8 +1405,13 @@ 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']) {
sh = elfshname(".symtab");
sh->type = SHT_SYMTAB;

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