Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(582)

Delta Between Two Patch Sets: src/cmd/ld/ldelf.c

Issue 4633043: code review 4633043: 8l/ld: Further adjustments for a port of Go to Plan 9 n... (Closed)
Left Patch Set: Created 13 years, 9 months ago
Right Patch Set: diff -r 61ed63d57306 https://go.googlecode.com/hg/ Created 13 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/cmd/ld/dwarf.c ('k') | src/cmd/ld/ldmacho.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /* 1 /*
2 Derived from Plan 9 from User Space's src/libmach/elf.h, elf.c 2 Derived from Plan 9 from User Space's src/libmach/elf.h, elf.c
3 http://code.swtch.com/plan9port/src/tip/src/libmach/ 3 http://code.swtch.com/plan9port/src/tip/src/libmach/
4 4
5 Copyright © 2004 Russ Cox. 5 Copyright © 2004 Russ Cox.
6 Portions Copyright © 2008-2010 Google Inc. 6 Portions Copyright © 2008-2010 Google Inc.
7 Portions Copyright © 2010 The Go Authors. 7 Portions Copyright © 2010 The Go Authors.
8 8
9 Permission is hereby granted, free of charge, to any person obtaining a copy 9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal 10 of this software and associated documentation files (the "Software"), to deal
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 uchar hdrbuf[64]; 321 uchar hdrbuf[64];
322 uchar *p; 322 uchar *p;
323 ElfHdrBytes *hdr; 323 ElfHdrBytes *hdr;
324 ElfObj *obj; 324 ElfObj *obj;
325 ElfSect *sect, *rsect; 325 ElfSect *sect, *rsect;
326 ElfSym sym; 326 ElfSym sym;
327 Endian *e; 327 Endian *e;
328 Reloc *r, *rp; 328 Reloc *r, *rp;
329 Sym *s; 329 Sym *s;
330 330
331 USED(pkg);
331 if(debug['v']) 332 if(debug['v'])
332 Bprint(&bso, "%5.2f ldelf %s\n", cputime(), pn); 333 Bprint(&bso, "%5.2f ldelf %s\n", cputime(), pn);
333 334
334 version++; 335 version++;
335 base = Boffset(f); 336 base = Boffset(f);
336 337
337 » if(Bread(f, &hdrbuf, sizeof hdrbuf) != sizeof hdrbuf) 338 » if(Bread(f, hdrbuf, sizeof hdrbuf) != sizeof hdrbuf)
338 goto bad; 339 goto bad;
339 » hdr = (ElfHdrBytes*)&hdrbuf; 340 » hdr = (ElfHdrBytes*)hdrbuf;
340 if(memcmp(hdr->ident, ElfMagic, 4) != 0) 341 if(memcmp(hdr->ident, ElfMagic, 4) != 0)
341 goto bad; 342 goto bad;
342 switch(hdr->ident[5]) { 343 switch(hdr->ident[5]) {
343 case ElfDataLsb: 344 case ElfDataLsb:
344 e = ≤ 345 e = ≤
345 break; 346 break;
346 case ElfDataMsb: 347 case ElfDataMsb:
347 e = &be; 348 e = &be;
348 break; 349 break;
349 default: 350 default:
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 for(i=0; i<obj->nsect; i++) { 512 for(i=0; i<obj->nsect; i++) {
512 sect = &obj->sect[i]; 513 sect = &obj->sect[i];
513 if((sect->type != ElfSectProgbits && sect->type != ElfSectNobits ) || !(sect->flags&ElfSectFlagAlloc)) 514 if((sect->type != ElfSectProgbits && sect->type != ElfSectNobits ) || !(sect->flags&ElfSectFlagAlloc))
514 continue; 515 continue;
515 if(sect->type != ElfSectNobits && map(obj, sect) < 0) 516 if(sect->type != ElfSectNobits && map(obj, sect) < 0)
516 goto bad; 517 goto bad;
517 ················ 518 ················
518 name = smprint("%s(%s)", pn, sect->name); 519 name = smprint("%s(%s)", pn, sect->name);
519 s = lookup(name, version); 520 s = lookup(name, version);
520 free(name); 521 free(name);
521 » » switch(sect->flags&(ElfSectFlagAlloc|ElfSectFlagWrite|ElfSectFla gExec)) { 522 » » switch((int)sect->flags&(ElfSectFlagAlloc|ElfSectFlagWrite|ElfSe ctFlagExec)) {
522 default: 523 default:
523 werrstr("unexpected flags for ELF section %s", sect->nam e); 524 werrstr("unexpected flags for ELF section %s", sect->nam e);
524 goto bad; 525 goto bad;
525 case ElfSectFlagAlloc: 526 case ElfSectFlagAlloc:
526 s->type = SRODATA; 527 s->type = SRODATA;
527 break; 528 break;
528 case ElfSectFlagAlloc + ElfSectFlagWrite: 529 case ElfSectFlagAlloc + ElfSectFlagWrite:
529 s->type = SDATA; 530 s->type = SDATA;
530 break; 531 break;
531 case ElfSectFlagAlloc + ElfSectFlagExec: 532 case ElfSectFlagAlloc + ElfSectFlagExec:
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 case R('8', R_386_GOTPC): 807 case R('8', R_386_GOTPC):
807 *siz = 4; 808 *siz = 4;
808 break; 809 break;
809 case R('6', R_X86_64_64): 810 case R('6', R_X86_64_64):
810 *siz = 8; 811 *siz = 8;
811 break; 812 break;
812 } 813 }
813 814
814 return 256+elftype; 815 return 256+elftype;
815 } 816 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b