Commit a1f57598 authored by Michael Hudson-Doyle's avatar Michael Hudson-Doyle Committed by Ian Lance Taylor

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