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

Delta Between Two Patch Sets: src/cmd/link/load.go

Issue 88190043: code review 88190043: liblink, cmd/ld: reenable nosplit checking and test (Closed)
Left Patch Set: Created 10 years, 11 months ago
Right Patch Set: diff -r 4873079c140c https://code.google.com/p/go/ Created 10 years, 11 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/pcln.c ('k') | src/cmd/link/testdata/autosection.6 » ('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 // Copyright 2014 The Go Authors. All rights reserved. 1 // Copyright 2014 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 // Loading of code and data fragments from package files into final image. 5 // Loading of code and data fragments from package files into final image.
6 6
7 package main 7 package main
8 8
9 import "os" 9 import "os"
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 _, err := f.ReadAt(data, sym.Data.Offset) 68 _, err := f.ReadAt(data, sym.Data.Offset)
69 if err != nil { 69 if err != nil {
70 p.errorf("reading %v: %v", sym.SymID, err) 70 p.errorf("reading %v: %v", sym.SymID, err)
71 } 71 }
72 p.relocateSym(sym, data) 72 p.relocateSym(sym, data)
73 } 73 }
74 } 74 }
75 75
76 // TODO(rsc): Define full enumeration for relocation types. 76 // TODO(rsc): Define full enumeration for relocation types.
77 const ( 77 const (
78 » R_ADDR = 1 78 » R_ADDR = 1
79 » R_SIZE = 2 79 » R_SIZE = 2
80 » R_PCREL = 5 80 » R_CALL = 3
81 » R_CALLARM = 4
82 » R_CALLIND = 5
83 » R_CONST = 6
84 » R_PCREL = 7
81 ) 85 )
82 86
83 // relocateSym applies relocations to sym's data. 87 // relocateSym applies relocations to sym's data.
84 func (p *Prog) relocateSym(sym *Sym, data []byte) { 88 func (p *Prog) relocateSym(sym *Sym, data []byte) {
85 for i := range sym.Reloc { 89 for i := range sym.Reloc {
86 r := &sym.Reloc[i] 90 r := &sym.Reloc[i]
87 targ := p.Syms[r.Sym] 91 targ := p.Syms[r.Sym]
88 if targ == nil { 92 if targ == nil {
89 p.errorf("%v: reference to undefined symbol %v", sym, r. Sym) 93 p.errorf("%v: reference to undefined symbol %v", sym, r. Sym)
90 continue 94 continue
91 } 95 }
92 val := targ.Addr + Addr(r.Add) 96 val := targ.Addr + Addr(r.Add)
93 switch r.Type { 97 switch r.Type {
94 default: 98 default:
95 p.errorf("%v: unknown relocation type %d", sym, r.Type) 99 p.errorf("%v: unknown relocation type %d", sym, r.Type)
96 » » case R_ADDR: 100 » » case R_ADDR, R_CALLIND:
97 // ok 101 // ok
98 » » case R_PCREL: 102 » » case R_PCREL, R_CALL:
99 val -= sym.Addr + Addr(r.Offset+r.Size) 103 val -= sym.Addr + Addr(r.Offset+r.Size)
100 } 104 }
101 frag := data[r.Offset : r.Offset+r.Size] 105 frag := data[r.Offset : r.Offset+r.Size]
102 switch r.Size { 106 switch r.Size {
103 default: 107 default:
104 p.errorf("%v: unknown relocation size %d", sym, r.Size) 108 p.errorf("%v: unknown relocation size %d", sym, r.Size)
105 case 4: 109 case 4:
106 // TODO(rsc): Check for overflow? 110 // TODO(rsc): Check for overflow?
107 p.byteorder.PutUint32(frag, uint32(val)) 111 p.byteorder.PutUint32(frag, uint32(val))
108 case 8: 112 case 8:
109 p.byteorder.PutUint64(frag, uint64(val)) 113 p.byteorder.PutUint64(frag, uint64(val))
110 } 114 }
111 } 115 }
112 } 116 }
LEFTRIGHT

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