mirror of
https://github.com/golang/go
synced 2024-11-23 22:50:05 -07:00
runtime, cmd/internal/ld: rename themoduledata to firstmoduledata
'themoduledata' doesn't really make sense now we support multiple moduledata objects. Change-Id: I8263045d8f62a42cb523502b37289b0fba054f62 Reviewed-on: https://go-review.googlesource.com/8521 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
a2a8a0468a
commit
a1f57598cc
@ -202,7 +202,7 @@ func container(s *LSym) int {
|
||||
|
||||
var pclntab_zpcln Pcln
|
||||
|
||||
// These variables are used to initialize runtime.themoduledata, see symtab.go:symtab.
|
||||
// These variables are used to initialize runtime.firstmoduledata, see symtab.go:symtab.
|
||||
var pclntabNfunc int32
|
||||
var pclntabFiletabOffset int32
|
||||
var pclntabPclntabOffset int32
|
||||
|
@ -408,7 +408,7 @@ func symtab() {
|
||||
// runtime to use. Any changes here must be matched by changes to
|
||||
// the definition of moduledata in runtime/symtab.go.
|
||||
// This code uses several global variables that are set by pcln.go:pclntab.
|
||||
moduledata := Linklookup(Ctxt, "runtime.themoduledata", 0)
|
||||
moduledata := Linklookup(Ctxt, "runtime.firstmoduledata", 0)
|
||||
moduledata.Type = SNOPTRDATA
|
||||
moduledatasize := moduledata.Size
|
||||
moduledata.Size = 0 // truncate symbol back to 0 bytes to reinitialize
|
||||
|
@ -433,18 +433,18 @@ func finq_callback(fn *funcval, obj unsafe.Pointer, nret uintptr, fint *_type, o
|
||||
func dumproots() {
|
||||
// TODO(mwhudson): dump datamask etc from all objects
|
||||
// data segment
|
||||
dumpbvtypes(&themoduledata.gcdatamask, unsafe.Pointer(themoduledata.data))
|
||||
dumpbvtypes(&firstmoduledata.gcdatamask, unsafe.Pointer(firstmoduledata.data))
|
||||
dumpint(tagData)
|
||||
dumpint(uint64(themoduledata.data))
|
||||
dumpmemrange(unsafe.Pointer(themoduledata.data), themoduledata.edata-themoduledata.data)
|
||||
dumpfields(themoduledata.gcdatamask)
|
||||
dumpint(uint64(firstmoduledata.data))
|
||||
dumpmemrange(unsafe.Pointer(firstmoduledata.data), firstmoduledata.edata-firstmoduledata.data)
|
||||
dumpfields(firstmoduledata.gcdatamask)
|
||||
|
||||
// bss segment
|
||||
dumpbvtypes(&themoduledata.gcbssmask, unsafe.Pointer(themoduledata.bss))
|
||||
dumpbvtypes(&firstmoduledata.gcbssmask, unsafe.Pointer(firstmoduledata.bss))
|
||||
dumpint(tagBSS)
|
||||
dumpint(uint64(themoduledata.bss))
|
||||
dumpmemrange(unsafe.Pointer(themoduledata.bss), themoduledata.ebss-themoduledata.bss)
|
||||
dumpfields(themoduledata.gcbssmask)
|
||||
dumpint(uint64(firstmoduledata.bss))
|
||||
dumpmemrange(unsafe.Pointer(firstmoduledata.bss), firstmoduledata.ebss-firstmoduledata.bss)
|
||||
dumpfields(firstmoduledata.gcbssmask)
|
||||
|
||||
// MSpan.types
|
||||
allspans := h_allspans
|
||||
|
@ -322,7 +322,7 @@ func mallocinit() {
|
||||
// So adjust it upward a little bit ourselves: 1/4 MB to get
|
||||
// away from the running binary image and then round up
|
||||
// to a MB boundary.
|
||||
p = round(themoduledata.end+(1<<18), 1<<20)
|
||||
p = round(firstmoduledata.end+(1<<18), 1<<20)
|
||||
pSize = bitmapSize + spansSize + arenaSize + _PageSize
|
||||
p = uintptr(sysReserve(unsafe.Pointer(p), pSize, &reserved))
|
||||
if p != 0 {
|
||||
|
@ -427,7 +427,7 @@ func wbshadowinit() {
|
||||
|
||||
mheap_.shadow_reserved = reserved
|
||||
|
||||
for datap := &themoduledata; datap != nil; datap = datap.next {
|
||||
for datap := &firstmoduledata; datap != nil; datap = datap.next {
|
||||
start := ^uintptr(0)
|
||||
end := uintptr(0)
|
||||
if start > datap.noptrdata {
|
||||
@ -474,7 +474,7 @@ func wbshadowinit() {
|
||||
// shadowptr returns a pointer to the shadow value for addr.
|
||||
//go:nosplit
|
||||
func shadowptr(addr uintptr) *uintptr {
|
||||
for datap := &themoduledata; datap != nil; datap = datap.next {
|
||||
for datap := &firstmoduledata; datap != nil; datap = datap.next {
|
||||
if datap.data_start <= addr && addr < datap.data_end {
|
||||
return (*uintptr)(unsafe.Pointer(addr + datap.shadow_data))
|
||||
}
|
||||
|
@ -747,7 +747,7 @@ func getgcmask(p unsafe.Pointer, t *_type, mask **byte, len *uintptr) {
|
||||
const typeBitsPerByte = 8 / typeBitsWidth
|
||||
|
||||
// data
|
||||
for datap := &themoduledata; datap != nil; datap = datap.next {
|
||||
for datap := &firstmoduledata; datap != nil; datap = datap.next {
|
||||
if datap.data <= uintptr(p) && uintptr(p) < datap.edata {
|
||||
n := (*ptrtype)(unsafe.Pointer(t)).elem.size
|
||||
*len = n / ptrSize
|
||||
|
@ -116,7 +116,7 @@ func memRound(p uintptr) uintptr {
|
||||
}
|
||||
|
||||
func initBloc() {
|
||||
bloc = memRound(themoduledata.end)
|
||||
bloc = memRound(firstmoduledata.end)
|
||||
}
|
||||
|
||||
func sbrk(n uintptr) unsafe.Pointer {
|
||||
|
@ -289,7 +289,7 @@ func SetFinalizer(obj interface{}, finalizer interface{}) {
|
||||
// The relevant segments are: noptrdata, data, bss, noptrbss.
|
||||
// We cannot assume they are in any order or even contiguous,
|
||||
// due to external linking.
|
||||
for datap := &themoduledata; datap != nil; datap = datap.next {
|
||||
for datap := &firstmoduledata; datap != nil; datap = datap.next {
|
||||
if datap.noptrdata <= uintptr(e.data) && uintptr(e.data) < datap.enoptrdata ||
|
||||
datap.data <= uintptr(e.data) && uintptr(e.data) < datap.edata ||
|
||||
datap.bss <= uintptr(e.data) && uintptr(e.data) < datap.ebss ||
|
||||
|
@ -151,7 +151,7 @@ func gcinit() {
|
||||
|
||||
work.markfor = parforalloc(_MaxGcproc)
|
||||
gcpercent = readgogc()
|
||||
for datap := &themoduledata; datap != nil; datap = datap.next {
|
||||
for datap := &firstmoduledata; datap != nil; datap = datap.next {
|
||||
datap.gcdatamask = unrollglobgcprog((*byte)(unsafe.Pointer(datap.gcdata)), datap.edata-datap.data)
|
||||
datap.gcbssmask = unrollglobgcprog((*byte)(unsafe.Pointer(datap.gcbss)), datap.ebss-datap.bss)
|
||||
}
|
||||
|
@ -60,12 +60,12 @@ func markroot(desc *parfor, i uint32) {
|
||||
// Note: if you add a case here, please also update heapdump.go:dumproots.
|
||||
switch i {
|
||||
case _RootData:
|
||||
for datap := &themoduledata; datap != nil; datap = datap.next {
|
||||
for datap := &firstmoduledata; datap != nil; datap = datap.next {
|
||||
scanblock(datap.data, datap.edata-datap.data, datap.gcdatamask.bytedata, &gcw)
|
||||
}
|
||||
|
||||
case _RootBss:
|
||||
for datap := &themoduledata; datap != nil; datap = datap.next {
|
||||
for datap := &firstmoduledata; datap != nil; datap = datap.next {
|
||||
scanblock(datap.bss, datap.ebss-datap.bss, datap.gcbssmask.bytedata, &gcw)
|
||||
}
|
||||
|
||||
|
@ -2406,7 +2406,7 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) {
|
||||
// If all of the above has failed, account it against abstract "System" or "GC".
|
||||
n = 2
|
||||
// "ExternalCode" is better than "etext".
|
||||
if pc > themoduledata.etext {
|
||||
if pc > firstmoduledata.etext {
|
||||
pc = funcPC(_ExternalCode) + _PCQuantum
|
||||
}
|
||||
stk[0] = pc
|
||||
|
@ -119,29 +119,29 @@ func raceinit() uintptr {
|
||||
// Round data segment to page boundaries, because it's used in mmap().
|
||||
start := ^uintptr(0)
|
||||
end := uintptr(0)
|
||||
if start > themoduledata.noptrdata {
|
||||
start = themoduledata.noptrdata
|
||||
if start > firstmoduledata.noptrdata {
|
||||
start = firstmoduledata.noptrdata
|
||||
}
|
||||
if start > themoduledata.data {
|
||||
start = themoduledata.data
|
||||
if start > firstmoduledata.data {
|
||||
start = firstmoduledata.data
|
||||
}
|
||||
if start > themoduledata.noptrbss {
|
||||
start = themoduledata.noptrbss
|
||||
if start > firstmoduledata.noptrbss {
|
||||
start = firstmoduledata.noptrbss
|
||||
}
|
||||
if start > themoduledata.bss {
|
||||
start = themoduledata.bss
|
||||
if start > firstmoduledata.bss {
|
||||
start = firstmoduledata.bss
|
||||
}
|
||||
if end < themoduledata.enoptrdata {
|
||||
end = themoduledata.enoptrdata
|
||||
if end < firstmoduledata.enoptrdata {
|
||||
end = firstmoduledata.enoptrdata
|
||||
}
|
||||
if end < themoduledata.edata {
|
||||
end = themoduledata.edata
|
||||
if end < firstmoduledata.edata {
|
||||
end = firstmoduledata.edata
|
||||
}
|
||||
if end < themoduledata.enoptrbss {
|
||||
end = themoduledata.enoptrbss
|
||||
if end < firstmoduledata.enoptrbss {
|
||||
end = firstmoduledata.enoptrbss
|
||||
}
|
||||
if end < themoduledata.ebss {
|
||||
end = themoduledata.ebss
|
||||
if end < firstmoduledata.ebss {
|
||||
end = firstmoduledata.ebss
|
||||
}
|
||||
size := round(end-start, _PageSize)
|
||||
racecall(&__tsan_map_shadow, start, size, 0, 0)
|
||||
|
@ -427,8 +427,8 @@ func gomcache() *mcache {
|
||||
//go:linkname reflect_typelinks reflect.typelinks
|
||||
//go:nosplit
|
||||
func reflect_typelinks() [][]*_type {
|
||||
ret := [][]*_type{themoduledata.typelinks}
|
||||
for datap := themoduledata.next; datap != nil; datap = datap.next {
|
||||
ret := [][]*_type{firstmoduledata.typelinks}
|
||||
for datap := firstmoduledata.next; datap != nil; datap = datap.next {
|
||||
ret = append(ret, datap.typelinks)
|
||||
}
|
||||
return ret
|
||||
|
@ -12,7 +12,7 @@ func isgoexception(info *exceptionrecord, r *context) bool {
|
||||
// Only handle exception if executing instructions in Go binary
|
||||
// (not Windows library code).
|
||||
// TODO(mwhudson): needs to loop to support shared libs
|
||||
if r.ip() < themoduledata.text || themoduledata.etext < r.ip() {
|
||||
if r.ip() < firstmoduledata.text || firstmoduledata.etext < r.ip() {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ type moduledata struct {
|
||||
next *moduledata
|
||||
}
|
||||
|
||||
var themoduledata moduledata // linker symbol
|
||||
var firstmoduledata moduledata // linker symbol
|
||||
|
||||
type functab struct {
|
||||
entry uintptr
|
||||
@ -87,34 +87,34 @@ func symtabverify() {
|
||||
// See golang.org/s/go12symtab for header: 0xfffffffb,
|
||||
// two zero bytes, a byte giving the PC quantum,
|
||||
// and a byte giving the pointer width in bytes.
|
||||
pcln := *(**[8]byte)(unsafe.Pointer(&themoduledata.pclntable))
|
||||
pcln32 := *(**[2]uint32)(unsafe.Pointer(&themoduledata.pclntable))
|
||||
pcln := *(**[8]byte)(unsafe.Pointer(&firstmoduledata.pclntable))
|
||||
pcln32 := *(**[2]uint32)(unsafe.Pointer(&firstmoduledata.pclntable))
|
||||
if pcln32[0] != 0xfffffffb || pcln[4] != 0 || pcln[5] != 0 || pcln[6] != _PCQuantum || pcln[7] != ptrSize {
|
||||
println("runtime: function symbol table header:", hex(pcln32[0]), hex(pcln[4]), hex(pcln[5]), hex(pcln[6]), hex(pcln[7]))
|
||||
throw("invalid function symbol table\n")
|
||||
}
|
||||
|
||||
// ftab is lookup table for function by program counter.
|
||||
nftab := len(themoduledata.ftab) - 1
|
||||
nftab := len(firstmoduledata.ftab) - 1
|
||||
for i := 0; i < nftab; i++ {
|
||||
// NOTE: ftab[nftab].entry is legal; it is the address beyond the final function.
|
||||
if themoduledata.ftab[i].entry > themoduledata.ftab[i+1].entry {
|
||||
f1 := (*_func)(unsafe.Pointer(&themoduledata.pclntable[themoduledata.ftab[i].funcoff]))
|
||||
f2 := (*_func)(unsafe.Pointer(&themoduledata.pclntable[themoduledata.ftab[i+1].funcoff]))
|
||||
if firstmoduledata.ftab[i].entry > firstmoduledata.ftab[i+1].entry {
|
||||
f1 := (*_func)(unsafe.Pointer(&firstmoduledata.pclntable[firstmoduledata.ftab[i].funcoff]))
|
||||
f2 := (*_func)(unsafe.Pointer(&firstmoduledata.pclntable[firstmoduledata.ftab[i+1].funcoff]))
|
||||
f2name := "end"
|
||||
if i+1 < nftab {
|
||||
f2name = funcname(f2)
|
||||
}
|
||||
println("function symbol table not sorted by program counter:", hex(themoduledata.ftab[i].entry), funcname(f1), ">", hex(themoduledata.ftab[i+1].entry), f2name)
|
||||
println("function symbol table not sorted by program counter:", hex(firstmoduledata.ftab[i].entry), funcname(f1), ">", hex(firstmoduledata.ftab[i+1].entry), f2name)
|
||||
for j := 0; j <= i; j++ {
|
||||
print("\t", hex(themoduledata.ftab[j].entry), " ", funcname((*_func)(unsafe.Pointer(&themoduledata.pclntable[themoduledata.ftab[j].funcoff]))), "\n")
|
||||
print("\t", hex(firstmoduledata.ftab[j].entry), " ", funcname((*_func)(unsafe.Pointer(&firstmoduledata.pclntable[firstmoduledata.ftab[j].funcoff]))), "\n")
|
||||
}
|
||||
throw("invalid runtime symbol table")
|
||||
}
|
||||
}
|
||||
|
||||
if themoduledata.minpc != themoduledata.ftab[0].entry ||
|
||||
themoduledata.maxpc != themoduledata.ftab[nftab].entry {
|
||||
if firstmoduledata.minpc != firstmoduledata.ftab[0].entry ||
|
||||
firstmoduledata.maxpc != firstmoduledata.ftab[nftab].entry {
|
||||
throw("minpc or maxpc invalid")
|
||||
}
|
||||
}
|
||||
@ -147,7 +147,7 @@ func (f *Func) FileLine(pc uintptr) (file string, line int) {
|
||||
}
|
||||
|
||||
func findmoduledatap(pc uintptr) *moduledata {
|
||||
for datap := &themoduledata; datap != nil; datap = datap.next {
|
||||
for datap := &firstmoduledata; datap != nil; datap = datap.next {
|
||||
if datap.minpc <= pc && pc <= datap.maxpc {
|
||||
return datap
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user