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")
86
86
return f.Sections[link].Data()
341
341
return f.getSymbols32(typ)
344
return nil, nil, os.ErrorString("not implemented")
344
return nil, nil, os.NewError("not implemented")
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")
353
353
data, err := symtabSection.Data()
355
return nil, nil, os.ErrorString("cannot load symbol section")
355
return nil, nil, os.NewError("cannot load symbol section")
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")
362
362
strdata, err := f.stringTable(symtabSection.Link)
364
return nil, nil, os.ErrorString("cannot load string table section")
364
return nil, nil, os.NewError("cannot load string table section")
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")
396
396
data, err := symtabSection.Data()
398
return nil, nil, os.ErrorString("cannot load symbol section")
398
return nil, nil, os.NewError("cannot load symbol section")
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")
405
405
strdata, err := f.stringTable(symtabSection.Link)
407
return nil, nil, os.ErrorString("cannot load string table section")
407
return nil, nil, os.NewError("cannot load string table section")
410
410
// The first entry is all zeros.
462
462
return f.applyRelocationsAMD64(dst, rels)
465
return os.ErrorString("not implemented")
465
return os.NewError("not implemented")
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")
473
473
symbols, _, err := f.getSymbols(SHT_SYMTAB)