@@ -10,7 +10,6 @@ import (
10
10
"cmd/link/internal/loader"
11
11
"cmd/link/internal/sym"
12
12
"debug/elf"
13
- "log"
14
13
)
15
14
16
15
// Decoding the type.* symbols. This has to be in sync with
@@ -230,15 +229,8 @@ func decodetypeGcmask(ctxt *Link, s loader.Sym) []byte {
230
229
ptrdata := decodetypePtrdata (ctxt .Arch , symData )
231
230
sect := findShlibSection (ctxt , ctxt .loader .SymPkg (s ), addr )
232
231
if sect != nil {
233
- bits := ptrdata / int64 (ctxt .Arch .PtrSize )
234
- r := make ([]byte , (bits + 7 )/ 8 )
235
- // ldshlibsyms avoids closing the ELF file so sect.ReadAt works.
236
- // If we remove this read (and the ones in decodetypeGcprog), we
237
- // can close the file.
238
- _ , err := sect .ReadAt (r , int64 (addr - sect .Addr ))
239
- if err != nil {
240
- log .Fatal (err )
241
- }
232
+ r := make ([]byte , ptrdata / int64 (ctxt .Arch .PtrSize ))
233
+ sect .ReadAt (r , int64 (addr - sect .Addr ))
242
234
return r
243
235
}
244
236
Exitf ("cannot find gcmask for %s" , ctxt .loader .SymName (s ))
@@ -259,15 +251,9 @@ func decodetypeGcprog(ctxt *Link, s loader.Sym) []byte {
259
251
// A gcprog is a 4-byte uint32 indicating length, followed by
260
252
// the actual program.
261
253
progsize := make ([]byte , 4 )
262
- _ , err := sect .ReadAt (progsize , int64 (addr - sect .Addr ))
263
- if err != nil {
264
- log .Fatal (err )
265
- }
254
+ sect .ReadAt (progsize , int64 (addr - sect .Addr ))
266
255
progbytes := make ([]byte , ctxt .Arch .ByteOrder .Uint32 (progsize ))
267
- _ , err = sect .ReadAt (progbytes , int64 (addr - sect .Addr + 4 ))
268
- if err != nil {
269
- log .Fatal (err )
270
- }
256
+ sect .ReadAt (progbytes , int64 (addr - sect .Addr + 4 ))
271
257
return append (progsize , progbytes ... )
272
258
}
273
259
Exitf ("cannot find gcmask for %s" , ctxt .loader .SymName (s ))
@@ -282,7 +268,7 @@ func decodetypeGcprog(ctxt *Link, s loader.Sym) []byte {
282
268
func findShlibSection (ctxt * Link , path string , addr uint64 ) * elf.Section {
283
269
for _ , shlib := range ctxt .Shlibs {
284
270
if shlib .Path == path {
285
- for _ , sect := range shlib .File .Sections [ 1 :] { // skip the NULL section
271
+ for _ , sect := range shlib .File .Sections {
286
272
if sect .Addr <= addr && addr <= sect .Addr + sect .Size {
287
273
return sect
288
274
}
@@ -293,5 +279,8 @@ func findShlibSection(ctxt *Link, path string, addr uint64) *elf.Section {
293
279
}
294
280
295
281
func decodetypeGcprogShlib (ctxt * Link , data []byte ) uint64 {
282
+ if ctxt .Arch .Family == sys .ARM64 {
283
+ return 0
284
+ }
296
285
return decodeInuxi (ctxt .Arch , data [2 * int32 (ctxt .Arch .PtrSize )+ 8 + 1 * int32 (ctxt .Arch .PtrSize ):], ctxt .Arch .PtrSize )
297
286
}
0 commit comments