OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "l.h" | 5 #include "l.h" |
6 #include "lib.h" | 6 #include "lib.h" |
7 #include "../ld/elf.h" | 7 #include "../ld/elf.h" |
8 | 8 |
9 /* | 9 /* |
10 * We use the 64-bit data structures on both 32- and 64-bit machines | 10 * We use the 64-bit data structures on both 32- and 64-bit machines |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 addstring(shstrtab, ".rel.text"); | 923 addstring(shstrtab, ".rel.text"); |
924 addstring(shstrtab, ".rel.rodata"); | 924 addstring(shstrtab, ".rel.rodata"); |
925 addstring(shstrtab, ".rel.typelink"); | 925 addstring(shstrtab, ".rel.typelink"); |
926 addstring(shstrtab, ".rel.gcdata"); | 926 addstring(shstrtab, ".rel.gcdata"); |
927 addstring(shstrtab, ".rel.gcbss"); | 927 addstring(shstrtab, ".rel.gcbss"); |
928 addstring(shstrtab, ".rel.gosymtab"); | 928 addstring(shstrtab, ".rel.gosymtab"); |
929 addstring(shstrtab, ".rel.gopclntab"); | 929 addstring(shstrtab, ".rel.gopclntab"); |
930 addstring(shstrtab, ".rel.noptrdata"); | 930 addstring(shstrtab, ".rel.noptrdata"); |
931 addstring(shstrtab, ".rel.data"); | 931 addstring(shstrtab, ".rel.data"); |
932 } | 932 } |
| 933 // add a .note.GNU-stack section to mark the stack as non-execut
able |
| 934 addstring(shstrtab, ".note.GNU-stack"); |
933 } | 935 } |
934 | 936 |
935 if(!debug['s']) { | 937 if(!debug['s']) { |
936 addstring(shstrtab, ".symtab"); | 938 addstring(shstrtab, ".symtab"); |
937 addstring(shstrtab, ".strtab"); | 939 addstring(shstrtab, ".strtab"); |
938 dwarfaddshstrings(shstrtab); | 940 dwarfaddshstrings(shstrtab); |
939 } | 941 } |
940 addstring(shstrtab, ".shstrtab"); | 942 addstring(shstrtab, ".shstrtab"); |
941 | 943 |
942 if(!debug['d']) { /* -d suppresses dynamic loader format */ | 944 if(!debug['d']) { /* -d suppresses dynamic loader format */ |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 for(sect=segtext.sect; sect!=nil; sect=sect->next) | 1398 for(sect=segtext.sect; sect!=nil; sect=sect->next) |
1397 elfshbits(sect); | 1399 elfshbits(sect); |
1398 for(sect=segdata.sect; sect!=nil; sect=sect->next) | 1400 for(sect=segdata.sect; sect!=nil; sect=sect->next) |
1399 elfshbits(sect); | 1401 elfshbits(sect); |
1400 | 1402 |
1401 if(linkmode == LinkExternal) { | 1403 if(linkmode == LinkExternal) { |
1402 for(sect=segtext.sect; sect!=nil; sect=sect->next) | 1404 for(sect=segtext.sect; sect!=nil; sect=sect->next) |
1403 elfshreloc(sect); | 1405 elfshreloc(sect); |
1404 for(sect=segdata.sect; sect!=nil; sect=sect->next) | 1406 for(sect=segdata.sect; sect!=nil; sect=sect->next) |
1405 elfshreloc(sect); | 1407 elfshreloc(sect); |
| 1408 // add a .note.GNU-stack section to mark the stack as non-execut
able |
| 1409 sh = elfshname(".note.GNU-stack"); |
| 1410 sh->type = SHT_PROGBITS; |
| 1411 sh->addralign = 1; |
| 1412 sh->flags = 0; |
1406 } | 1413 } |
1407 » » | 1414 |
1408 if(!debug['s']) { | 1415 if(!debug['s']) { |
1409 sh = elfshname(".symtab"); | 1416 sh = elfshname(".symtab"); |
1410 sh->type = SHT_SYMTAB; | 1417 sh->type = SHT_SYMTAB; |
1411 sh->off = symo; | 1418 sh->off = symo; |
1412 sh->size = symsize; | 1419 sh->size = symsize; |
1413 sh->addralign = PtrSize; | 1420 sh->addralign = PtrSize; |
1414 sh->entsize = 8+2*PtrSize; | 1421 sh->entsize = 8+2*PtrSize; |
1415 sh->link = elfshname(".strtab")->shnum; | 1422 sh->link = elfshname(".strtab")->shnum; |
1416 sh->info = elfglobalsymndx; | 1423 sh->info = elfglobalsymndx; |
1417 | 1424 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 if(HEADTYPE == Hnetbsd) | 1477 if(HEADTYPE == Hnetbsd) |
1471 a += elfwritenetbsdsig(); | 1478 a += elfwritenetbsdsig(); |
1472 if(HEADTYPE == Hopenbsd) | 1479 if(HEADTYPE == Hopenbsd) |
1473 a += elfwriteopenbsdsig(); | 1480 a += elfwriteopenbsdsig(); |
1474 if(buildinfolen > 0) | 1481 if(buildinfolen > 0) |
1475 a += elfwritebuildinfo(); | 1482 a += elfwritebuildinfo(); |
1476 } | 1483 } |
1477 if(a > ELFRESERVE)······ | 1484 if(a > ELFRESERVE)······ |
1478 diag("ELFRESERVE too small: %d > %d", a, ELFRESERVE); | 1485 diag("ELFRESERVE too small: %d > %d", a, ELFRESERVE); |
1479 } | 1486 } |
OLD | NEW |