LEFT | RIGHT |
(no file at all) | |
1 // Inferno utils/8l/asm.c | 1 // Inferno utils/8l/asm.c |
2 // http://code.google.com/p/inferno-os/source/browse/utils/8l/asm.c | 2 // http://code.google.com/p/inferno-os/source/browse/utils/8l/asm.c |
3 // | 3 // |
4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. | 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. |
5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) | 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) |
6 // Portions Copyright © 1997-1999 Vita Nuova Limited | 6 // Portions Copyright © 1997-1999 Vita Nuova Limited |
7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) | 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) |
8 // Portions Copyright © 2004,2006 Bruce Ellis | 8 // Portions Copyright © 2004,2006 Bruce Ellis |
9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) | 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) |
10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others | 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 elfstr[ElfStrGot] = addstring(shstrtab, ".got"); | 543 elfstr[ElfStrGot] = addstring(shstrtab, ".got"); |
544 elfstr[ElfStrGotPlt] = addstring(shstrtab, ".got.plt"); | 544 elfstr[ElfStrGotPlt] = addstring(shstrtab, ".got.plt"); |
545 elfstr[ElfStrDynamic] = addstring(shstrtab, ".dynamic"); | 545 elfstr[ElfStrDynamic] = addstring(shstrtab, ".dynamic"); |
546 elfstr[ElfStrDynsym] = addstring(shstrtab, ".dynsym"); | 546 elfstr[ElfStrDynsym] = addstring(shstrtab, ".dynsym"); |
547 elfstr[ElfStrDynstr] = addstring(shstrtab, ".dynstr"); | 547 elfstr[ElfStrDynstr] = addstring(shstrtab, ".dynstr"); |
548 elfstr[ElfStrRel] = addstring(shstrtab, ".rel"); | 548 elfstr[ElfStrRel] = addstring(shstrtab, ".rel"); |
549 elfstr[ElfStrRelPlt] = addstring(shstrtab, ".rel.plt"); | 549 elfstr[ElfStrRelPlt] = addstring(shstrtab, ".rel.plt"); |
550 elfstr[ElfStrPlt] = addstring(shstrtab, ".plt"); | 550 elfstr[ElfStrPlt] = addstring(shstrtab, ".plt"); |
551 elfstr[ElfStrGnuVersion] = addstring(shstrtab, ".gnu.version"); | 551 elfstr[ElfStrGnuVersion] = addstring(shstrtab, ".gnu.version"); |
552 elfstr[ElfStrGnuVersionR] = addstring(shstrtab, ".gnu.version_r"
); | 552 elfstr[ElfStrGnuVersionR] = addstring(shstrtab, ".gnu.version_r"
); |
553 | |
554 /* interpreter string */ | |
555 if(interpreter == nil) { | |
556 switch(HEADTYPE) { | |
557 case Hlinux: | |
558 interpreter = linuxdynld; | |
559 break; | |
560 case Hfreebsd: | |
561 interpreter = freebsddynld; | |
562 break; | |
563 } | |
564 } | |
565 s = lookup(".interp", 0); | |
566 s->type = SELFROSECT; | |
567 s->reachable = 1; | |
568 addstring(s, interpreter); | |
569 | 553 |
570 /* dynamic symbol table - first entry all zeros */ | 554 /* dynamic symbol table - first entry all zeros */ |
571 s = lookup(".dynsym", 0); | 555 s = lookup(".dynsym", 0); |
572 s->type = SELFROSECT; | 556 s->type = SELFROSECT; |
573 s->reachable = 1; | 557 s->reachable = 1; |
574 s->size += ELF32SYMSIZE; | 558 s->size += ELF32SYMSIZE; |
575 | 559 |
576 /* dynamic string table */ | 560 /* dynamic string table */ |
577 s = lookup(".dynstr", 0); | 561 s = lookup(".dynstr", 0); |
578 s->reachable = 1; | 562 s->reachable = 1; |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 o = segtext.fileoff - pph->off; | 941 o = segtext.fileoff - pph->off; |
958 segtext.fileoff -= o; | 942 segtext.fileoff -= o; |
959 segtext.filelen += o; | 943 segtext.filelen += o; |
960 | 944 |
961 if(!debug['d']) { | 945 if(!debug['d']) { |
962 /* interpreter */ | 946 /* interpreter */ |
963 sh = newElfShdr(elfstr[ElfStrInterp]); | 947 sh = newElfShdr(elfstr[ElfStrInterp]); |
964 sh->type = SHT_PROGBITS; | 948 sh->type = SHT_PROGBITS; |
965 sh->flags = SHF_ALLOC; | 949 sh->flags = SHF_ALLOC; |
966 sh->addralign = 1; | 950 sh->addralign = 1; |
967 » » » shsym(sh, lookup(".interp", 0)); | 951 » » » if(interpreter == nil) { |
| 952 » » » » switch(HEADTYPE) { |
| 953 » » » » case Hlinux: |
| 954 » » » » » interpreter = linuxdynld; |
| 955 » » » » » break; |
| 956 » » » » case Hfreebsd: |
| 957 » » » » » interpreter = freebsddynld; |
| 958 » » » » » break; |
| 959 » » » » } |
| 960 » » » } |
| 961 » » » elfinterp(sh, startva, interpreter); |
968 | 962 |
969 ph = newElfPhdr(); | 963 ph = newElfPhdr(); |
970 ph->type = PT_INTERP; | 964 ph->type = PT_INTERP; |
971 ph->flags = PF_R; | 965 ph->flags = PF_R; |
972 phsh(ph, sh); | 966 phsh(ph, sh); |
973 } | 967 } |
974 | 968 |
975 elfphload(&segtext); | 969 elfphload(&segtext); |
976 elfphload(&segdata); | 970 elfphload(&segdata); |
977 | 971 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 pph->filesz = eh->phnum * eh->phentsize; | 1135 pph->filesz = eh->phnum * eh->phentsize; |
1142 pph->memsz = pph->filesz; | 1136 pph->memsz = pph->filesz; |
1143 } | 1137 } |
1144 | 1138 |
1145 cseek(0); | 1139 cseek(0); |
1146 a = 0; | 1140 a = 0; |
1147 a += elfwritehdr(); | 1141 a += elfwritehdr(); |
1148 a += elfwritephdrs(); | 1142 a += elfwritephdrs(); |
1149 a += elfwriteshdrs(); | 1143 a += elfwriteshdrs(); |
1150 cflush(); | 1144 cflush(); |
1151 » » if(a > ELFRESERVE)»····· | 1145 » » if(a+elfwriteinterp() > ELFRESERVE)»···· |
1152 diag("ELFRESERVE too small: %d > %d", a, ELFRESERVE); | 1146 diag("ELFRESERVE too small: %d > %d", a, ELFRESERVE); |
1153 break; | 1147 break; |
1154 | 1148 |
1155 case Hwindows: | 1149 case Hwindows: |
1156 asmbpe(); | 1150 asmbpe(); |
1157 break; | 1151 break; |
1158 } | 1152 } |
1159 cflush(); | 1153 cflush(); |
1160 } | 1154 } |
1161 | 1155 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 if(a->type == D_AUTO) | 1244 if(a->type == D_AUTO) |
1251 put(nil, a->asym->name, 'a', -a->aoffset, 0, 0,
a->gotype); | 1245 put(nil, a->asym->name, 'a', -a->aoffset, 0, 0,
a->gotype); |
1252 else | 1246 else |
1253 if(a->type == D_PARAM) | 1247 if(a->type == D_PARAM) |
1254 put(nil, a->asym->name, 'p', a->aoffset, 0, 0, a
->gotype); | 1248 put(nil, a->asym->name, 'p', a->aoffset, 0, 0, a
->gotype); |
1255 } | 1249 } |
1256 if(debug['v'] || debug['n']) | 1250 if(debug['v'] || debug['n']) |
1257 Bprint(&bso, "symsize = %d\n", symsize); | 1251 Bprint(&bso, "symsize = %d\n", symsize); |
1258 Bflush(&bso); | 1252 Bflush(&bso); |
1259 } | 1253 } |
LEFT | RIGHT |