• Adrian Hunter's avatar
    perf test: Add Symbols test · 1b69346e
    Adrian Hunter authored
    Add a test to check function symbols do not overlap and are not zero
    length.
    
    The main motivation for the test is to make it easier to review changes
    to PLT symbol synthesis i.e. changes to dso__synthesize_plt_symbols().
    
    By default the test uses the perf executable as a test DSO, but a
    specific DSO can be specified via a new perf test option "--dso".
    
    The test is useful in the following ways:
    
     - Any DSO can be tested, even ones that do not run on the current
     architecture. For example, using cross-compiled DSOs to see how
     well perf handles different architectures.
    
     - With verbose > 1 (e.g. -vv), all the symbols are printed, which
     makes it easier to see issues.
    
     - perf removes duplicate symbols and expands zero-length symbols
     to reach the next symbol, however that is done before adding
     synthesized symbols, so the test is checking those also.
    
    Example:
    
      $ perf test -v Symbols
       74: Symbols                                                         :
      --- start ---
      test child forked, pid 154918
      Testing /home/user/bin/perf
      Overlapping symbols:
       7d000-7f3a0 g _init
       7d030-7d040 g __printf_chk@plt
      test child finished with -1
      ---- end ----
      Symbols: FAILED!
    
    Note the test fails because perf expands the _init symbol over the PLT
    because there are no PLT symbols at that point, but then
    dso__synthesize_plt_symbols() creates them.
    Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
    Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Acked-by: default avatarIan Rogers <irogers@google.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Link: https://lore.kernel.org/r/20230120123456.12449-2-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    1b69346e
symbols.c 3 KB