================ @@ -0,0 +1,631 @@ +## This test verifies that loading an ELF file that has no section headers can +## load the dynamic symbol table using the DT_SYMTAB, DT_SYMENT, DT_HASH or +## the DT_GNU_HASH .dynamic key/value pairs that are loaded via the PT_DYNAMIC +## segment. +## +## This test will convert a shared library from yaml, strip its section headers, +## and varify that LLDB can load the dynamic symbol table. We must manually +## strip the section headers from a full shared library because our ELF YAML +## support in obj2yaml/yaml2obj doesn't support ELF files with program headers +## only, they must have sections or the file doesn't get recreated correctlty. + +# RUN: yaml2obj %s -o %t +# RUN: llvm-strip --strip-sections %t -o %t.noshdrs + +# RUN: %lldb -b \ +# RUN: -o "target create -d '%t.noshdrs'" \ +# RUN: -o "image dump objfile" \ +# RUN: | FileCheck %s --dump-input=always +# CHECK: (lldb) image dump objfile +# CHECK: Dumping headers for 1 module(s). +# CHECK: ObjectFileELF, file = +# CHECK: ELF Header +# Make sure there are no section headers +# CHECK: e_shnum = 0x00000000 +# Make sure we were able to load the symbols +# CHECK: elf-dynsym.yaml.tmp.noshdrs, num_symbols = 9: +# CHECK: [ 0] 1 Undefined 0x0000000000000000 0x0000000000000000 0x00000022 __cxa_finalize +# CHECK: [ 1] 2 X Undefined 0x0000000000000000 0x0000000000000000 0x00000012 puts +# CHECK: [ 2] 3 Undefined 0x0000000000000000 0x0000000000000000 0x00000020 _ITM_deregisterTMCloneTable +# CHECK: [ 3] 4 Undefined 0x0000000000000000 0x0000000000000000 0x00000020 __gmon_start__ +# CHECK: [ 4] 5 Undefined 0x0000000000000000 0x0000000000000000 0x00000020 _ITM_registerTMCloneTable +# CHECK: [ 5] 6 X Code 0x0000000000001135 0x0000000000000016 0x00000012 baz() +# CHECK: [ 6] 7 X Code 0x000000000000111f 0x0000000000000016 0x00000012 bar() +# CHECK: [ 7] 8 X Code 0x000000000000114b 0x0000000000000016 0x00000012 biz() +# CHECK: [ 8] 9 X Code 0x0000000000001109 0x0000000000000016 0x00000012 foo() + +--- !ELF ---------------- labath wrote:
I see the problem. I used the version of lld on my system, and it looks like the behavior has changed slightly for the version at HEAD. Sorry about that. I believe this has everything you need: ``` $ bin/llvm-mc -triple=x86_64-pc-linux -filetype=obj -o - - <<<".globl defined, undefined; defined:" | bin/ld.lld /dev/stdin -o - --hash-style=gnu -export-dynamic -shared -z nosectionheader | llvm-readelf - -d -l Elf file type is DYN (Shared object file) Entry point 0x0 There are 6 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align PHDR 0x000040 0x0000000000000040 0x0000000000000040 0x000188 0x000188 R 0x8 LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x000243 0x000243 R 0x1000 LOAD 0x000248 0x0000000000002248 0x0000000000002248 0x000060 0x000db8 RW 0x1000 DYNAMIC 0x000248 0x0000000000002248 0x0000000000002248 0x000060 0x000060 RW 0x8 GNU_RELRO 0x000248 0x0000000000002248 0x0000000000002248 0x000060 0x000db8 R 0x1 GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x0 Section to Segment mapping: Segment Sections... 00 01 02 03 04 05 Dynamic section at offset 0x248 contains 6 entries: Tag Type Name/Value 0x0000000000000006 (SYMTAB) 0x1c8 0x000000000000000b (SYMENT) 24 (bytes) 0x0000000000000005 (STRTAB) 0x230 0x000000000000000a (STRSZ) 19 (bytes) 0x000000006ffffef5 (GNU_HASH) 0x210 0x0000000000000000 (NULL) 0x0 ``` https://github.com/llvm/llvm-project/pull/112596 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits