brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 96ede5a Raw
70 lines · plain
1# RUN: yaml2obj %s -o %t2# RUN: llvm-objcopy %t %t23# RUN: llvm-readobj --dyn-syms %t2 | FileCheck %s4 5## This checks that section references in the dynamic symbol table are not6## corrupted after processing a file where the sequence of section headers does7## not follow the order of their offsets. The tool avoids updating loadable8## sections, so, the content of the dynamic symbol table stays intact and the9## used section indices are preserved. In this test, the section 'dummy' comes10## first while having the offset after all other sections. If the section11## headers were sorted by their offsets by the tool, what it did before, the12## index of the '.text' section would change from '2' to '1', which resulted13## in an incorrect reference in the corresponding dynamic symbol 'foo'.14 15# CHECK:      Name: foo16# CHECK-NEXT: Value:17# CHECK-NEXT: Size:18# CHECK-NEXT: Binding:19# CHECK-NEXT: Type:20# CHECK-NEXT: Other:21# CHECK-NEXT: Section: .text22 23!ELF24FileHeader:25  Class:           ELFCLASS6426  Data:            ELFDATA2LSB27  Type:            ET_DYN28  Machine:         EM_X86_6429ProgramHeaders:30  - Type:            PT_LOAD31    Flags:           [ PF_X, PF_R ]32    FirstSec:        .text33    LastSec:         .text34    Align:           0x100035Sections:36  - Name:            .text37    Type:            SHT_PROGBITS38    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]39    AddressAlign:    0x440    Offset:          0x100041    Content:         000000000000000042  - Name:            .dynsym43    Type:            SHT_DYNSYM44    Flags:           [ SHF_ALLOC ]45    Link:            .dynstr46  - Name:            .dynstr47    Type:            SHT_STRTAB48    Flags:           [ SHF_ALLOC ]49  - Name:            dummy50    Type:            SHT_PROGBITS51    Flags:           [ SHF_ALLOC ]52    Offset:          0x110053  - Type:            SectionHeaderTable54    Sections:55## 'dummy' comes before '.text' in the section header table despite its offset56## is larger.57      - Name:            dummy58      - Name:            .text59      - Name:            .dynsym60      - Name:            .dynstr61      - Name:            .shstrtab62      - Name:            .strtab63DynamicSymbols:64  - Name:            foo65    Type:            STT_FUNC66    Section:         .text67    Binding:         STB_GLOBAL68    Value:           0x069    Size:            0x870