brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.1 KiB · 8c1d7d1 Raw
196 lines · plain
1## Show that llvm-objdump can dump dynamic relocations.2## Specifically, we are checking that the tags DT_RELA, DT_REL and DT_JMPREL3## properly identify relocation tables.4 5# RUN: yaml2obj --docnum=1 %s -o %t.empty6# RUN: not llvm-objdump -R %t.empty 2>&1 | FileCheck %s --check-prefix=NO-DYNAMIC7 8# NO-DYNAMIC: error: '{{.*}}': not a dynamic object9 10--- !ELF11FileHeader:12  Class:   ELFCLASS6413  Data:    ELFDATA2LSB14  Type:    ET_DYN15 16# RUN: yaml2obj --docnum=2 -DTYPE=ET_EXEC %s -o %t117# RUN: llvm-objdump --dynamic-reloc %t1 | FileCheck %s --strict-whitespace --match-full-lines18 19## e_type doesn't matter at all.20# RUN: yaml2obj --docnum=2 -DTYPE=0x1234 %s -o %t221# RUN: llvm-objdump -R %t2 | FileCheck %s --strict-whitespace --match-full-lines22 23#      CHECK:{{.*}}file format elf64-x86-6424#CHECK-EMPTY:25# CHECK-NEXT:DYNAMIC RELOCATION RECORDS26# CHECK-NEXT:OFFSET           TYPE                     VALUE27# CHECK-NEXT:0000000000000000 R_X86_64_RELATIVE        *ABS*28# CHECK-NEXT:0000000000000000 R_X86_64_JUMP_SLOT       bar29# CHECK-NEXT:0000000000000008 R_X86_64_NONE            foo30#CHECK-EMPTY:31 32## -r ignores dynamic relocations.33# RUN: llvm-objdump -r %t2 | FileCheck %s --check-prefix=STATIC-RELOC34 35# STATIC-RELOC-NOT: RELOCATION RECORDS36 37--- !ELF38FileHeader:39  Class:   ELFCLASS6440  Data:    ELFDATA2LSB41  Type:    [[TYPE]]42  Machine: EM_X86_6443Sections:44  - Name:         .foo45    Type:         SHT_PROGBITS46    Size:         1647    Flags:        [SHF_ALLOC]48    Address:      0x10000049    AddressAlign: 0x10050  - Name:         .got.plt51    Type:         SHT_PROGBITS52    Flags:        [SHF_WRITE, SHF_ALLOC]53    Address:      0x10010054    AddressAlign: 0x100055  - Name:         .rela.dyn56    Type:         SHT_RELA57    Address:      0x10020058    AddressAlign: 0x10059    Info:         .foo60    Link:         .dynsym61    Flags:        [SHF_ALLOC]62    Relocations:63      - Offset: 064        Type:   R_X86_64_RELATIVE65        Addend: 066  - Name:         .rela.plt67    Type:         SHT_RELA68    Address:      0x10030069    AddressAlign: 0x10070    Info:         .got.plt71    Link:         .dynsym72    Flags:        [SHF_ALLOC]73    Relocations:74      - Offset: 075        Symbol: bar76        Type:   R_X86_64_JUMP_SLOT77  - Name:         .rel.dyn78    Type:         SHT_REL79    Address:      0x10040080    AddressAlign: 0x10081    Info:         .foo82    Link:         .dynsym83    Flags:        [SHF_ALLOC]84    Relocations:85      - Offset: 886        Symbol: foo87        Type:   R_X86_64_NONE88  - Name:         .dynamic89    Type:         SHT_DYNAMIC90    Address:      0x10050091    AddressAlign: 0x10092    Link:         .dynstr93    Flags:        [SHF_ALLOC]94    Entries:95      - Tag: DT_RELA96        Value: 0x10020097      - Tag: DT_RELASZ98        Value: 2499      - Tag: DT_RELAENT100        Value: 24101      - Tag: DT_JMPREL102        Value: 0x100300103      - Tag: DT_PLTREL104        Value: 7105      - Tag: DT_PLTRELSZ106        Value: 24107      - Tag: DT_REL108        Value: 0x100400109      - Tag: DT_RELSZ110        Value: 16111      - Tag: DT_RELENT112        Value: 16113      - Tag: DT_NULL114        Value: 0115ProgramHeaders:116  - Type:     PT_LOAD117    VAddr:    0x100000118    Align:    0x100119    FirstSec: .foo120    LastSec:  .dynamic121  - Type:     PT_DYNAMIC122    VAddr:    0x100500123    Align:    0x100124    FirstSec: .dynamic125    LastSec:  .dynamic126DynamicSymbols:127  - Name:    foo128    Section: .foo129    Binding: STB_GLOBAL130  - Name:    bar131    Type:    STT_FUNC132    Binding: STB_GLOBAL133 134## Test a 32-bit object.135# RUN: yaml2obj --docnum=3 %s -o %t.i386136# RUN: llvm-objdump -R %t.i386 | FileCheck %s --check-prefix=I386 --strict-whitespace --match-full-lines137 138#      I386:{{.*}}file format elf32-i386139#I386-EMPTY:140# I386-NEXT:DYNAMIC RELOCATION RECORDS141# I386-NEXT:OFFSET   TYPE                     VALUE142# I386-NEXT:00000030 R_386_RELATIVE           *ABS*143# I386-NEXT:00000010 R_386_NONE               foo144#I386-EMPTY:145 146--- !ELF147FileHeader:148  Class:           ELFCLASS32149  Data:            ELFDATA2LSB150  Type:            ET_DYN151  Machine:         EM_386152ProgramHeaders:153  - Type:     PT_LOAD154    FirstSec: .rel.dyn155    LastSec:  .data156  - Type:     PT_DYNAMIC157    VAddr:    0x10158    FirstSec: .dynamic159    LastSec:  .dynamic160Sections:161  - Name:            .rel.dyn162    Type:            SHT_REL163    Link:            .dynsym164    Flags:           [ SHF_ALLOC ]165    AddressAlign:    0x4166    Relocations:167      - Offset:          0x30168        Type:            R_386_RELATIVE169      - Offset:          0x10170        Symbol:          foo171        Type:            R_386_NONE172  - Name:            .dynamic173    Type:            SHT_DYNAMIC174    Flags:           [ SHF_ALLOC ]175    Link:            .dynstr176    AddressAlign:    0x4177    Entries:178      - Tag:             DT_REL179        Value:           0x0180      - Tag:             DT_RELSZ181        Value:           0x10182      - Tag:             DT_RELENT183        Value:           0x8184      - Tag:             DT_RELCOUNT185        Value:           0x1186      - Tag:             DT_NULL187        Value:           0x0188  - Name:            .data189    Type:            SHT_PROGBITS190    Flags:           [ SHF_WRITE, SHF_ALLOC ]191    AddressAlign:    0x4192    Content:         '80110000'193DynamicSymbols:194  - Name:    foo195    Section: .data196