115 lines · plain
1## This test shows that llvm-objdump can handle sections with the same address2## when symbols in those sections are referenced. In the past, the section3## picked was non-deterministic, resulting in different symbols being found for4## the section. The test uses YAML for the input, as we need a fully linked ELF5## to reproduce the original failure.6 7## Two empty sections, one with symbol in, one without.8# RUN: yaml2obj %s --docnum=1 -o %t1 -D SIZE1=0 -D SIZE2=0 -D SECTION=.second -D INDEX=SHN_ABS9# RUN: llvm-objdump -d %t1 | FileCheck %s --check-prefix=TARGET10# RUN: yaml2obj %s --docnum=1 -o %t2 -D SIZE1=0 -D SIZE2=0 -D SECTION=.first -D INDEX=SHN_ABS11# RUN: llvm-objdump -d %t2 | FileCheck %s --check-prefix=TARGET12 13## Two sections, one empty with symbol, other non-empty, without symbol.14# RUN: yaml2obj %s --docnum=1 -o %t3 -D SIZE1=1 -D SIZE2=0 -D SECTION=.second -D INDEX=SHN_ABS15# RUN: llvm-objdump -d %t3 | FileCheck %s --check-prefix=TARGET16# RUN: yaml2obj %s --docnum=1 -o %t4 -D SIZE1=0 -D SIZE2=1 -D SECTION=.first -D INDEX=SHN_ABS17# RUN: llvm-objdump -d %t4 | FileCheck %s --check-prefix=TARGET18 19## Fall back to absolute symbol if no symbol found in candidate sections.20# RUN: yaml2obj %s --docnum=1 -o %t5 -D SIZE1=1 -D SIZE2=0 -D SECTION=.caller -D INDEX=SHN_ABS21# RUN: llvm-objdump -d %t5 | FileCheck %s --check-prefix=ABSOLUTE22 23## Show that other symbols with reserved st_shndx values are treated as absolute24## symbols.25# RUN: yaml2obj %s --docnum=1 -o %t6 -D SIZE1=1 -D SIZE2=0 -D SECTION=.caller -D INDEX=SHN_LOPROC26# RUN: llvm-objdump -d %t6 | FileCheck %s --check-prefix=ABSOLUTE27 28## Print no target if no symbol in section/absolute symbol found.29# RUN: llvm-objcopy %t5 %t7 -N other30# RUN: llvm-objdump -d %t7 | FileCheck %s --check-prefix=FAIL31 32# TARGET: callq 0x5 <target>33# ABSOLUTE: callq 0x5 <other+0x5>34# FAIL: callq 0x5{{$}}35 36--- !ELF37FileHeader:38 Class: ELFCLASS6439 Data: ELFDATA2LSB40 Type: ET_EXEC41 Machine: EM_X86_6442Sections:43 - Name: .caller44 Type: SHT_PROGBITS45 Flags: [SHF_ALLOC, SHF_EXECINSTR]46 Address: 0x047 Content: e800000000 ## Call instruction to next address.48 - Name: .first49 Type: SHT_PROGBITS50 Flags: [SHF_ALLOC, SHF_EXECINSTR]51 Address: 0x552 Size: [[SIZE1]]53 - Name: .second54 Type: SHT_PROGBITS55 Flags: [SHF_ALLOC, SHF_EXECINSTR]56 Address: 0x557 Size: [[SIZE2]]58Symbols:59 - Name: target60 Section: [[SECTION]]61 Value: 0x562 - Name: other63 Index: [[INDEX]]64 Value: 0x065 66## Two empty sections, both with symbols.67# RUN: yaml2obj %s --docnum=2 -o %t7 -D SIZE1=0 -D SIZE2=0 -D SYMVAL1=0x5 -D SYMVAL2=0x568# RUN: llvm-objdump -d %t7 | FileCheck %s --check-prefix=SECOND69 70## Two sections, both with symbols, one empty, the other not.71# RUN: yaml2obj %s --docnum=2 -o %t8 -D SIZE1=1 -D SIZE2=0 -D SYMVAL1=0x5 -D SYMVAL2=0x572# RUN: llvm-objdump -d %t8 | FileCheck %s --check-prefix=FIRST73# RUN: yaml2obj %s --docnum=2 -o %t9 -D SIZE1=0 -D SIZE2=1 -D SYMVAL1=0x5 -D SYMVAL2=0x574# RUN: llvm-objdump -d %t9 | FileCheck %s --check-prefix=SECOND75 76## Two sections, both with symbols, one empty, other not, symbol in non-empty77## section has value higher than target address.78# RUN: yaml2obj %s --docnum=2 -o %t10 -D SIZE1=1 -D SIZE2=0 -D SYMVAL1=0x6 -D SYMVAL2=0x579# RUN: llvm-objdump -d %t10 | FileCheck %s --check-prefix=SECOND80# RUN: yaml2obj %s --docnum=2 -o %t11 -D SIZE1=0 -D SIZE2=1 -D SYMVAL1=0x5 -D SYMVAL2=0x681# RUN: llvm-objdump -d %t11 | FileCheck %s --check-prefix=FIRST82 83# FIRST: callq 0x5 <first>84# SECOND: callq 0x5 <second>85 86--- !ELF87FileHeader:88 Class: ELFCLASS6489 Data: ELFDATA2LSB90 Type: ET_EXEC91 Machine: EM_X86_6492Sections:93 - Name: .caller94 Type: SHT_PROGBITS95 Flags: [SHF_ALLOC, SHF_EXECINSTR]96 Address: 0x097 Content: e800000000 ## Call instruction to next address.98 - Name: .first99 Type: SHT_PROGBITS100 Flags: [SHF_ALLOC, SHF_EXECINSTR]101 Address: 0x5102 Size: [[SIZE1]]103 - Name: .second104 Type: SHT_PROGBITS105 Flags: [SHF_ALLOC, SHF_EXECINSTR]106 Address: 0x5107 Size: [[SIZE2]]108Symbols:109 - Name: first110 Section: .first111 Value: [[SYMVAL1]]112 - Name: second113 Section: .second114 Value: [[SYMVAL2]]115