1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
14 // TODO: remove duplicate code
15 func TestSymbols(t
*testing
.T
) {
16 do
:= func(file
string, ts
[]Symbol
, getfunc
func(*File
) ([]Symbol
, error
)) {
19 if path
.Ext(file
) == ".gz" {
21 if r
, err
= decompress(file
); err
== nil {
28 t
.Errorf("TestSymbols: cannot open file %s: %v", file
, err
)
33 if err
!= nil && err
!= ErrNoSymbols
{
36 } else if err
== ErrNoSymbols
{
39 if !reflect
.DeepEqual(ts
, fs
) {
40 t
.Errorf("%s: Symbols = %v, want %v", file
, ts
, fs
)
43 for file
, ts
:= range symbolsGolden
{
44 do(file
, ts
, (*File
).Symbols
)
46 for file
, ts
:= range dynamicSymbolsGolden
{
47 do(file
, ts
, (*File
).DynamicSymbols
)
51 // golden symbol table data generated by testdata/getgoldsym.c
53 var symbolsGolden
= map[string][]Symbol
{
54 "testdata/gcc-amd64-linux-exec": {
336 Name
: "call_gmon_start",
352 Name
: "__CTOR_LIST__",
360 Name
: "__DTOR_LIST__",
368 Name
: "__JCR_LIST__",
376 Name
: "__do_global_dtors_aux",
384 Name
: "completed.6183",
416 Name
: "__CTOR_END__",
424 Name
: "__DTOR_END__",
432 Name
: "__FRAME_END__",
448 Name
: "__do_global_ctors_aux",
472 Name
: "_GLOBAL_OFFSET_TABLE_",
480 Name
: "__init_array_end",
488 Name
: "__init_array_start",
512 Name
: "__libc_csu_fini",
528 Name
: "__gmon_start__",
536 Name
: "_Jv_RegisterClasses",
544 Name
: "puts@@GLIBC_2.2.5",
560 Name
: "__libc_start_main@@GLIBC_2.2.5",
568 Name
: "_IO_stdin_used",
576 Name
: "__data_start",
584 Name
: "__dso_handle",
592 Name
: "__libc_csu_init",
640 "testdata/go-relocation-test-clang-x86.obj": {
642 Name
: "go-relocation-test-clang.c",
650 Name
: ".Linfo_string0",
658 Name
: ".Linfo_string1",
666 Name
: ".Linfo_string2",
674 Name
: ".Linfo_string3",
682 Name
: ".Linfo_string4",
802 "testdata/hello-world-core.gz": {},
805 var dynamicSymbolsGolden
= map[string][]Symbol
{
806 "testdata/gcc-amd64-linux-exec": {
808 Name
: "__gmon_start__",
824 Name
: "__libc_start_main",
832 "testdata/go-relocation-test-clang-x86.obj": {},
833 "testdata/hello-world-core.gz": {},