~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to src/pkg/debug/elf/file.go

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-08-03 17:04:59 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110803170459-wzd99m3567y80ila
Tags: 1:59-1
* Imported Upstream version 59
* Refresh patches to a new release
* Fix FTBFS on ARM (Closes: #634270)
* Update version.bash to work with Debian packaging and not hg
  repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
// specified link value.
82
82
func (f *File) stringTable(link uint32) ([]byte, os.Error) {
83
83
        if link <= 0 || link >= uint32(len(f.Sections)) {
84
 
                return nil, os.ErrorString("section has invalid string table link")
 
84
                return nil, os.NewError("section has invalid string table link")
85
85
        }
86
86
        return f.Sections[link].Data()
87
87
}
341
341
                return f.getSymbols32(typ)
342
342
        }
343
343
 
344
 
        return nil, nil, os.ErrorString("not implemented")
 
344
        return nil, nil, os.NewError("not implemented")
345
345
}
346
346
 
347
347
func (f *File) getSymbols32(typ SectionType) ([]Symbol, []byte, os.Error) {
348
348
        symtabSection := f.SectionByType(typ)
349
349
        if symtabSection == nil {
350
 
                return nil, nil, os.ErrorString("no symbol section")
 
350
                return nil, nil, os.NewError("no symbol section")
351
351
        }
352
352
 
353
353
        data, err := symtabSection.Data()
354
354
        if err != nil {
355
 
                return nil, nil, os.ErrorString("cannot load symbol section")
 
355
                return nil, nil, os.NewError("cannot load symbol section")
356
356
        }
357
357
        symtab := bytes.NewBuffer(data)
358
358
        if symtab.Len()%Sym32Size != 0 {
359
 
                return nil, nil, os.ErrorString("length of symbol section is not a multiple of SymSize")
 
359
                return nil, nil, os.NewError("length of symbol section is not a multiple of SymSize")
360
360
        }
361
361
 
362
362
        strdata, err := f.stringTable(symtabSection.Link)
363
363
        if err != nil {
364
 
                return nil, nil, os.ErrorString("cannot load string table section")
 
364
                return nil, nil, os.NewError("cannot load string table section")
365
365
        }
366
366
 
367
367
        // The first entry is all zeros.
390
390
func (f *File) getSymbols64(typ SectionType) ([]Symbol, []byte, os.Error) {
391
391
        symtabSection := f.SectionByType(typ)
392
392
        if symtabSection == nil {
393
 
                return nil, nil, os.ErrorString("no symbol section")
 
393
                return nil, nil, os.NewError("no symbol section")
394
394
        }
395
395
 
396
396
        data, err := symtabSection.Data()
397
397
        if err != nil {
398
 
                return nil, nil, os.ErrorString("cannot load symbol section")
 
398
                return nil, nil, os.NewError("cannot load symbol section")
399
399
        }
400
400
        symtab := bytes.NewBuffer(data)
401
401
        if symtab.Len()%Sym64Size != 0 {
402
 
                return nil, nil, os.ErrorString("length of symbol section is not a multiple of Sym64Size")
 
402
                return nil, nil, os.NewError("length of symbol section is not a multiple of Sym64Size")
403
403
        }
404
404
 
405
405
        strdata, err := f.stringTable(symtabSection.Link)
406
406
        if err != nil {
407
 
                return nil, nil, os.ErrorString("cannot load string table section")
 
407
                return nil, nil, os.NewError("cannot load string table section")
408
408
        }
409
409
 
410
410
        // The first entry is all zeros.
462
462
                return f.applyRelocationsAMD64(dst, rels)
463
463
        }
464
464
 
465
 
        return os.ErrorString("not implemented")
 
465
        return os.NewError("not implemented")
466
466
}
467
467
 
468
468
func (f *File) applyRelocationsAMD64(dst []byte, rels []byte) os.Error {
469
469
        if len(rels)%Sym64Size != 0 {
470
 
                return os.ErrorString("length of relocation section is not a multiple of Sym64Size")
 
470
                return os.NewError("length of relocation section is not a multiple of Sym64Size")
471
471
        }
472
472
 
473
473
        symbols, _, err := f.getSymbols(SHT_SYMTAB)