| ## Check that llvm-readobj/llvm-readelf reports an error when dumping relocations if a dynamic |
| ## symbol name offset is broken (goes past the end of the dynamic symbol string table). |
| |
| # RUN: yaml2obj %s -o %t |
| # RUN: llvm-readobj --dyn-relocations %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=LLVM |
| # RUN: llvm-readelf --dyn-relocations %t 2>&1 | FileCheck %s -DFILE=%t --check-prefix=GNU |
| |
| # LLVM: Dynamic Relocations { |
| # LLVM-EMPTY: |
| # LLVM-NEXT: warning: '[[FILE]]': unable to get name of the dynamic symbol with index 1: st_name (0x1234) is past the end of the string table of size 0x1 |
| # LLVM-NEXT: 0x0 R_X86_64_NONE <corrupt> 0x0 |
| # LLVM-NEXT: } |
| |
| # GNU: 'RELA' relocation section at offset {{.+}} contains 24 bytes: |
| # GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend |
| # GNU-EMPTY: |
| # GNU-NEXT: warning: '[[FILE]]': unable to get name of the dynamic symbol with index 1: st_name (0x1234) is past the end of the string table of size 0x1 |
| # GNU-NEXT: 0000000000000000 0000000100000000 R_X86_64_NONE 0000000000000000 <corrupt> + 0 |
| |
| --- !ELF |
| FileHeader: |
| Class: ELFCLASS64 |
| Data: ELFDATA2LSB |
| Type: ET_DYN |
| Machine: EM_X86_64 |
| Sections: |
| - Name: .rela.dyn |
| Type: SHT_RELA |
| Link: .dynsym |
| Relocations: |
| - Offset: 0x0 |
| Symbol: 1 ## Index of a dynamic symbol with a broken st_name. |
| Type: R_X86_64_NONE |
| - Name: .dynamic |
| Type: SHT_DYNAMIC |
| Entries: |
| - Tag: DT_RELA |
| Value: 0x0000000000000000 |
| - Tag: DT_RELASZ |
| Value: 0x0000000000000018 |
| - Tag: DT_RELAENT |
| Value: 0x0000000000000018 |
| - Tag: DT_NULL |
| Value: 0x0000000000000000 |
| DynamicSymbols: |
| - NameIndex: 0x1234 |
| ProgramHeaders: |
| - Type: PT_LOAD |
| Sections: |
| - Section: .rela.dyn |
| - Section: .dynamic |