[llvm] [llvm-gsymutil] Option --symtab-file to specify a separate binary (PR #79898)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 12:55:59 PST 2024


https://github.com/kusmour created https://github.com/llvm/llvm-project/pull/79898

Summary:
There are cases where separate debuginfo file only contains DWARF and symbol table exists in the executable. Offer a flag to specify a separate file for llvm-gsymutil to extract symbol table from.

NOTE: Not supporting this flag for `MachOUniversalBinary` yet, as dSYM usually contains both

Test Plan:
Added FileCheck tests
```
./bin/llvm-lit -sv llvm/test/tools/llvm-gsymutil/X86/elf-dwarf-only.yaml
./bin/llvm-lit -sv llvm/test/tools/llvm-gsymutil/X86/elf-symtab.yaml
```

>From 0393fd75800078c9040c49ede2b4e5ffd79e0c1a Mon Sep 17 00:00:00 2001
From: Wanyi Ye <wanyi at fb.com>
Date: Mon, 29 Jan 2024 12:08:08 -0800
Subject: [PATCH] [llvm-gsymutil] Option --symtab-file to specify a separate
 binary

Summary:
There are cases where separate debuginfo file only contains DWARF and symbol table exists in the executable.
Offer a flag to specify a separate file for llvm-gsymutil to extract symbol table from.

NOTE: Not supporting this flag for `MachOUniversalBinary` yet, as dSYM usually contains both

Test Plan:
Added FileCheck tests
```
./bin/llvm-lit -sv llvm/test/tools/llvm-gsymutil/X86/elf-dwarf-only.yaml
./bin/llvm-lit -sv llvm/test/tools/llvm-gsymutil/X86/elf-symtab.yaml
```
---
 .../llvm-gsymutil/X86/elf-dwarf-only.yaml     | 689 ++++++++++++++++++
 .../tools/llvm-gsymutil/X86/elf-symtab.yaml   | 654 +++++++++++++++++
 llvm/tools/llvm-gsymutil/Opts.td              |   3 +
 llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp    |  48 +-
 4 files changed, 1391 insertions(+), 3 deletions(-)
 create mode 100644 llvm/test/tools/llvm-gsymutil/X86/elf-dwarf-only.yaml
 create mode 100644 llvm/test/tools/llvm-gsymutil/X86/elf-symtab.yaml

diff --git a/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf-only.yaml b/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf-only.yaml
new file mode 100644
index 000000000000000..31d6ce4183aabc9
--- /dev/null
+++ b/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf-only.yaml
@@ -0,0 +1,689 @@
+## Test loading ELF files with only DWARF.
+## First we make the ELF file from yaml,
+## then we convert the ELF file to GSYM,
+## then we do lookups on the newly created .gsym
+
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-gsymutil --convert %t -o %t.gsym 2>&1 | FileCheck %s --check-prefix=CONVERT
+# RUN: llvm-gsymutil --address 0x00000000004011e0 %t.gsym | FileCheck %s --check-prefix=LOOKUP
+
+# CONVERT: Input file: {{.*\.yaml\.tmp}}
+# CONVERT: Output file (x86_64): {{.*\.yaml\.tmp\.gsym}}
+# CONVERT: Loaded 2 functions from DWARF.
+# CONVERT: Loaded 0 functions from symbol table.
+# CONVERT: Pruned 0 functions, ended with 2 total
+
+# LOOKUP: Looking up addresses in "{{.*\.yaml\.tmp\.gsym}}":
+# LOOKUP: 0x00000000004011e0: main @ /tmp/test_gsymutil/main.cpp
+
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_X86_64
+  Entry:           0x4010B0
+ProgramHeaders:
+  - Type:            PT_PHDR
+    Flags:           [ PF_R ]
+    VAddr:           0x400040
+    Align:           0x8
+  - Type:            PT_INTERP
+    Flags:           [ PF_R ]
+    FirstSec:        .interp
+    LastSec:         .interp
+    VAddr:           0x400318
+  - Type:            PT_LOAD
+    Flags:           [ PF_R ]
+    FirstSec:        .interp
+    LastSec:         .rela.plt
+    VAddr:           0x400000
+    Align:           0x1000
+  - Type:            PT_LOAD
+    Flags:           [ PF_X, PF_R ]
+    FirstSec:        .init
+    LastSec:         .fini
+    VAddr:           0x401000
+    Align:           0x1000
+  - Type:            PT_LOAD
+    Flags:           [ PF_R ]
+    FirstSec:        .rodata
+    LastSec:         .eh_frame
+    VAddr:           0x402000
+    Align:           0x1000
+  - Type:            PT_LOAD
+    Flags:           [ PF_W, PF_R ]
+    FirstSec:        .init_array
+    LastSec:         .bss
+    VAddr:           0x403DA8
+    Align:           0x1000
+  - Type:            PT_DYNAMIC
+    Flags:           [ PF_W, PF_R ]
+    FirstSec:        .dynamic
+    LastSec:         .dynamic
+    VAddr:           0x403DC0
+    Align:           0x8
+  - Type:            PT_NOTE
+    Flags:           [ PF_R ]
+    FirstSec:        .note.gnu.property
+    LastSec:         .note.gnu.property
+    VAddr:           0x400338
+    Align:           0x8
+  - Type:            PT_NOTE
+    Flags:           [ PF_R ]
+    FirstSec:        .note.gnu.build-id
+    LastSec:         .note.ABI-tag
+    VAddr:           0x400358
+    Align:           0x4
+  - Type:            PT_GNU_PROPERTY
+    Flags:           [ PF_R ]
+    FirstSec:        .note.gnu.property
+    LastSec:         .note.gnu.property
+    VAddr:           0x400338
+    Align:           0x8
+  - Type:            PT_GNU_EH_FRAME
+    Flags:           [ PF_R ]
+    FirstSec:        .eh_frame_hdr
+    LastSec:         .eh_frame_hdr
+    VAddr:           0x402034
+    Align:           0x4
+  - Type:            PT_GNU_STACK
+    Flags:           [ PF_W, PF_R ]
+    Align:           0x10
+  - Type:            PT_GNU_RELRO
+    Flags:           [ PF_R ]
+    FirstSec:        .init_array
+    LastSec:         .got
+    VAddr:           0x403DA8
+Sections:
+  - Name:            .interp
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x400318
+    AddressAlign:    0x1
+    Content:         2F6C696236342F6C642D6C696E75782D7838362D36342E736F2E3200
+  - Name:            .note.gnu.property
+    Type:            SHT_NOTE
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x400338
+    AddressAlign:    0x8
+    Notes:
+      - Name:            GNU
+        Desc:            028000C0040000000300000000000000
+        Type:            NT_GNU_PROPERTY_TYPE_0
+  - Name:            .note.gnu.build-id
+    Type:            SHT_NOTE
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x400358
+    AddressAlign:    0x4
+    Notes:
+      - Name:            GNU
+        Desc:            6E3474EA595AB65F323A92D034BA2EA01E807B91
+        Type:            NT_PRPSINFO
+  - Name:            .note.ABI-tag
+    Type:            SHT_NOTE
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x40037C
+    AddressAlign:    0x4
+    Notes:
+      - Name:            GNU
+        Desc:            '00000000030000000200000000000000'
+        Type:            NT_VERSION
+  - Name:            .gnu.hash
+    Type:            SHT_GNU_HASH
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x4003A0
+    Link:            .dynsym
+    AddressAlign:    0x8
+    Header:
+      SymNdx:          0xA
+      Shift2:          0x6
+    BloomFilter:     [ 0x10000100100000 ]
+    HashBuckets:     [ 0xA, 0x0 ]
+    HashValues:      [ 0x9F4FD20, 0x430C9815 ]
+  - Name:            .dynsym
+    Type:            SHT_DYNSYM
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x4003C8
+    Link:            .dynstr
+    AddressAlign:    0x8
+  - Name:            .dynstr
+    Type:            SHT_STRTAB
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x4004E8
+    AddressAlign:    0x1
+  - Name:            .gnu.version
+    Type:            SHT_GNU_versym
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x400660
+    Link:            .dynsym
+    AddressAlign:    0x2
+    Entries:         [ 0, 3, 4, 2, 2, 2, 1, 1, 1, 2, 2, 2 ]
+  - Name:            .gnu.version_r
+    Type:            SHT_GNU_verneed
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x400678
+    Link:            .dynstr
+    AddressAlign:    0x8
+    Dependencies:
+      - Version:         1
+        File:            libc.so.6
+        Entries:
+          - Name:            GLIBC_2.2.5
+            Hash:            157882997
+            Flags:           0
+            Other:           4
+          - Name:            GLIBC_2.34
+            Hash:            110530996
+            Flags:           0
+            Other:           3
+      - Version:         1
+        File:            'libstdc++.so.6'
+        Entries:
+          - Name:            GLIBCXX_3.4
+            Hash:            143796596
+            Flags:           0
+            Other:           2
+  - Name:            .rela.dyn
+    Type:            SHT_RELA
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x4006C8
+    Link:            .dynsym
+    AddressAlign:    0x8
+    Relocations:
+      - Offset:          0x403FC0
+        Symbol:          __libc_start_main
+        Type:            R_X86_64_GLOB_DAT
+      - Offset:          0x403FC8
+        Symbol:          _ITM_deregisterTMCloneTable
+        Type:            R_X86_64_GLOB_DAT
+      - Offset:          0x403FD0
+        Symbol:          __gmon_start__
+        Type:            R_X86_64_GLOB_DAT
+      - Offset:          0x403FD8
+        Symbol:          _ITM_registerTMCloneTable
+        Type:            R_X86_64_GLOB_DAT
+      - Offset:          0x403FE0
+        Symbol:          _ZNSt8ios_base4InitD1Ev
+        Type:            R_X86_64_GLOB_DAT
+      - Offset:          0x404040
+        Symbol:          _ZSt4cout
+        Type:            R_X86_64_COPY
+  - Name:            .rela.plt
+    Type:            SHT_RELA
+    Flags:           [ SHF_ALLOC, SHF_INFO_LINK ]
+    Address:         0x400758
+    Link:            .dynsym
+    AddressAlign:    0x8
+    Info:            .got.plt
+    Relocations:
+      - Offset:          0x404000
+        Symbol:          _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
+        Type:            R_X86_64_JUMP_SLOT
+      - Offset:          0x404008
+        Symbol:          __cxa_atexit
+        Type:            R_X86_64_JUMP_SLOT
+      - Offset:          0x404010
+        Symbol:          _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
+        Type:            R_X86_64_JUMP_SLOT
+      - Offset:          0x404018
+        Symbol:          _ZNSolsEPFRSoS_E
+        Type:            R_X86_64_JUMP_SLOT
+      - Offset:          0x404020
+        Symbol:          _ZNSt8ios_base4InitC1Ev
+        Type:            R_X86_64_JUMP_SLOT
+  - Name:            .init
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x401000
+    AddressAlign:    0x4
+    Offset:          0x1000
+    Content:         F30F1EFA4883EC08488B05C12F00004885C07402FFD04883C408C3
+  - Name:            .plt
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x401020
+    AddressAlign:    0x10
+    EntSize:         0x10
+    Content:         FF35CA2F0000FF25CC2F00000F1F4000FF25CA2F00006800000000E9E0FFFFFFFF25C22F00006801000000E9D0FFFFFFFF25BA2F00006802000000E9C0FFFFFFFF25B22F00006803000000E9B0FFFFFFFF25AA2F00006804000000E9A0FFFFFF
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x401080
+    AddressAlign:    0x10
+    Content:         F30F1EFA53488D1DC53000004889DFE8DCFFFFFF488B3D452F00004889DE5B488D15620F0000E995FFFFFF0F1F440000F30F1EFA31ED4989D15E4889E24883E4F050544531C031C948C7C7E0114000FF15EB2E0000F4662E0F1F840000000000F30F1EFAC3662E0F1F84000000000090488D3D392F0000488D05322F00004839F87415488B05BE2E00004885C07409FFE00F1F8000000000C30F1F8000000000488D3D092F0000488D35022F00004829FE4889F048C1EE3F48C1F8034801C648D1FE7414488B058D2E00004885C07408FFE0660F1F440000C30F1F8000000000F30F1EFA803DE52F0000007513554889E5E87AFFFFFFC605D32F0000015DC390C366662E0F1F8400000000000F1F4000F30F1EFAEB8A662E0F1F840000000000554889E548BF404040000000000048BE1020400000000000E893FEFFFF4889C748BE3010400000000000E891FEFFFF5DC36666666666662E0F1F840000000000554889E54883EC10C745FC0000000048BF404040000000000048BE1C20400000000000E848FEFFFF4889C748BE3010400000000000E846FEFFFFE881FFFFFF48BF404040000000000048BE2820400000000000E818FEFFFF4889C748BE3010400000000000E816FEFFFF31C04883C4105DC3662E0F1F8400000000000F1F4000F30F1EFAC3
+  - Name:            .fini
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x401268
+    AddressAlign:    0x4
+    Content:         F30F1EFA4883EC084883C408C3
+  - Name:            .rodata
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x402000
+    AddressAlign:    0x8
+    Offset:          0x2000
+    Content:         010002000000000000000000000000005468697320697320666F6F0068656C6C6F20776F726C6400616674657220666F6F00
+  - Name:            .eh_frame_hdr
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x402034
+    AddressAlign:    0x4
+    Content:         011B033B4000000007000000ECEFFFFF840000004CF0FFFF000100007CF0FFFF5C000000ACF0FFFF700000006CF1FFFFAC000000ACF1FFFFCC0000002CF2FFFFEC000000
+  - Name:            .eh_frame
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x402078
+    AddressAlign:    0x8
+    Content:         1400000000000000017A5200017810011B0C070890010000100000001C00000018F0FFFF2600000000440710100000003000000034F0FFFF0500000000000000240000004400000060EFFFFF60000000000E10460E184A0F0B770880003F1A3B2A332422000000001C0000006C000000B8F0FFFF3100000000410E108602430D066C0C07080000001C0000008C000000D8F0FFFF7200000000410E108602430D06026D0C0708000010000000AC00000038F1FFFF050000000000000018000000C000000044EFFFFF2B00000000450E1083025A0E0800000000000000
+  - Name:            .init_array
+    Type:            SHT_INIT_ARRAY
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x403DA8
+    AddressAlign:    0x8
+    EntSize:         0x8
+    Offset:          0x2DA8
+    Content:         '80104000000000009011400000000000'
+  - Name:            .fini_array
+    Type:            SHT_FINI_ARRAY
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x403DB8
+    AddressAlign:    0x8
+    EntSize:         0x8
+    Content:         '6011400000000000'
+  - Name:            .dynamic
+    Type:            SHT_DYNAMIC
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x403DC0
+    Link:            .dynstr
+    AddressAlign:    0x8
+    Entries:
+      - Tag:             DT_NEEDED
+        Value:           0x123
+      - Tag:             DT_NEEDED
+        Value:           0x132
+      - Tag:             DT_NEEDED
+        Value:           0x13C
+      - Tag:             DT_NEEDED
+        Value:           0x14A
+      - Tag:             DT_INIT
+        Value:           0x401000
+      - Tag:             DT_FINI
+        Value:           0x401268
+      - Tag:             DT_INIT_ARRAY
+        Value:           0x403DA8
+      - Tag:             DT_INIT_ARRAYSZ
+        Value:           0x10
+      - Tag:             DT_FINI_ARRAY
+        Value:           0x403DB8
+      - Tag:             DT_FINI_ARRAYSZ
+        Value:           0x8
+      - Tag:             DT_GNU_HASH
+        Value:           0x4003A0
+      - Tag:             DT_STRTAB
+        Value:           0x4004E8
+      - Tag:             DT_SYMTAB
+        Value:           0x4003C8
+      - Tag:             DT_STRSZ
+        Value:           0x177
+      - Tag:             DT_SYMENT
+        Value:           0x18
+      - Tag:             DT_DEBUG
+        Value:           0x0
+      - Tag:             DT_PLTGOT
+        Value:           0x403FE8
+      - Tag:             DT_PLTRELSZ
+        Value:           0x78
+      - Tag:             DT_PLTREL
+        Value:           0x7
+      - Tag:             DT_JMPREL
+        Value:           0x400758
+      - Tag:             DT_RELA
+        Value:           0x4006C8
+      - Tag:             DT_RELASZ
+        Value:           0x90
+      - Tag:             DT_RELAENT
+        Value:           0x18
+      - Tag:             DT_VERNEED
+        Value:           0x400678
+      - Tag:             DT_VERNEEDNUM
+        Value:           0x2
+      - Tag:             DT_VERSYM
+        Value:           0x400660
+      - Tag:             DT_NULL
+        Value:           0x0
+      - Tag:             DT_NULL
+        Value:           0x0
+      - Tag:             DT_NULL
+        Value:           0x0
+      - Tag:             DT_NULL
+        Value:           0x0
+      - Tag:             DT_NULL
+        Value:           0x0
+      - Tag:             DT_NULL
+        Value:           0x0
+  - Name:            .got
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x403FC0
+    AddressAlign:    0x8
+    EntSize:         0x8
+    Content:         '00000000000000000000000000000000000000000000000000000000000000000000000000000000'
+  - Name:            .got.plt
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x403FE8
+    AddressAlign:    0x8
+    EntSize:         0x8
+    Content:         C03D4000000000000000000000000000000000000000000036104000000000004610400000000000561040000000000066104000000000007610400000000000
+  - Name:            .data
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x404028
+    AddressAlign:    0x1
+    Content:         '00000000'
+  - Name:            .bss
+    Type:            SHT_NOBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x404040
+    AddressAlign:    0x40
+    Offset:          0x302C
+    Size:            0x118
+  - Name:            .comment
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_MERGE, SHF_STRINGS ]
+    AddressAlign:    0x1
+    EntSize:         0x1
+    Content:         4743433A2028474E55292031312E342E312032303233303630352028526564204861742031312E342E312D3229004743433A2028474E55292031332E322E312032303233313131302028526564204861742031332E322E312D352900636C616E672076657273696F6E2031372E302E31202843656E744F532031372E302E312D322E656C392900
+  - Name:            .gnu.build.attributes
+    Type:            SHT_NOTE
+    Address:         0x406158
+    AddressAlign:    0x4
+    Notes:
+      - Name:            "GA$\x013a1"
+        Desc:            B010400000000000D610400000000000
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            E510400000000000E510400000000000
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            '00104000000000001610400000000000'
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            '68124000000000007012400000000000'
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            F0104000000000009611400000000000
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            '65124000000000006512400000000000'
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            '65124000000000006512400000000000'
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            16104000000000001B10400000000000
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            '70124000000000007512400000000000'
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+  - Name:            .debug_info
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x1
+    Content:         1219000004000000000008010000000021002B0000000000000034000000A011400000000000B2000000023B000000010509031020400000000000034700000004530000000C00054C0000000602060000060107470000000807023B000000010909031C20400000000000027C000000010B09032820400000000000034700000004530000000A0008A011400000000000310000000156B2070000BA070000010409E011400000000000720000000156BE0700000108CC0600000A5B0000000B04407A0600000B048DE60600000B048FF10600000B0490030700000B04912A0700000B04925C0700000B0493730700000B0494990700000B0495B00700000B0496C80700000B0497E40700000B0498F60700000B0499020800000B049A440800000B049B650800000B049C810800000B049DAC0800000B049EC30800000B04A0D50800000B04A2F20800000B04A30E0900000B04A4250900000B04A6770900000B04A9970900000B04ACB80900000B04AED80900000B04B0EF0900000B04B20A0A00000B04B3300A00000B04B4460A00000B04B55C0A00000B04B6720A00000B04B7880A00000B04B89E0A00000B04B9D30A00000B04BAE40A00000B04BBFF0A00000B04BC1A0B00000B04BD350B00000B04BE600B00000B04BF760B00000B04C19E0B00000B04C3BC0B00000B04C4D70B00000B04C5FA0B00000B04C6160C00000B04C7310C00000B04C8430C00000B04C95F0C00000B04CA7B0C00000B04CB970C00000B04CCB30C00000B04CDC60C00000B04CEDD0C00000B04CFF30C00000B04D0090D00000B04D11F0D00000B04D2350D00000C040B01E90D00000C040C01070E00000C040D012A0E00000C041B019E0B00000C041E01770900000C042101B80900000C042401EF0900000C042801E90D00000C042901070E00000C042A012A0E00000A160300000D180300000B0955D40200000E74030000A803000009E60F4D0E00000F4D0E000000000B0942AA02000010260300006203000009510FAA020000000B09F3B60200000B0A35520E00000B0A36570E00000B0A376D0E00000B0D407D0E00000B0D418E0E00000B0D429F0E00000B0D43B00E00000B0D44C10E00000B0D45D20E00000B0D46E30E00000B0D47F40E00000B0D48050F00000B0D49160F00000B0D4A270F00000B0D4B380F00000B0D4C490F00000B0D575A0F000011450400000B1034780F00000B11838A0F00000B1184960F00000B1186BF0F00000B1188C70F00000B118ADE0F00000B118DF60F00000B1190081000000B1191191000000B11922A1000000B11933B1000000B1194881000000B11959F1000000B1196B61000000B1197C41000000B1198D21000000B1199E41000000B119AF61000000B119B0D1100000B119D1F1100000B119E361100000B119F521100000B11A16E1100000B11A48B1100000B11A7991100000B11A8A51100000B11A9BC1100000B11AACA1100000B11ABEA1100000B11AC051200000B11AD201200000B11AF321200000B11B04E1200000B11F4651200000B11F68E1200000B11F89C1200000B11F9AB0D00000B11FAAE1200000B11FCC51200000B11FD0C1300000B11FED61200000B11FFF11200000C110001221300000B1362381300000B1363431300000B13655E1300000B1366711300000B1367821300000B1368941300000B1369A61300000B136AB71300000B136BC91300000B136CEF1300000B136D0B1400000B136E211400000B136F391400000B1370501400000B1371671400000B13728D1400000B1373A91400000B1374C51400000B1375E11400000B1376021500000B1377141500000B13783A1500000B13794C1500000B137E581500000B137F661500000B1380791500000B1381901500000B1382A21500000B1383B41500000B1384C51500000B1385DB1500000B1386E91500000B1387001600000B1388131600000B1389341600000B138A4C1600000B138B681600000B138D731600000B138F841600000B13909B1600000B1391B71600000B1392CE1600000B13B9EA1600000B13BA071700000B13BB271700000B13BC421700000B13BD631700000B173A831700000B1A52AE1700000B1A53CE1700000B1A54E60600000B1A56D91700000B1A57EA1700000B1A59FB1700000B1A5B0C1800000B1A5C1D1800000B1A5D331800000B1A5E441800000B1A5F551800000B1A60661800000B1A61771800000B1A62881800000B1A63991800000B1A64AA1800000B1A65BB1800000B1A66D11800000B1A67E21800000B1A68F31800000B1A69041900000012850600008B00000003061290060000890000000215130508020D145F000000CC060000020F001467000000AD0600000214041505040210146F000000D30600000212001482000000DA0600000213000000067E000000050406750000000704034C0000000453000000040012D306000095000000051416CE040000061D01E60600000FCC06000000169C00000006E802E60600000F1507000000171A0700001225070000AC000000070518A300000016B3000000060503460700000F520700000FCC0600000F5707000000174B07000006BA00000005041946070000191507000016C200000006F602E60600000F4B0700000F150700000016C9000000060C03CC0600000F8A0700000F5707000000198F0700001794070000054B07000016D0000000064C02CC0600000F150700000FCC060000001649010000065302CC0600000F570700000F8A0700001A001BD6000000DF000000069102CC0600000F570700000F8A0700001A00169D00000006E902E60600000F15070000001CE700000006EF02E606000016F00000000634011E0800000F300800000F1E0800000F3A08000000122908000005010000082E06F7000000070819350800001747000000193F080000177A060000160C0100000629011E0800000F520700000F300800000F1E0800000F3A080000001614010000062501CC0600000F7708000000177C080000057A060000161C0100000652011E0800000F520700000FA20800000F1E0800000F3A0800000019A7080000173508000016C300000006F702E60600000F4B0700000F1507000000162601000006FD02E60600000F4B0700000016A7010000065D02CC0600000F520700000F1E0800000F8A0700001A001B2F01000038010000069802CC0600000F8A0700000F8A0700001A001640010000061403E60600000FE60600000F15070000001648010000066502CC0600000F570700000F8A0700000F410900000017460900001D0586010000181E52010000D3060000001E5C010000D3060000041E6601000076090000081E780100007609000010001F1B940100009D01000006C702CC0600000F570700000F8A0700000F410900000016A6010000067202CC0600000F520700000F1E0800000F8A0700000F41090000001BB0010000B901000006CE02CC0600000F8A0700000F8A0700000F410900000016C2010000066D02CC0600000F8A0700000F41090000001BCB010000D401000006CB02CC0600000F8A0700000F410900000016DC010000062E011E0800000F260A00000F4B0700000F3A08000000192B0A0000174C00000020E40100000661460700000F520700000F8A0700000020EB010000066ACC0600000F8F0700000F8F0700000020F20100000683CC0600000F8F0700000F8F0700000020FA0100000657460700000F520700000F8A07000000200102000006BC1E0800000F8F0700000F8F0700000016090200000654031E0800000F520700000F1E0800000F8A0700000FBF0A00000019C40A000017C90A000005CE0A00001812020000201502000006DF1E0800000F8F07000000201C0200000665460700000F520700000F8A0700000F1E080000002024020000066DCC0600000F8F0700000F8F0700000F1E08000000202C020000065C460700000F520700000F8A0700000F1E0800000016340200000658011E0800000F260A00000F560B00000F1E0800000F3A08000000195B0B0000178F070000203E02000006C01E0800000F8F0700000F8F070000001645020000067A018D0B00000F8A0700000F940B00000006EB020000040819990B00001746070000164C020000067F01B50B00000F8A0700000F940B00000006530200000404205902000006DA460700000F520700000F8A0700000F940B000000166002000006AD01F30B00000F8A0700000F940B00000FCC0600000006000100000508166702000006B201290800000F8A0700000F940B00000FCC06000000206F02000006871E0800000F520700000F8A0700000F1E080000001677020000062101CC0600000FE606000000167D020000060301CC0600000F8F0700000F8F0700000F1E080000001685020000060701460700000F520700000F8A0700000F1E08000000168D020000060C01460700000F460700000F8F0700000F1E080000001696020000061001460700000F460700000F4B0700000F1E08000000164A010000065A02CC0600000F8A0700001A001B9E020000A7020000069502CC0600000F8A0700001A0020AE02000006A5460700000F8F0700000F4B0700000020B502000006CA460700000F8F0700000F8F0700000020BD02000006AF460700000F8F0700000F4B0700000020C502000006D5460700000F8F0700000F8F0700000020CC02000006FE460700000F8F0700000F4B0700000F1E080000000AD40200000B04FBE90D00000C040401070E00000C0405012A0E00000B11CC651200000B11D28E1200000B11D69C1200000B11DCAE1200000B11E7C51200000B11E8D61200000B11E9F11200000B11EB0C1300000B11EC2213000021550500002B05000011D9651200000F230E00000F230E0000000B13AFEA1600000B13B0071700000B13B1271700000B13B2421700000B13B3631700000016DE020000068101000E00000F8A0700000F940B00000006E6020000041016F202000006BA01230E00000F8A0700000F940B00000FCC06000000060C030000050816FA02000006C101460E00000F8A0700000F940B00000FCC060000000603030000070822AA02000018AD03000020B30300000B7A2B0A00000FCC0600000F350800000023BD0300000B7D780E000017520E000020C80300000C6CCC0600000FCC0600000020D00300000C6DCC0600000FCC0600000020D80300000C6ECC0600000FCC0600000020E00300000C6FCC0600000FCC0600000020E80300000C71CC0600000FCC0600000020F00300000C70CC0600000FCC0600000020F80300000C72CC0600000FCC0600000020000400000C73CC0600000FCC0600000020080400000C74CC0600000FCC0600000020100400000C75CC0600000FCC0600000020180400000C76CC0600000FCC0600000020210400000C7ACC0600000FCC0600000020290400000C7DCC0600000FCC0600000020310400000C82CC0600000FCC060000000A39040000240E3A630300000016250500000F4E03CC0600000FCC0600000012950F0000170500000F3E2512A10F0000160500000F461305100F42144D040000F30B00000F44001452040000F30B00000F45080026560400000F5402165C0400000F4F02760900000F1E0800000F1E08000000166A0400000F5802CC0600000FF00F00000017F50F00002716710400000F5D02CC0600000FF00F000000207F0400000F658D0B00000F350800000020840400000F68CC0600000F350800000020890400000F6BF30B00000F3508000000168E0400000F3A03760900000F611000000F611000000F1E0800000F1E0800000F67100000001766100000282973100000960400000F2E0317781000002ACC0600000F611000000F611000000016A40400000F1E02760900000F1E0800000F1E08000000162B0500000F5A038A0F00000FCC0600000FCC060000002B7A0400000F6E020FCC060000002CAB0400000F2A020F760900000016B00400000F7F022B0A00000F350800000016240500000F4F03F30B00000FF30B000000162A0500000F5C03960F00000FF30B00000FF30B00000016B70400000F1B02760900000F1E0800000016BE0400000FA003CC0600000F350800000F1E0800000016C40400000FAB031E0800000F520700000F300800000F1E0800000016CD0400000FA303CC0600000F520700000F300800000F1E080000002CD40400000F44030F760900000F1E0800000F1E0800000F67100000002B740400000F74020FCC060000001CE30400000FC501CC06000016DA0400000F2602760900000F760900000F1E080000002CE20400000FC7010FD30600000020E80400000F758D0B00000F300800000FE01100000019E5110000172B0A000020EF0400000FB0F30B00000F300800000FE01100000FCC0600000020F60400000FB4290800000F300800000FE01100000FCC0600000016FE0400000F1503CC0600000F350800000016050500000FAF031E0800000F260A00000F8A0700000F1E08000000160E0500000FA703CC0600000F2B0A00000F4B070000001270120000150500000F501305100F4C144D040000230E00000F4E001452040000230E00000F4F08002B1D0500000F7A020FCC0600000016230500000F5203230E00000F230E00000016290500000F6003651200000F230E00000F230E000000202F0500000F70230E00000F350800000020350500000FC8230E00000F300800000FE01100000FCC06000000203D0500000FCD460E00000F300800000FE01100000FCC0600000020460500000F7BB50B00000F300800000FE011000000204D0500000F7E000E00000F300800000FE0110000001225070000A70000001207124E1300006D0500001554125913000074050000140E186A0500002C7D050000150C030F6C130000001738130000208605000015ACCC0600000F6C13000000168D050000150E03CC0600000F6C130000001692050000151003CC0600000F6C13000000209905000015E0CC0600000F6C1300000016A005000015FB01CC0600000F6C1300000016A605000015F202CC0600000FE01300000FE513000000196C13000019EA130000174313000016AE050000154A022B0A00000F260A00000FCC0600000FE01300000020B405000015FC6C1300000F300800000F30080000001670060000155801CC0600000FE01300000F300800001A0016BA050000151F02CC0600000FCC0600000F6C1300000016C0050000158902CC0600000F300800000FE01300000016C6050000159D021E0800000F881400000F1E0800000F1E0800000FE013000000197609000016CC0500001503016C1300000F300800000F300800000FE0130000001BD4050000DD05000015AC01CC0600000FE01300000F300800001A0016E405000015C302CC0600000F6C1300000FF30B00000FCC0600000016EA05000015F702CC0600000F6C1300000FF81400000017FD140000054313000016F205000015C802F30B00000F6C1300000016F805000015A3021E0800000F351500000F1E0800000F1E0800000FE013000000196110000016A105000015FC01CC0600000F6C130000001CFF050000150202CC0600002C07060000151E030F35080000001671060000155E01CC0600000F300800001A0016BB050000152002CC0600000FCC0600000F6C13000000160E060000152602CC0600000FCC0600000016C1050000158F02CC0600000F350800000020160600001592CC0600000F3508000000201D0600001594CC0600000F350800000F35080000002C2406000015CD020F6C130000001B2B0600003406000015AF01CC0600000F300800001A002C3A0600001542010FE01300000F260A0000001641060000154601CC0600000FE01300000F260A00000FCC0600000F1E080000001681060000156001CC0600000F260A00000F300800001A001B490600005206000015B101CC0600000F300800000F300800001A00235906000015B66C130000206106000015C72B0A00000F2B0A0000001668060000159602CC0600000FCC0600000F6C13000000166F060000156701CC0600000FE01300000F300800000F41090000001678060000156D01CC0600000F300800000F41090000001680060000156F01CC0600000F260A00000F300800000F410900000016AB060000157401CC0600000F260A00000F1E0800000F300800001A001B890600009206000015D901CC0600000FE01300000F300800000F41090000001B9A060000A306000015DE01CC0600000F300800000F410900000016AA060000157801CC0600000F260A00000F1E0800000F300800000F41090000001BB4060000BD06000015E101CC0600000F300800000F300800000F4109000000128E170000F7060000161813052016132DC5060000230E0000161408002DDE060000000E0000161610100012B91700000D070000193017BE17000005C317000012CC0600000307000018291229080000170700001B2620200700001B5FCC0600000FE60600000020290700001B65CC0600000FE60600000020320700001B92CC0600000FE606000000203B0700001B68CC0600000FE60600000020440700001B9FCC0600000FE60600000FCE17000000204D0700001B6CCC0600000FE60600000020560700001B70CC0600000FE606000000205F0700001B75CC0600000FE60600000020680700001B78CC0600000FE60600000020710700001B7DCC0600000FE606000000207A0700001B82CC0600000FE60600000020830700001B87CC0600000FE606000000208C0700001B8CCC0600000FE60600000020960700001937E60600000FE60600000FAE1700000020A00700001BA6E60600000FE60600000020A90700001BA9E60600000FE60600000020980700001934AE1700000F350800000020460700001B9BCE1700000F350800000000
+  - Name:            .debug_abbrev
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x1
+    Content:         011101250E1305030E10171B0E11011206000002340049133A0B3B0B02180000030101491300000421004913370B000005260049130000062400030E3E0B0B0B0000072400030E0B0B3E0B0000082E001101120640186E0E030E3A0B3B0B3F190000092E00110112064018030E3A0B3B0B49133F1900000A3901030E00000B08003A0B3B0B181300000C08003A0B3B05181300000D0200030E3C1900000E2E016E0E030E3A0B3B0B3C193F1900000F050049130000102E016E0E030E3A0B3B0B3C193F198701190000113900030E00001216004913030E3A0B3B0B0000131301360B0B0B3A0B3B0B0000140D00030E49133A0B3B0B380B0000151701360B0B0B3A0B3B0B0000162E01030E3A0B3B0549133C193F190000170F0049130000181300030E3C190000193700491300001A180000001B2E016E0E030E3A0B3B0549133C193F1900001C2E00030E3A0B3B0549133C193F1900001D1301360B030E0B0B00001E0D00030E4913380B00001F0F000000202E01030E3A0B3B0B49133C193F190000212E016E0E030E3A0B3B0B49133C193F19000022100049130000232E00030E3A0B3B0B49133C193F190000243A003A0B3B0B181300002513003C190000262E00030E3A0B3B053C193F198701190000271500000028260000002916004913030E3A0B3B0500002A1501491300002B2E01030E3A0B3B053C193F1987011900002C2E01030E3A0B3B053C193F1900002D0D00030E49133A0B3B0B88010F380B000000
+  - Name:            .debug_line
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x1
+    Content:         230300000400DE020000010101FB0E0D0001010101000000010000012F7573722F696E636C7564652F626974732F7479706573002F6F70742F72682F6763632D746F6F6C7365742D31332F726F6F742F7573722F6C69622F6763632F7838365F36342D7265646861742D6C696E75782F31332F2E2E2F2E2E2F2E2E2F2E2E2F696E636C7564652F632B2B2F3133002F7573722F696E636C756465002F7573722F62696E2F2E2E2F6C69622F636C616E672F31372F696E636C756465002F6F70742F72682F6763632D746F6F6C7365742D31332F726F6F742F7573722F6C69622F6763632F7838365F36342D7265646861742D6C696E75782F31332F2E2E2F2E2E2F2E2E2F2E2E2F696E636C7564652F632B2B2F31332F62697473002F6F70742F72682F6763632D746F6F6C7365742D31332F726F6F742F7573722F6C69622F6763632F7838365F36342D7265646861742D6C696E75782F31332F2E2E2F2E2E2F2E2E2F2E2E2F696E636C7564652F632B2B2F31332F6465627567002F7573722F696E636C7564652F6269747300006D61696E2E637070000000005F5F6D6273746174655F742E68000100006D6273746174655F742E68000100006377636861720002000077696E745F742E680001000077636861722E68000300005F5F46494C452E68000100007374646465662E6800040000657863657074696F6E5F7074722E6800050000636C6F63616C65000200006C6F63616C652E680003000063747970652E68000300006363747970650002000064656275672E68000600007374646C69622E68000300007374645F6162732E6800050000637374646C69620002000046494C452E680001000063737464696F000200005F5F66706F735F742E6800010000737464696F2E68000300005F5F7374646465665F6D61785F616C69676E5F742E6800040000637374646465660002000074797065732E68000700007763747970652E680003000063776374797065000200007763747970652D77636861722E680007000000000902A01140000000000015050F0A4B05200608AC0501060BE505000814050F0AE505200608AC050506E5050F59051E0608AC050506E5060B2E0206000101
+Symbols:
+  - Type:            STT_FILE
+    Index:           SHN_ABS
+DynamicSymbols:
+  - Name:            __libc_start_main
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            __cxa_atexit
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _ZNSolsEPFRSoS_E
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _ZNSt8ios_base4InitC1Ev
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _ITM_deregisterTMCloneTable
+    Binding:         STB_WEAK
+  - Name:            __gmon_start__
+    Binding:         STB_WEAK
+  - Name:            _ITM_registerTMCloneTable
+    Binding:         STB_WEAK
+  - Name:            _ZNSt8ios_base4InitD1Ev
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+    Value:           0x401030
+  - Name:            _ZSt4cout
+    Type:            STT_OBJECT
+    Section:         .bss
+    Binding:         STB_GLOBAL
+    Value:           0x404040
+    Size:            0x110
+DWARF:
+  debug_str:
+    - 'clang version 17.0.1 (CentOS 17.0.1-2.el9)'
+    - main.cpp
+    - '/tmp/test_gsymutil'
+    - __ARRAY_SIZE_TYPE__
+    - std
+    - __count
+    - __value
+    - __wch
+    - unsigned int
+    - __wchb
+    - __mbstate_t
+    - wint_t
+    - fgetwc
+    - _IO_FILE
+    - __FILE
+    - fgetws
+    - wchar_t
+    - fputwc
+    - fputws
+    - fwide
+    - __isoc99_fwscanf
+    - getwchar
+    - mbrlen
+    - unsigned long
+    - size_t
+    - mbrtowc
+    - mbsinit
+    - mbsrtowcs
+    - putwchar
+    - __isoc99_swscanf
+    - ungetwc
+    - vfwprintf
+    - gp_offset
+    - fp_offset
+    - overflow_arg_area
+    - reg_save_area
+    - __va_list_tag
+    - __isoc99_vfwscanf
+    - vswprintf
+    - __isoc99_vswscanf
+    - vwprintf
+    - __isoc99_vwscanf
+    - wcrtomb
+    - wcscat
+    - wcscmp
+    - wcscoll
+    - wcscpy
+    - wcscspn
+    - wcsftime
+    - tm
+    - wcslen
+    - wcsncat
+    - wcsncmp
+    - wcsncpy
+    - wcsrtombs
+    - wcsspn
+    - wcstod
+    - wcstof
+    - float
+    - wcstok
+    - wcstol
+    - wcstoul
+    - wcsxfrm
+    - wctob
+    - wmemcmp
+    - wmemcpy
+    - wmemmove
+    - wmemset
+    - __isoc99_wscanf
+    - wcschr
+    - wcspbrk
+    - wcsrchr
+    - wcsstr
+    - wmemchr
+    - __gnu_cxx
+    - wcstold
+    - long double
+    - wcstoll
+    - wcstoull
+    - unsigned long long
+    - __exception_ptr
+    - _ZSt17rethrow_exceptionNSt15__exception_ptr13exception_ptrE
+    - rethrow_exception
+    - _ZNSt15__exception_ptr4swapERNS_13exception_ptrES1_
+    - swap
+    - lconv
+    - setlocale
+    - localeconv
+    - isalnum
+    - isalpha
+    - iscntrl
+    - isdigit
+    - isgraph
+    - islower
+    - isprint
+    - ispunct
+    - isspace
+    - isupper
+    - isxdigit
+    - tolower
+    - toupper
+    - isblank
+    - __gnu_debug
+    - __debug
+    - quot
+    - rem
+    - abort
+    - aligned_alloc
+    - atexit
+    - at_quick_exit
+    - atof
+    - atoi
+    - atol
+    - bsearch
+    - __compar_fn_t
+    - calloc
+    - free
+    - getenv
+    - malloc
+    - mblen
+    - mbstowcs
+    - mbtowc
+    - qsort
+    - realloc
+    - srand
+    - strtod
+    - strtol
+    - strtoul
+    - system
+    - wcstombs
+    - wctomb
+    - lldiv_t
+    - _Exit
+    - llabs
+    - lldiv
+    - atoll
+    - strtoll
+    - strtoull
+    - strtof
+    - strtold
+    - _ZN9__gnu_cxx3divExx
+    - _G_fpos_t
+    - __fpos_t
+    - clearerr
+    - fclose
+    - feof
+    - ferror
+    - fflush
+    - fgetc
+    - fgetpos
+    - fgets
+    - fopen
+    - fputc
+    - fputs
+    - fread
+    - freopen
+    - __isoc99_fscanf
+    - fseek
+    - fsetpos
+    - ftell
+    - fwrite
+    - getchar
+    - perror
+    - putchar
+    - remove
+    - rename
+    - rewind
+    - __isoc99_scanf
+    - setbuf
+    - setvbuf
+    - __isoc99_sscanf
+    - tmpfile
+    - tmpnam
+    - ungetc
+    - vfprintf
+    - vprintf
+    - vsprintf
+    - __isoc99_vfscanf
+    - __isoc99_vscanf
+    - vsnprintf
+    - __isoc99_vsscanf
+    - __clang_max_align_nonce1
+    - __clang_max_align_nonce2
+    - max_align_t
+    - __int32_t
+    - wctrans_t
+    - wctype_t
+    - iswalnum
+    - iswalpha
+    - iswblank
+    - iswcntrl
+    - iswctype
+    - iswdigit
+    - iswgraph
+    - iswlower
+    - iswprint
+    - iswpunct
+    - iswspace
+    - iswupper
+    - iswxdigit
+    - towctrans
+    - towlower
+    - towupper
+    - _Z3foov
+    - foo
+    - main
+...
diff --git a/llvm/test/tools/llvm-gsymutil/X86/elf-symtab.yaml b/llvm/test/tools/llvm-gsymutil/X86/elf-symtab.yaml
new file mode 100644
index 000000000000000..31a05ce07547a10
--- /dev/null
+++ b/llvm/test/tools/llvm-gsymutil/X86/elf-symtab.yaml
@@ -0,0 +1,654 @@
+## Test loading ELF files with only symbol table and only DWARF.
+## First we make the ELF files from yaml, then we convert the ELF files to GSYM
+## and perform lookups on the newly created GSYM
+## Notice the second lookup will have more info as we included DWARF
+
+# RUN: yaml2obj %s -o %t
+# RUN: yaml2obj %p/elf-dwarf-only.yaml -o elf-dwarf-only.yaml.tmp
+# RUN: llvm-gsymutil --convert %t -o %t.gsym 2>&1 | FileCheck %s --check-prefix=CONVERT
+# RUN: llvm-gsymutil --convert elf-dwarf-only.yaml.tmp --symtab-file %t 2>&1 | FileCheck %s --check-prefix=CONVERT1
+# RUN: llvm-gsymutil --address 0x00000000004011e0 %t.gsym | FileCheck %s --check-prefix=LOOKUP
+# RUN: llvm-gsymutil --address 0x00000000004011e0 elf-dwarf-only.yaml.tmp.gsym | FileCheck %s --check-prefix=LOOKUP1
+
+# CONVERT: Input file: {{.*\.yaml\.tmp}}
+# CONVERT: Output file (x86_64): {{.*\.yaml\.tmp\.gsym}}
+# CONVERT: Loaded 0 functions from DWARF.
+# CONVERT: Loaded 12 functions from symbol table.
+# CONVERT: Pruned 0 functions, ended with 12 total
+
+# CONVERT1: Input file: {{.*\.yaml\.tmp}}
+# CONVERT1: Output file (x86_64): {{.*\.yaml\.tmp\.gsym}}
+# CONVERT1: Loaded 2 functions from DWARF.
+# CONVERT1: Using symbol table file: {{.*\.yaml\.tmp}}
+# CONVERT1: Loaded 12 functions from symbol table.
+# CONVERT1: Pruned 2 functions, ended with 12 total
+
+# LOOKUP: Looking up addresses in "{{.*\.yaml\.tmp\.gsym}}":
+# LOOKUP: 0x00000000004011e0: main
+
+# LOOKUP1: Looking up addresses in "{{.*\.yaml\.tmp\.gsym}}":
+# LOOKUP1: 0x00000000004011e0: main @ /tmp/test_gsymutil/main.cpp
+
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_X86_64
+  Entry:           0x4010B0
+ProgramHeaders:
+  - Type:            PT_PHDR
+    Flags:           [ PF_R ]
+    VAddr:           0x400040
+    Align:           0x8
+  - Type:            PT_INTERP
+    Flags:           [ PF_R ]
+    FirstSec:        .interp
+    LastSec:         .interp
+    VAddr:           0x400318
+  - Type:            PT_LOAD
+    Flags:           [ PF_R ]
+    FirstSec:        .interp
+    LastSec:         .rela.plt
+    VAddr:           0x400000
+    Align:           0x1000
+  - Type:            PT_LOAD
+    Flags:           [ PF_X, PF_R ]
+    FirstSec:        .init
+    LastSec:         .fini
+    VAddr:           0x401000
+    Align:           0x1000
+  - Type:            PT_LOAD
+    Flags:           [ PF_R ]
+    FirstSec:        .rodata
+    LastSec:         .eh_frame
+    VAddr:           0x402000
+    Align:           0x1000
+  - Type:            PT_LOAD
+    Flags:           [ PF_W, PF_R ]
+    FirstSec:        .init_array
+    LastSec:         .bss
+    VAddr:           0x403DA8
+    Align:           0x1000
+  - Type:            PT_DYNAMIC
+    Flags:           [ PF_W, PF_R ]
+    FirstSec:        .dynamic
+    LastSec:         .dynamic
+    VAddr:           0x403DC0
+    Align:           0x8
+  - Type:            PT_NOTE
+    Flags:           [ PF_R ]
+    FirstSec:        .note.gnu.property
+    LastSec:         .note.gnu.property
+    VAddr:           0x400338
+    Align:           0x8
+  - Type:            PT_NOTE
+    Flags:           [ PF_R ]
+    FirstSec:        .note.gnu.build-id
+    LastSec:         .note.ABI-tag
+    VAddr:           0x400358
+    Align:           0x4
+  - Type:            PT_GNU_PROPERTY
+    Flags:           [ PF_R ]
+    FirstSec:        .note.gnu.property
+    LastSec:         .note.gnu.property
+    VAddr:           0x400338
+    Align:           0x8
+  - Type:            PT_GNU_EH_FRAME
+    Flags:           [ PF_R ]
+    FirstSec:        .eh_frame_hdr
+    LastSec:         .eh_frame_hdr
+    VAddr:           0x402034
+    Align:           0x4
+  - Type:            PT_GNU_STACK
+    Flags:           [ PF_W, PF_R ]
+    Align:           0x10
+  - Type:            PT_GNU_RELRO
+    Flags:           [ PF_R ]
+    FirstSec:        .init_array
+    LastSec:         .got
+    VAddr:           0x403DA8
+Sections:
+  - Name:            .interp
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x400318
+    AddressAlign:    0x1
+    Content:         2F6C696236342F6C642D6C696E75782D7838362D36342E736F2E3200
+  - Name:            .note.gnu.property
+    Type:            SHT_NOTE
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x400338
+    AddressAlign:    0x8
+    Notes:
+      - Name:            GNU
+        Desc:            028000C0040000000300000000000000
+        Type:            NT_GNU_PROPERTY_TYPE_0
+  - Name:            .note.gnu.build-id
+    Type:            SHT_NOTE
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x400358
+    AddressAlign:    0x4
+    Notes:
+      - Name:            GNU
+        Desc:            6E3474EA595AB65F323A92D034BA2EA01E807B91
+        Type:            NT_PRPSINFO
+  - Name:            .note.ABI-tag
+    Type:            SHT_NOTE
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x40037C
+    AddressAlign:    0x4
+    Notes:
+      - Name:            GNU
+        Desc:            '00000000030000000200000000000000'
+        Type:            NT_VERSION
+  - Name:            .gnu.hash
+    Type:            SHT_GNU_HASH
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x4003A0
+    Link:            .dynsym
+    AddressAlign:    0x8
+    Header:
+      SymNdx:          0xA
+      Shift2:          0x6
+    BloomFilter:     [ 0x10000100100000 ]
+    HashBuckets:     [ 0xA, 0x0 ]
+    HashValues:      [ 0x9F4FD20, 0x430C9815 ]
+  - Name:            .dynsym
+    Type:            SHT_DYNSYM
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x4003C8
+    Link:            .dynstr
+    AddressAlign:    0x8
+  - Name:            .dynstr
+    Type:            SHT_STRTAB
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x4004E8
+    AddressAlign:    0x1
+  - Name:            .gnu.version
+    Type:            SHT_GNU_versym
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x400660
+    Link:            .dynsym
+    AddressAlign:    0x2
+    Entries:         [ 0, 3, 4, 2, 2, 2, 1, 1, 1, 2, 2, 2 ]
+  - Name:            .gnu.version_r
+    Type:            SHT_GNU_verneed
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x400678
+    Link:            .dynstr
+    AddressAlign:    0x8
+    Dependencies:
+      - Version:         1
+        File:            libc.so.6
+        Entries:
+          - Name:            GLIBC_2.2.5
+            Hash:            157882997
+            Flags:           0
+            Other:           4
+          - Name:            GLIBC_2.34
+            Hash:            110530996
+            Flags:           0
+            Other:           3
+      - Version:         1
+        File:            'libstdc++.so.6'
+        Entries:
+          - Name:            GLIBCXX_3.4
+            Hash:            143796596
+            Flags:           0
+            Other:           2
+  - Name:            .rela.dyn
+    Type:            SHT_RELA
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x4006C8
+    Link:            .dynsym
+    AddressAlign:    0x8
+    Relocations:
+      - Offset:          0x403FC0
+        Symbol:          __libc_start_main
+        Type:            R_X86_64_GLOB_DAT
+      - Offset:          0x403FC8
+        Symbol:          _ITM_deregisterTMCloneTable
+        Type:            R_X86_64_GLOB_DAT
+      - Offset:          0x403FD0
+        Symbol:          __gmon_start__
+        Type:            R_X86_64_GLOB_DAT
+      - Offset:          0x403FD8
+        Symbol:          _ITM_registerTMCloneTable
+        Type:            R_X86_64_GLOB_DAT
+      - Offset:          0x403FE0
+        Symbol:          _ZNSt8ios_base4InitD1Ev
+        Type:            R_X86_64_GLOB_DAT
+      - Offset:          0x404040
+        Symbol:          _ZSt4cout
+        Type:            R_X86_64_COPY
+  - Name:            .rela.plt
+    Type:            SHT_RELA
+    Flags:           [ SHF_ALLOC, SHF_INFO_LINK ]
+    Address:         0x400758
+    Link:            .dynsym
+    AddressAlign:    0x8
+    Info:            .got.plt
+    Relocations:
+      - Offset:          0x404000
+        Symbol:          _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
+        Type:            R_X86_64_JUMP_SLOT
+      - Offset:          0x404008
+        Symbol:          __cxa_atexit
+        Type:            R_X86_64_JUMP_SLOT
+      - Offset:          0x404010
+        Symbol:          _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
+        Type:            R_X86_64_JUMP_SLOT
+      - Offset:          0x404018
+        Symbol:          _ZNSolsEPFRSoS_E
+        Type:            R_X86_64_JUMP_SLOT
+      - Offset:          0x404020
+        Symbol:          _ZNSt8ios_base4InitC1Ev
+        Type:            R_X86_64_JUMP_SLOT
+  - Name:            .init
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x401000
+    AddressAlign:    0x4
+    Offset:          0x1000
+    Content:         F30F1EFA4883EC08488B05C12F00004885C07402FFD04883C408C3
+  - Name:            .plt
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x401020
+    AddressAlign:    0x10
+    EntSize:         0x10
+    Content:         FF35CA2F0000FF25CC2F00000F1F4000FF25CA2F00006800000000E9E0FFFFFFFF25C22F00006801000000E9D0FFFFFFFF25BA2F00006802000000E9C0FFFFFFFF25B22F00006803000000E9B0FFFFFFFF25AA2F00006804000000E9A0FFFFFF
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x401080
+    AddressAlign:    0x10
+    Content:         F30F1EFA53488D1DC53000004889DFE8DCFFFFFF488B3D452F00004889DE5B488D15620F0000E995FFFFFF0F1F440000F30F1EFA31ED4989D15E4889E24883E4F050544531C031C948C7C7E0114000FF15EB2E0000F4662E0F1F840000000000F30F1EFAC3662E0F1F84000000000090488D3D392F0000488D05322F00004839F87415488B05BE2E00004885C07409FFE00F1F8000000000C30F1F8000000000488D3D092F0000488D35022F00004829FE4889F048C1EE3F48C1F8034801C648D1FE7414488B058D2E00004885C07408FFE0660F1F440000C30F1F8000000000F30F1EFA803DE52F0000007513554889E5E87AFFFFFFC605D32F0000015DC390C366662E0F1F8400000000000F1F4000F30F1EFAEB8A662E0F1F840000000000554889E548BF404040000000000048BE1020400000000000E893FEFFFF4889C748BE3010400000000000E891FEFFFF5DC36666666666662E0F1F840000000000554889E54883EC10C745FC0000000048BF404040000000000048BE1C20400000000000E848FEFFFF4889C748BE3010400000000000E846FEFFFFE881FFFFFF48BF404040000000000048BE2820400000000000E818FEFFFF4889C748BE3010400000000000E816FEFFFF31C04883C4105DC3662E0F1F8400000000000F1F4000F30F1EFAC3
+  - Name:            .fini
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x401268
+    AddressAlign:    0x4
+    Content:         F30F1EFA4883EC084883C408C3
+  - Name:            .rodata
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x402000
+    AddressAlign:    0x8
+    Offset:          0x2000
+    Content:         010002000000000000000000000000005468697320697320666F6F0068656C6C6F20776F726C6400616674657220666F6F00
+  - Name:            .eh_frame_hdr
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x402034
+    AddressAlign:    0x4
+    Content:         011B033B4000000007000000ECEFFFFF840000004CF0FFFF000100007CF0FFFF5C000000ACF0FFFF700000006CF1FFFFAC000000ACF1FFFFCC0000002CF2FFFFEC000000
+  - Name:            .eh_frame
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x402078
+    AddressAlign:    0x8
+    Content:         1400000000000000017A5200017810011B0C070890010000100000001C00000018F0FFFF2600000000440710100000003000000034F0FFFF0500000000000000240000004400000060EFFFFF60000000000E10460E184A0F0B770880003F1A3B2A332422000000001C0000006C000000B8F0FFFF3100000000410E108602430D066C0C07080000001C0000008C000000D8F0FFFF7200000000410E108602430D06026D0C0708000010000000AC00000038F1FFFF050000000000000018000000C000000044EFFFFF2B00000000450E1083025A0E0800000000000000
+  - Name:            .init_array
+    Type:            SHT_INIT_ARRAY
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x403DA8
+    AddressAlign:    0x8
+    EntSize:         0x8
+    Offset:          0x2DA8
+    Content:         '80104000000000009011400000000000'
+  - Name:            .fini_array
+    Type:            SHT_FINI_ARRAY
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x403DB8
+    AddressAlign:    0x8
+    EntSize:         0x8
+    Content:         '6011400000000000'
+  - Name:            .dynamic
+    Type:            SHT_DYNAMIC
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x403DC0
+    Link:            .dynstr
+    AddressAlign:    0x8
+    Entries:
+      - Tag:             DT_NEEDED
+        Value:           0x123
+      - Tag:             DT_NEEDED
+        Value:           0x132
+      - Tag:             DT_NEEDED
+        Value:           0x13C
+      - Tag:             DT_NEEDED
+        Value:           0x14A
+      - Tag:             DT_INIT
+        Value:           0x401000
+      - Tag:             DT_FINI
+        Value:           0x401268
+      - Tag:             DT_INIT_ARRAY
+        Value:           0x403DA8
+      - Tag:             DT_INIT_ARRAYSZ
+        Value:           0x10
+      - Tag:             DT_FINI_ARRAY
+        Value:           0x403DB8
+      - Tag:             DT_FINI_ARRAYSZ
+        Value:           0x8
+      - Tag:             DT_GNU_HASH
+        Value:           0x4003A0
+      - Tag:             DT_STRTAB
+        Value:           0x4004E8
+      - Tag:             DT_SYMTAB
+        Value:           0x4003C8
+      - Tag:             DT_STRSZ
+        Value:           0x177
+      - Tag:             DT_SYMENT
+        Value:           0x18
+      - Tag:             DT_DEBUG
+        Value:           0x0
+      - Tag:             DT_PLTGOT
+        Value:           0x403FE8
+      - Tag:             DT_PLTRELSZ
+        Value:           0x78
+      - Tag:             DT_PLTREL
+        Value:           0x7
+      - Tag:             DT_JMPREL
+        Value:           0x400758
+      - Tag:             DT_RELA
+        Value:           0x4006C8
+      - Tag:             DT_RELASZ
+        Value:           0x90
+      - Tag:             DT_RELAENT
+        Value:           0x18
+      - Tag:             DT_VERNEED
+        Value:           0x400678
+      - Tag:             DT_VERNEEDNUM
+        Value:           0x2
+      - Tag:             DT_VERSYM
+        Value:           0x400660
+      - Tag:             DT_NULL
+        Value:           0x0
+      - Tag:             DT_NULL
+        Value:           0x0
+      - Tag:             DT_NULL
+        Value:           0x0
+      - Tag:             DT_NULL
+        Value:           0x0
+      - Tag:             DT_NULL
+        Value:           0x0
+      - Tag:             DT_NULL
+        Value:           0x0
+  - Name:            .got
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x403FC0
+    AddressAlign:    0x8
+    EntSize:         0x8
+    Content:         '00000000000000000000000000000000000000000000000000000000000000000000000000000000'
+  - Name:            .got.plt
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x403FE8
+    AddressAlign:    0x8
+    EntSize:         0x8
+    Content:         C03D4000000000000000000000000000000000000000000036104000000000004610400000000000561040000000000066104000000000007610400000000000
+  - Name:            .data
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x404028
+    AddressAlign:    0x1
+    Content:         '00000000'
+  - Name:            .bss
+    Type:            SHT_NOBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x404040
+    AddressAlign:    0x40
+    Offset:          0x302C
+    Size:            0x118
+  - Name:            .comment
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_MERGE, SHF_STRINGS ]
+    AddressAlign:    0x1
+    EntSize:         0x1
+    Content:         4743433A2028474E55292031312E342E312032303233303630352028526564204861742031312E342E312D3229004743433A2028474E55292031332E322E312032303233313131302028526564204861742031332E322E312D352900636C616E672076657273696F6E2031372E302E31202843656E744F532031372E302E312D322E656C392900
+  - Name:            .gnu.build.attributes
+    Type:            SHT_NOTE
+    Address:         0x406158
+    AddressAlign:    0x4
+    Notes:
+      - Name:            "GA$\x013a1"
+        Desc:            B010400000000000D610400000000000
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            E510400000000000E510400000000000
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            '00104000000000001610400000000000'
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            '68124000000000007012400000000000'
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            F0104000000000009611400000000000
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            '65124000000000006512400000000000'
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            '65124000000000006512400000000000'
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            16104000000000001B10400000000000
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+      - Name:            "GA$\x013a1"
+        Desc:            '70124000000000007512400000000000'
+        Type:            NT_GNU_BUILD_ATTRIBUTE_OPEN
+Symbols:
+  - Name:            __abi_tag
+    Type:            STT_OBJECT
+    Section:         .note.ABI-tag
+    Value:           0x40037C
+    Size:            0x20
+  - Name:            _GLOBAL__sub_I.00090_ios_init.cc
+    Type:            STT_FUNC
+    Section:         .text
+    Value:           0x401080
+    Size:            0x2B
+  - Name:            _ZStL8__ioinit
+    Type:            STT_OBJECT
+    Section:         .bss
+    Value:           0x404151
+    Size:            0x1
+  - Name:            deregister_tm_clones
+    Type:            STT_FUNC
+    Section:         .text
+    Value:           0x4010F0
+  - Name:            register_tm_clones
+    Type:            STT_FUNC
+    Section:         .text
+    Value:           0x401120
+  - Name:            __do_global_dtors_aux
+    Type:            STT_FUNC
+    Section:         .text
+    Value:           0x401160
+  - Name:            completed.0
+    Type:            STT_OBJECT
+    Section:         .bss
+    Value:           0x404150
+    Size:            0x1
+  - Name:            __do_global_dtors_aux_fini_array_entry
+    Type:            STT_OBJECT
+    Section:         .fini_array
+    Value:           0x403DB8
+  - Name:            frame_dummy
+    Type:            STT_FUNC
+    Section:         .text
+    Value:           0x401190
+  - Name:            __frame_dummy_init_array_entry
+    Type:            STT_OBJECT
+    Section:         .init_array
+    Value:           0x403DB0
+  - Name:            __FRAME_END__
+    Type:            STT_OBJECT
+    Section:         .eh_frame
+    Value:           0x402150
+  - Name:            __GNU_EH_FRAME_HDR
+    Section:         .eh_frame_hdr
+    Value:           0x402034
+  - Name:            _DYNAMIC
+    Type:            STT_OBJECT
+    Section:         .dynamic
+    Value:           0x403DC0
+  - Name:            _GLOBAL_OFFSET_TABLE_
+    Type:            STT_OBJECT
+    Section:         .got.plt
+    Value:           0x403FE8
+  - Name:            _edata
+    Section:         .data
+    Binding:         STB_GLOBAL
+    Value:           0x40402C
+  - Name:            data_start
+    Section:         .data
+    Binding:         STB_WEAK
+    Value:           0x404028
+  - Name:            _IO_stdin_used
+    Type:            STT_OBJECT
+    Section:         .rodata
+    Binding:         STB_GLOBAL
+    Value:           0x402000
+    Size:            0x4
+  - Name:            main
+    Type:            STT_FUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x4011E0
+    Size:            0x72
+  - Name:            '_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_ at GLIBCXX_3.4'
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+    Value:           0x401030
+  - Name:            __dso_handle
+    Type:            STT_OBJECT
+    Section:         .rodata
+    Binding:         STB_GLOBAL
+    Value:           0x402008
+    Other:           [ STV_HIDDEN ]
+  - Name:            _fini
+    Type:            STT_FUNC
+    Section:         .fini
+    Binding:         STB_GLOBAL
+    Value:           0x401268
+    Other:           [ STV_HIDDEN ]
+  - Name:            '__libc_start_main at GLIBC_2.34'
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _dl_relocate_static_pie
+    Type:            STT_FUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x4010E0
+    Size:            0x5
+    Other:           [ STV_HIDDEN ]
+  - Name:            '__cxa_atexit at GLIBC_2.2.5'
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _start
+    Type:            STT_FUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x4010B0
+    Size:            0x26
+  - Name:            '_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc at GLIBCXX_3.4'
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            '_ZNSolsEPFRSoS_E at GLIBCXX_3.4'
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _init
+    Type:            STT_FUNC
+    Section:         .init
+    Binding:         STB_GLOBAL
+    Value:           0x401000
+    Other:           [ STV_HIDDEN ]
+  - Name:            __TMC_END__
+    Type:            STT_OBJECT
+    Section:         .data
+    Binding:         STB_GLOBAL
+    Value:           0x404030
+    Other:           [ STV_HIDDEN ]
+  - Name:            '_ZSt4cout at GLIBCXX_3.4'
+    Type:            STT_OBJECT
+    Section:         .bss
+    Binding:         STB_GLOBAL
+    Value:           0x404040
+    Size:            0x110
+  - Name:            __data_start
+    Section:         .data
+    Binding:         STB_GLOBAL
+    Value:           0x404028
+  - Name:            _end
+    Section:         .bss
+    Binding:         STB_GLOBAL
+    Value:           0x404158
+  - Name:            __bss_start
+    Section:         .bss
+    Binding:         STB_GLOBAL
+    Value:           0x40402C
+  - Name:            _Z3foov
+    Type:            STT_FUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x4011A0
+    Size:            0x31
+  - Name:            '_ZNSt8ios_base4InitC1Ev at GLIBCXX_3.4'
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _ZSt21ios_base_library_initv
+    Type:            STT_FUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x401260
+    Size:            0x5
+  - Name:            _ITM_deregisterTMCloneTable
+    Binding:         STB_WEAK
+  - Name:            __gmon_start__
+    Binding:         STB_WEAK
+  - Name:            _ITM_registerTMCloneTable
+    Binding:         STB_WEAK
+  - Name:            '_ZNSt8ios_base4InitD1Ev at GLIBCXX_3.4'
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+DynamicSymbols:
+  - Name:            __libc_start_main
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            __cxa_atexit
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _ZNSolsEPFRSoS_E
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _ZNSt8ios_base4InitC1Ev
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _ITM_deregisterTMCloneTable
+    Binding:         STB_WEAK
+  - Name:            __gmon_start__
+    Binding:         STB_WEAK
+  - Name:            _ITM_registerTMCloneTable
+    Binding:         STB_WEAK
+  - Name:            _ZNSt8ios_base4InitD1Ev
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+    Value:           0x401030
+  - Name:            _ZSt4cout
+    Type:            STT_OBJECT
+    Section:         .bss
+    Binding:         STB_GLOBAL
+    Value:           0x404040
+    Size:            0x110
+...
diff --git a/llvm/tools/llvm-gsymutil/Opts.td b/llvm/tools/llvm-gsymutil/Opts.td
index 740291479f93232..ea67a940c56e23a 100644
--- a/llvm/tools/llvm-gsymutil/Opts.td
+++ b/llvm/tools/llvm-gsymutil/Opts.td
@@ -35,3 +35,6 @@ defm address : Eq<"address", "Lookup an address in a GSYM file">;
 def addresses_from_stdin :
   FF<"addresses-from-stdin",
      "Lookup addresses in a GSYM file that are read from stdin\nEach input line is expected to be of the following format: <addr> <gsym-path>">;
+defm symtab_file :
+  Eq<"symtab-file",
+     "Specify a separate file for symbol table to GSYM conversion.\nIn case the symbol table and debug info are not in the same binary. Does not support universal binary.">;
diff --git a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
index e5ae726546d4e44..07d3a2f63384f00 100644
--- a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
+++ b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
@@ -92,6 +92,7 @@ static uint64_t SegmentSize;
 static bool Quiet;
 static std::vector<uint64_t> LookupAddresses;
 static bool LookupAddressesFromStdin;
+static std::string SymbolTableFilename;
 
 static void parseArgs(int argc, char **argv) {
   GSYMUtilOptTable Tbl;
@@ -110,8 +111,9 @@ static void parseArgs(int argc, char **argv) {
         "information in each GSYM file.\n"
         "Specify a single GSYM file along with one or more --lookup options to "
         "lookup addresses within that GSYM file.\n"
-        "Use the --convert option to specify a file with option --out-file "
-        "option to convert to GSYM format.\n";
+        "Use the --convert option to specify a file (with --symtab-file if "
+        "needed) "
+        "with option --out-file option to convert to GSYM format.\n";
 
     Tbl.printHelp(llvm::outs(), "llvm-gsymutil [options] <input GSYM files>",
                   Overview);
@@ -169,6 +171,9 @@ static void parseArgs(int argc, char **argv) {
   }
 
   LookupAddressesFromStdin = Args.hasArg(OPT_addresses_from_stdin);
+
+  if (const llvm::opt::Arg *A = Args.getLastArg(OPT_symtab_file_EQ))
+    SymbolTableFilename = A->getValue();
 }
 
 /// @}
@@ -358,7 +363,38 @@ static llvm::Error handleObjectFile(ObjectFile &Obj,
     return Err;
 
   // Get the UUID and convert symbol table to GSYM.
-  if (auto Err = ObjectFileTransformer::convert(Obj, LogOS, Gsym))
+  // Use a separate file for symbol table if specified
+  std::string SymtabFile = SymbolTableFilename;
+  ErrorOr<std::unique_ptr<MemoryBuffer>> SymtabBuffOrErr = nullptr;
+  std::unique_ptr<MemoryBuffer> SymtabBuffer = nullptr;
+  if (!SymtabFile.empty()) {
+    outs() << "Using symbol table file: " << SymbolTableFilename << "\n";
+    SymtabBuffOrErr = MemoryBuffer::getFileOrSTDIN(SymtabFile);
+    error(SymtabFile, SymtabBuffOrErr.getError());
+    SymtabBuffer = std::move(SymtabBuffOrErr.get());
+    Expected<std::unique_ptr<Binary>> SymtabBinOrErr =
+        object::createBinary(*SymtabBuffer);
+    error(SymtabFile, errorToErrorCode(SymtabBinOrErr.takeError()));
+    if (auto Symtab = dyn_cast<ObjectFile>(SymtabBinOrErr->get())) {
+      Triple ObjTriple(Obj.makeTriple());
+      Triple SymtabTriple(Symtab->makeTriple());
+      if (ObjTriple.getArchName() != SymtabTriple.getArchName())
+        return createStringError(std::errc::invalid_argument,
+                                 "Cannot use symbol table file %s in %s for "
+                                 "binary in %s architecture.",
+                                 SymtabFile.c_str(),
+                                 ObjTriple.getArchName().data(),
+                                 SymtabTriple.getArchName().data());
+      if (auto Err = ObjectFileTransformer::convert(*Symtab, LogOS, Gsym))
+        return Err;
+    } else
+      return createStringError(std::errc::invalid_argument,
+                               "Input symbol table file %s is not a "
+                               "valid object file.\n"
+                               "Supported files are ELF and mach-o "
+                               "(exclude universal binary) files.",
+                               SymtabFile.c_str());
+  } else if (auto Err = ObjectFileTransformer::convert(Obj, LogOS, Gsym))
     return Err;
 
   // Finalize the GSYM to make it ready to save to disk. This will remove
@@ -400,6 +436,12 @@ static llvm::Error handleBuffer(StringRef Filename, MemoryBufferRef Buffer,
     if (auto Err = handleObjectFile(*Obj, OutFile))
       return Err;
   } else if (auto *Fat = dyn_cast<MachOUniversalBinary>(BinOrErr->get())) {
+    // Symbol table file is not accepted with universal binary
+    std::string SymtabFile = SymbolTableFilename;
+    if (!SymtabFile.empty())
+      return createStringError(std::errc::invalid_argument,
+                               "--symtab-file is not accepted for "
+                               "universal binary conversion");
     // Iterate over all contained architectures and filter out any that were
     // not specified with the "--arch <arch>" option. If the --arch option was
     // not specified on the command line, we will process all architectures.



More information about the llvm-commits mailing list