dwarf_loader: Check .notes section for LTO build info

In [1], linux introduced a note with type BUILD_COMPILER_LTO_INFO.  If
this note type exist, there is no need to scan .debug_abbrev section for
cross-cu reference. With a kernel built with [1], the cus__merging_cu()
overhead is about 3us for either LTO or non-LTO vmlinux.

 [1] https://lore.kernel.org/bpf/20210401012406.1800957-1-yhs@fb.com/

Committer testing:

Using a thin-LTO built vmlinux that doesn't have the
LINUX_ELFNOTE_BUILD_LTO note:

  $ readelf --notes vmlinux.clang.thin.LTO

  Displaying notes found in: .notes
    Owner                Data size 	Description
    Xen                  0x00000006	Unknown note type: (0x00000006)
     description data: 6c 69 6e 75 78 00
    Xen                  0x00000004	Unknown note type: (0x00000007)
     description data: 32 2e 36 00
    Xen                  0x00000008	Unknown note type: (0x00000005)
     description data: 78 65 6e 2d 33 2e 30 00
    Xen                  0x00000008	Unknown note type: (0x00000003)
     description data: 00 00 00 80 ff ff ff ff
    Xen                  0x00000008	Unknown note type: (0x0000000f)
     description data: 00 00 00 00 80 00 00 00
    Xen                  0x00000008	NT_VERSION (version)
     description data: c0 e1 33 83 ff ff ff ff
    Xen                  0x00000008	NT_ARCH (architecture)
     description data: 00 20 00 81 ff ff ff ff
    Xen                  0x00000029	Unknown note type: (0x0000000a)
     description data: 21 77 72 69 74 61 62 6c 65 5f 70 61 67 65 5f 74 61 62 6c 65 73 7c 70 61 65 5f 70 67 64 69 72 5f 61 62 6f 76 65 5f 34 67 62
    Xen                  0x00000004	Unknown note type: (0x00000011)
     description data: 01 88 00 00
    Xen                  0x00000004	Unknown note type: (0x00000009)
     description data: 79 65 73 00
    Xen                  0x00000008	Unknown note type: (0x00000008)
     description data: 67 65 6e 65 72 69 63 00
    Xen                  0x00000010	Unknown note type: (0x0000000d)
     description data: 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
    Xen                  0x00000004	Unknown note type: (0x0000000e)
     description data: 01 00 00 00
    Xen                  0x00000004	Unknown note type: (0x00000010)
     description data: 01 00 00 00
    Xen                  0x00000008	Unknown note type: (0x0000000c)
     description data: 00 00 00 00 00 80 ff ff
    Xen                  0x00000008	Unknown note type: (0x00000004)
     description data: 00 00 00 00 00 00 00 00
    Xen                  0x00000008	Unknown note type: (0x00000012)
     description data: e0 02 00 01 00 00 00 00
    Linux                0x00000017	OPEN
     description data: 34 2e 31 39 2e 34 2d 33 30 30 2e 66 63 32 39 2e 78 38 36 5f 36 34 00
    GNU                  0x00000014	NT_GNU_BUILD_ID (unique build ID bitstring)
      Build ID: 354f81317b1b3c35f3f81f8d9f04d0c8caccb09a
  $

Then with one with the new ELF note stating that this binary was built
with LTO:

  [acme@five pahole]$ readelf --notes vmlinux.clang.thin.LTO+ELF_note

  Displaying notes found in: .notes
    Owner                Data size 	Description
    Xen                  0x00000006	Unknown note type: (0x00000006)
     description data: 6c 69 6e 75 78 00
    Xen                  0x00000004	Unknown note type: (0x00000007)
     description data: 32 2e 36 00
    Xen                  0x00000008	Unknown note type: (0x00000005)
     description data: 78 65 6e 2d 33 2e 30 00
    Xen                  0x00000008	Unknown note type: (0x00000003)
     description data: 00 00 00 80 ff ff ff ff
    Xen                  0x00000008	Unknown note type: (0x0000000f)
     description data: 00 00 00 00 80 00 00 00
    Xen                  0x00000008	NT_VERSION (version)
     description data: c0 e1 33 83 ff ff ff ff
    Xen                  0x00000008	NT_ARCH (architecture)
     description data: 00 20 00 81 ff ff ff ff
    Xen                  0x00000029	Unknown note type: (0x0000000a)
     description data: 21 77 72 69 74 61 62 6c 65 5f 70 61 67 65 5f 74 61 62 6c 65 73 7c 70 61 65 5f 70 67 64 69 72 5f 61 62 6f 76 65 5f 34 67 62
    Xen                  0x00000004	Unknown note type: (0x00000011)
     description data: 01 88 00 00
    Xen                  0x00000004	Unknown note type: (0x00000009)
     description data: 79 65 73 00
    Xen                  0x00000008	Unknown note type: (0x00000008)
     description data: 67 65 6e 65 72 69 63 00
    Xen                  0x00000010	Unknown note type: (0x0000000d)
     description data: 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
    Xen                  0x00000004	Unknown note type: (0x0000000e)
     description data: 01 00 00 00
    Xen                  0x00000004	Unknown note type: (0x00000010)
     description data: 01 00 00 00
    Xen                  0x00000008	Unknown note type: (0x0000000c)
     description data: 00 00 00 00 00 80 ff ff
    Xen                  0x00000008	Unknown note type: (0x00000004)
     description data: 00 00 00 00 00 00 00 00
    Xen                  0x00000008	Unknown note type: (0x00000012)
     description data: e0 02 00 01 00 00 00 00
    Linux                0x00000017	OPEN
     description data: 34 2e 31 39 2e 34 2d 33 30 30 2e 66 63 32 39 2e 78 38 36 5f 36 34 00
    Linux                0x00000004	func
     description data: 01 00 00 00
    GNU                  0x00000014	NT_GNU_BUILD_ID (unique build ID bitstring)
      Build ID: aeba9ffc929acd3cd573b4d1afc8df9af4f3694d
  $

Now to see the diff:

  $ readelf --notes vmlinux.clang.thin.LTO+ELF_note > with-note
  $ readelf --notes vmlinux.clang.thin.LTO > without-note
  $ diff -u without-note with-note
  --- without-note	2021-04-02 10:23:57.545349084 -0300
  +++ with-note	2021-04-02 10:23:50.690196102 -0300
  @@ -37,5 +37,7 @@
      description data: e0 02 00 01 00 00 00 00
     Linux                0x00000017	OPEN
      description data: 34 2e 31 39 2e 34 2d 33 30 30 2e 66 63 32 39 2e 78 38 36 5f 36 34 00
  +  Linux                0x00000004	func
  +   description data: 01 00 00 00
     GNU                  0x00000014	NT_GNU_BUILD_ID (unique build ID bitstring)
  -    Build ID: 354f81317b1b3c35f3f81f8d9f04d0c8caccb09a
  +    Build ID: aeba9ffc929acd3cd573b4d1afc8df9af4f3694d
  $

Signed-off-by: Yonghong Song <yhs@fb.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Bill Wendling <morbo@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: David Blaikie <dblaikie@gmail.com>
Cc: Fāng-ruì Sòng <maskray@google.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Cc: kernel-team@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 file changed