Skip to content

Commit

Permalink
cmd/internal/ld: delete Biobuf
Browse files Browse the repository at this point in the history
Update golang#10652

This proposal deletes cmd/internal/ld.Biobuf and replaces all uses with
cmd/internal/obj.Biobuf. As cmd/internal/ld already imported cmd/internal/obj
there are no additional dependencies created.

Notes:

- ld.Boffset included more checks, so it was merged into obj.Boffset
- obj.Bflush was removed in 8d16253, so replaced all calls to
  ld.Bflush, with obj.Biobuf.Flush.
- Almost all of this change was prepared with sed.

Change-Id: I814854d52f5729a5a40c523c8188e465246b88da
Reviewed-on: https://go-review.googlesource.com/9660
Reviewed-by: Keith Randall <[email protected]>
Run-TryBot: Dave Cheney <[email protected]>
  • Loading branch information
davecheney committed May 4, 2015
1 parent 5ffdf53 commit 71274e4
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 288 deletions.
10 changes: 5 additions & 5 deletions src/cmd/5l/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f asmb\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

if ld.Iself {
ld.Asmbelfsetup()
Expand All @@ -597,7 +597,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f rodatblk\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

ld.Cseek(int64(ld.Segrodata.Fileoff))
ld.Datblk(int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
Expand All @@ -606,7 +606,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f datblk\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

ld.Cseek(int64(ld.Segdata.Fileoff))
ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
Expand Down Expand Up @@ -639,7 +639,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f sym\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()
switch ld.HEADTYPE {
default:
if ld.Iself {
Expand Down Expand Up @@ -700,7 +700,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f header\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()
ld.Cseek(0)
switch ld.HEADTYPE {
default:
Expand Down
12 changes: 6 additions & 6 deletions src/cmd/6l/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,12 +696,12 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f asmb\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f codeblk\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

if ld.Iself {
ld.Asmbelfsetup()
Expand All @@ -719,7 +719,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f rodatblk\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

ld.Cseek(int64(ld.Segrodata.Fileoff))
ld.Datblk(int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
Expand All @@ -728,7 +728,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f datblk\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

ld.Cseek(int64(ld.Segdata.Fileoff))
ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
Expand Down Expand Up @@ -782,7 +782,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f sym\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()
switch ld.HEADTYPE {
default:
case obj.Hplan9,
Expand Down Expand Up @@ -859,7 +859,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f headr\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()
ld.Cseek(0)
switch ld.HEADTYPE {
default:
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/7l/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f asmb\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

if ld.Iself {
ld.Asmbelfsetup()
Expand All @@ -337,7 +337,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f rodatblk\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

ld.Cseek(int64(ld.Segrodata.Fileoff))
ld.Datblk(int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
Expand All @@ -346,7 +346,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f datblk\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

ld.Cseek(int64(ld.Segdata.Fileoff))
ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
Expand Down Expand Up @@ -379,7 +379,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f sym\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()
switch ld.HEADTYPE {
default:
if ld.Iself {
Expand Down Expand Up @@ -440,7 +440,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f header\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()
ld.Cseek(0)
switch ld.HEADTYPE {
default:
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/8l/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f asmb\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

if ld.Iself {
ld.Asmbelfsetup()
Expand All @@ -588,7 +588,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f rodatblk\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

ld.Cseek(int64(ld.Segrodata.Fileoff))
ld.Datblk(int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
Expand All @@ -597,7 +597,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f datblk\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

ld.Cseek(int64(ld.Segdata.Fileoff))
ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
Expand Down Expand Up @@ -627,7 +627,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f sym\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()
switch ld.HEADTYPE {
default:
if ld.Iself {
Expand Down Expand Up @@ -697,7 +697,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f headr\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()
ld.Cseek(0)
switch ld.HEADTYPE {
default:
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/9l/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f asmb\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

if ld.Iself {
ld.Asmbelfsetup()
Expand All @@ -708,7 +708,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f rodatblk\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

ld.Cseek(int64(ld.Segrodata.Fileoff))
ld.Datblk(int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
Expand All @@ -717,7 +717,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f datblk\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()

ld.Cseek(int64(ld.Segdata.Fileoff))
ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
Expand All @@ -732,7 +732,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f sym\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()
switch ld.HEADTYPE {
default:
if ld.Iself {
Expand Down Expand Up @@ -785,7 +785,7 @@ func asmb() {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f header\n", obj.Cputime())
}
ld.Bflush(&ld.Bso)
ld.Bso.Flush()
ld.Cseek(0)
switch ld.HEADTYPE {
default:
Expand Down
8 changes: 4 additions & 4 deletions src/cmd/internal/ld/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ func reloc() {
if Debug['v'] != 0 {
fmt.Fprintf(&Bso, "%5.2f reloc\n", obj.Cputime())
}
Bflush(&Bso)
Bso.Flush()

for s := Ctxt.Textp; s != nil; s = s.Next {
relocsym(s)
Expand Down Expand Up @@ -685,7 +685,7 @@ func dynreloc() {
if Debug['v'] != 0 {
fmt.Fprintf(&Bso, "%5.2f reloc\n", obj.Cputime())
}
Bflush(&Bso)
Bso.Flush()

for s := Ctxt.Textp; s != nil; s = s.Next {
dynrelocsym(s)
Expand Down Expand Up @@ -817,7 +817,7 @@ func Codeblk(addr int64, size int64) {
}
}

Bflush(&Bso)
Bso.Flush()
}

func Datblk(addr int64, size int64) {
Expand Down Expand Up @@ -1204,7 +1204,7 @@ func dodata() {
if Debug['v'] != 0 {
fmt.Fprintf(&Bso, "%5.2f dodata\n", obj.Cputime())
}
Bflush(&Bso)
Bso.Flush()

var last *LSym
datap = nil
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/internal/ld/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func lookupImport(name string) *Import {
return x
}

func ldpkg(f *Biobuf, pkg string, length int64, filename string, whence int) {
func ldpkg(f *obj.Biobuf, pkg string, length int64, filename string, whence int) {
var p0, p1 int

if Debug['g'] != 0 {
Expand All @@ -69,7 +69,7 @@ func ldpkg(f *Biobuf, pkg string, length int64, filename string, whence int) {
}

bdata := make([]byte, length)
if int64(Bread(f, bdata)) != length {
if int64(obj.Bread(f, bdata)) != length {
fmt.Fprintf(os.Stderr, "%s: short pkg read %s\n", os.Args[0], filename)
if Debug['u'] != 0 {
errorexit()
Expand Down
12 changes: 6 additions & 6 deletions src/cmd/internal/ld/ldelf.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ type ElfSect struct {
}

type ElfObj struct {
f *Biobuf
f *obj.Biobuf
base int64 // offset in f where ELF begins
length int64 // length of ELF
is64 int
Expand Down Expand Up @@ -315,13 +315,13 @@ func valuecmp(a *LSym, b *LSym) int {
return 0
}

func ldelf(f *Biobuf, pkg string, length int64, pn string) {
func ldelf(f *obj.Biobuf, pkg string, length int64, pn string) {
if Debug['v'] != 0 {
fmt.Fprintf(&Bso, "%5.2f ldelf %s\n", obj.Cputime(), pn)
}

Ctxt.Version++
base := int32(Boffset(f))
base := int32(obj.Boffset(f))

var add uint64
var e binary.ByteOrder
Expand All @@ -344,7 +344,7 @@ func ldelf(f *Biobuf, pkg string, length int64, pn string) {
var sect *ElfSect
var sym ElfSym
var symbols []*LSym
if Bread(f, hdrbuf[:]) != len(hdrbuf) {
if obj.Bread(f, hdrbuf[:]) != len(hdrbuf) {
goto bad
}
hdr = new(ElfHdrBytes)
Expand Down Expand Up @@ -457,7 +457,7 @@ func ldelf(f *Biobuf, pkg string, length int64, pn string) {

elfobj.nsect = uint(elfobj.shnum)
for i := 0; uint(i) < elfobj.nsect; i++ {
if Bseek(f, int64(uint64(base)+elfobj.shoff+uint64(int64(i)*int64(elfobj.shentsize))), 0) < 0 {
if obj.Bseek(f, int64(uint64(base)+elfobj.shoff+uint64(int64(i)*int64(elfobj.shentsize))), 0) < 0 {
goto bad
}
sect = &elfobj.sect[i]
Expand Down Expand Up @@ -826,7 +826,7 @@ func elfmap(elfobj *ElfObj, sect *ElfSect) (err error) {

sect.base = make([]byte, sect.size)
err = fmt.Errorf("short read")
if Bseek(elfobj.f, int64(uint64(elfobj.base)+sect.off), 0) < 0 || Bread(elfobj.f, sect.base) != len(sect.base) {
if obj.Bseek(elfobj.f, int64(uint64(elfobj.base)+sect.off), 0) < 0 || obj.Bread(elfobj.f, sect.base) != len(sect.base) {
return err
}

Expand Down
Loading

0 comments on commit 71274e4

Please sign in to comment.