LEFT | RIGHT |
(no file at all) | |
1 // Inferno utils/5l/asm.c | 1 // Inferno utils/5l/asm.c |
2 // http://code.google.com/p/inferno-os/source/browse/utils/5l/asm.c | 2 // http://code.google.com/p/inferno-os/source/browse/utils/5l/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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 elfstr[ElfStrInterp] = addstring(shstrtab, ".interp"); | 177 elfstr[ElfStrInterp] = addstring(shstrtab, ".interp"); |
178 elfstr[ElfStrHash] = addstring(shstrtab, ".hash"); | 178 elfstr[ElfStrHash] = addstring(shstrtab, ".hash"); |
179 elfstr[ElfStrGot] = addstring(shstrtab, ".got"); | 179 elfstr[ElfStrGot] = addstring(shstrtab, ".got"); |
180 elfstr[ElfStrGotPlt] = addstring(shstrtab, ".got.plt"); | 180 elfstr[ElfStrGotPlt] = addstring(shstrtab, ".got.plt"); |
181 elfstr[ElfStrDynamic] = addstring(shstrtab, ".dynamic"); | 181 elfstr[ElfStrDynamic] = addstring(shstrtab, ".dynamic"); |
182 elfstr[ElfStrDynsym] = addstring(shstrtab, ".dynsym"); | 182 elfstr[ElfStrDynsym] = addstring(shstrtab, ".dynsym"); |
183 elfstr[ElfStrDynstr] = addstring(shstrtab, ".dynstr"); | 183 elfstr[ElfStrDynstr] = addstring(shstrtab, ".dynstr"); |
184 elfstr[ElfStrRel] = addstring(shstrtab, ".rel"); | 184 elfstr[ElfStrRel] = addstring(shstrtab, ".rel"); |
185 elfstr[ElfStrRelPlt] = addstring(shstrtab, ".rel.plt"); | 185 elfstr[ElfStrRelPlt] = addstring(shstrtab, ".rel.plt"); |
186 elfstr[ElfStrPlt] = addstring(shstrtab, ".plt"); | 186 elfstr[ElfStrPlt] = addstring(shstrtab, ".plt"); |
187 | |
188 /* interpreter string */ | |
189 if(interpreter == nil) | |
190 interpreter = linuxdynld; | |
191 s = lookup(".interp", 0); | |
192 s->type = SELFROSECT; | |
193 s->reachable = 1; | |
194 addstring(s, interpreter); | |
195 | 187 |
196 /* dynamic symbol table - first entry all zeros */ | 188 /* dynamic symbol table - first entry all zeros */ |
197 s = lookup(".dynsym", 0); | 189 s = lookup(".dynsym", 0); |
198 s->type = SELFROSECT; | 190 s->type = SELFROSECT; |
199 s->reachable = 1; | 191 s->reachable = 1; |
200 s->value += ELF32SYMSIZE; | 192 s->value += ELF32SYMSIZE; |
201 | 193 |
202 /* dynamic string table */ | 194 /* dynamic string table */ |
203 s = lookup(".dynstr", 0); | 195 s = lookup(".dynstr", 0); |
204 s->type = SELFROSECT; | 196 s->type = SELFROSECT; |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 o = segtext.fileoff - pph->off; | 477 o = segtext.fileoff - pph->off; |
486 segtext.fileoff -= o; | 478 segtext.fileoff -= o; |
487 segtext.filelen += o; | 479 segtext.filelen += o; |
488 | 480 |
489 if(!debug['d']) { | 481 if(!debug['d']) { |
490 /* interpreter for dynamic linking */ | 482 /* interpreter for dynamic linking */ |
491 sh = newElfShdr(elfstr[ElfStrInterp]); | 483 sh = newElfShdr(elfstr[ElfStrInterp]); |
492 sh->type = SHT_PROGBITS; | 484 sh->type = SHT_PROGBITS; |
493 sh->flags = SHF_ALLOC; | 485 sh->flags = SHF_ALLOC; |
494 sh->addralign = 1; | 486 sh->addralign = 1; |
495 » » » shsym(sh, lookup(".interp", 0)); | 487 » » » if(interpreter == nil) |
| 488 » » » » interpreter = linuxdynld; |
| 489 » » » elfinterp(sh, startva, interpreter); |
496 | 490 |
497 ph = newElfPhdr(); | 491 ph = newElfPhdr(); |
498 ph->type = PT_INTERP; | 492 ph->type = PT_INTERP; |
499 ph->flags = PF_R; | 493 ph->flags = PF_R; |
500 phsh(ph, sh); | 494 phsh(ph, sh); |
501 } | 495 } |
502 | 496 |
503 elfphload(&segtext); | 497 elfphload(&segtext); |
504 elfphload(&segdata); | 498 elfphload(&segdata); |
505 | 499 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 pph->filesz = eh->phnum * eh->phentsize; | 625 pph->filesz = eh->phnum * eh->phentsize; |
632 pph->memsz = pph->filesz; | 626 pph->memsz = pph->filesz; |
633 } | 627 } |
634 | 628 |
635 cseek(0); | 629 cseek(0); |
636 a = 0; | 630 a = 0; |
637 a += elfwritehdr(); | 631 a += elfwritehdr(); |
638 a += elfwritephdrs(); | 632 a += elfwritephdrs(); |
639 a += elfwriteshdrs(); | 633 a += elfwriteshdrs(); |
640 cflush(); | 634 cflush(); |
641 » » if(a > ELFRESERVE)»····· | 635 » » if(a+elfwriteinterp() > ELFRESERVE)»···· |
642 diag("ELFRESERVE too small: %d > %d", a, ELFRESERVE); | 636 diag("ELFRESERVE too small: %d > %d", a, ELFRESERVE); |
643 break; | 637 break; |
644 } | 638 } |
645 cflush(); | 639 cflush(); |
646 if(debug['c']){ | 640 if(debug['c']){ |
647 print("textsize=%d\n", textsize); | 641 print("textsize=%d\n", textsize); |
648 print("datsize=%ulld\n", segdata.filelen); | 642 print("datsize=%ulld\n", segdata.filelen); |
649 print("bsssize=%ulld\n", segdata.len - segdata.filelen); | 643 print("bsssize=%ulld\n", segdata.len - segdata.filelen); |
650 print("symsize=%d\n", symsize); | 644 print("symsize=%d\n", symsize); |
651 print("lcsize=%d\n", lcsize); | 645 print("lcsize=%d\n", lcsize); |
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1875 if(debug['v'] || debug['n']) | 1869 if(debug['v'] || debug['n']) |
1876 Bprint(&bso, "symsize = %ud\n", symsize); | 1870 Bprint(&bso, "symsize = %ud\n", symsize); |
1877 Bflush(&bso); | 1871 Bflush(&bso); |
1878 } | 1872 } |
1879 | 1873 |
1880 void | 1874 void |
1881 setpersrc(Sym *s) | 1875 setpersrc(Sym *s) |
1882 { | 1876 { |
1883 USED(s); | 1877 USED(s); |
1884 } | 1878 } |
LEFT | RIGHT |