1## In this test we check the --needed-libs option. 2 3# RUN: yaml2obj %s --docnum=1 -o %t1 4# RUN: llvm-readobj --needed-libs %t1 2>&1 \ 5# RUN: | FileCheck %s -DFILE=%t1 --implicit-check-not=warning: --strict-whitespace --check-prefix=NEEDED-LIBS 6# RUN: llvm-readelf --needed-libs %t1 2>&1 \ 7# RUN: | FileCheck %s -DFILE=%t1 --implicit-check-not=warning: --strict-whitespace --check-prefix=NEEDED-LIBS 8 9## Check that library names are sorted when printed. 10## Document that we also sort error entries. 11 12# NEEDED-LIBS:{{^}}NeededLibraries [{{$}} 13# NEEDED-LIBS-NEXT: warning: '[[FILE]]': string table at offset 0x78: unable to read the string at 0x9999a11, it goes past the end of the table (0x85){{$}} 14# NEEDED-LIBS-NEXT: warning: '[[FILE]]': string table at offset 0x78: unable to read the string at 0x1111189, it goes past the end of the table (0x85){{$}} 15# NEEDED-LIBS-NEXT:{{^}} <?>{{$}} 16# NEEDED-LIBS-NEXT:{{^}} <?>{{$}} 17# NEEDED-LIBS-NEXT:{{^}} aaa{{$}} 18# NEEDED-LIBS-NEXT:{{^}} bbb{{$}} 19# NEEDED-LIBS-NEXT:{{^}} ccc{{$}} 20# NEEDED-LIBS-NEXT:{{^}}]{{$}} 21 22--- !ELF 23FileHeader: 24 Class: ELFCLASS64 25 Data: ELFDATA2LSB 26 Type: ET_EXEC 27 Machine: EM_X86_64 28Sections: 29 - Name: .dynstr 30 Type: SHT_STRTAB 31 Flags: [ SHF_ALLOC ] 32 Content: '00616161006262620063636300' ## 0,a,a,a,0,b,b,b,0,c,c,c,0 33 - Name: .dynamic 34 Type: SHT_DYNAMIC 35 Entries: 36 - Tag: DT_STRTAB 37 Value: 0x0000000000000000 38 - Tag: DT_NEEDED 39 Value: 0x9999999 40 - Tag: DT_NEEDED 41 Value: 9 42 - Tag: DT_NEEDED 43 Value: 1 44 - Tag: DT_NEEDED 45 Value: 5 46 - Tag: DT_NEEDED 47 Value: 0x1111111 48 - Tag: DT_STRSZ 49 Value: 0xD 50 - Tag: DT_NULL 51 Value: 0x0 52ProgramHeaders: 53 - Type: PT_LOAD 54 VAddr: 0x0 55 Sections: 56 - Section: .dynstr 57 - Section: .dynamic 58 59## Check what we print when the dynamic string table is empty. 60# RUN: yaml2obj %s --docnum=2 -o %t2 61# RUN: llvm-readobj --needed-libs %t2 2>&1 | \ 62# RUN: FileCheck %s -DFILE=%t2 --implicit-check-not=warning: --check-prefixes=EMPTY-DYNSTR,EMPTY-DYNSTR-LLVM 63# RUN: llvm-readelf --needed-libs %t2 2>&1 | \ 64# RUN: FileCheck %s -DFILE=%t2 --implicit-check-not=warning: --check-prefix=EMPTY-DYNSTR 65 66# EMPTY-DYNSTR: warning: '[[FILE]]': string table at offset 0x78: unable to read the string at 0x78, it goes past the end of the table (0x78) 67# EMPTY-DYNSTR-LLVM: LoadName: <?> 68# EMPTY-DYNSTR: NeededLibraries [ 69# EMPTY-DYNSTR-NEXT: warning: '[[FILE]]': string table at offset 0x78: unable to read the string at 0x79, it goes past the end of the table (0x78) 70# EMPTY-DYNSTR-NEXT: warning: '[[FILE]]': string table at offset 0x78: unable to read the string at 0x7a, it goes past the end of the table (0x78) 71# EMPTY-DYNSTR-NEXT: <?> 72# EMPTY-DYNSTR-NEXT: <?> 73# EMPTY-DYNSTR-NEXT: ] 74 75--- !ELF 76FileHeader: 77 Class: ELFCLASS64 78 Data: ELFDATA2LSB 79 Type: ET_EXEC 80 Machine: EM_X86_64 81Sections: 82 - Name: .dynstr 83 Type: SHT_STRTAB 84 Flags: [ SHF_ALLOC ] 85 Size: 0 86 - Name: .dynamic 87 Type: SHT_DYNAMIC 88 Address: 0x1000 89 Entries: 90 - Tag: DT_STRTAB 91 Value: 0x0000000000000000 92 - Tag: DT_NEEDED 93 Value: 1 94 - Tag: DT_NEEDED 95 Value: 2 96 - Tag: DT_STRSZ 97 Value: 0x0 98 - Tag: DT_NULL 99 Value: 0x0 100ProgramHeaders: 101 - Type: PT_LOAD 102 VAddr: 0x0 103 Sections: 104 - Section: .dynstr 105 - Section: .dynamic 106