mirror of
https://github.com/golang/go.git
synced 2026-01-29 23:22:06 +03:00
Compare commits
19 Commits
dev.corety
...
go1.24rc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16afa6a740 | ||
|
|
817d7bdc0a | ||
|
|
9118060040 | ||
|
|
077d51909d | ||
|
|
fafd4477f3 | ||
|
|
14bb1e11b9 | ||
|
|
0ca521f9c1 | ||
|
|
2297c34cdf | ||
|
|
c93477b5e5 | ||
|
|
3104b6adbb | ||
|
|
5424f2e200 | ||
|
|
d5c1333eb4 | ||
|
|
a7c4cadce0 | ||
|
|
979c1cfbe8 | ||
|
|
e424d78c3d | ||
|
|
6c25cf1c5f | ||
|
|
e0c76d95ab | ||
|
|
a9922d096f | ||
|
|
26682773ca |
@@ -106,33 +106,34 @@ pkg debug/elf, const VER_FLG_INFO = 4 #63952
|
||||
pkg debug/elf, const VER_FLG_INFO DynamicVersionFlag #63952
|
||||
pkg debug/elf, const VER_FLG_WEAK = 2 #63952
|
||||
pkg debug/elf, const VER_FLG_WEAK DynamicVersionFlag #63952
|
||||
pkg debug/elf, const VerFlagGlobal = 2 #63952
|
||||
pkg debug/elf, const VerFlagGlobal SymbolVersionFlag #63952
|
||||
pkg debug/elf, const VerFlagHidden = 4 #63952
|
||||
pkg debug/elf, const VerFlagHidden SymbolVersionFlag #63952
|
||||
pkg debug/elf, const VerFlagLocal = 1 #63952
|
||||
pkg debug/elf, const VerFlagLocal SymbolVersionFlag #63952
|
||||
pkg debug/elf, const VerFlagNone = 0 #63952
|
||||
pkg debug/elf, const VerFlagNone SymbolVersionFlag #63952
|
||||
pkg debug/elf, const VersionScopeGlobal = 2 #63952
|
||||
pkg debug/elf, const VersionScopeGlobal SymbolVersionScope #63952
|
||||
pkg debug/elf, const VersionScopeHidden = 4 #63952
|
||||
pkg debug/elf, const VersionScopeHidden SymbolVersionScope #63952
|
||||
pkg debug/elf, const VersionScopeLocal = 1 #63952
|
||||
pkg debug/elf, const VersionScopeLocal SymbolVersionScope #63952
|
||||
pkg debug/elf, const VersionScopeNone = 0 #63952
|
||||
pkg debug/elf, const VersionScopeNone SymbolVersionScope #63952
|
||||
pkg debug/elf, const VersionScopeSpecific = 3 #63952
|
||||
pkg debug/elf, const VersionScopeSpecific SymbolVersionScope #63952
|
||||
pkg debug/elf, method (*File) DynamicVersionNeeds() ([]DynamicVersionNeed, error) #63952
|
||||
pkg debug/elf, method (*File) DynamicVersions() ([]DynamicVersion, error) #63952
|
||||
pkg debug/elf, type DynamicVersion struct #63952
|
||||
pkg debug/elf, type DynamicVersion struct, Deps []string #63952
|
||||
pkg debug/elf, type DynamicVersion struct, Flags DynamicVersionFlag #63952
|
||||
pkg debug/elf, type DynamicVersion struct, Name string #63952
|
||||
pkg debug/elf, type DynamicVersion struct, Index uint16 #63952
|
||||
pkg debug/elf, type DynamicVersion struct, Version uint16 #63952
|
||||
pkg debug/elf, type DynamicVersionDep struct #63952
|
||||
pkg debug/elf, type DynamicVersionDep struct, Dep string #63952
|
||||
pkg debug/elf, type DynamicVersionDep struct, Flags DynamicVersionFlag #63952
|
||||
pkg debug/elf, type DynamicVersionDep struct, Other uint16 #63952
|
||||
pkg debug/elf, type DynamicVersionDep struct, Index uint16 #63952
|
||||
pkg debug/elf, type DynamicVersionFlag uint16 #63952
|
||||
pkg debug/elf, type DynamicVersionNeed struct #63952
|
||||
pkg debug/elf, type DynamicVersionNeed struct, Name string #63952
|
||||
pkg debug/elf, type DynamicVersionNeed struct, Needs []DynamicVersionDep #63952
|
||||
pkg debug/elf, type DynamicVersionNeed struct, Version uint16 #63952
|
||||
pkg debug/elf, type Symbol struct, VersionFlags SymbolVersionFlag #63952
|
||||
pkg debug/elf, type Symbol struct, VersionScope SymbolVersionScope #63952
|
||||
pkg debug/elf, type Symbol struct, VersionIndex int16 #63952
|
||||
pkg debug/elf, type SymbolVersionFlag uint8 #63952
|
||||
pkg debug/elf, type SymbolVersionScope uint8 #63952
|
||||
pkg encoding, type BinaryAppender interface { AppendBinary } #62384
|
||||
pkg encoding, type BinaryAppender interface, AppendBinary([]uint8) ([]uint8, error) #62384
|
||||
pkg encoding, type TextAppender interface { AppendText } #62384
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
branch: master
|
||||
branch: release-branch.go1.24
|
||||
parent-branch: master
|
||||
|
||||
@@ -247,7 +247,7 @@ func imag(c ComplexType) FloatType
|
||||
// to the zero value of the respective element type. If the argument
|
||||
// type is a type parameter, the type parameter's type set must
|
||||
// contain only map or slice types, and clear performs the operation
|
||||
// implied by the type argument.
|
||||
// implied by the type argument. If t is nil, clear is a no-op.
|
||||
func clear[T ~[]Type | ~map[Type]Type1](t T)
|
||||
|
||||
// The close built-in function closes a channel, which must be either
|
||||
|
||||
@@ -796,7 +796,7 @@ Instead, the build process generates an object file using dynamic
|
||||
linkage to the desired libraries. The main function is provided by
|
||||
_cgo_main.c:
|
||||
|
||||
int main() { return 0; }
|
||||
int main(int argc, char **argv) { return 0; }
|
||||
void crosscall2(void(*fn)(void*), void *a, int c, uintptr_t ctxt) { }
|
||||
uintptr_t _cgo_wait_runtime_init_done(void) { return 0; }
|
||||
void _cgo_release_context(uintptr_t ctxt) { }
|
||||
|
||||
@@ -59,7 +59,7 @@ func (p *Package) writeDefs() {
|
||||
|
||||
// Write C main file for using gcc to resolve imports.
|
||||
fmt.Fprintf(fm, "#include <stddef.h>\n") // For size_t below.
|
||||
fmt.Fprintf(fm, "int main() { return 0; }\n")
|
||||
fmt.Fprintf(fm, "int main(int argc __attribute__((unused)), char **argv __attribute__((unused))) { return 0; }\n")
|
||||
if *importRuntimeCgo {
|
||||
fmt.Fprintf(fm, "void crosscall2(void(*fn)(void*) __attribute__((unused)), void *a __attribute__((unused)), int c __attribute__((unused)), size_t ctxt __attribute__((unused))) { }\n")
|
||||
fmt.Fprintf(fm, "size_t _cgo_wait_runtime_init_done(void) { return 0; }\n")
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
// This program generates Go code that applies rewrite rules to a Value.
|
||||
// The generated code implements a function of type func (v *Value) bool
|
||||
// which reports whether if did something.
|
||||
// Ideas stolen from Swift: http://www.hpl.hp.com/techreports/Compaq-DEC/WRL-2000-2.html
|
||||
// Ideas stolen from the Swift Java compiler:
|
||||
// https://bitsavers.org/pdf/dec/tech_reports/WRL-2000-2.pdf
|
||||
|
||||
package main
|
||||
|
||||
|
||||
94
src/cmd/go/testdata/script/goauth_userauth.txt
vendored
94
src/cmd/go/testdata/script/goauth_userauth.txt
vendored
@@ -3,13 +3,8 @@
|
||||
|
||||
env GOPROXY=direct
|
||||
env GOSUMDB=off
|
||||
|
||||
# Use a custom authenticator to provide custom credentials
|
||||
mkdir $WORK/bin
|
||||
env PATH=$WORK/bin${:}$PATH
|
||||
cd auth
|
||||
go build -o $WORK/bin/my-auth$GOEXE .
|
||||
cd ..
|
||||
|
||||
# Without credentials, downloading a module from a path that requires HTTPS
|
||||
# basic auth should fail.
|
||||
@@ -21,8 +16,10 @@ stderr '^\tserver response: ACCESS DENIED, buddy$'
|
||||
! go mod tidy
|
||||
stderr '^\tserver response: ACCESS DENIED, buddy$'
|
||||
|
||||
# With credentials from the my-auth binary, it should succeed.
|
||||
env GOAUTH='my-auth'$GOEXE' --arg1 "value with spaces"'
|
||||
# Initial invocation of authenticator is successful.
|
||||
go build -o $WORK/bin/basic$GOEXE scripts/basic.go
|
||||
# With credentials from the binary, it should succeed.
|
||||
env GOAUTH='basic'$GOEXE
|
||||
cp go.mod.orig go.mod
|
||||
go get vcs-test.golang.org/auth/or401
|
||||
# go imports should resolve correctly as well.
|
||||
@@ -30,7 +27,54 @@ go mod tidy
|
||||
go list all
|
||||
stdout vcs-test.golang.org/auth/or401
|
||||
|
||||
-- auth/main.go --
|
||||
# Second invocation of authenticator is successful.
|
||||
go build -o $WORK/bin/reinvocation$GOEXE scripts/reinvocation.go
|
||||
# With credentials from the binary, it should succeed.
|
||||
env GOAUTH='reinvocation'$GOEXE
|
||||
cp go.mod.orig go.mod
|
||||
go get vcs-test.golang.org/auth/or401
|
||||
# go imports should resolve correctly as well.
|
||||
go mod tidy
|
||||
go list all
|
||||
stdout vcs-test.golang.org/auth/or401
|
||||
|
||||
# Authenticator can parse arguments correctly.
|
||||
go build -o $WORK/bin/arguments$GOEXE scripts/arguments.go
|
||||
# With credentials from the binary, it should succeed.
|
||||
env GOAUTH='arguments'$GOEXE' --arg1 "value with spaces"'
|
||||
cp go.mod.orig go.mod
|
||||
go get vcs-test.golang.org/auth/or401
|
||||
# go imports should resolve correctly as well.
|
||||
go mod tidy
|
||||
go list all
|
||||
stdout vcs-test.golang.org/auth/or401
|
||||
|
||||
# Authenticator provides bad credentials.
|
||||
go build -o $WORK/bin/invalid$GOEXE scripts/invalid.go
|
||||
# With credentials from the binary, it should fail.
|
||||
env GOAUTH='invalid'$GOEXE
|
||||
cp go.mod.orig go.mod
|
||||
! go get vcs-test.golang.org/auth/or401
|
||||
stderr '^\tserver response: ACCESS DENIED, buddy$'
|
||||
# go imports should fail as well.
|
||||
! go mod tidy
|
||||
stderr '^\tserver response: ACCESS DENIED, buddy$'
|
||||
|
||||
-- go.mod.orig --
|
||||
module private.example.com
|
||||
-- main.go --
|
||||
package useprivate
|
||||
|
||||
import "vcs-test.golang.org/auth/or401"
|
||||
-- scripts/basic.go --
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Printf("https://vcs-test.golang.org\n\nAuthorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l\n\n")
|
||||
}
|
||||
-- scripts/reinvocation.go --
|
||||
package main
|
||||
|
||||
import(
|
||||
@@ -45,11 +89,7 @@ import(
|
||||
)
|
||||
|
||||
func main() {
|
||||
arg1 := flag.String("arg1", "", "")
|
||||
flag.Parse()
|
||||
if *arg1 != "value with spaces" {
|
||||
log.Fatal("argument with spaces does not work")
|
||||
}
|
||||
// wait for re-invocation
|
||||
if !strings.HasPrefix(flag.Arg(0), "https://vcs-test.golang.org") {
|
||||
return
|
||||
@@ -68,12 +108,28 @@ func main() {
|
||||
}
|
||||
fmt.Printf("https://vcs-test.golang.org\n\nAuthorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l\n\n")
|
||||
}
|
||||
-- scripts/arguments.go --
|
||||
package main
|
||||
|
||||
-- auth/go.mod --
|
||||
module my-auth
|
||||
-- go.mod.orig --
|
||||
module private.example.com
|
||||
-- main.go --
|
||||
package useprivate
|
||||
import(
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
)
|
||||
|
||||
import "vcs-test.golang.org/auth/or401"
|
||||
func main() {
|
||||
arg1 := flag.String("arg1", "", "")
|
||||
flag.Parse()
|
||||
if *arg1 != "value with spaces" {
|
||||
log.Fatal("argument with spaces does not work")
|
||||
}
|
||||
fmt.Printf("https://vcs-test.golang.org\n\nAuthorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l\n\n")
|
||||
}
|
||||
-- scripts/invalid.go --
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Printf("https://vcs-test.golang.org\n\nAuthorization: Basic invalid\n\n")
|
||||
}
|
||||
@@ -2,13 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package objfile
|
||||
// Package disasm provides disassembly routines.
|
||||
//
|
||||
// It is broken out from cmd/internal/objfile so tools that don't need
|
||||
// disassembling don't need to depend on x/arch disassembler code.
|
||||
package disasm
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"container/list"
|
||||
"debug/gosym"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -19,6 +22,7 @@ import (
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"cmd/internal/objfile"
|
||||
"cmd/internal/src"
|
||||
|
||||
"golang.org/x/arch/arm/armasm"
|
||||
@@ -32,8 +36,8 @@ import (
|
||||
|
||||
// Disasm is a disassembler for a given File.
|
||||
type Disasm struct {
|
||||
syms []Sym //symbols in file, sorted by address
|
||||
pcln Liner // pcln table
|
||||
syms []objfile.Sym // symbols in file, sorted by address
|
||||
pcln objfile.Liner // pcln table
|
||||
text []byte // bytes of text segment (actual instructions)
|
||||
textStart uint64 // start PC of text
|
||||
textEnd uint64 // end PC of text
|
||||
@@ -42,8 +46,12 @@ type Disasm struct {
|
||||
byteOrder binary.ByteOrder // byte order for goarch
|
||||
}
|
||||
|
||||
// Disasm returns a disassembler for the file f.
|
||||
func (e *Entry) Disasm() (*Disasm, error) {
|
||||
// DisasmForFile returns a disassembler for the file f.
|
||||
func DisasmForFile(f *objfile.File) (*Disasm, error) {
|
||||
return disasmForEntry(f.Entries()[0])
|
||||
}
|
||||
|
||||
func disasmForEntry(e *objfile.Entry) (*Disasm, error) {
|
||||
syms, err := e.Symbols()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -269,7 +277,7 @@ func (d *Disasm) Print(w io.Writer, filter *regexp.Regexp, start, end uint64, pr
|
||||
}
|
||||
|
||||
// Decode disassembles the text segment range [start, end), calling f for each instruction.
|
||||
func (d *Disasm) Decode(start, end uint64, relocs []Reloc, gnuAsm bool, f func(pc, size uint64, file string, line int, text string)) {
|
||||
func (d *Disasm) Decode(start, end uint64, relocs []objfile.Reloc, gnuAsm bool, f func(pc, size uint64, file string, line int, text string)) {
|
||||
if start < d.textStart {
|
||||
start = d.textStart
|
||||
}
|
||||
@@ -452,9 +460,3 @@ var byteOrders = map[string]binary.ByteOrder{
|
||||
"riscv64": binary.LittleEndian,
|
||||
"s390x": binary.BigEndian,
|
||||
}
|
||||
|
||||
type Liner interface {
|
||||
// Given a pc, returns the corresponding file, line, and function data.
|
||||
// If unknown, returns "",0,nil.
|
||||
PCToLine(uint64) (string, int, *gosym.Func)
|
||||
}
|
||||
@@ -119,10 +119,6 @@ func (f *File) DWARF() (*dwarf.Data, error) {
|
||||
return f.entries[0].DWARF()
|
||||
}
|
||||
|
||||
func (f *File) Disasm() (*Disasm, error) {
|
||||
return f.entries[0].Disasm()
|
||||
}
|
||||
|
||||
func (e *Entry) Name() string {
|
||||
return e.name
|
||||
}
|
||||
@@ -181,3 +177,9 @@ func (e *Entry) LoadAddress() (uint64, error) {
|
||||
func (e *Entry) DWARF() (*dwarf.Data, error) {
|
||||
return e.raw.dwarf()
|
||||
}
|
||||
|
||||
type Liner interface {
|
||||
// Given a pc, returns the corresponding file, line, and function data.
|
||||
// If unknown, returns "",0,nil.
|
||||
PCToLine(uint64) (string, int, *gosym.Func)
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"cmd/internal/disasm"
|
||||
"cmd/internal/objfile"
|
||||
"cmd/internal/telemetry/counter"
|
||||
)
|
||||
@@ -82,7 +83,7 @@ func main() {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
dis, err := f.Disasm()
|
||||
dis, err := disasm.DisasmForFile(f)
|
||||
if err != nil {
|
||||
log.Fatalf("disassemble %s: %v", flag.Arg(0), err)
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"cmd/internal/disasm"
|
||||
"cmd/internal/objfile"
|
||||
"cmd/internal/telemetry/counter"
|
||||
|
||||
@@ -162,7 +163,7 @@ func adjustURL(source string, duration, timeout time.Duration) (string, time.Dur
|
||||
// (instead of invoking GNU binutils).
|
||||
type objTool struct {
|
||||
mu sync.Mutex
|
||||
disasmCache map[string]*objfile.Disasm
|
||||
disasmCache map[string]*disasm.Disasm
|
||||
}
|
||||
|
||||
func (*objTool) Open(name string, start, limit, offset uint64, relocationSymbol string) (driver.ObjFile, error) {
|
||||
@@ -202,11 +203,11 @@ func (t *objTool) Disasm(file string, start, end uint64, intelSyntax bool) ([]dr
|
||||
return asm, nil
|
||||
}
|
||||
|
||||
func (t *objTool) cachedDisasm(file string) (*objfile.Disasm, error) {
|
||||
func (t *objTool) cachedDisasm(file string) (*disasm.Disasm, error) {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
if t.disasmCache == nil {
|
||||
t.disasmCache = make(map[string]*objfile.Disasm)
|
||||
t.disasmCache = make(map[string]*disasm.Disasm)
|
||||
}
|
||||
d := t.disasmCache[file]
|
||||
if d != nil {
|
||||
@@ -216,7 +217,7 @@ func (t *objTool) cachedDisasm(file string) (*objfile.Disasm, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
d, err = f.Disasm()
|
||||
d, err = disasm.DisasmForFile(f)
|
||||
f.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"bytes"
|
||||
"crypto/internal/boring"
|
||||
"crypto/internal/fips140/ecdh"
|
||||
"crypto/internal/fips140only"
|
||||
"errors"
|
||||
"io"
|
||||
)
|
||||
@@ -43,6 +44,10 @@ func (c *nistCurve) GenerateKey(rand io.Reader) (*PrivateKey, error) {
|
||||
return k, nil
|
||||
}
|
||||
|
||||
if fips140only.Enabled && !fips140only.ApprovedRandomReader(rand) {
|
||||
return nil, errors.New("crypto/ecdh: only crypto/rand.Reader is allowed in FIPS 140-only mode")
|
||||
}
|
||||
|
||||
privateKey, err := c.generate(rand)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"crypto/internal/boring"
|
||||
"crypto/internal/boring/bbig"
|
||||
"crypto/internal/fips140/ecdsa"
|
||||
"crypto/internal/fips140only"
|
||||
"crypto/internal/randutil"
|
||||
"crypto/sha512"
|
||||
"crypto/subtle"
|
||||
@@ -182,6 +183,9 @@ func GenerateKey(c elliptic.Curve, rand io.Reader) (*PrivateKey, error) {
|
||||
}
|
||||
|
||||
func generateFIPS[P ecdsa.Point[P]](curve elliptic.Curve, c *ecdsa.Curve[P], rand io.Reader) (*PrivateKey, error) {
|
||||
if fips140only.Enabled && fips140only.ApprovedRandomReader(rand) {
|
||||
return nil, errors.New("crypto/ecdsa: only crypto/rand.Reader is allowed in FIPS 140-only mode")
|
||||
}
|
||||
privateKey, err := ecdsa.GenerateKey(c, rand)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -228,6 +232,9 @@ func SignASN1(rand io.Reader, priv *PrivateKey, hash []byte) ([]byte, error) {
|
||||
}
|
||||
|
||||
func signFIPS[P ecdsa.Point[P]](c *ecdsa.Curve[P], priv *PrivateKey, rand io.Reader, hash []byte) ([]byte, error) {
|
||||
if fips140only.Enabled && !fips140only.ApprovedRandomReader(rand) {
|
||||
return nil, errors.New("crypto/ecdsa: only crypto/rand.Reader is allowed in FIPS 140-only mode")
|
||||
}
|
||||
// privateKeyToFIPS is very slow in FIPS mode because it performs a
|
||||
// Sign+Verify cycle per FIPS 140-3 IG 10.3.A. We should find a way to cache
|
||||
// it or attach it to the PrivateKey.
|
||||
|
||||
@@ -7,7 +7,9 @@ package drbg
|
||||
import (
|
||||
"crypto/internal/entropy"
|
||||
"crypto/internal/fips140"
|
||||
"crypto/internal/randutil"
|
||||
"crypto/internal/sysrand"
|
||||
"io"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -56,3 +58,38 @@ func Read(b []byte) {
|
||||
b = b[size:]
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultReader is a sentinel type, embedded in the default
|
||||
// [crypto/rand.Reader], used to recognize it when passed to
|
||||
// APIs that accept a rand io.Reader.
|
||||
type DefaultReader interface{ defaultReader() }
|
||||
|
||||
// ReadWithReader uses Reader to fill b with cryptographically secure random
|
||||
// bytes. It is intended for use in APIs that expose a rand io.Reader.
|
||||
//
|
||||
// If Reader is not the default Reader from crypto/rand,
|
||||
// [randutil.MaybeReadByte] and [fips140.RecordNonApproved] are called.
|
||||
func ReadWithReader(r io.Reader, b []byte) error {
|
||||
if _, ok := r.(DefaultReader); ok {
|
||||
Read(b)
|
||||
return nil
|
||||
}
|
||||
|
||||
fips140.RecordNonApproved()
|
||||
randutil.MaybeReadByte(r)
|
||||
_, err := io.ReadFull(r, b)
|
||||
return err
|
||||
}
|
||||
|
||||
// ReadWithReaderDeterministic is like ReadWithReader, but it doesn't call
|
||||
// [randutil.MaybeReadByte] on non-default Readers.
|
||||
func ReadWithReaderDeterministic(r io.Reader, b []byte) error {
|
||||
if _, ok := r.(DefaultReader); ok {
|
||||
Read(b)
|
||||
return nil
|
||||
}
|
||||
|
||||
fips140.RecordNonApproved()
|
||||
_, err := io.ReadFull(r, b)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"crypto/internal/fips140/drbg"
|
||||
"crypto/internal/fips140/nistec"
|
||||
"crypto/internal/fips140deps/byteorder"
|
||||
"crypto/internal/randutil"
|
||||
"errors"
|
||||
"io"
|
||||
"math/bits"
|
||||
@@ -137,8 +136,6 @@ var p521Order = []byte{0x01, 0xff,
|
||||
}
|
||||
|
||||
// GenerateKey generates a new ECDSA private key pair for the specified curve.
|
||||
//
|
||||
// In FIPS mode, rand is ignored.
|
||||
func GenerateKey[P Point[P]](c *Curve[P], rand io.Reader) (*PrivateKey, error) {
|
||||
fips140.RecordApproved()
|
||||
// This procedure is equivalent to Key Pair Generation by Testing
|
||||
@@ -146,18 +143,13 @@ func GenerateKey[P Point[P]](c *Curve[P], rand io.Reader) (*PrivateKey, error) {
|
||||
|
||||
for {
|
||||
key := make([]byte, len(c.N))
|
||||
if fips140.Enabled {
|
||||
drbg.Read(key)
|
||||
} else {
|
||||
randutil.MaybeReadByte(rand)
|
||||
if _, err := io.ReadFull(rand, key); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// In tests, rand will return all zeros and NewPrivateKey will reject
|
||||
// the zero key as it generates the identity as a public key. This also
|
||||
// makes this function consistent with crypto/elliptic.GenerateKey.
|
||||
key[1] ^= 0x42
|
||||
if err := drbg.ReadWithReader(rand, key); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// In tests, rand will return all zeros and NewPrivateKey will reject
|
||||
// the zero key as it generates the identity as a public key. This also
|
||||
// makes this function consistent with crypto/elliptic.GenerateKey.
|
||||
key[1] ^= 0x42
|
||||
|
||||
// Mask off any excess bits if the size of the underlying field is not a
|
||||
// whole number of bytes, which is only the case for P-521.
|
||||
|
||||
@@ -54,7 +54,8 @@ func testHash() []byte {
|
||||
func fipsPCT[P Point[P]](c *Curve[P], k *PrivateKey) error {
|
||||
return fips140.PCT("ECDSA PCT", func() error {
|
||||
hash := testHash()
|
||||
sig, err := Sign(c, sha512.New, k, nil, hash)
|
||||
drbg := newDRBG(sha512.New, k.d, bits2octets(P256(), hash), nil)
|
||||
sig, err := sign(c, k, drbg, hash)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"crypto/internal/fips140/bigmod"
|
||||
"crypto/internal/fips140/drbg"
|
||||
"crypto/internal/fips140/nistec"
|
||||
"crypto/internal/randutil"
|
||||
"errors"
|
||||
"io"
|
||||
"sync"
|
||||
@@ -187,20 +186,11 @@ func NewPublicKey[P Point[P]](c *Curve[P], Q []byte) (*PublicKey, error) {
|
||||
}
|
||||
|
||||
// GenerateKey generates a new ECDSA private key pair for the specified curve.
|
||||
//
|
||||
// In FIPS mode, rand is ignored.
|
||||
func GenerateKey[P Point[P]](c *Curve[P], rand io.Reader) (*PrivateKey, error) {
|
||||
fips140.RecordApproved()
|
||||
|
||||
k, Q, err := randomPoint(c, func(b []byte) error {
|
||||
if fips140.Enabled {
|
||||
drbg.Read(b)
|
||||
return nil
|
||||
} else {
|
||||
randutil.MaybeReadByte(rand)
|
||||
_, err := io.ReadFull(rand, b)
|
||||
return err
|
||||
}
|
||||
return drbg.ReadWithReader(rand, b)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -281,8 +271,6 @@ type Signature struct {
|
||||
// the hash function H) using the private key, priv. If the hash is longer than
|
||||
// the bit-length of the private key's curve order, the hash will be truncated
|
||||
// to that length.
|
||||
//
|
||||
// The signature is randomized. If FIPS mode is enabled, rand is ignored.
|
||||
func Sign[P Point[P], H fips140.Hash](c *Curve[P], h func() H, priv *PrivateKey, rand io.Reader, hash []byte) (*Signature, error) {
|
||||
if priv.pub.curve != c.curve {
|
||||
return nil, errors.New("ecdsa: private key does not match curve")
|
||||
@@ -296,13 +284,8 @@ func Sign[P Point[P], H fips140.Hash](c *Curve[P], h func() H, priv *PrivateKey,
|
||||
// advantage of closely resembling Deterministic ECDSA.
|
||||
|
||||
Z := make([]byte, len(priv.d))
|
||||
if fips140.Enabled {
|
||||
drbg.Read(Z)
|
||||
} else {
|
||||
randutil.MaybeReadByte(rand)
|
||||
if _, err := io.ReadFull(rand, Z); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := drbg.ReadWithReader(rand, Z); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// See https://github.com/cfrg/draft-irtf-cfrg-det-sigs-with-noise/issues/6
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"crypto/internal/fips140/edwards25519"
|
||||
"crypto/internal/fips140/sha512"
|
||||
"errors"
|
||||
"io"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@@ -61,24 +60,14 @@ func (pub *PublicKey) Bytes() []byte {
|
||||
}
|
||||
|
||||
// GenerateKey generates a new Ed25519 private key pair.
|
||||
//
|
||||
// In FIPS mode, rand is ignored. Otherwise, the output of this function is
|
||||
// deterministic, and equivalent to reading 32 bytes from rand, and passing them
|
||||
// to [NewKeyFromSeed].
|
||||
func GenerateKey(rand io.Reader) (*PrivateKey, error) {
|
||||
func GenerateKey() (*PrivateKey, error) {
|
||||
priv := &PrivateKey{}
|
||||
return generateKey(priv, rand)
|
||||
return generateKey(priv)
|
||||
}
|
||||
|
||||
func generateKey(priv *PrivateKey, rand io.Reader) (*PrivateKey, error) {
|
||||
func generateKey(priv *PrivateKey) (*PrivateKey, error) {
|
||||
fips140.RecordApproved()
|
||||
if fips140.Enabled {
|
||||
drbg.Read(priv.seed[:])
|
||||
} else {
|
||||
if _, err := io.ReadFull(rand, priv.seed[:]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
drbg.Read(priv.seed[:])
|
||||
precomputePrivateKey(priv)
|
||||
if err := fipsPCT(priv); err != nil {
|
||||
// This clearly can't happen, but FIPS 140-3 requires that we check.
|
||||
|
||||
@@ -8,15 +8,12 @@ import (
|
||||
"crypto/internal/fips140"
|
||||
"crypto/internal/fips140/bigmod"
|
||||
"crypto/internal/fips140/drbg"
|
||||
"crypto/internal/randutil"
|
||||
"errors"
|
||||
"io"
|
||||
)
|
||||
|
||||
// GenerateKey generates a new RSA key pair of the given bit size.
|
||||
// bits must be at least 128.
|
||||
//
|
||||
// When operating in FIPS mode, rand is ignored.
|
||||
func GenerateKey(rand io.Reader, bits int) (*PrivateKey, error) {
|
||||
if bits < 128 {
|
||||
return nil, errors.New("rsa: key too small")
|
||||
@@ -94,7 +91,7 @@ func GenerateKey(rand io.Reader, bits int) (*PrivateKey, error) {
|
||||
}
|
||||
|
||||
// randomPrime returns a random prime number of the given bit size following
|
||||
// the process in FIPS 186-5, Appendix A.1.3. rand is ignored in FIPS mode.
|
||||
// the process in FIPS 186-5, Appendix A.1.3.
|
||||
func randomPrime(rand io.Reader, bits int) ([]byte, error) {
|
||||
if bits < 64 {
|
||||
return nil, errors.New("rsa: prime size must be at least 32-bit")
|
||||
@@ -102,13 +99,8 @@ func randomPrime(rand io.Reader, bits int) ([]byte, error) {
|
||||
|
||||
b := make([]byte, (bits+7)/8)
|
||||
for {
|
||||
if fips140.Enabled {
|
||||
drbg.Read(b)
|
||||
} else {
|
||||
randutil.MaybeReadByte(rand)
|
||||
if _, err := io.ReadFull(rand, b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := drbg.ReadWithReader(rand, b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if excess := len(b)*8 - bits; excess != 0 {
|
||||
b[0] >>= excess
|
||||
|
||||
@@ -264,8 +264,6 @@ func PSSMaxSaltLength(pub *PublicKey, hash fips140.Hash) (int, error) {
|
||||
}
|
||||
|
||||
// SignPSS calculates the signature of hashed using RSASSA-PSS.
|
||||
//
|
||||
// In FIPS mode, rand is ignored and can be nil.
|
||||
func SignPSS(rand io.Reader, priv *PrivateKey, hash fips140.Hash, hashed []byte, saltLength int) ([]byte, error) {
|
||||
fipsSelfTest()
|
||||
fips140.RecordApproved()
|
||||
@@ -286,12 +284,8 @@ func SignPSS(rand io.Reader, priv *PrivateKey, hash fips140.Hash, hashed []byte,
|
||||
fips140.RecordNonApproved()
|
||||
}
|
||||
salt := make([]byte, saltLength)
|
||||
if fips140.Enabled {
|
||||
drbg.Read(salt)
|
||||
} else {
|
||||
if _, err := io.ReadFull(rand, salt); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := drbg.ReadWithReaderDeterministic(rand, salt); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
emBits := priv.pub.N.BitLen() - 1
|
||||
@@ -374,8 +368,6 @@ func checkApprovedHash(hash fips140.Hash) {
|
||||
}
|
||||
|
||||
// EncryptOAEP encrypts the given message with RSAES-OAEP.
|
||||
//
|
||||
// In FIPS mode, random is ignored and can be nil.
|
||||
func EncryptOAEP(hash, mgfHash fips140.Hash, random io.Reader, pub *PublicKey, msg []byte, label []byte) ([]byte, error) {
|
||||
// Note that while we don't commit to deterministic execution with respect
|
||||
// to the random stream, we also don't apply MaybeReadByte, so per Hyrum's
|
||||
@@ -408,13 +400,8 @@ func EncryptOAEP(hash, mgfHash fips140.Hash, random io.Reader, pub *PublicKey, m
|
||||
db[len(db)-len(msg)-1] = 1
|
||||
copy(db[len(db)-len(msg):], msg)
|
||||
|
||||
if fips140.Enabled {
|
||||
drbg.Read(seed)
|
||||
} else {
|
||||
_, err := io.ReadFull(random, seed)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := drbg.ReadWithReaderDeterministic(random, seed); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mgf1XOR(db, mgfHash, seed)
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
package fips140only
|
||||
|
||||
import (
|
||||
"crypto/internal/fips140/drbg"
|
||||
"crypto/internal/fips140/sha256"
|
||||
"crypto/internal/fips140/sha3"
|
||||
"crypto/internal/fips140/sha512"
|
||||
"hash"
|
||||
"internal/godebug"
|
||||
"io"
|
||||
)
|
||||
|
||||
// Enabled reports whether FIPS 140-only mode is enabled, in which non-approved
|
||||
@@ -24,3 +26,8 @@ func ApprovedHash(h hash.Hash) bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func ApprovedRandomReader(r io.Reader) bool {
|
||||
_, ok := r.(drbg.DefaultReader)
|
||||
return ok
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestConditionals(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ecdsa.SignDeterministic(ecdsa.P256(), sha256.New, kDSA, make([]byte, 32))
|
||||
k25519, err := ed25519.GenerateKey(rand.Reader)
|
||||
k25519, err := ed25519.GenerateKey()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,9 @@ func init() {
|
||||
Reader = &reader{}
|
||||
}
|
||||
|
||||
type reader struct{}
|
||||
type reader struct {
|
||||
drbg.DefaultReader
|
||||
}
|
||||
|
||||
func (r *reader) Read(b []byte) (n int, err error) {
|
||||
boring.Unreachable()
|
||||
|
||||
@@ -17,6 +17,9 @@ import (
|
||||
const (
|
||||
// PSSSaltLengthAuto causes the salt in a PSS signature to be as large
|
||||
// as possible when signing, and to be auto-detected when verifying.
|
||||
//
|
||||
// When signing in FIPS 140-3 mode, the salt length is capped at the length
|
||||
// of the hash function used in the signature.
|
||||
PSSSaltLengthAuto = 0
|
||||
// PSSSaltLengthEqualsHash causes the salt length to equal the length
|
||||
// of the hash used in the signature.
|
||||
@@ -67,6 +70,9 @@ func SignPSS(rand io.Reader, priv *PrivateKey, hash crypto.Hash, digest []byte,
|
||||
if fips140only.Enabled && !fips140only.ApprovedHash(hash.New()) {
|
||||
return nil, errors.New("crypto/rsa: use of hash functions other than SHA-2 or SHA-3 is not allowed in FIPS 140-only mode")
|
||||
}
|
||||
if fips140only.Enabled && !fips140only.ApprovedRandomReader(rand) {
|
||||
return nil, errors.New("crypto/rsa: only crypto/rand.Reader is allowed in FIPS 140-only mode")
|
||||
}
|
||||
|
||||
if opts != nil && opts.Hash != 0 {
|
||||
hash = opts.Hash
|
||||
@@ -188,6 +194,9 @@ func EncryptOAEP(hash hash.Hash, random io.Reader, pub *PublicKey, msg []byte, l
|
||||
if fips140only.Enabled && !fips140only.ApprovedHash(hash) {
|
||||
return nil, errors.New("crypto/rsa: use of hash functions other than SHA-2 or SHA-3 is not allowed in FIPS 140-only mode")
|
||||
}
|
||||
if fips140only.Enabled && !fips140only.ApprovedRandomReader(random) {
|
||||
return nil, errors.New("crypto/rsa: only crypto/rand.Reader is allowed in FIPS 140-only mode")
|
||||
}
|
||||
|
||||
defer hash.Reset()
|
||||
|
||||
|
||||
@@ -322,6 +322,9 @@ func GenerateKey(random io.Reader, bits int) (*PrivateKey, error) {
|
||||
if fips140only.Enabled && bits%2 == 1 {
|
||||
return nil, errors.New("crypto/rsa: use of keys with odd size is not allowed in FIPS 140-only mode")
|
||||
}
|
||||
if fips140only.Enabled && !fips140only.ApprovedRandomReader(random) {
|
||||
return nil, errors.New("crypto/rsa: only crypto/rand.Reader is allowed in FIPS 140-only mode")
|
||||
}
|
||||
|
||||
k, err := rsa.GenerateKey(random, bits)
|
||||
if err != nil {
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"crypto"
|
||||
"crypto/internal/boring"
|
||||
"crypto/internal/cryptotest"
|
||||
"crypto/internal/fips140"
|
||||
"crypto/rand"
|
||||
. "crypto/rsa"
|
||||
"crypto/sha1"
|
||||
@@ -782,9 +781,6 @@ type testEncryptOAEPStruct struct {
|
||||
}
|
||||
|
||||
func TestEncryptOAEP(t *testing.T) {
|
||||
if fips140.Enabled {
|
||||
t.Skip("FIPS mode overrides the deterministic random source")
|
||||
}
|
||||
sha1 := sha1.New()
|
||||
n := new(big.Int)
|
||||
for i, test := range testEncryptOAEPData {
|
||||
|
||||
@@ -209,10 +209,22 @@ type Symbol struct {
|
||||
Name string
|
||||
Info, Other byte
|
||||
|
||||
// These fields are used for symbol versioning
|
||||
// and are present only for the dynamic symbol table.
|
||||
// VersionScope describes the version in which the symbol is defined.
|
||||
// This is only set for the dynamic symbol table.
|
||||
// When no symbol versioning information is available,
|
||||
// this is VersionScopeNone.
|
||||
VersionScope SymbolVersionScope
|
||||
// VersionIndex is the version index.
|
||||
// This is only set if VersionScope is VersionScopeSpecific or
|
||||
// VersionScopeHidden. This is only set for the dynamic symbol table.
|
||||
// This index will match either [DynamicVersion.Index]
|
||||
// in the slice returned by [File.DynamicVersions],
|
||||
// or [DynamicVersiondep.Index] in the Needs field
|
||||
// of the elements of the slice returned by [File.DynamicVersionNeeds].
|
||||
// In general, a defined symbol will have an index referring
|
||||
// to DynamicVersions, and an undefined symbol will have an index
|
||||
// referring to some version in DynamicVersionNeeds.
|
||||
VersionIndex int16
|
||||
VersionFlags SymbolVersionFlag
|
||||
|
||||
Section SectionIndex
|
||||
Value, Size uint64
|
||||
@@ -1455,9 +1467,13 @@ func (f *File) DynamicSymbols() ([]Symbol, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if f.gnuVersionInit(str) {
|
||||
hasVersions, err := f.gnuVersionInit(str)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if hasVersions {
|
||||
for i := range sym {
|
||||
sym[i].VersionIndex, sym[i].Version, sym[i].Library, sym[i].VersionFlags = f.gnuVersion(i)
|
||||
sym[i].VersionIndex, sym[i].Version, sym[i].Library, sym[i].VersionScope = f.gnuVersion(i)
|
||||
}
|
||||
}
|
||||
return sym, nil
|
||||
@@ -1478,7 +1494,9 @@ func (f *File) ImportedSymbols() ([]ImportedSymbol, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
f.gnuVersionInit(str)
|
||||
if _, err := f.gnuVersionInit(str); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var all []ImportedSymbol
|
||||
for i, s := range sym {
|
||||
if ST_BIND(s.Info) == STB_GLOBAL && s.Section == SHN_UNDEF {
|
||||
@@ -1490,46 +1508,57 @@ func (f *File) ImportedSymbols() ([]ImportedSymbol, error) {
|
||||
return all, nil
|
||||
}
|
||||
|
||||
type SymbolVersionFlag byte
|
||||
// SymbolVersionScope describes the version in which a [Symbol] is defined.
|
||||
// This is only used for the dynamic symbol table.
|
||||
type SymbolVersionScope byte
|
||||
|
||||
const (
|
||||
VerFlagNone SymbolVersionFlag = 0x0 // No flags.
|
||||
VerFlagLocal SymbolVersionFlag = 0x1 // Symbol has local scope.
|
||||
VerFlagGlobal SymbolVersionFlag = 0x2 // Symbol has global scope.
|
||||
VerFlagHidden SymbolVersionFlag = 0x4 // Symbol is hidden.
|
||||
VersionScopeNone SymbolVersionScope = iota // no symbol version available
|
||||
VersionScopeLocal // symbol has local scope
|
||||
VersionScopeGlobal // symbol has global scope and is in the base version
|
||||
VersionScopeSpecific // symbol has global scope and is in the version given by VersionIndex
|
||||
VersionScopeHidden // symbol is in the version given by VersionIndex, and is hidden
|
||||
)
|
||||
|
||||
// DynamicVersion is a version defined by a dynamic object.
|
||||
// This describes entries in the ELF SHT_GNU_verdef section.
|
||||
// We assume that the vd_version field is 1.
|
||||
// Note that the name of the version appears here;
|
||||
// it is not in the first Deps entry as it is in the ELF file.
|
||||
type DynamicVersion struct {
|
||||
Version uint16 // Version of data structure.
|
||||
Flags DynamicVersionFlag
|
||||
Index uint16 // Version index.
|
||||
Deps []string // Dependencies.
|
||||
Name string // Name of version defined by this index.
|
||||
Index uint16 // Version index.
|
||||
Flags DynamicVersionFlag
|
||||
Deps []string // Names of versions that this version depends upon.
|
||||
}
|
||||
|
||||
// DynamicVersionNeed describes a shared library needed by a dynamic object,
|
||||
// with a list of the versions needed from that shared library.
|
||||
// This describes entries in the ELF SHT_GNU_verneed section.
|
||||
// We assume that the vn_version field is 1.
|
||||
type DynamicVersionNeed struct {
|
||||
Version uint16 // Version of data structure.
|
||||
Name string // Shared library name.
|
||||
Needs []DynamicVersionDep // Dependencies.
|
||||
Name string // Shared library name.
|
||||
Needs []DynamicVersionDep // Dependencies.
|
||||
}
|
||||
|
||||
// DynamicVersionDep is a version needed from some shared library.
|
||||
type DynamicVersionDep struct {
|
||||
Flags DynamicVersionFlag
|
||||
Other uint16 // Version index.
|
||||
Index uint16 // Version index.
|
||||
Dep string // Name of required version.
|
||||
}
|
||||
|
||||
// dynamicVersions returns version information for a dynamic object.
|
||||
func (f *File) dynamicVersions(str []byte) bool {
|
||||
func (f *File) dynamicVersions(str []byte) error {
|
||||
if f.dynVers != nil {
|
||||
// Already initialized.
|
||||
return true
|
||||
return nil
|
||||
}
|
||||
|
||||
// Accumulate verdef information.
|
||||
vd := f.SectionByType(SHT_GNU_VERDEF)
|
||||
if vd == nil {
|
||||
return false
|
||||
return nil
|
||||
}
|
||||
d, _ := vd.Data()
|
||||
|
||||
@@ -1540,12 +1569,20 @@ func (f *File) dynamicVersions(str []byte) bool {
|
||||
break
|
||||
}
|
||||
version := f.ByteOrder.Uint16(d[i : i+2])
|
||||
if version != 1 {
|
||||
return &FormatError{int64(vd.Offset + uint64(i)), "unexpected dynamic version", version}
|
||||
}
|
||||
flags := DynamicVersionFlag(f.ByteOrder.Uint16(d[i+2 : i+4]))
|
||||
ndx := f.ByteOrder.Uint16(d[i+4 : i+6])
|
||||
cnt := f.ByteOrder.Uint16(d[i+6 : i+8])
|
||||
aux := f.ByteOrder.Uint32(d[i+12 : i+16])
|
||||
next := f.ByteOrder.Uint32(d[i+16 : i+20])
|
||||
|
||||
if cnt == 0 {
|
||||
return &FormatError{int64(vd.Offset + uint64(i)), "dynamic version has no name", nil}
|
||||
}
|
||||
|
||||
var name string
|
||||
var depName string
|
||||
var deps []string
|
||||
j := i + int(aux)
|
||||
@@ -1557,16 +1594,20 @@ func (f *File) dynamicVersions(str []byte) bool {
|
||||
vnext := f.ByteOrder.Uint32(d[j+4 : j+8])
|
||||
depName, _ = getString(str, int(vname))
|
||||
|
||||
deps = append(deps, depName)
|
||||
if c == 0 {
|
||||
name = depName
|
||||
} else {
|
||||
deps = append(deps, depName)
|
||||
}
|
||||
|
||||
j += int(vnext)
|
||||
}
|
||||
|
||||
dynVers = append(dynVers, DynamicVersion{
|
||||
Version: version,
|
||||
Flags: flags,
|
||||
Index: ndx,
|
||||
Deps: deps,
|
||||
Name: name,
|
||||
Index: ndx,
|
||||
Flags: flags,
|
||||
Deps: deps,
|
||||
})
|
||||
|
||||
if next == 0 {
|
||||
@@ -1577,7 +1618,7 @@ func (f *File) dynamicVersions(str []byte) bool {
|
||||
|
||||
f.dynVers = dynVers
|
||||
|
||||
return true
|
||||
return nil
|
||||
}
|
||||
|
||||
// DynamicVersions returns version information for a dynamic object.
|
||||
@@ -1587,7 +1628,11 @@ func (f *File) DynamicVersions() ([]DynamicVersion, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !f.gnuVersionInit(str) {
|
||||
hasVersions, err := f.gnuVersionInit(str)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !hasVersions {
|
||||
return nil, errors.New("DynamicVersions: missing version table")
|
||||
}
|
||||
}
|
||||
@@ -1596,16 +1641,16 @@ func (f *File) DynamicVersions() ([]DynamicVersion, error) {
|
||||
}
|
||||
|
||||
// dynamicVersionNeeds returns version dependencies for a dynamic object.
|
||||
func (f *File) dynamicVersionNeeds(str []byte) bool {
|
||||
func (f *File) dynamicVersionNeeds(str []byte) error {
|
||||
if f.dynVerNeeds != nil {
|
||||
// Already initialized.
|
||||
return true
|
||||
return nil
|
||||
}
|
||||
|
||||
// Accumulate verneed information.
|
||||
vn := f.SectionByType(SHT_GNU_VERNEED)
|
||||
if vn == nil {
|
||||
return false
|
||||
return nil
|
||||
}
|
||||
d, _ := vn.Data()
|
||||
|
||||
@@ -1617,7 +1662,7 @@ func (f *File) dynamicVersionNeeds(str []byte) bool {
|
||||
}
|
||||
vers := f.ByteOrder.Uint16(d[i : i+2])
|
||||
if vers != 1 {
|
||||
break
|
||||
return &FormatError{int64(vn.Offset + uint64(i)), "unexpected dynamic need version", vers}
|
||||
}
|
||||
cnt := f.ByteOrder.Uint16(d[i+2 : i+4])
|
||||
fileoff := f.ByteOrder.Uint32(d[i+4 : i+8])
|
||||
@@ -1632,14 +1677,14 @@ func (f *File) dynamicVersionNeeds(str []byte) bool {
|
||||
break
|
||||
}
|
||||
flags := DynamicVersionFlag(f.ByteOrder.Uint16(d[j+4 : j+6]))
|
||||
other := f.ByteOrder.Uint16(d[j+6 : j+8])
|
||||
index := f.ByteOrder.Uint16(d[j+6 : j+8])
|
||||
nameoff := f.ByteOrder.Uint32(d[j+8 : j+12])
|
||||
next := f.ByteOrder.Uint32(d[j+12 : j+16])
|
||||
depName, _ := getString(str, int(nameoff))
|
||||
|
||||
deps = append(deps, DynamicVersionDep{
|
||||
Flags: flags,
|
||||
Other: other,
|
||||
Index: index,
|
||||
Dep: depName,
|
||||
})
|
||||
|
||||
@@ -1650,9 +1695,8 @@ func (f *File) dynamicVersionNeeds(str []byte) bool {
|
||||
}
|
||||
|
||||
dynVerNeeds = append(dynVerNeeds, DynamicVersionNeed{
|
||||
Version: vers,
|
||||
Name: file,
|
||||
Needs: deps,
|
||||
Name: file,
|
||||
Needs: deps,
|
||||
})
|
||||
|
||||
if next == 0 {
|
||||
@@ -1663,7 +1707,7 @@ func (f *File) dynamicVersionNeeds(str []byte) bool {
|
||||
|
||||
f.dynVerNeeds = dynVerNeeds
|
||||
|
||||
return true
|
||||
return nil
|
||||
}
|
||||
|
||||
// DynamicVersionNeeds returns version dependencies for a dynamic object.
|
||||
@@ -1673,7 +1717,11 @@ func (f *File) DynamicVersionNeeds() ([]DynamicVersionNeed, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !f.gnuVersionInit(str) {
|
||||
hasVersions, err := f.gnuVersionInit(str)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !hasVersions {
|
||||
return nil, errors.New("DynamicVersionNeeds: missing version table")
|
||||
}
|
||||
}
|
||||
@@ -1683,66 +1731,66 @@ func (f *File) DynamicVersionNeeds() ([]DynamicVersionNeed, error) {
|
||||
|
||||
// gnuVersionInit parses the GNU version tables
|
||||
// for use by calls to gnuVersion.
|
||||
func (f *File) gnuVersionInit(str []byte) bool {
|
||||
// It reports whether any version tables were found.
|
||||
func (f *File) gnuVersionInit(str []byte) (bool, error) {
|
||||
// Versym parallels symbol table, indexing into verneed.
|
||||
vs := f.SectionByType(SHT_GNU_VERSYM)
|
||||
if vs == nil {
|
||||
return false
|
||||
return false, nil
|
||||
}
|
||||
d, _ := vs.Data()
|
||||
|
||||
f.gnuVersym = d
|
||||
f.dynamicVersions(str)
|
||||
f.dynamicVersionNeeds(str)
|
||||
return true
|
||||
if err := f.dynamicVersions(str); err != nil {
|
||||
return false, err
|
||||
}
|
||||
if err := f.dynamicVersionNeeds(str); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// gnuVersion adds Library and Version information to sym,
|
||||
// which came from offset i of the symbol table.
|
||||
func (f *File) gnuVersion(i int) (versionIndex int16, version string, library string, versionFlags SymbolVersionFlag) {
|
||||
func (f *File) gnuVersion(i int) (versionIndex int16, version string, library string, versionFlags SymbolVersionScope) {
|
||||
// Each entry is two bytes; skip undef entry at beginning.
|
||||
i = (i + 1) * 2
|
||||
if i >= len(f.gnuVersym) {
|
||||
return -1, "", "", VerFlagNone
|
||||
return -1, "", "", VersionScopeNone
|
||||
}
|
||||
s := f.gnuVersym[i:]
|
||||
if len(s) < 2 {
|
||||
return -1, "", "", VerFlagNone
|
||||
return -1, "", "", VersionScopeNone
|
||||
}
|
||||
j := int32(f.ByteOrder.Uint16(s))
|
||||
var ndx = int16(j & 0x7fff)
|
||||
ndx := int16(j & 0x7fff)
|
||||
|
||||
if ndx == 0 {
|
||||
return ndx, "", "", VerFlagLocal
|
||||
} else if ndx == 1 {
|
||||
return ndx, "", "", VerFlagGlobal
|
||||
if j == 0 {
|
||||
return ndx, "", "", VersionScopeLocal
|
||||
} else if j == 1 {
|
||||
return ndx, "", "", VersionScopeGlobal
|
||||
}
|
||||
|
||||
if ndx < 2 {
|
||||
return 0, "", "", VerFlagNone
|
||||
scope := VersionScopeSpecific
|
||||
if j&0x8000 != 0 {
|
||||
scope = VersionScopeHidden
|
||||
}
|
||||
|
||||
for _, v := range f.dynVerNeeds {
|
||||
for _, n := range v.Needs {
|
||||
if uint16(ndx) == n.Other {
|
||||
return ndx, n.Dep, v.Name, VerFlagHidden
|
||||
if uint16(ndx) == n.Index {
|
||||
return ndx, n.Dep, v.Name, scope
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range f.dynVers {
|
||||
if uint16(ndx) == v.Index {
|
||||
if len(v.Deps) > 0 {
|
||||
flags := VerFlagNone
|
||||
if j&0x8000 != 0 {
|
||||
flags = VerFlagHidden
|
||||
}
|
||||
return ndx, v.Deps[0], "", flags
|
||||
}
|
||||
return ndx, v.Name, "", scope
|
||||
}
|
||||
}
|
||||
|
||||
return -1, "", "", VerFlagNone
|
||||
return -1, "", "", VersionScopeNone
|
||||
}
|
||||
|
||||
// ImportedLibraries returns the names of all libraries
|
||||
|
||||
@@ -78,80 +78,80 @@ var fileTests = []fileTest{
|
||||
},
|
||||
[]string{"libc.so.6"},
|
||||
[]Symbol{
|
||||
{"", 3, 0, -1, VerFlagNone, 1, 134512852, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 2, 134512876, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 3, 134513020, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 4, 134513292, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 5, 134513480, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 6, 134513512, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 7, 134513532, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 8, 134513612, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 9, 134513996, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 10, 134514008, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 11, 134518268, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 12, 134518280, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 13, 134518284, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 14, 134518436, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 15, 134518444, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 16, 134518452, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 17, 134518456, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 18, 134518484, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 19, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 20, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 21, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 22, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 23, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 24, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 25, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 26, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 27, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 28, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 29, 0, 0, "", ""},
|
||||
{"crt1.c", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"/usr/src/lib/csu/i386-elf/crti.S", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"<command line>", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"<built-in>", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"/usr/src/lib/csu/i386-elf/crti.S", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"crtstuff.c", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"__CTOR_LIST__", 1, 0, -1, VerFlagNone, 14, 134518436, 0, "", ""},
|
||||
{"__DTOR_LIST__", 1, 0, -1, VerFlagNone, 15, 134518444, 0, "", ""},
|
||||
{"__EH_FRAME_BEGIN__", 1, 0, -1, VerFlagNone, 12, 134518280, 0, "", ""},
|
||||
{"__JCR_LIST__", 1, 0, -1, VerFlagNone, 16, 134518452, 0, "", ""},
|
||||
{"p.0", 1, 0, -1, VerFlagNone, 11, 134518276, 0, "", ""},
|
||||
{"completed.1", 1, 0, -1, VerFlagNone, 18, 134518484, 1, "", ""},
|
||||
{"__do_global_dtors_aux", 2, 0, -1, VerFlagNone, 8, 134513760, 0, "", ""},
|
||||
{"object.2", 1, 0, -1, VerFlagNone, 18, 134518488, 24, "", ""},
|
||||
{"frame_dummy", 2, 0, -1, VerFlagNone, 8, 134513836, 0, "", ""},
|
||||
{"crtstuff.c", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"__CTOR_END__", 1, 0, -1, VerFlagNone, 14, 134518440, 0, "", ""},
|
||||
{"__DTOR_END__", 1, 0, -1, VerFlagNone, 15, 134518448, 0, "", ""},
|
||||
{"__FRAME_END__", 1, 0, -1, VerFlagNone, 12, 134518280, 0, "", ""},
|
||||
{"__JCR_END__", 1, 0, -1, VerFlagNone, 16, 134518452, 0, "", ""},
|
||||
{"__do_global_ctors_aux", 2, 0, -1, VerFlagNone, 8, 134513960, 0, "", ""},
|
||||
{"/usr/src/lib/csu/i386-elf/crtn.S", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"<command line>", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"<built-in>", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"/usr/src/lib/csu/i386-elf/crtn.S", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"hello.c", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"printf", 18, 0, -1, VerFlagNone, 0, 0, 44, "", ""},
|
||||
{"_DYNAMIC", 17, 0, -1, VerFlagNone, 65521, 134518284, 0, "", ""},
|
||||
{"__dso_handle", 17, 2, -1, VerFlagNone, 11, 134518272, 0, "", ""},
|
||||
{"_init", 18, 0, -1, VerFlagNone, 6, 134513512, 0, "", ""},
|
||||
{"environ", 17, 0, -1, VerFlagNone, 18, 134518512, 4, "", ""},
|
||||
{"__deregister_frame_info", 32, 0, -1, VerFlagNone, 0, 0, 0, "", ""},
|
||||
{"__progname", 17, 0, -1, VerFlagNone, 11, 134518268, 4, "", ""},
|
||||
{"_start", 18, 0, -1, VerFlagNone, 8, 134513612, 145, "", ""},
|
||||
{"__bss_start", 16, 0, -1, VerFlagNone, 65521, 134518484, 0, "", ""},
|
||||
{"main", 18, 0, -1, VerFlagNone, 8, 134513912, 46, "", ""},
|
||||
{"_init_tls", 18, 0, -1, VerFlagNone, 0, 0, 5, "", ""},
|
||||
{"_fini", 18, 0, -1, VerFlagNone, 9, 134513996, 0, "", ""},
|
||||
{"atexit", 18, 0, -1, VerFlagNone, 0, 0, 43, "", ""},
|
||||
{"_edata", 16, 0, -1, VerFlagNone, 65521, 134518484, 0, "", ""},
|
||||
{"_GLOBAL_OFFSET_TABLE_", 17, 0, -1, VerFlagNone, 65521, 134518456, 0, "", ""},
|
||||
{"_end", 16, 0, -1, VerFlagNone, 65521, 134518516, 0, "", ""},
|
||||
{"exit", 18, 0, -1, VerFlagNone, 0, 0, 68, "", ""},
|
||||
{"_Jv_RegisterClasses", 32, 0, -1, VerFlagNone, 0, 0, 0, "", ""},
|
||||
{"__register_frame_info", 32, 0, -1, VerFlagNone, 0, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 1, 134512852, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 2, 134512876, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 3, 134513020, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 4, 134513292, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 5, 134513480, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 6, 134513512, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 7, 134513532, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 8, 134513612, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 9, 134513996, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 10, 134514008, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 11, 134518268, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 12, 134518280, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 13, 134518284, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 14, 134518436, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 15, 134518444, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 16, 134518452, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 17, 134518456, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 18, 134518484, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 19, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 20, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 21, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 22, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 23, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 24, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 25, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 26, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 27, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 28, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 29, 0, 0, "", ""},
|
||||
{"crt1.c", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"/usr/src/lib/csu/i386-elf/crti.S", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"<command line>", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"<built-in>", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"/usr/src/lib/csu/i386-elf/crti.S", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"crtstuff.c", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"__CTOR_LIST__", 1, 0, VersionScopeNone, -1, 14, 134518436, 0, "", ""},
|
||||
{"__DTOR_LIST__", 1, 0, VersionScopeNone, -1, 15, 134518444, 0, "", ""},
|
||||
{"__EH_FRAME_BEGIN__", 1, 0, VersionScopeNone, -1, 12, 134518280, 0, "", ""},
|
||||
{"__JCR_LIST__", 1, 0, VersionScopeNone, -1, 16, 134518452, 0, "", ""},
|
||||
{"p.0", 1, 0, VersionScopeNone, -1, 11, 134518276, 0, "", ""},
|
||||
{"completed.1", 1, 0, VersionScopeNone, -1, 18, 134518484, 1, "", ""},
|
||||
{"__do_global_dtors_aux", 2, 0, VersionScopeNone, -1, 8, 134513760, 0, "", ""},
|
||||
{"object.2", 1, 0, VersionScopeNone, -1, 18, 134518488, 24, "", ""},
|
||||
{"frame_dummy", 2, 0, VersionScopeNone, -1, 8, 134513836, 0, "", ""},
|
||||
{"crtstuff.c", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"__CTOR_END__", 1, 0, VersionScopeNone, -1, 14, 134518440, 0, "", ""},
|
||||
{"__DTOR_END__", 1, 0, VersionScopeNone, -1, 15, 134518448, 0, "", ""},
|
||||
{"__FRAME_END__", 1, 0, VersionScopeNone, -1, 12, 134518280, 0, "", ""},
|
||||
{"__JCR_END__", 1, 0, VersionScopeNone, -1, 16, 134518452, 0, "", ""},
|
||||
{"__do_global_ctors_aux", 2, 0, VersionScopeNone, -1, 8, 134513960, 0, "", ""},
|
||||
{"/usr/src/lib/csu/i386-elf/crtn.S", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"<command line>", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"<built-in>", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"/usr/src/lib/csu/i386-elf/crtn.S", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"hello.c", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"printf", 18, 0, VersionScopeNone, -1, 0, 0, 44, "", ""},
|
||||
{"_DYNAMIC", 17, 0, VersionScopeNone, -1, 65521, 134518284, 0, "", ""},
|
||||
{"__dso_handle", 17, 2, VersionScopeNone, -1, 11, 134518272, 0, "", ""},
|
||||
{"_init", 18, 0, VersionScopeNone, -1, 6, 134513512, 0, "", ""},
|
||||
{"environ", 17, 0, VersionScopeNone, -1, 18, 134518512, 4, "", ""},
|
||||
{"__deregister_frame_info", 32, 0, VersionScopeNone, -1, 0, 0, 0, "", ""},
|
||||
{"__progname", 17, 0, VersionScopeNone, -1, 11, 134518268, 4, "", ""},
|
||||
{"_start", 18, 0, VersionScopeNone, -1, 8, 134513612, 145, "", ""},
|
||||
{"__bss_start", 16, 0, VersionScopeNone, -1, 65521, 134518484, 0, "", ""},
|
||||
{"main", 18, 0, VersionScopeNone, -1, 8, 134513912, 46, "", ""},
|
||||
{"_init_tls", 18, 0, VersionScopeNone, -1, 0, 0, 5, "", ""},
|
||||
{"_fini", 18, 0, VersionScopeNone, -1, 9, 134513996, 0, "", ""},
|
||||
{"atexit", 18, 0, VersionScopeNone, -1, 0, 0, 43, "", ""},
|
||||
{"_edata", 16, 0, VersionScopeNone, -1, 65521, 134518484, 0, "", ""},
|
||||
{"_GLOBAL_OFFSET_TABLE_", 17, 0, VersionScopeNone, -1, 65521, 134518456, 0, "", ""},
|
||||
{"_end", 16, 0, VersionScopeNone, -1, 65521, 134518516, 0, "", ""},
|
||||
{"exit", 18, 0, VersionScopeNone, -1, 0, 0, 68, "", ""},
|
||||
{"_Jv_RegisterClasses", 32, 0, VersionScopeNone, -1, 0, 0, 0, "", ""},
|
||||
{"__register_frame_info", 32, 0, VersionScopeNone, -1, 0, 0, 0, "", ""},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -208,79 +208,79 @@ var fileTests = []fileTest{
|
||||
},
|
||||
[]string{"libc.so.6"},
|
||||
[]Symbol{
|
||||
{"", 3, 0, -1, VerFlagNone, 1, 4194816, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 2, 4194844, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 3, 4194880, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 4, 4194920, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 5, 4194952, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 6, 4195048, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 7, 4195110, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 8, 4195120, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 9, 4195152, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 10, 4195176, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 11, 4195224, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 12, 4195248, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 13, 4195296, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 14, 4195732, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 15, 4195748, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 16, 4195768, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 17, 4195808, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 18, 6293128, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 19, 6293144, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 20, 6293160, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 21, 6293168, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 22, 6293584, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 23, 6293592, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 24, 6293632, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 25, 6293656, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 26, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 27, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 28, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 29, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 30, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 31, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 32, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 33, 0, 0, "", ""},
|
||||
{"init.c", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"initfini.c", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"call_gmon_start", 2, 0, -1, VerFlagNone, 13, 4195340, 0, "", ""},
|
||||
{"crtstuff.c", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"__CTOR_LIST__", 1, 0, -1, VerFlagNone, 18, 6293128, 0, "", ""},
|
||||
{"__DTOR_LIST__", 1, 0, -1, VerFlagNone, 19, 6293144, 0, "", ""},
|
||||
{"__JCR_LIST__", 1, 0, -1, VerFlagNone, 20, 6293160, 0, "", ""},
|
||||
{"__do_global_dtors_aux", 2, 0, -1, VerFlagNone, 13, 4195376, 0, "", ""},
|
||||
{"completed.6183", 1, 0, -1, VerFlagNone, 25, 6293656, 1, "", ""},
|
||||
{"p.6181", 1, 0, -1, VerFlagNone, 24, 6293648, 0, "", ""},
|
||||
{"frame_dummy", 2, 0, -1, VerFlagNone, 13, 4195440, 0, "", ""},
|
||||
{"crtstuff.c", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"__CTOR_END__", 1, 0, -1, VerFlagNone, 18, 6293136, 0, "", ""},
|
||||
{"__DTOR_END__", 1, 0, -1, VerFlagNone, 19, 6293152, 0, "", ""},
|
||||
{"__FRAME_END__", 1, 0, -1, VerFlagNone, 17, 4195968, 0, "", ""},
|
||||
{"__JCR_END__", 1, 0, -1, VerFlagNone, 20, 6293160, 0, "", ""},
|
||||
{"__do_global_ctors_aux", 2, 0, -1, VerFlagNone, 13, 4195680, 0, "", ""},
|
||||
{"initfini.c", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"hello.c", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"_GLOBAL_OFFSET_TABLE_", 1, 2, -1, VerFlagNone, 23, 6293592, 0, "", ""},
|
||||
{"__init_array_end", 0, 2, -1, VerFlagNone, 18, 6293124, 0, "", ""},
|
||||
{"__init_array_start", 0, 2, -1, VerFlagNone, 18, 6293124, 0, "", ""},
|
||||
{"_DYNAMIC", 1, 2, -1, VerFlagNone, 21, 6293168, 0, "", ""},
|
||||
{"data_start", 32, 0, -1, VerFlagNone, 24, 6293632, 0, "", ""},
|
||||
{"__libc_csu_fini", 18, 0, -1, VerFlagNone, 13, 4195520, 2, "", ""},
|
||||
{"_start", 18, 0, -1, VerFlagNone, 13, 4195296, 0, "", ""},
|
||||
{"__gmon_start__", 32, 0, -1, VerFlagNone, 0, 0, 0, "", ""},
|
||||
{"_Jv_RegisterClasses", 32, 0, -1, VerFlagNone, 0, 0, 0, "", ""},
|
||||
{"puts@@GLIBC_2.2.5", 18, 0, -1, VerFlagNone, 0, 0, 396, "", ""},
|
||||
{"_fini", 18, 0, -1, VerFlagNone, 14, 4195732, 0, "", ""},
|
||||
{"__libc_start_main@@GLIBC_2.2.5", 18, 0, -1, VerFlagNone, 0, 0, 450, "", ""},
|
||||
{"_IO_stdin_used", 17, 0, -1, VerFlagNone, 15, 4195748, 4, "", ""},
|
||||
{"__data_start", 16, 0, -1, VerFlagNone, 24, 6293632, 0, "", ""},
|
||||
{"__dso_handle", 17, 2, -1, VerFlagNone, 24, 6293640, 0, "", ""},
|
||||
{"__libc_csu_init", 18, 0, -1, VerFlagNone, 13, 4195536, 137, "", ""},
|
||||
{"__bss_start", 16, 0, -1, VerFlagNone, 65521, 6293656, 0, "", ""},
|
||||
{"_end", 16, 0, -1, VerFlagNone, 65521, 6293664, 0, "", ""},
|
||||
{"_edata", 16, 0, -1, VerFlagNone, 65521, 6293656, 0, "", ""},
|
||||
{"main", 18, 0, -1, VerFlagNone, 13, 4195480, 27, "", ""},
|
||||
{"_init", 18, 0, -1, VerFlagNone, 11, 4195224, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 1, 4194816, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 2, 4194844, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 3, 4194880, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 4, 4194920, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 5, 4194952, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 6, 4195048, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 7, 4195110, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 8, 4195120, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 9, 4195152, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 10, 4195176, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 11, 4195224, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 12, 4195248, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 13, 4195296, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 14, 4195732, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 15, 4195748, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 16, 4195768, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 17, 4195808, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 18, 6293128, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 19, 6293144, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 20, 6293160, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 21, 6293168, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 22, 6293584, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 23, 6293592, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 24, 6293632, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 25, 6293656, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 26, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 27, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 28, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 29, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 30, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 31, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 32, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 33, 0, 0, "", ""},
|
||||
{"init.c", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"initfini.c", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"call_gmon_start", 2, 0, VersionScopeNone, -1, 13, 4195340, 0, "", ""},
|
||||
{"crtstuff.c", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"__CTOR_LIST__", 1, 0, VersionScopeNone, -1, 18, 6293128, 0, "", ""},
|
||||
{"__DTOR_LIST__", 1, 0, VersionScopeNone, -1, 19, 6293144, 0, "", ""},
|
||||
{"__JCR_LIST__", 1, 0, VersionScopeNone, -1, 20, 6293160, 0, "", ""},
|
||||
{"__do_global_dtors_aux", 2, 0, VersionScopeNone, -1, 13, 4195376, 0, "", ""},
|
||||
{"completed.6183", 1, 0, VersionScopeNone, -1, 25, 6293656, 1, "", ""},
|
||||
{"p.6181", 1, 0, VersionScopeNone, -1, 24, 6293648, 0, "", ""},
|
||||
{"frame_dummy", 2, 0, VersionScopeNone, -1, 13, 4195440, 0, "", ""},
|
||||
{"crtstuff.c", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"__CTOR_END__", 1, 0, VersionScopeNone, -1, 18, 6293136, 0, "", ""},
|
||||
{"__DTOR_END__", 1, 0, VersionScopeNone, -1, 19, 6293152, 0, "", ""},
|
||||
{"__FRAME_END__", 1, 0, VersionScopeNone, -1, 17, 4195968, 0, "", ""},
|
||||
{"__JCR_END__", 1, 0, VersionScopeNone, -1, 20, 6293160, 0, "", ""},
|
||||
{"__do_global_ctors_aux", 2, 0, VersionScopeNone, -1, 13, 4195680, 0, "", ""},
|
||||
{"initfini.c", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"hello.c", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"_GLOBAL_OFFSET_TABLE_", 1, 2, VersionScopeNone, -1, 23, 6293592, 0, "", ""},
|
||||
{"__init_array_end", 0, 2, VersionScopeNone, -1, 18, 6293124, 0, "", ""},
|
||||
{"__init_array_start", 0, 2, VersionScopeNone, -1, 18, 6293124, 0, "", ""},
|
||||
{"_DYNAMIC", 1, 2, VersionScopeNone, -1, 21, 6293168, 0, "", ""},
|
||||
{"data_start", 32, 0, VersionScopeNone, -1, 24, 6293632, 0, "", ""},
|
||||
{"__libc_csu_fini", 18, 0, VersionScopeNone, -1, 13, 4195520, 2, "", ""},
|
||||
{"_start", 18, 0, VersionScopeNone, -1, 13, 4195296, 0, "", ""},
|
||||
{"__gmon_start__", 32, 0, VersionScopeNone, -1, 0, 0, 0, "", ""},
|
||||
{"_Jv_RegisterClasses", 32, 0, VersionScopeNone, -1, 0, 0, 0, "", ""},
|
||||
{"puts@@GLIBC_2.2.5", 18, 0, VersionScopeNone, -1, 0, 0, 396, "", ""},
|
||||
{"_fini", 18, 0, VersionScopeNone, -1, 14, 4195732, 0, "", ""},
|
||||
{"__libc_start_main@@GLIBC_2.2.5", 18, 0, VersionScopeNone, -1, 0, 0, 450, "", ""},
|
||||
{"_IO_stdin_used", 17, 0, VersionScopeNone, -1, 15, 4195748, 4, "", ""},
|
||||
{"__data_start", 16, 0, VersionScopeNone, -1, 24, 6293632, 0, "", ""},
|
||||
{"__dso_handle", 17, 2, VersionScopeNone, -1, 24, 6293640, 0, "", ""},
|
||||
{"__libc_csu_init", 18, 0, VersionScopeNone, -1, 13, 4195536, 137, "", ""},
|
||||
{"__bss_start", 16, 0, VersionScopeNone, -1, 65521, 6293656, 0, "", ""},
|
||||
{"_end", 16, 0, VersionScopeNone, -1, 65521, 6293664, 0, "", ""},
|
||||
{"_edata", 16, 0, VersionScopeNone, -1, 65521, 6293656, 0, "", ""},
|
||||
{"main", 18, 0, VersionScopeNone, -1, 13, 4195480, 27, "", ""},
|
||||
{"_init", 18, 0, VersionScopeNone, -1, 11, 4195224, 0, "", ""},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -338,21 +338,21 @@ var fileTests = []fileTest{
|
||||
[]ProgHeader{},
|
||||
nil,
|
||||
[]Symbol{
|
||||
{"hello.c", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 1, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 3, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 4, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 5, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 6, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 8, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 9, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 11, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 13, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 15, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 16, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 14, 0, 0, "", ""},
|
||||
{"main", 18, 0, -1, VerFlagNone, 1, 0, 23, "", ""},
|
||||
{"puts", 16, 0, -1, VerFlagNone, 0, 0, 0, "", ""},
|
||||
{"hello.c", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 1, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 3, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 4, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 5, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 6, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 8, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 9, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 11, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 13, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 15, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 16, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 14, 0, 0, "", ""},
|
||||
{"main", 18, 0, VersionScopeNone, -1, 1, 0, 23, "", ""},
|
||||
{"puts", 16, 0, VersionScopeNone, -1, 0, 0, 0, "", ""},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -384,21 +384,21 @@ var fileTests = []fileTest{
|
||||
[]ProgHeader{},
|
||||
nil,
|
||||
[]Symbol{
|
||||
{"hello.c", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 1, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 3, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 4, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 5, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 6, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 8, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 9, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 11, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 13, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 15, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 16, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 14, 0, 0, "", ""},
|
||||
{"main", 18, 0, -1, VerFlagNone, 1, 0, 27, "", ""},
|
||||
{"puts", 16, 0, -1, VerFlagNone, 0, 0, 0, "", ""},
|
||||
{"hello.c", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 1, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 3, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 4, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 5, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 6, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 8, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 9, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 11, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 13, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 15, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 16, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 14, 0, 0, "", ""},
|
||||
{"main", 18, 0, VersionScopeNone, -1, 1, 0, 27, "", ""},
|
||||
{"puts", 16, 0, VersionScopeNone, -1, 0, 0, 0, "", ""},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -430,21 +430,21 @@ var fileTests = []fileTest{
|
||||
[]ProgHeader{},
|
||||
nil,
|
||||
[]Symbol{
|
||||
{"hello.c", 4, 0, -1, VerFlagNone, 65521, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 1, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 3, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 4, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 5, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 6, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 8, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 9, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 11, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 13, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 15, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 16, 0, 0, "", ""},
|
||||
{"", 3, 0, -1, VerFlagNone, 14, 0, 0, "", ""},
|
||||
{"main", 18, 0, -1, VerFlagNone, 1, 0, 44, "", ""},
|
||||
{"puts", 16, 0, -1, VerFlagNone, 0, 0, 0, "", ""},
|
||||
{"hello.c", 4, 0, VersionScopeNone, -1, 65521, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 1, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 3, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 4, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 5, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 6, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 8, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 9, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 11, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 13, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 15, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 16, 0, 0, "", ""},
|
||||
{"", 3, 0, VersionScopeNone, -1, 14, 0, 0, "", ""},
|
||||
{"main", 18, 0, VersionScopeNone, -1, 1, 0, 44, "", ""},
|
||||
{"puts", 16, 0, VersionScopeNone, -1, 0, 0, 0, "", ""},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@ import (
|
||||
var gooses []string
|
||||
|
||||
func main() {
|
||||
data, err := os.ReadFile("../../internal/syslist/syslist..go")
|
||||
data, err := os.ReadFile("../../internal/syslist/syslist.go")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -110,12 +110,20 @@ func sendFile(dstFD *FD, src int, offset *int64, size int64) (written int64, err
|
||||
// Retry.
|
||||
case syscall.ENOSYS, syscall.EOPNOTSUPP, syscall.EINVAL:
|
||||
// ENOSYS indicates no kernel support for sendfile.
|
||||
// EINVAL indicates a FD type which does not support sendfile.
|
||||
// EINVAL indicates a FD type that does not support sendfile.
|
||||
//
|
||||
// On Linux, copy_file_range can return EOPNOTSUPP when copying
|
||||
// to a NFS file (issue #40731); check for it here just in case.
|
||||
return written, err, written > 0
|
||||
default:
|
||||
// We want to handle ENOTSUP like EOPNOTSUPP.
|
||||
// It's a pain to put it as a switch case
|
||||
// because on Linux systems ENOTSUP == EOPNOTSUPP,
|
||||
// so the compiler complains about a duplicate case.
|
||||
if err == syscall.ENOTSUP {
|
||||
return written, err, written > 0
|
||||
}
|
||||
|
||||
// Not a retryable error.
|
||||
return written, err, true
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func ExampleDiscardHandler() {
|
||||
func Example_discardHandler() {
|
||||
// A slog.TextHandler can output log messages.
|
||||
logger1 := slog.New(slog.NewTextHandler(
|
||||
os.Stdout,
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
)
|
||||
|
||||
// Protocols is a set of HTTP protocols.
|
||||
// The zero value is an empty set of protocols.
|
||||
//
|
||||
// The supported protocols are:
|
||||
//
|
||||
|
||||
@@ -129,22 +129,14 @@ func interfaceAddrTable(ifi *Interface) ([]Addr, error) {
|
||||
if err != nil {
|
||||
return nil, os.NewSyscallError("parsenetlinkmessage", err)
|
||||
}
|
||||
var ift []Interface
|
||||
if ifi == nil {
|
||||
var err error
|
||||
ift, err = interfaceTable(0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
ifat, err := addrTable(ift, ifi, msgs)
|
||||
ifat, err := addrTable(ifi, msgs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ifat, nil
|
||||
}
|
||||
|
||||
func addrTable(ift []Interface, ifi *Interface, msgs []syscall.NetlinkMessage) ([]Addr, error) {
|
||||
func addrTable(ifi *Interface, msgs []syscall.NetlinkMessage) ([]Addr, error) {
|
||||
var ifat []Addr
|
||||
loop:
|
||||
for _, m := range msgs {
|
||||
@@ -153,14 +145,7 @@ loop:
|
||||
break loop
|
||||
case syscall.RTM_NEWADDR:
|
||||
ifam := (*syscall.IfAddrmsg)(unsafe.Pointer(&m.Data[0]))
|
||||
if len(ift) != 0 || ifi.Index == int(ifam.Index) {
|
||||
if len(ift) != 0 {
|
||||
var err error
|
||||
ifi, err = interfaceByIndex(ift, int(ifam.Index))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if ifi == nil || ifi.Index == int(ifam.Index) {
|
||||
attrs, err := syscall.ParseNetlinkRouteAttr(&m)
|
||||
if err != nil {
|
||||
return nil, os.NewSyscallError("parsenetlinkrouteattr", err)
|
||||
|
||||
86
src/net/sendfile_unix_test.go
Normal file
86
src/net/sendfile_unix_test.go
Normal file
@@ -0,0 +1,86 @@
|
||||
// Copyright 2024 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.
|
||||
|
||||
//go:build unix
|
||||
|
||||
package net
|
||||
|
||||
import (
|
||||
"internal/testpty"
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
"syscall"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Issue 70763: test that we don't fail on sendfile from a tty.
|
||||
func TestCopyFromTTY(t *testing.T) {
|
||||
pty, ttyName, err := testpty.Open()
|
||||
if err != nil {
|
||||
t.Skipf("skipping test because pty open failed: %v", err)
|
||||
}
|
||||
defer pty.Close()
|
||||
|
||||
// Use syscall.Open so that the tty is blocking.
|
||||
ttyFD, err := syscall.Open(ttyName, syscall.O_RDWR, 0)
|
||||
if err != nil {
|
||||
t.Skipf("skipping test because tty open failed: %v", err)
|
||||
}
|
||||
defer syscall.Close(ttyFD)
|
||||
|
||||
tty := os.NewFile(uintptr(ttyFD), "tty")
|
||||
defer tty.Close()
|
||||
|
||||
ln := newLocalListener(t, "tcp")
|
||||
defer ln.Close()
|
||||
|
||||
ch := make(chan bool)
|
||||
|
||||
const data = "data\n"
|
||||
|
||||
var wg sync.WaitGroup
|
||||
defer wg.Wait()
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
conn, err := ln.Accept()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
buf := make([]byte, len(data))
|
||||
if _, err := io.ReadFull(conn, buf); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
ch <- true
|
||||
}()
|
||||
|
||||
conn, err := Dial("tcp", ln.Addr().String())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
if _, err := pty.Write([]byte(data)); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
<-ch
|
||||
if err := pty.Close(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}()
|
||||
|
||||
lr := io.LimitReader(tty, int64(len(data)))
|
||||
if _, err := io.Copy(conn, lr); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
@@ -289,6 +289,7 @@ func (iter *MapIter) Key() Value {
|
||||
// It is equivalent to v.Set(iter.Key()), but it avoids allocating a new Value.
|
||||
// As in Go, the key must be assignable to v's type and
|
||||
// must not be derived from an unexported field.
|
||||
// It panics if [Value.CanSet] returns false.
|
||||
func (v Value) SetIterKey(iter *MapIter) {
|
||||
if !iter.hiter.initialized() {
|
||||
panic("reflect: Value.SetIterKey called before Next")
|
||||
@@ -332,6 +333,7 @@ func (iter *MapIter) Value() Value {
|
||||
// It is equivalent to v.Set(iter.Value()), but it avoids allocating a new Value.
|
||||
// As in Go, the value must be assignable to v's type and
|
||||
// must not be derived from an unexported field.
|
||||
// It panics if [Value.CanSet] returns false.
|
||||
func (v Value) SetIterValue(iter *MapIter) {
|
||||
if !iter.hiter.initialized() {
|
||||
panic("reflect: Value.SetIterValue called before Next")
|
||||
|
||||
@@ -240,6 +240,7 @@ func (iter *MapIter) Key() Value {
|
||||
// It is equivalent to v.Set(iter.Key()), but it avoids allocating a new Value.
|
||||
// As in Go, the key must be assignable to v's type and
|
||||
// must not be derived from an unexported field.
|
||||
// It panics if [Value.CanSet] returns false.
|
||||
func (v Value) SetIterKey(iter *MapIter) {
|
||||
if !iter.hiter.Initialized() {
|
||||
panic("reflect: Value.SetIterKey called before Next")
|
||||
@@ -283,6 +284,7 @@ func (iter *MapIter) Value() Value {
|
||||
// It is equivalent to v.Set(iter.Value()), but it avoids allocating a new Value.
|
||||
// As in Go, the value must be assignable to v's type and
|
||||
// must not be derived from an unexported field.
|
||||
// It panics if [Value.CanSet] returns false.
|
||||
func (v Value) SetIterValue(iter *MapIter) {
|
||||
if !iter.hiter.Initialized() {
|
||||
panic("reflect: Value.SetIterValue called before Next")
|
||||
|
||||
@@ -2072,7 +2072,8 @@ func (v Value) SetBool(x bool) {
|
||||
}
|
||||
|
||||
// SetBytes sets v's underlying value.
|
||||
// It panics if v's underlying value is not a slice of bytes.
|
||||
// It panics if v's underlying value is not a slice of bytes
|
||||
// or if [Value.CanSet] returns false.
|
||||
func (v Value) SetBytes(x []byte) {
|
||||
v.mustBeAssignable()
|
||||
v.mustBe(Slice)
|
||||
@@ -2083,7 +2084,8 @@ func (v Value) SetBytes(x []byte) {
|
||||
}
|
||||
|
||||
// setRunes sets v's underlying value.
|
||||
// It panics if v's underlying value is not a slice of runes (int32s).
|
||||
// It panics if v's underlying value is not a slice of runes (int32s)
|
||||
// or if [Value.CanSet] returns false.
|
||||
func (v Value) setRunes(x []rune) {
|
||||
v.mustBeAssignable()
|
||||
v.mustBe(Slice)
|
||||
@@ -2094,7 +2096,8 @@ func (v Value) setRunes(x []rune) {
|
||||
}
|
||||
|
||||
// SetComplex sets v's underlying value to x.
|
||||
// It panics if v's Kind is not [Complex64] or [Complex128], or if [Value.CanSet] returns false.
|
||||
// It panics if v's Kind is not [Complex64] or [Complex128],
|
||||
// or if [Value.CanSet] returns false.
|
||||
func (v Value) SetComplex(x complex128) {
|
||||
v.mustBeAssignable()
|
||||
switch k := v.kind(); k {
|
||||
@@ -2108,7 +2111,8 @@ func (v Value) SetComplex(x complex128) {
|
||||
}
|
||||
|
||||
// SetFloat sets v's underlying value to x.
|
||||
// It panics if v's Kind is not [Float32] or [Float64], or if [Value.CanSet] returns false.
|
||||
// It panics if v's Kind is not [Float32] or [Float64],
|
||||
// or if [Value.CanSet] returns false.
|
||||
func (v Value) SetFloat(x float64) {
|
||||
v.mustBeAssignable()
|
||||
switch k := v.kind(); k {
|
||||
@@ -2122,7 +2126,8 @@ func (v Value) SetFloat(x float64) {
|
||||
}
|
||||
|
||||
// SetInt sets v's underlying value to x.
|
||||
// It panics if v's Kind is not [Int], [Int8], [Int16], [Int32], or [Int64], or if [Value.CanSet] returns false.
|
||||
// It panics if v's Kind is not [Int], [Int8], [Int16], [Int32], or [Int64],
|
||||
// or if [Value.CanSet] returns false.
|
||||
func (v Value) SetInt(x int64) {
|
||||
v.mustBeAssignable()
|
||||
switch k := v.kind(); k {
|
||||
@@ -2142,8 +2147,9 @@ func (v Value) SetInt(x int64) {
|
||||
}
|
||||
|
||||
// SetLen sets v's length to n.
|
||||
// It panics if v's Kind is not [Slice] or if n is negative or
|
||||
// greater than the capacity of the slice.
|
||||
// It panics if v's Kind is not [Slice], or if n is negative or
|
||||
// greater than the capacity of the slice,
|
||||
// or if [Value.CanSet] returns false.
|
||||
func (v Value) SetLen(n int) {
|
||||
v.mustBeAssignable()
|
||||
v.mustBe(Slice)
|
||||
@@ -2155,8 +2161,9 @@ func (v Value) SetLen(n int) {
|
||||
}
|
||||
|
||||
// SetCap sets v's capacity to n.
|
||||
// It panics if v's Kind is not [Slice] or if n is smaller than the length or
|
||||
// greater than the capacity of the slice.
|
||||
// It panics if v's Kind is not [Slice], or if n is smaller than the length or
|
||||
// greater than the capacity of the slice,
|
||||
// or if [Value.CanSet] returns false.
|
||||
func (v Value) SetCap(n int) {
|
||||
v.mustBeAssignable()
|
||||
v.mustBe(Slice)
|
||||
@@ -2168,7 +2175,8 @@ func (v Value) SetCap(n int) {
|
||||
}
|
||||
|
||||
// SetUint sets v's underlying value to x.
|
||||
// It panics if v's Kind is not [Uint], [Uintptr], [Uint8], [Uint16], [Uint32], or [Uint64], or if [Value.CanSet] returns false.
|
||||
// It panics if v's Kind is not [Uint], [Uintptr], [Uint8], [Uint16], [Uint32], or [Uint64],
|
||||
// or if [Value.CanSet] returns false.
|
||||
func (v Value) SetUint(x uint64) {
|
||||
v.mustBeAssignable()
|
||||
switch k := v.kind(); k {
|
||||
@@ -2190,7 +2198,8 @@ func (v Value) SetUint(x uint64) {
|
||||
}
|
||||
|
||||
// SetPointer sets the [unsafe.Pointer] value v to x.
|
||||
// It panics if v's Kind is not [UnsafePointer].
|
||||
// It panics if v's Kind is not [UnsafePointer]
|
||||
// or if [Value.CanSet] returns false.
|
||||
func (v Value) SetPointer(x unsafe.Pointer) {
|
||||
v.mustBeAssignable()
|
||||
v.mustBe(UnsafePointer)
|
||||
@@ -2558,8 +2567,8 @@ func arrayAt(p unsafe.Pointer, i int, eltSize uintptr, whySafe string) unsafe.Po
|
||||
// another n elements. After Grow(n), at least n elements can be appended
|
||||
// to the slice without another allocation.
|
||||
//
|
||||
// It panics if v's Kind is not a [Slice] or if n is negative or too large to
|
||||
// allocate the memory.
|
||||
// It panics if v's Kind is not a [Slice], or if n is negative or too large to
|
||||
// allocate the memory, or if [Value.CanSet] returns false.
|
||||
func (v Value) Grow(n int) {
|
||||
v.mustBeAssignable()
|
||||
v.mustBe(Slice)
|
||||
@@ -2647,6 +2656,7 @@ func AppendSlice(s, t Value) Value {
|
||||
// It returns the number of elements copied.
|
||||
// Dst and src each must have kind [Slice] or [Array], and
|
||||
// dst and src must have the same element type.
|
||||
// It dst is an [Array], it panics if [Value.CanSet] returns false.
|
||||
//
|
||||
// As a special case, src can have kind [String] if the element type of dst is kind [Uint8].
|
||||
func Copy(dst, src Value) int {
|
||||
|
||||
@@ -124,7 +124,7 @@ func Setenv(key, value string) error {
|
||||
}
|
||||
|
||||
func Clearenv() {
|
||||
envOnce.Do(copyenv) // prevent copyenv in Getenv/Setenv
|
||||
envOnce.Do(copyenv)
|
||||
|
||||
envLock.Lock()
|
||||
defer envLock.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user