Source file src/debug/elf/symbols_test.go

     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.
     4  
     5  package elf
     6  
     7  import (
     8  	"io"
     9  	"path"
    10  	"reflect"
    11  	"testing"
    12  )
    13  
    14  // TODO: remove duplicate code
    15  func TestSymbols(t *testing.T) {
    16  	do := func(file string, ts []Symbol, getfunc func(*File) ([]Symbol, error)) {
    17  		var f *File
    18  		var err error
    19  		if path.Ext(file) == ".gz" {
    20  			var r io.ReaderAt
    21  			if r, err = decompress(file); err == nil {
    22  				f, err = NewFile(r)
    23  			}
    24  		} else {
    25  			f, err = Open(file)
    26  		}
    27  		if err != nil {
    28  			t.Errorf("TestSymbols: cannot open file %s: %v", file, err)
    29  			return
    30  		}
    31  		defer f.Close()
    32  		fs, err := getfunc(f)
    33  		if err != nil && err != ErrNoSymbols {
    34  			t.Error(err)
    35  			return
    36  		} else if err == ErrNoSymbols {
    37  			fs = []Symbol{}
    38  		}
    39  		if !reflect.DeepEqual(ts, fs) {
    40  			t.Errorf("%s: Symbols = %v, want %v", file, ts, fs)
    41  		}
    42  	}
    43  	for file, ts := range symbolsGolden {
    44  		do(file, ts, (*File).Symbols)
    45  	}
    46  	for file, ts := range dynamicSymbolsGolden {
    47  		do(file, ts, (*File).DynamicSymbols)
    48  	}
    49  }
    50  
    51  // golden symbol table data generated by testdata/getgoldsym.c
    52  
    53  var symbolsGolden = map[string][]Symbol{
    54  	"testdata/gcc-amd64-linux-exec": {
    55  		Symbol{
    56  			Name:         "",
    57  			Info:         0x3,
    58  			Other:        0x0,
    59  			VersionIndex: -1,
    60  			VersionFlags: VerFlagNone,
    61  			Section:      0x1,
    62  			Value:        0x400200,
    63  			Size:         0x0,
    64  		},
    65  		Symbol{
    66  			Name:         "",
    67  			Info:         0x3,
    68  			Other:        0x0,
    69  			VersionIndex: -1,
    70  			VersionFlags: VerFlagNone,
    71  			Section:      0x2,
    72  			Value:        0x40021C,
    73  			Size:         0x0,
    74  		},
    75  		Symbol{
    76  			Name:         "",
    77  			Info:         0x3,
    78  			Other:        0x0,
    79  			VersionIndex: -1,
    80  			VersionFlags: VerFlagNone,
    81  			Section:      0x3,
    82  			Value:        0x400240,
    83  			Size:         0x0,
    84  		},
    85  		Symbol{
    86  			Name:         "",
    87  			Info:         0x3,
    88  			Other:        0x0,
    89  			VersionIndex: -1,
    90  			VersionFlags: VerFlagNone,
    91  			Section:      0x4,
    92  			Value:        0x400268,
    93  			Size:         0x0,
    94  		},
    95  		Symbol{
    96  			Name:         "",
    97  			Info:         0x3,
    98  			Other:        0x0,
    99  			VersionIndex: -1,
   100  			VersionFlags: VerFlagNone,
   101  			Section:      0x5,
   102  			Value:        0x400288,
   103  			Size:         0x0,
   104  		},
   105  		Symbol{
   106  			Name:         "",
   107  			Info:         0x3,
   108  			Other:        0x0,
   109  			VersionIndex: -1,
   110  			VersionFlags: VerFlagNone,
   111  			Section:      0x6,
   112  			Value:        0x4002E8,
   113  			Size:         0x0,
   114  		},
   115  		Symbol{
   116  			Name:         "",
   117  			Info:         0x3,
   118  			Other:        0x0,
   119  			VersionIndex: -1,
   120  			VersionFlags: VerFlagNone,
   121  			Section:      0x7,
   122  			Value:        0x400326,
   123  			Size:         0x0,
   124  		},
   125  		Symbol{
   126  			Name:         "",
   127  			Info:         0x3,
   128  			Other:        0x0,
   129  			VersionIndex: -1,
   130  			VersionFlags: VerFlagNone,
   131  			Section:      0x8,
   132  			Value:        0x400330,
   133  			Size:         0x0,
   134  		},
   135  		Symbol{
   136  			Name:         "",
   137  			Info:         0x3,
   138  			Other:        0x0,
   139  			VersionIndex: -1,
   140  			VersionFlags: VerFlagNone,
   141  			Section:      0x9,
   142  			Value:        0x400350,
   143  			Size:         0x0,
   144  		},
   145  		Symbol{
   146  			Name:         "",
   147  			Info:         0x3,
   148  			Other:        0x0,
   149  			VersionIndex: -1,
   150  			VersionFlags: VerFlagNone,
   151  			Section:      0xA,
   152  			Value:        0x400368,
   153  			Size:         0x0,
   154  		},
   155  		Symbol{
   156  			Name:         "",
   157  			Info:         0x3,
   158  			Other:        0x0,
   159  			VersionIndex: -1,
   160  			VersionFlags: VerFlagNone,
   161  			Section:      0xB,
   162  			Value:        0x400398,
   163  			Size:         0x0,
   164  		},
   165  		Symbol{
   166  			Name:         "",
   167  			Info:         0x3,
   168  			Other:        0x0,
   169  			VersionIndex: -1,
   170  			VersionFlags: VerFlagNone,
   171  			Section:      0xC,
   172  			Value:        0x4003B0,
   173  			Size:         0x0,
   174  		},
   175  		Symbol{
   176  			Name:         "",
   177  			Info:         0x3,
   178  			Other:        0x0,
   179  			VersionIndex: -1,
   180  			VersionFlags: VerFlagNone,
   181  			Section:      0xD,
   182  			Value:        0x4003E0,
   183  			Size:         0x0,
   184  		},
   185  		Symbol{
   186  			Name:         "",
   187  			Info:         0x3,
   188  			Other:        0x0,
   189  			VersionIndex: -1,
   190  			VersionFlags: VerFlagNone,
   191  			Section:      0xE,
   192  			Value:        0x400594,
   193  			Size:         0x0,
   194  		},
   195  		Symbol{
   196  			Name:         "",
   197  			Info:         0x3,
   198  			Other:        0x0,
   199  			VersionIndex: -1,
   200  			VersionFlags: VerFlagNone,
   201  			Section:      0xF,
   202  			Value:        0x4005A4,
   203  			Size:         0x0,
   204  		},
   205  		Symbol{
   206  			Name:         "",
   207  			Info:         0x3,
   208  			Other:        0x0,
   209  			VersionIndex: -1,
   210  			VersionFlags: VerFlagNone,
   211  			Section:      0x10,
   212  			Value:        0x4005B8,
   213  			Size:         0x0,
   214  		},
   215  		Symbol{
   216  			Name:         "",
   217  			Info:         0x3,
   218  			Other:        0x0,
   219  			VersionIndex: -1,
   220  			VersionFlags: VerFlagNone,
   221  			Section:      0x11,
   222  			Value:        0x4005E0,
   223  			Size:         0x0,
   224  		},
   225  		Symbol{
   226  			Name:         "",
   227  			Info:         0x3,
   228  			Other:        0x0,
   229  			VersionIndex: -1,
   230  			VersionFlags: VerFlagNone,
   231  			Section:      0x12,
   232  			Value:        0x600688,
   233  			Size:         0x0,
   234  		},
   235  		Symbol{
   236  			Name:         "",
   237  			Info:         0x3,
   238  			Other:        0x0,
   239  			VersionIndex: -1,
   240  			VersionFlags: VerFlagNone,
   241  			Section:      0x13,
   242  			Value:        0x600698,
   243  			Size:         0x0,
   244  		},
   245  		Symbol{
   246  			Name:         "",
   247  			Info:         0x3,
   248  			Other:        0x0,
   249  			VersionIndex: -1,
   250  			VersionFlags: VerFlagNone,
   251  			Section:      0x14,
   252  			Value:        0x6006A8,
   253  			Size:         0x0,
   254  		},
   255  		Symbol{
   256  			Name:         "",
   257  			Info:         0x3,
   258  			Other:        0x0,
   259  			VersionIndex: -1,
   260  			VersionFlags: VerFlagNone,
   261  			Section:      0x15,
   262  			Value:        0x6006B0,
   263  			Size:         0x0,
   264  		},
   265  		Symbol{
   266  			Name:         "",
   267  			Info:         0x3,
   268  			Other:        0x0,
   269  			VersionIndex: -1,
   270  			VersionFlags: VerFlagNone,
   271  			Section:      0x16,
   272  			Value:        0x600850,
   273  			Size:         0x0,
   274  		},
   275  		Symbol{
   276  			Name:         "",
   277  			Info:         0x3,
   278  			Other:        0x0,
   279  			VersionIndex: -1,
   280  			VersionFlags: VerFlagNone,
   281  			Section:      0x17,
   282  			Value:        0x600858,
   283  			Size:         0x0,
   284  		},
   285  		Symbol{
   286  			Name:         "",
   287  			Info:         0x3,
   288  			Other:        0x0,
   289  			VersionIndex: -1,
   290  			VersionFlags: VerFlagNone,
   291  			Section:      0x18,
   292  			Value:        0x600880,
   293  			Size:         0x0,
   294  		},
   295  		Symbol{
   296  			Name:         "",
   297  			Info:         0x3,
   298  			Other:        0x0,
   299  			VersionIndex: -1,
   300  			VersionFlags: VerFlagNone,
   301  			Section:      0x19,
   302  			Value:        0x600898,
   303  			Size:         0x0,
   304  		},
   305  		Symbol{
   306  			Name:         "",
   307  			Info:         0x3,
   308  			Other:        0x0,
   309  			VersionIndex: -1,
   310  			VersionFlags: VerFlagNone,
   311  			Section:      0x1A,
   312  			Value:        0x0,
   313  			Size:         0x0,
   314  		},
   315  		Symbol{
   316  			Name:         "",
   317  			Info:         0x3,
   318  			Other:        0x0,
   319  			VersionIndex: -1,
   320  			VersionFlags: VerFlagNone,
   321  			Section:      0x1B,
   322  			Value:        0x0,
   323  			Size:         0x0,
   324  		},
   325  		Symbol{
   326  			Name:         "",
   327  			Info:         0x3,
   328  			Other:        0x0,
   329  			VersionIndex: -1,
   330  			VersionFlags: VerFlagNone,
   331  			Section:      0x1C,
   332  			Value:        0x0,
   333  			Size:         0x0,
   334  		},
   335  		Symbol{
   336  			Name:         "",
   337  			Info:         0x3,
   338  			Other:        0x0,
   339  			VersionIndex: -1,
   340  			VersionFlags: VerFlagNone,
   341  			Section:      0x1D,
   342  			Value:        0x0,
   343  			Size:         0x0,
   344  		},
   345  		Symbol{
   346  			Name:         "",
   347  			Info:         0x3,
   348  			Other:        0x0,
   349  			VersionIndex: -1,
   350  			VersionFlags: VerFlagNone,
   351  			Section:      0x1E,
   352  			Value:        0x0,
   353  			Size:         0x0,
   354  		},
   355  		Symbol{
   356  			Name:         "",
   357  			Info:         0x3,
   358  			Other:        0x0,
   359  			VersionIndex: -1,
   360  			VersionFlags: VerFlagNone,
   361  			Section:      0x1F,
   362  			Value:        0x0,
   363  			Size:         0x0,
   364  		},
   365  		Symbol{
   366  			Name:         "",
   367  			Info:         0x3,
   368  			Other:        0x0,
   369  			VersionIndex: -1,
   370  			VersionFlags: VerFlagNone,
   371  			Section:      0x20,
   372  			Value:        0x0,
   373  			Size:         0x0,
   374  		},
   375  		Symbol{
   376  			Name:         "",
   377  			Info:         0x3,
   378  			Other:        0x0,
   379  			VersionIndex: -1,
   380  			VersionFlags: VerFlagNone,
   381  			Section:      0x21,
   382  			Value:        0x0,
   383  			Size:         0x0,
   384  		},
   385  		Symbol{
   386  			Name:         "init.c",
   387  			Info:         0x4,
   388  			Other:        0x0,
   389  			VersionIndex: -1,
   390  			VersionFlags: VerFlagNone,
   391  			Section:      0xFFF1,
   392  			Value:        0x0,
   393  			Size:         0x0,
   394  		},
   395  		Symbol{
   396  			Name:         "initfini.c",
   397  			Info:         0x4,
   398  			Other:        0x0,
   399  			VersionIndex: -1,
   400  			VersionFlags: VerFlagNone,
   401  			Section:      0xFFF1,
   402  			Value:        0x0,
   403  			Size:         0x0,
   404  		},
   405  		Symbol{
   406  			Name:         "call_gmon_start",
   407  			Info:         0x2,
   408  			Other:        0x0,
   409  			VersionIndex: -1,
   410  			VersionFlags: VerFlagNone,
   411  			Section:      0xD,
   412  			Value:        0x40040C,
   413  			Size:         0x0,
   414  		},
   415  		Symbol{
   416  			Name:         "crtstuff.c",
   417  			Info:         0x4,
   418  			Other:        0x0,
   419  			VersionIndex: -1,
   420  			VersionFlags: VerFlagNone,
   421  			Section:      0xFFF1,
   422  			Value:        0x0,
   423  			Size:         0x0,
   424  		},
   425  		Symbol{
   426  			Name:         "__CTOR_LIST__",
   427  			Info:         0x1,
   428  			Other:        0x0,
   429  			VersionIndex: -1,
   430  			VersionFlags: VerFlagNone,
   431  			Section:      0x12,
   432  			Value:        0x600688,
   433  			Size:         0x0,
   434  		},
   435  		Symbol{
   436  			Name:         "__DTOR_LIST__",
   437  			Info:         0x1,
   438  			Other:        0x0,
   439  			VersionIndex: -1,
   440  			VersionFlags: VerFlagNone,
   441  			Section:      0x13,
   442  			Value:        0x600698,
   443  			Size:         0x0,
   444  		},
   445  		Symbol{
   446  			Name:         "__JCR_LIST__",
   447  			Info:         0x1,
   448  			Other:        0x0,
   449  			VersionIndex: -1,
   450  			VersionFlags: VerFlagNone,
   451  			Section:      0x14,
   452  			Value:        0x6006A8,
   453  			Size:         0x0,
   454  		},
   455  		Symbol{
   456  			Name:         "__do_global_dtors_aux",
   457  			Info:         0x2,
   458  			Other:        0x0,
   459  			VersionIndex: -1,
   460  			VersionFlags: VerFlagNone,
   461  			Section:      0xD,
   462  			Value:        0x400430,
   463  			Size:         0x0,
   464  		},
   465  		Symbol{
   466  			Name:         "completed.6183",
   467  			Info:         0x1,
   468  			Other:        0x0,
   469  			VersionIndex: -1,
   470  			VersionFlags: VerFlagNone,
   471  			Section:      0x19,
   472  			Value:        0x600898,
   473  			Size:         0x1,
   474  		},
   475  		Symbol{
   476  			Name:         "p.6181",
   477  			Info:         0x1,
   478  			Other:        0x0,
   479  			VersionIndex: -1,
   480  			VersionFlags: VerFlagNone,
   481  			Section:      0x18,
   482  			Value:        0x600890,
   483  			Size:         0x0,
   484  		},
   485  		Symbol{
   486  			Name:         "frame_dummy",
   487  			Info:         0x2,
   488  			Other:        0x0,
   489  			VersionIndex: -1,
   490  			VersionFlags: VerFlagNone,
   491  			Section:      0xD,
   492  			Value:        0x400470,
   493  			Size:         0x0,
   494  		},
   495  		Symbol{
   496  			Name:         "crtstuff.c",
   497  			Info:         0x4,
   498  			Other:        0x0,
   499  			VersionIndex: -1,
   500  			VersionFlags: VerFlagNone,
   501  			Section:      0xFFF1,
   502  			Value:        0x0,
   503  			Size:         0x0,
   504  		},
   505  		Symbol{
   506  			Name:         "__CTOR_END__",
   507  			Info:         0x1,
   508  			Other:        0x0,
   509  			VersionIndex: -1,
   510  			VersionFlags: VerFlagNone,
   511  			Section:      0x12,
   512  			Value:        0x600690,
   513  			Size:         0x0,
   514  		},
   515  		Symbol{
   516  			Name:         "__DTOR_END__",
   517  			Info:         0x1,
   518  			Other:        0x0,
   519  			VersionIndex: -1,
   520  			VersionFlags: VerFlagNone,
   521  			Section:      0x13,
   522  			Value:        0x6006A0,
   523  			Size:         0x0,
   524  		},
   525  		Symbol{
   526  			Name:         "__FRAME_END__",
   527  			Info:         0x1,
   528  			Other:        0x0,
   529  			VersionIndex: -1,
   530  			VersionFlags: VerFlagNone,
   531  			Section:      0x11,
   532  			Value:        0x400680,
   533  			Size:         0x0,
   534  		},
   535  		Symbol{
   536  			Name:         "__JCR_END__",
   537  			Info:         0x1,
   538  			Other:        0x0,
   539  			VersionIndex: -1,
   540  			VersionFlags: VerFlagNone,
   541  			Section:      0x14,
   542  			Value:        0x6006A8,
   543  			Size:         0x0,
   544  		},
   545  		Symbol{
   546  			Name:         "__do_global_ctors_aux",
   547  			Info:         0x2,
   548  			Other:        0x0,
   549  			VersionIndex: -1,
   550  			VersionFlags: VerFlagNone,
   551  			Section:      0xD,
   552  			Value:        0x400560,
   553  			Size:         0x0,
   554  		},
   555  		Symbol{
   556  			Name:         "initfini.c",
   557  			Info:         0x4,
   558  			Other:        0x0,
   559  			VersionIndex: -1,
   560  			VersionFlags: VerFlagNone,
   561  			Section:      0xFFF1,
   562  			Value:        0x0,
   563  			Size:         0x0,
   564  		},
   565  		Symbol{
   566  			Name:         "hello.c",
   567  			Info:         0x4,
   568  			Other:        0x0,
   569  			VersionIndex: -1,
   570  			VersionFlags: VerFlagNone,
   571  			Section:      0xFFF1,
   572  			Value:        0x0,
   573  			Size:         0x0,
   574  		},
   575  		Symbol{
   576  			Name:         "_GLOBAL_OFFSET_TABLE_",
   577  			Info:         0x1,
   578  			Other:        0x2,
   579  			VersionIndex: -1,
   580  			VersionFlags: VerFlagNone,
   581  			Section:      0x17,
   582  			Value:        0x600858,
   583  			Size:         0x0,
   584  		},
   585  		Symbol{
   586  			Name:         "__init_array_end",
   587  			Info:         0x0,
   588  			Other:        0x2,
   589  			VersionIndex: -1,
   590  			VersionFlags: VerFlagNone,
   591  			Section:      0x12,
   592  			Value:        0x600684,
   593  			Size:         0x0,
   594  		},
   595  		Symbol{
   596  			Name:         "__init_array_start",
   597  			Info:         0x0,
   598  			Other:        0x2,
   599  			VersionIndex: -1,
   600  			VersionFlags: VerFlagNone,
   601  			Section:      0x12,
   602  			Value:        0x600684,
   603  			Size:         0x0,
   604  		},
   605  		Symbol{
   606  			Name:         "_DYNAMIC",
   607  			Info:         0x1,
   608  			Other:        0x2,
   609  			VersionIndex: -1,
   610  			VersionFlags: VerFlagNone,
   611  			Section:      0x15,
   612  			Value:        0x6006B0,
   613  			Size:         0x0,
   614  		},
   615  		Symbol{
   616  			Name:         "data_start",
   617  			Info:         0x20,
   618  			Other:        0x0,
   619  			VersionIndex: -1,
   620  			VersionFlags: VerFlagNone,
   621  			Section:      0x18,
   622  			Value:        0x600880,
   623  			Size:         0x0,
   624  		},
   625  		Symbol{
   626  			Name:         "__libc_csu_fini",
   627  			Info:         0x12,
   628  			Other:        0x0,
   629  			VersionIndex: -1,
   630  			VersionFlags: VerFlagNone,
   631  			Section:      0xD,
   632  			Value:        0x4004C0,
   633  			Size:         0x2,
   634  		},
   635  		Symbol{
   636  			Name:         "_start",
   637  			Info:         0x12,
   638  			Other:        0x0,
   639  			VersionIndex: -1,
   640  			VersionFlags: VerFlagNone,
   641  			Section:      0xD,
   642  			Value:        0x4003E0,
   643  			Size:         0x0,
   644  		},
   645  		Symbol{
   646  			Name:         "__gmon_start__",
   647  			Info:         0x20,
   648  			Other:        0x0,
   649  			VersionIndex: -1,
   650  			VersionFlags: VerFlagNone,
   651  			Section:      0x0,
   652  			Value:        0x0,
   653  			Size:         0x0,
   654  		},
   655  		Symbol{
   656  			Name:         "_Jv_RegisterClasses",
   657  			Info:         0x20,
   658  			Other:        0x0,
   659  			VersionIndex: -1,
   660  			VersionFlags: VerFlagNone,
   661  			Section:      0x0,
   662  			Value:        0x0,
   663  			Size:         0x0,
   664  		},
   665  		Symbol{
   666  			Name:         "puts@@GLIBC_2.2.5",
   667  			Info:         0x12,
   668  			Other:        0x0,
   669  			VersionIndex: -1,
   670  			VersionFlags: VerFlagNone,
   671  			Section:      0x0,
   672  			Value:        0x0,
   673  			Size:         0x18C,
   674  		},
   675  		Symbol{
   676  			Name:         "_fini",
   677  			Info:         0x12,
   678  			Other:        0x0,
   679  			VersionIndex: -1,
   680  			VersionFlags: VerFlagNone,
   681  			Section:      0xE,
   682  			Value:        0x400594,
   683  			Size:         0x0,
   684  		},
   685  		Symbol{
   686  			Name:         "__libc_start_main@@GLIBC_2.2.5",
   687  			Info:         0x12,
   688  			Other:        0x0,
   689  			VersionIndex: -1,
   690  			VersionFlags: VerFlagNone,
   691  			Section:      0x0,
   692  			Value:        0x0,
   693  			Size:         0x1C2,
   694  		},
   695  		Symbol{
   696  			Name:         "_IO_stdin_used",
   697  			Info:         0x11,
   698  			Other:        0x0,
   699  			VersionIndex: -1,
   700  			VersionFlags: VerFlagNone,
   701  			Section:      0xF,
   702  			Value:        0x4005A4,
   703  			Size:         0x4,
   704  		},
   705  		Symbol{
   706  			Name:         "__data_start",
   707  			Info:         0x10,
   708  			Other:        0x0,
   709  			VersionIndex: -1,
   710  			VersionFlags: VerFlagNone,
   711  			Section:      0x18,
   712  			Value:        0x600880,
   713  			Size:         0x0,
   714  		},
   715  		Symbol{
   716  			Name:         "__dso_handle",
   717  			Info:         0x11,
   718  			Other:        0x2,
   719  			VersionIndex: -1,
   720  			VersionFlags: VerFlagNone,
   721  			Section:      0x18,
   722  			Value:        0x600888,
   723  			Size:         0x0,
   724  		},
   725  		Symbol{
   726  			Name:         "__libc_csu_init",
   727  			Info:         0x12,
   728  			Other:        0x0,
   729  			VersionIndex: -1,
   730  			VersionFlags: VerFlagNone,
   731  			Section:      0xD,
   732  			Value:        0x4004D0,
   733  			Size:         0x89,
   734  		},
   735  		Symbol{
   736  			Name:         "__bss_start",
   737  			Info:         0x10,
   738  			Other:        0x0,
   739  			VersionIndex: -1,
   740  			VersionFlags: VerFlagNone,
   741  			Section:      0xFFF1,
   742  			Value:        0x600898,
   743  			Size:         0x0,
   744  		},
   745  		Symbol{
   746  			Name:         "_end",
   747  			Info:         0x10,
   748  			Other:        0x0,
   749  			VersionIndex: -1,
   750  			VersionFlags: VerFlagNone,
   751  			Section:      0xFFF1,
   752  			Value:        0x6008A0,
   753  			Size:         0x0,
   754  		},
   755  		Symbol{
   756  			Name:         "_edata",
   757  			Info:         0x10,
   758  			Other:        0x0,
   759  			VersionIndex: -1,
   760  			VersionFlags: VerFlagNone,
   761  			Section:      0xFFF1,
   762  			Value:        0x600898,
   763  			Size:         0x0,
   764  		},
   765  		Symbol{
   766  			Name:         "main",
   767  			Info:         0x12,
   768  			Other:        0x0,
   769  			VersionIndex: -1,
   770  			VersionFlags: VerFlagNone,
   771  			Section:      0xD,
   772  			Value:        0x400498,
   773  			Size:         0x1B,
   774  		},
   775  		Symbol{
   776  			Name:         "_init",
   777  			Info:         0x12,
   778  			Other:        0x0,
   779  			VersionIndex: -1,
   780  			VersionFlags: VerFlagNone,
   781  			Section:      0xB,
   782  			Value:        0x400398,
   783  			Size:         0x0,
   784  		},
   785  	},
   786  	"testdata/go-relocation-test-clang-x86.obj": {
   787  		Symbol{
   788  			Name:         "go-relocation-test-clang.c",
   789  			Info:         0x4,
   790  			Other:        0x0,
   791  			VersionIndex: -1,
   792  			VersionFlags: VerFlagNone,
   793  			Section:      0xFFF1,
   794  			Value:        0x0,
   795  			Size:         0x0,
   796  		},
   797  		Symbol{
   798  			Name:         ".Linfo_string0",
   799  			Info:         0x0,
   800  			Other:        0x0,
   801  			VersionIndex: -1,
   802  			VersionFlags: VerFlagNone,
   803  			Section:      0xC,
   804  			Value:        0x0,
   805  			Size:         0x0,
   806  		},
   807  		Symbol{
   808  			Name:         ".Linfo_string1",
   809  			Info:         0x0,
   810  			Other:        0x0,
   811  			VersionIndex: -1,
   812  			VersionFlags: VerFlagNone,
   813  			Section:      0xC,
   814  			Value:        0x2C,
   815  			Size:         0x0,
   816  		},
   817  		Symbol{
   818  			Name:         ".Linfo_string2",
   819  			Info:         0x0,
   820  			Other:        0x0,
   821  			VersionIndex: -1,
   822  			VersionFlags: VerFlagNone,
   823  			Section:      0xC,
   824  			Value:        0x47,
   825  			Size:         0x0,
   826  		},
   827  		Symbol{
   828  			Name:         ".Linfo_string3",
   829  			Info:         0x0,
   830  			Other:        0x0,
   831  			VersionIndex: -1,
   832  			VersionFlags: VerFlagNone,
   833  			Section:      0xC,
   834  			Value:        0x4C,
   835  			Size:         0x0,
   836  		},
   837  		Symbol{
   838  			Name:         ".Linfo_string4",
   839  			Info:         0x0,
   840  			Other:        0x0,
   841  			VersionIndex: -1,
   842  			VersionFlags: VerFlagNone,
   843  			Section:      0xC,
   844  			Value:        0x4E,
   845  			Size:         0x0,
   846  		},
   847  		Symbol{
   848  			Name:         "",
   849  			Info:         0x3,
   850  			Other:        0x0,
   851  			VersionIndex: -1,
   852  			VersionFlags: VerFlagNone,
   853  			Section:      0x1,
   854  			Value:        0x0,
   855  			Size:         0x0,
   856  		},
   857  		Symbol{
   858  			Name:         "",
   859  			Info:         0x3,
   860  			Other:        0x0,
   861  			VersionIndex: -1,
   862  			VersionFlags: VerFlagNone,
   863  			Section:      0x2,
   864  			Value:        0x0,
   865  			Size:         0x0,
   866  		},
   867  		Symbol{
   868  			Name:         "",
   869  			Info:         0x3,
   870  			Other:        0x0,
   871  			VersionIndex: -1,
   872  			VersionFlags: VerFlagNone,
   873  			Section:      0x3,
   874  			Value:        0x0,
   875  			Size:         0x0,
   876  		},
   877  		Symbol{
   878  			Name:         "",
   879  			Info:         0x3,
   880  			Other:        0x0,
   881  			VersionIndex: -1,
   882  			VersionFlags: VerFlagNone,
   883  			Section:      0x4,
   884  			Value:        0x0,
   885  			Size:         0x0,
   886  		},
   887  		Symbol{
   888  			Name:         "",
   889  			Info:         0x3,
   890  			Other:        0x0,
   891  			VersionIndex: -1,
   892  			VersionFlags: VerFlagNone,
   893  			Section:      0x6,
   894  			Value:        0x0,
   895  			Size:         0x0,
   896  		},
   897  		Symbol{
   898  			Name:         "",
   899  			Info:         0x3,
   900  			Other:        0x0,
   901  			VersionIndex: -1,
   902  			VersionFlags: VerFlagNone,
   903  			Section:      0x7,
   904  			Value:        0x0,
   905  			Size:         0x0,
   906  		},
   907  		Symbol{
   908  			Name:         "",
   909  			Info:         0x3,
   910  			Other:        0x0,
   911  			VersionIndex: -1,
   912  			VersionFlags: VerFlagNone,
   913  			Section:      0x8,
   914  			Value:        0x0,
   915  			Size:         0x0,
   916  		},
   917  		Symbol{
   918  			Name:         "",
   919  			Info:         0x3,
   920  			Other:        0x0,
   921  			VersionIndex: -1,
   922  			VersionFlags: VerFlagNone,
   923  			Section:      0xA,
   924  			Value:        0x0,
   925  			Size:         0x0,
   926  		},
   927  		Symbol{
   928  			Name:         "",
   929  			Info:         0x3,
   930  			Other:        0x0,
   931  			VersionIndex: -1,
   932  			VersionFlags: VerFlagNone,
   933  			Section:      0xC,
   934  			Value:        0x0,
   935  			Size:         0x0,
   936  		},
   937  		Symbol{
   938  			Name:         "",
   939  			Info:         0x3,
   940  			Other:        0x0,
   941  			VersionIndex: -1,
   942  			VersionFlags: VerFlagNone,
   943  			Section:      0xD,
   944  			Value:        0x0,
   945  			Size:         0x0,
   946  		},
   947  		Symbol{
   948  			Name:         "",
   949  			Info:         0x3,
   950  			Other:        0x0,
   951  			VersionIndex: -1,
   952  			VersionFlags: VerFlagNone,
   953  			Section:      0xE,
   954  			Value:        0x0,
   955  			Size:         0x0,
   956  		},
   957  		Symbol{
   958  			Name:         "",
   959  			Info:         0x3,
   960  			Other:        0x0,
   961  			VersionIndex: -1,
   962  			VersionFlags: VerFlagNone,
   963  			Section:      0xF,
   964  			Value:        0x0,
   965  			Size:         0x0,
   966  		},
   967  		Symbol{
   968  			Name:         "",
   969  			Info:         0x3,
   970  			Other:        0x0,
   971  			VersionIndex: -1,
   972  			VersionFlags: VerFlagNone,
   973  			Section:      0x10,
   974  			Value:        0x0,
   975  			Size:         0x0,
   976  		},
   977  		Symbol{
   978  			Name:         "v",
   979  			Info:         0x11,
   980  			Other:        0x0,
   981  			VersionIndex: -1,
   982  			VersionFlags: VerFlagNone,
   983  			Section:      0xFFF2,
   984  			Value:        0x4,
   985  			Size:         0x4,
   986  		},
   987  	},
   988  	"testdata/hello-world-core.gz": {},
   989  }
   990  
   991  var dynamicSymbolsGolden = map[string][]Symbol{
   992  	"testdata/gcc-amd64-linux-exec": {
   993  		Symbol{
   994  			Name:         "__gmon_start__",
   995  			Info:         0x20,
   996  			Other:        0x0,
   997  			VersionIndex: 0x0,
   998  			VersionFlags: VerFlagLocal,
   999  			Section:      0x0,
  1000  			Value:        0x0,
  1001  			Size:         0x0,
  1002  		},
  1003  		Symbol{
  1004  			Name:         "puts",
  1005  			Info:         0x12,
  1006  			Other:        0x0,
  1007  			VersionIndex: 0x2,
  1008  			VersionFlags: VerFlagHidden,
  1009  			Section:      0x0,
  1010  			Value:        0x0,
  1011  			Size:         0x18C,
  1012  			Version:      "GLIBC_2.2.5",
  1013  			Library:      "libc.so.6",
  1014  		},
  1015  		Symbol{
  1016  			Name:         "__libc_start_main",
  1017  			Info:         0x12,
  1018  			Other:        0x0,
  1019  			VersionIndex: 0x2,
  1020  			VersionFlags: VerFlagHidden,
  1021  			Section:      0x0,
  1022  			Value:        0x0,
  1023  			Size:         0x1C2,
  1024  			Version:      "GLIBC_2.2.5",
  1025  			Library:      "libc.so.6",
  1026  		},
  1027  	},
  1028  	"testdata/go-relocation-test-clang-x86.obj": {},
  1029  	"testdata/hello-world-core.gz":              {},
  1030  	"testdata/libtiffxx.so_": {
  1031  		Symbol{
  1032  			Name:         "_ZNSo3putEc",
  1033  			Info:         0x12,
  1034  			Other:        0x0,
  1035  			VersionIndex: 0x3,
  1036  			VersionFlags: VerFlagHidden,
  1037  			Section:      0x0,
  1038  			Value:        0x0,
  1039  			Size:         0x0,
  1040  			Version:      "GLIBCXX_3.4",
  1041  			Library:      "libstdc++.so.6",
  1042  		},
  1043  		Symbol{
  1044  			Name:         "strchr",
  1045  			Info:         0x12,
  1046  			Other:        0x0,
  1047  			VersionIndex: 0x4,
  1048  			VersionFlags: VerFlagHidden,
  1049  			Section:      0x0,
  1050  			Value:        0x0,
  1051  			Size:         0x0,
  1052  			Version:      "GLIBC_2.2.5",
  1053  			Library:      "libc.so.6",
  1054  		},
  1055  		Symbol{
  1056  			Name:         "__cxa_finalize",
  1057  			Info:         0x22,
  1058  			Other:        0x0,
  1059  			VersionIndex: 0x4,
  1060  			VersionFlags: VerFlagHidden,
  1061  			Section:      0x0,
  1062  			Value:        0x0,
  1063  			Size:         0x0,
  1064  			Version:      "GLIBC_2.2.5",
  1065  			Library:      "libc.so.6",
  1066  		},
  1067  		Symbol{
  1068  			Name:         "_ZNSo5tellpEv",
  1069  			Info:         0x12,
  1070  			Other:        0x0,
  1071  			VersionIndex: 0x3,
  1072  			VersionFlags: VerFlagHidden,
  1073  			Section:      0x0,
  1074  			Value:        0x0,
  1075  			Size:         0x0,
  1076  			Version:      "GLIBCXX_3.4",
  1077  			Library:      "libstdc++.so.6",
  1078  		},
  1079  		Symbol{
  1080  			Name:         "_ZNSo5seekpElSt12_Ios_Seekdir",
  1081  			Info:         0x12,
  1082  			Other:        0x0,
  1083  			VersionIndex: 0x3,
  1084  			VersionFlags: VerFlagHidden,
  1085  			Section:      0x0,
  1086  			Value:        0x0,
  1087  			Size:         0x0,
  1088  			Version:      "GLIBCXX_3.4",
  1089  			Library:      "libstdc++.so.6",
  1090  		},
  1091  		Symbol{
  1092  			Name:         "_Znwm",
  1093  			Info:         0x12,
  1094  			Other:        0x0,
  1095  			VersionIndex: 0x3,
  1096  			VersionFlags: VerFlagHidden,
  1097  			Section:      0x0,
  1098  			Value:        0x0,
  1099  			Size:         0x0,
  1100  			Version:      "GLIBCXX_3.4",
  1101  			Library:      "libstdc++.so.6",
  1102  		},
  1103  		Symbol{
  1104  			Name:         "_ZdlPvm",
  1105  			Info:         0x12,
  1106  			Other:        0x0,
  1107  			VersionIndex: 0x5,
  1108  			VersionFlags: VerFlagHidden,
  1109  			Section:      0x0,
  1110  			Value:        0x0,
  1111  			Size:         0x0,
  1112  			Version:      "CXXABI_1.3.9",
  1113  			Library:      "libstdc++.so.6",
  1114  		},
  1115  		Symbol{
  1116  			Name:         "__stack_chk_fail",
  1117  			Info:         0x12,
  1118  			Other:        0x0,
  1119  			VersionIndex: 0x6,
  1120  			VersionFlags: VerFlagHidden,
  1121  			Section:      0x0,
  1122  			Value:        0x0,
  1123  			Size:         0x0,
  1124  			Version:      "GLIBC_2.4",
  1125  			Library:      "libc.so.6",
  1126  		},
  1127  		Symbol{
  1128  			Name:         "_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l",
  1129  			Info:         0x12,
  1130  			Other:        0x0,
  1131  			VersionIndex: 0x7,
  1132  			VersionFlags: VerFlagHidden,
  1133  			Section:      0x0,
  1134  			Value:        0x0,
  1135  			Size:         0x0,
  1136  			Version:      "GLIBCXX_3.4.9",
  1137  			Library:      "libstdc++.so.6",
  1138  		},
  1139  		Symbol{
  1140  			Name:         "_ZNSo5seekpESt4fposI11__mbstate_tE",
  1141  			Info:         0x12,
  1142  			Other:        0x0,
  1143  			VersionIndex: 0x3,
  1144  			VersionFlags: VerFlagHidden,
  1145  			Section:      0x0,
  1146  			Value:        0x0,
  1147  			Size:         0x0,
  1148  			Version:      "GLIBCXX_3.4",
  1149  			Library:      "libstdc++.so.6",
  1150  		},
  1151  		Symbol{
  1152  			Name:         "_ZNSi4readEPcl",
  1153  			Info:         0x12,
  1154  			Other:        0x0,
  1155  			VersionIndex: 0x3,
  1156  			VersionFlags: VerFlagHidden,
  1157  			Section:      0x0,
  1158  			Value:        0x0,
  1159  			Size:         0x0,
  1160  			Version:      "GLIBCXX_3.4",
  1161  			Library:      "libstdc++.so.6",
  1162  		},
  1163  		Symbol{
  1164  			Name:         "_ZNSi5seekgESt4fposI11__mbstate_tE",
  1165  			Info:         0x12,
  1166  			Other:        0x0,
  1167  			VersionIndex: 0x3,
  1168  			VersionFlags: VerFlagHidden,
  1169  			Section:      0x0,
  1170  			Value:        0x0,
  1171  			Size:         0x0,
  1172  			Version:      "GLIBCXX_3.4",
  1173  			Library:      "libstdc++.so.6",
  1174  		},
  1175  		Symbol{
  1176  			Name:         "_ZNSo5writeEPKcl",
  1177  			Info:         0x12,
  1178  			Other:        0x0,
  1179  			VersionIndex: 0x3,
  1180  			VersionFlags: VerFlagHidden,
  1181  			Section:      0x0,
  1182  			Value:        0x0,
  1183  			Size:         0x0,
  1184  			Version:      "GLIBCXX_3.4",
  1185  			Library:      "libstdc++.so.6",
  1186  		},
  1187  		Symbol{
  1188  			Name:         "_ZNSi5seekgElSt12_Ios_Seekdir",
  1189  			Info:         0x12,
  1190  			Other:        0x0,
  1191  			VersionIndex: 0x3,
  1192  			VersionFlags: VerFlagHidden,
  1193  			Section:      0x0,
  1194  			Value:        0x0,
  1195  			Size:         0x0,
  1196  			Version:      "GLIBCXX_3.4",
  1197  			Library:      "libstdc++.so.6",
  1198  		},
  1199  		Symbol{
  1200  			Name:         "_ZSt21ios_base_library_initv",
  1201  			Info:         0x12,
  1202  			Other:        0x0,
  1203  			VersionIndex: 0x8,
  1204  			VersionFlags: VerFlagHidden,
  1205  			Section:      0x0,
  1206  			Value:        0x0,
  1207  			Size:         0x0,
  1208  			Version:      "GLIBCXX_3.4.32",
  1209  			Library:      "libstdc++.so.6",
  1210  		},
  1211  		Symbol{
  1212  			Name:         "TIFFClientOpen",
  1213  			Info:         0x12,
  1214  			Other:        0x0,
  1215  			VersionIndex: 0x9,
  1216  			VersionFlags: VerFlagHidden,
  1217  			Section:      0x0,
  1218  			Value:        0x0,
  1219  			Size:         0x0,
  1220  			Version:      "LIBTIFF_4.0",
  1221  			Library:      "libtiff.so.6",
  1222  		},
  1223  		Symbol{
  1224  			Name:         "_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate",
  1225  			Info:         0x12,
  1226  			Other:        0x0,
  1227  			VersionIndex: 0x3,
  1228  			VersionFlags: VerFlagHidden,
  1229  			Section:      0x0,
  1230  			Value:        0x0,
  1231  			Size:         0x0,
  1232  			Version:      "GLIBCXX_3.4",
  1233  			Library:      "libstdc++.so.6",
  1234  		},
  1235  		Symbol{
  1236  			Name:         "_ZNSi5tellgEv",
  1237  			Info:         0x12,
  1238  			Other:        0x0,
  1239  			VersionIndex: 0x3,
  1240  			VersionFlags: VerFlagHidden,
  1241  			Section:      0x0,
  1242  			Value:        0x0,
  1243  			Size:         0x0,
  1244  			Version:      "GLIBCXX_3.4",
  1245  			Library:      "libstdc++.so.6",
  1246  		},
  1247  		Symbol{
  1248  			Name:         "_ITM_deregisterTMCloneTable",
  1249  			Info:         0x20,
  1250  			Other:        0x0,
  1251  			VersionIndex: 0x1,
  1252  			VersionFlags: VerFlagGlobal,
  1253  			Section:      0x0,
  1254  			Value:        0x0,
  1255  			Size:         0x0,
  1256  		},
  1257  		Symbol{
  1258  			Name:         "__gmon_start__",
  1259  			Info:         0x20,
  1260  			Other:        0x0,
  1261  			VersionIndex: 0x1,
  1262  			VersionFlags: VerFlagGlobal,
  1263  			Section:      0x0,
  1264  			Value:        0x0,
  1265  			Size:         0x0,
  1266  		},
  1267  		Symbol{
  1268  			Name:         "_ITM_registerTMCloneTable",
  1269  			Info:         0x20,
  1270  			Other:        0x0,
  1271  			VersionIndex: 0x1,
  1272  			VersionFlags: VerFlagGlobal,
  1273  			Section:      0x0,
  1274  			Value:        0x0,
  1275  			Size:         0x0,
  1276  		},
  1277  		Symbol{
  1278  			Name:         "LIBTIFFXX_4.0",
  1279  			Info:         0x11,
  1280  			Other:        0x0,
  1281  			VersionIndex: 0x2,
  1282  			VersionFlags: VerFlagNone,
  1283  			Section:      0xFFF1,
  1284  			Value:        0x0,
  1285  			Size:         0x0,
  1286  			Version:      "LIBTIFFXX_4.0",
  1287  			Library:      "",
  1288  		},
  1289  		Symbol{
  1290  			Name:         "_Z14TIFFStreamOpenPKcPSo",
  1291  			Info:         0x12,
  1292  			Other:        0x0,
  1293  			VersionIndex: 0x2,
  1294  			VersionFlags: VerFlagNone,
  1295  			Section:      0xF,
  1296  			Value:        0x1860,
  1297  			Size:         0xB8,
  1298  			Version:      "LIBTIFFXX_4.0",
  1299  			Library:      "",
  1300  		},
  1301  		Symbol{
  1302  			Name:         "_Z14TIFFStreamOpenPKcPSi",
  1303  			Info:         0x12,
  1304  			Other:        0x0,
  1305  			VersionIndex: 0x2,
  1306  			VersionFlags: VerFlagNone,
  1307  			Section:      0xF,
  1308  			Value:        0x1920,
  1309  			Size:         0x13,
  1310  			Version:      "LIBTIFFXX_4.0",
  1311  			Library:      "",
  1312  		},
  1313  	},
  1314  }
  1315  

View as plain text