| James Henderson | 5fc812f | 2019-01-22 09:35:35 +0000 | [diff] [blame] | 1 | # RUN: llvm-readelf --hash-symbols %p/Inputs/dynamic-table-exe.x86 \ | 
|  | 2 | # RUN:   | FileCheck %s --check-prefix HASH | 
|  | 3 |  | 
|  | 4 | # HASH:     Symbol table of .hash for image: | 
|  | 5 | # HASH-NEXT:   Num Buc:    Value  Size   Type   Bind Vis      Ndx Name | 
|  | 6 | # HASH-NEXT:     9   0: 00000000     0 FUNC    GLOBAL DEFAULT UND __gxx_personality_v0@CXXABI_1.3 | 
|  | 7 | # HASH-NEXT:    13   0: 00001b64     0 NOTYPE  GLOBAL DEFAULT ABS _edata{{$}} | 
|  | 8 | # HASH-NEXT:     7   0: 00000000     0 FUNC    GLOBAL DEFAULT UND _ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@GLIBCXX_3.4 | 
|  | 9 | # HASH-NEXT:     2   0: 00000000     0 NOTYPE  WEAK   DEFAULT UND _Jv_RegisterClasses{{$}} | 
|  | 10 | # HASH-NEXT:     1   0: 00000000     0 NOTYPE  WEAK   DEFAULT UND __gmon_start__{{$}} | 
|  | 11 | # HASH-NEXT:    16   1: 00000850    81 FUNC    GLOBAL DEFAULT  14 main{{$}} | 
|  | 12 | # HASH-NEXT:    10   1: 00000000     0 FUNC    GLOBAL DEFAULT UND _Unwind_Resume@GCC_3.0 | 
|  | 13 | # HASH-NEXT:     8   1: 00000000     0 FUNC    GLOBAL DEFAULT UND puts@GLIBC_2.0 | 
|  | 14 | # HASH-NEXT:    12   1: 00001b68     0 NOTYPE  GLOBAL DEFAULT ABS _end{{$}} | 
|  | 15 | # HASH-NEXT:     6   1: 00000000     0 FUNC    GLOBAL DEFAULT UND _ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@GLIBCXX_3.4 | 
|  | 16 | # HASH-NEXT:     5   1: 00000000     0 NOTYPE  WEAK   DEFAULT UND _ITM_registerTMCloneTable{{$}} | 
|  | 17 | # HASH-NEXT:     4   1: 00000000     0 NOTYPE  WEAK   DEFAULT UND _ITM_deregisterTMCloneTable{{$}} | 
|  | 18 | # HASH-NEXT:     3   1: 00000000     0 FUNC    GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.0 | 
|  | 19 | # HASH-NEXT:    11   2: 00000000     0 FUNC    WEAK   DEFAULT UND __cxa_finalize@GLIBC_2.1.3 | 
|  | 20 | # HASH-NEXT:    15   2: 00001b64     0 NOTYPE  GLOBAL DEFAULT ABS __bss_start{{$}} | 
|  | 21 | # HASH-NEXT:    14   2: 0000093c     4 OBJECT  GLOBAL DEFAULT  16 _IO_stdin_used{{$}} | 
|  | 22 | # HASH:     Symbol table of .gnu.hash for image: | 
|  | 23 | # HASH-NEXT:   Num Buc:    Value  Size   Type   Bind Vis      Ndx Name | 
|  | 24 | # HASH-NEXT:    12   0: 00001b68     0 NOTYPE  GLOBAL DEFAULT ABS _end{{$}} | 
|  | 25 | # HASH-NEXT:    13   0: 00001b64     0 NOTYPE  GLOBAL DEFAULT ABS _edata{{$}} | 
|  | 26 | # HASH-NEXT:    14   1: 0000093c     4 OBJECT  GLOBAL DEFAULT  16 _IO_stdin_used{{$}} | 
|  | 27 | # HASH-NEXT:    15   1: 00001b64     0 NOTYPE  GLOBAL DEFAULT ABS __bss_start{{$}} | 
|  | 28 | # HASH-NEXT:    16   1: 00000850    81 FUNC    GLOBAL DEFAULT  14 main{{$}} | 
|  | 29 |  | 
|  | 30 | ## Show that if there are no hash sections, we do not print anything. | 
|  | 31 | # RUN: yaml2obj %s -o %t.o | 
|  | 32 | # RUN: llvm-readelf --hash-symbols %t.o \ | 
|  | 33 | # RUN:   | FileCheck %s --check-prefix NO-HASH --allow-empty | 
|  | 34 |  | 
|  | 35 | # NO-HASH-NOT: {{.}} | 
|  | 36 |  | 
|  | 37 | ## Sanity check that we can still find the dynamic symbols (i.e. the above test | 
|  | 38 | ## doesn't pass due to a mistake in the dynamic section). | 
|  | 39 | # RUN: llvm-readelf --dyn-symbols %t.o | FileCheck %s --check-prefix DYNSYMS | 
|  | 40 |  | 
|  | 41 | # DYNSYMS: Symbol table '.dynsym' contains 2 entries: | 
|  | 42 |  | 
|  | 43 | !ELF | 
|  | 44 | FileHeader: | 
|  | 45 | Class:           ELFCLASS64 | 
|  | 46 | Data:            ELFDATA2LSB | 
|  | 47 | Type:            ET_DYN | 
|  | 48 | Machine:         EM_X86_64 | 
|  | 49 | Sections: | 
|  | 50 | ## TODO:  Replace the raw section contents with more meaningful dynamic | 
|  | 51 | ## tags/symbols/etc, once yaml2obj supports it. | 
|  | 52 | ## FIXME: yaml2obj does not currently allow custom addresses for .dynstr and | 
|  | 53 | ## .dynsym if DynamicSymbols are specified. | 
|  | 54 | ## See https://bugs.llvm.org/show_bug.cgi?id=40339 | 
|  | 55 | - Name:         .dynstr | 
|  | 56 | Type:         SHT_STRTAB | 
|  | 57 | Flags:        [ SHF_ALLOC ] | 
|  | 58 | AddressAlign: 0x100 | 
|  | 59 | EntSize:      0x1 | 
|  | 60 | ## "\0_Z3fooi\0" | 
|  | 61 | Content: "005f5a33666f6f6900" | 
|  | 62 | - Name:         .dynsym | 
|  | 63 | Type:         SHT_DYNSYM | 
|  | 64 | Flags:        [ SHF_ALLOC ] | 
|  | 65 | Link:         .dynstr | 
|  | 66 | Info:         1 | 
|  | 67 | Address:      0x100 | 
|  | 68 | AddressAlign: 0x100 | 
|  | 69 | EntSize:      0x18 | 
|  | 70 | ## Null symbol; | 
|  | 71 | ## st_name: 1; st_info: Global | Func; st_other: 0; | 
|  | 72 | ##   st_shndx: .text.foo; st_value: 0x2000; st_size: 0 | 
|  | 73 | Content: "000000000000000000000000000000000000000000000000010000001200040000200000000000000000000000000000" | 
| George Rimar | 0e7ed91 | 2019-02-09 11:34:28 +0000 | [diff] [blame^] | 74 | - Name:            .dynamic | 
|  | 75 | Type:            SHT_DYNAMIC | 
|  | 76 | Flags:           [ SHF_ALLOC ] | 
|  | 77 | Address:         0x0000000000001000 | 
|  | 78 | Link:            .dynstr | 
|  | 79 | AddressAlign:    0x0000000000001000 | 
|  | 80 | EntSize:         0x0000000000000010 | 
|  | 81 | Entries: | 
|  | 82 | - Tag:             DT_STRTAB | 
|  | 83 | Value:           0x0000000000000000 | 
|  | 84 | - Tag:             DT_STRSZ | 
|  | 85 | Value:           0x0000000000000009 | 
|  | 86 | - Tag:             DT_SYMTAB | 
|  | 87 | Value:           0x0000000000000100 | 
|  | 88 | - Tag:             DT_SYMENT | 
|  | 89 | Value:           0x0000000000000018 | 
|  | 90 | - Tag:             DT_NULL | 
|  | 91 | Value:           0x0000000000000000 | 
| James Henderson | 5fc812f | 2019-01-22 09:35:35 +0000 | [diff] [blame] | 92 | - Name:  .text.foo | 
|  | 93 | Type:  SHT_PROGBITS | 
|  | 94 | Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ] | 
|  | 95 | Size:  0x40 | 
|  | 96 | Address: 0x2000 | 
|  | 97 | AddressAlign: 0x2000 | 
|  | 98 | ProgramHeaders: | 
|  | 99 | - Type:  PT_LOAD | 
|  | 100 | Flags: [ PF_R, PF_X ] | 
|  | 101 | VAddr: 0x0 | 
|  | 102 | PAddr: 0x0 | 
|  | 103 | Sections: | 
|  | 104 | - Section: .dynsym | 
|  | 105 | - Section: .dynstr | 
|  | 106 | - Section: .dynamic | 
|  | 107 | - Section: .text.foo | 
|  | 108 | - Type:  PT_DYNAMIC | 
|  | 109 | Flags: [ PF_R ] | 
|  | 110 | VAddr: 0x1000 | 
|  | 111 | PAddr: 0x1000 | 
|  | 112 | Sections: | 
|  | 113 | - Section: .dynamic |