OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Package macho implements access to Mach-O object files, as defined by | 5 // Package macho implements access to Mach-O object files, as defined by |
6 // http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptua
l/MachORuntime/Reference/reference.html. | 6 // http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptua
l/MachORuntime/Reference/reference.html. |
7 package macho | 7 package macho |
8 | 8 |
9 // High level access to low level data structures. | 9 // High level access to low level data structures. |
10 | 10 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } | 299 } |
300 } | 300 } |
301 return f, nil | 301 return f, nil |
302 } | 302 } |
303 | 303 |
304 func (f *File) pushSection(sh *Section, r io.ReaderAt) { | 304 func (f *File) pushSection(sh *Section, r io.ReaderAt) { |
305 n := len(f.Sections) | 305 n := len(f.Sections) |
306 if n >= cap(f.Sections) { | 306 if n >= cap(f.Sections) { |
307 m := (n + 1) * 2 | 307 m := (n + 1) * 2 |
308 new := make([]*Section, n, m) | 308 new := make([]*Section, n, m) |
309 » » for i, sh := range f.Sections { | 309 » » copy(new, f.Sections) |
310 » » » new[i] = sh | |
311 » » } | |
312 f.Sections = new | 310 f.Sections = new |
313 } | 311 } |
314 f.Sections = f.Sections[0 : n+1] | 312 f.Sections = f.Sections[0 : n+1] |
315 f.Sections[n] = sh | 313 f.Sections[n] = sh |
316 sh.sr = io.NewSectionReader(r, int64(sh.Offset), int64(sh.Size)) | 314 sh.sr = io.NewSectionReader(r, int64(sh.Offset), int64(sh.Size)) |
317 sh.ReaderAt = sh.sr | 315 sh.ReaderAt = sh.sr |
318 } | 316 } |
319 | 317 |
320 func cstring(b []byte) string { | 318 func cstring(b []byte) string { |
321 var i int | 319 var i int |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 b, err := s.Data() | 359 b, err := s.Data() |
362 if err != nil && uint64(len(b)) < s.Size { | 360 if err != nil && uint64(len(b)) < s.Size { |
363 return nil, err | 361 return nil, err |
364 } | 362 } |
365 dat[i] = b | 363 dat[i] = b |
366 } | 364 } |
367 | 365 |
368 abbrev, info, str := dat[0], dat[1], dat[2] | 366 abbrev, info, str := dat[0], dat[1], dat[2] |
369 return dwarf.New(abbrev, nil, nil, info, nil, nil, nil, str) | 367 return dwarf.New(abbrev, nil, nil, info, nil, nil, nil, str) |
370 } | 368 } |
OLD | NEW |