X7ROOT File Manager
Current Path:
/opt/golang/1.22.0/src/cmd/link/internal/ld
opt
/
golang
/
1.22.0
/
src
/
cmd
/
link
/
internal
/
ld
/
📁
..
📄
ar.go
(7.15 KB)
📄
asmb.go
(5.44 KB)
📄
config.go
(5.64 KB)
📄
data.go
(99.49 KB)
📄
data_test.go
(2.27 KB)
📄
deadcode.go
(18.8 KB)
📄
deadcode_test.go
(1.69 KB)
📄
decodesym.go
(10.12 KB)
📄
dwarf.go
(72.42 KB)
📄
dwarf_test.go
(48.49 KB)
📄
elf.go
(63.2 KB)
📄
elf_test.go
(4.18 KB)
📄
errors.go
(1.89 KB)
📄
execarchive.go
(876 B)
📄
execarchive_noexec.go
(320 B)
📄
fallocate_test.go
(1.69 KB)
📄
go.go
(11.17 KB)
📄
go_test.go
(2.67 KB)
📄
heap.go
(1.89 KB)
📄
heap_test.go
(1.87 KB)
📄
inittask.go
(6.18 KB)
📄
issue33808_test.go
(792 B)
📄
ld.go
(7.98 KB)
📄
ld_test.go
(10.34 KB)
📄
lib.go
(86.45 KB)
📄
link.go
(5.13 KB)
📄
macho.go
(43.68 KB)
📄
macho_combine_dwarf.go
(13.1 KB)
📄
main.go
(15.99 KB)
📄
msync_darwin_libc.go
(307 B)
📄
nooptcgolink_test.go
(733 B)
📄
outbuf.go
(8.05 KB)
📄
outbuf_darwin.go
(1.35 KB)
📄
outbuf_freebsd.go
(515 B)
📄
outbuf_linux.go
(304 B)
📄
outbuf_mmap.go
(1.46 KB)
📄
outbuf_nofallocate.go
(301 B)
📄
outbuf_nommap.go
(741 B)
📄
outbuf_notdarwin.go
(236 B)
📄
outbuf_test.go
(2.21 KB)
📄
outbuf_windows.go
(2.31 KB)
📄
pcln.go
(29.75 KB)
📄
pe.go
(48.82 KB)
📄
seh.go
(2.05 KB)
📄
stackcheck.go
(11.88 KB)
📄
stackcheck_test.go
(2.25 KB)
📄
sym.go
(3.91 KB)
📄
symtab.go
(29.17 KB)
📄
target.go
(3.86 KB)
📁
testdata
📄
typelink.go
(1.87 KB)
📄
util.go
(2.5 KB)
📄
xcoff.go
(51.76 KB)
Editing: data_test.go
// Copyright 2020 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ld import ( "cmd/internal/objabi" "cmd/internal/sys" "cmd/link/internal/loader" "internal/buildcfg" "testing" ) func setUpContext(arch *sys.Arch, iself bool, ht objabi.HeadType, bm, lm string) *Link { ctxt := linknew(arch) ctxt.HeadType = ht er := loader.ErrorReporter{} ctxt.loader = loader.NewLoader(0, &er) ctxt.BuildMode.Set(bm) ctxt.LinkMode.Set(lm) ctxt.IsELF = iself ctxt.mustSetHeadType() ctxt.setArchSyms() return ctxt } // Make sure the addgotsym properly increases the symbols. func TestAddGotSym(t *testing.T) { tests := []struct { arch *sys.Arch ht objabi.HeadType bm, lm string rel string relsize int gotsize int }{ { arch: sys.Arch386, ht: objabi.Hlinux, bm: "pie", lm: "internal", rel: ".rel", relsize: 2 * sys.Arch386.PtrSize, gotsize: sys.Arch386.PtrSize, }, { arch: sys.ArchAMD64, ht: objabi.Hlinux, bm: "pie", lm: "internal", rel: ".rela", relsize: 3 * sys.ArchAMD64.PtrSize, gotsize: sys.ArchAMD64.PtrSize, }, { arch: sys.ArchAMD64, ht: objabi.Hdarwin, bm: "pie", lm: "external", gotsize: sys.ArchAMD64.PtrSize, }, } // Save the architecture as we're going to set it on each test run. origArch := buildcfg.GOARCH defer func() { buildcfg.GOARCH = origArch }() for i, test := range tests { iself := len(test.rel) != 0 buildcfg.GOARCH = test.arch.Name ctxt := setUpContext(test.arch, iself, test.ht, test.bm, test.lm) foo := ctxt.loader.CreateSymForUpdate("foo", 0) ctxt.loader.CreateExtSym("bar", 0) AddGotSym(&ctxt.Target, ctxt.loader, &ctxt.ArchSyms, foo.Sym(), 0) if iself { rel := ctxt.loader.Lookup(test.rel, 0) if rel == 0 { t.Fatalf("[%d] could not find symbol: %q", i, test.rel) } if s := ctxt.loader.SymSize(rel); s != int64(test.relsize) { t.Fatalf("[%d] expected ldr.Size(%q) == %v, got %v", i, test.rel, test.relsize, s) } } if s := ctxt.loader.SymSize(ctxt.loader.Lookup(".got", 0)); s != int64(test.gotsize) { t.Fatalf(`[%d] expected ldr.Size(".got") == %v, got %v`, i, test.gotsize, s) } } }
Upload File
Create Folder