[BOLT] Fix two aarch64 tests
authorVladislav Khmelevsky <och95@yandex.ru>
Thu, 7 Apr 2022 18:56:05 +0000 (21:56 +0300)
committerVladislav Khmelevsky <och95@yandex.ru>
Wed, 13 Apr 2022 10:38:32 +0000 (13:38 +0300)
tls-lld test might be broken since compiler might optimize plt function
call and use address directly from got table. The test is removed since
plt-gnu-ld checks the same functionality + versioning symbol matching,
no need to keep both of the tests.
The toolchain might optimize relocations in runtime-relocs test, replace
the test compilation with yaml files.

Differential Revision: https://reviews.llvm.org/D123332

bolt/test/AArch64/Inputs/rels-exe.yaml [new file with mode: 0644]
bolt/test/AArch64/Inputs/rels-so.yaml [new file with mode: 0644]
bolt/test/AArch64/Inputs/tls-ld.yaml [moved from bolt/test/runtime/AArch64/Inputs/tls_ld.yaml with 100% similarity]
bolt/test/AArch64/Inputs/tls-trad.yaml [moved from bolt/test/runtime/AArch64/Inputs/tls_trad.yaml with 100% similarity]
bolt/test/AArch64/plt-lld.test [deleted file]
bolt/test/AArch64/runtime-relocs.test [new file with mode: 0644]
bolt/test/runtime/AArch64/Inputs/runtime_relocs.c [deleted file]
bolt/test/runtime/AArch64/runtime_relocs.c [deleted file]

diff --git a/bolt/test/AArch64/Inputs/rels-exe.yaml b/bolt/test/AArch64/Inputs/rels-exe.yaml
new file mode 100644 (file)
index 0000000..58f538d
--- /dev/null
@@ -0,0 +1,351 @@
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_AARCH64
+  Entry:           0x210710
+ProgramHeaders:
+  - Type:            PT_PHDR
+    Flags:           [ PF_R ]
+    VAddr:           0x200040
+    Align:           0x8
+  - Type:            PT_INTERP
+    Flags:           [ PF_R ]
+    FirstSec:        .interp
+    LastSec:         .interp
+    VAddr:           0x2002A8
+  - Type:            PT_LOAD
+    Flags:           [ PF_R ]
+    FirstSec:        .interp
+    LastSec:         .rodata
+    VAddr:           0x200000
+    Align:           0x10000
+  - Type:            PT_LOAD
+    Flags:           [ PF_X, PF_R ]
+    FirstSec:        .text
+    LastSec:         .iplt
+    VAddr:           0x210710
+    Align:           0x10000
+  - Type:            PT_LOAD
+    Flags:           [ PF_W, PF_R ]
+    FirstSec:        .iplt
+    LastSec:         .got
+    VAddr:           0x220990
+    Align:           0x10000
+  - Type:            PT_LOAD
+    Flags:           [ PF_W, PF_R ]
+    FirstSec:        .data
+    LastSec:         .bss
+    VAddr:           0x230B40
+    Align:           0x10000
+  - Type:            PT_DYNAMIC
+    Flags:           [ PF_W, PF_R ]
+    FirstSec:        .dynamic
+    LastSec:         .dynamic
+    VAddr:           0x2209A0
+    Align:           0x8
+Sections:
+  - Name:            .interp
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x2002A8
+    AddressAlign:    0x1
+    Content:         2F6C69622F6C642D6C696E75782D616172636836342E736F2E3100
+  - Name:            .dynsym
+    Type:            SHT_DYNSYM
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x2002E8
+    Link:            .dynstr
+    AddressAlign:    0x8
+  - Name:            .dynstr
+    Type:            SHT_STRTAB
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x200418
+    AddressAlign:    0x1
+  - Name:            .rela.dyn
+    Type:            SHT_RELA
+    Flags:           [ SHF_ALLOC, SHF_INFO_LINK ]
+    Address:         0x2004A0
+    Link:            .dynsym
+    AddressAlign:    0x8
+    Info:            .got.plt
+    Relocations:
+      - Offset:          0x220B38
+        Symbol:          t1
+        Type:            R_AARCH64_TLS_TPREL64
+      - Offset:          0x230B98
+        Symbol:          a
+        Type:            R_AARCH64_COPY
+      - Offset:          0x230B88
+        Type:            R_AARCH64_IRELATIVE
+        Addend:          2164764
+  - Name:            .rela.plt
+    Type:            SHT_RELA
+    Flags:           [ SHF_ALLOC, SHF_INFO_LINK ]
+    Address:         0x200500
+    Link:            .dynsym
+    AddressAlign:    0x8
+    Info:            .got.plt
+    Relocations:
+      - Offset:          0x230B68
+        Symbol:          abort
+        Type:            R_AARCH64_JUMP_SLOT
+      - Offset:          0x230B70
+        Symbol:          __libc_start_main
+        Type:            R_AARCH64_JUMP_SLOT
+      - Offset:          0x230B80
+        Symbol:          inc
+        Type:            R_AARCH64_JUMP_SLOT
+  - Name:            .rodata
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_MERGE ]
+    Address:         0x200560
+    AddressAlign:    0x8
+    Content:         '010002000000000000000000000000000000000000000000'
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x210710
+    AddressAlign:    0x8
+    Content:         1D0080D21E0080D2E50300AAE10340F9E2230091E60300910000009000201D911F2003D5230A00101F2003D5E40D0010840000947F0000943800001480000090009845F9400000B482000014C0035FD61F2003D5601F10101F2003D5211F10103F0000EBC000005481FFFF9021B442F9610000B4F00301AA00021FD6C0035FD61F2003D5E01D10101F2003D5A11D1010210000CB22FC7FD3410C818BFF0781EB21FC4193C000005482FFFF9042B842F9620000B4F00302AA00021FD6C0035FD6FD7BBEA9FD030091F30B00F91301009060426E3980000035DEFFFF972000805260422E39F30B40F9FD7BC2A8C0035FD6E4FFFF17FF4300D1E00F00B9E80F40B900050071FF430091C0035FD61F2003D520FFFF10C0035FD6FF8300D1FD7B01A9FD4300918A0000904A9D45F949D03BD528696AB80805001128692AB808010090E80700F900994BB94A000094E80740F900994BB943000094E0031F2AFD7B41A9FF830091C0035FD6FD7BBCA9FD030091F35301A91F2003D5D4080810F55B02A91F2003D535080810940215CBF603002AF76303A9F70301AAF80302AA14000094FF0F94EB6001005494FE4393130080D2A37A73F8E20318AA73060091E10317AAE003162A60003FD69F0213EB21FFFF54F35341A9F55B42A9F76343A9FD7BC4A8C0035FD61F2003D5C0035FD6
+  - Name:            .plt
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x210920
+    AddressAlign:    0x10
+    Content:         F07BBFA91001009011B245F910822D9120021FD61F2003D51F2003D51F2003D51001009011B645F910A22D9120021FD61001009011BA45F910C22D9120021FD61001009011BE45F910E22D9120021FD61001009011C245F910022E9120021FD6
+  - Name:            .iplt
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x210980
+    AddressAlign:    0x10
+    Content:         1001009011C645F910222E9120021FD6
+  - Name:            .dynamic
+    Type:            SHT_DYNAMIC
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x2209A0
+    Link:            .dynstr
+    AddressAlign:    0x8
+    Entries:
+      - Tag:             DT_NEEDED
+        Value:           0x7C
+      - Tag:             DT_NEEDED
+        Value:           0x67
+      - Tag:             DT_DEBUG
+        Value:           0x0
+      - Tag:             DT_RELA
+        Value:           0x2004A0
+      - Tag:             DT_RELASZ
+        Value:           0x48
+      - Tag:             DT_RELAENT
+        Value:           0x18
+      - Tag:             DT_JMPREL
+        Value:           0x200500
+      - Tag:             DT_PLTRELSZ
+        Value:           0x48
+      - Tag:             DT_PLTGOT
+        Value:           0x230B50
+      - Tag:             DT_PLTREL
+        Value:           0x7
+      - Tag:             DT_SYMTAB
+        Value:           0x2002E8
+      - Tag:             DT_SYMENT
+        Value:           0x18
+      - Tag:             DT_STRTAB
+        Value:           0x200418
+      - Tag:             DT_STRSZ
+        Value:           0x83
+      - Tag:             DT_NULL
+        Value:           0x0
+  - Name:            .got
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x220B30
+    AddressAlign:    0x8
+    Content:         '00000000000000000000000000000000'
+  - Name:            .data
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x230B40
+    AddressAlign:    0x8
+    Content:         '00000000000000000000000000000000'
+  - Name:            .got.plt
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x230B50
+    AddressAlign:    0x8
+    Content:         '00000000000000000000000000000000000000000000000020092100000000002009210000000000200921000000000020092100000000000000000000000000'
+  - Name:            .bss
+    Type:            SHT_NOBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x230B90
+    AddressAlign:    0x8
+    Size:            0xC
+  - Name:            .rela.text
+    Type:            SHT_RELA
+    Flags:           [ SHF_INFO_LINK ]
+    Link:            .symtab
+    AddressAlign:    0x8
+    Info:            .text
+    Relocations:
+      - Offset:          0x210728
+        Symbol:          .text
+        Type:            R_AARCH64_ADR_PREL_PG_HI21
+        Addend:          56
+      - Offset:          0x21072C
+        Symbol:          .text
+        Type:            R_AARCH64_ADD_ABS_LO12_NC
+        Addend:          56
+      - Offset:          0x210740
+        Symbol:          __libc_start_main
+        Type:            R_AARCH64_CALL26
+      - Offset:          0x210744
+        Symbol:          abort
+        Type:            R_AARCH64_CALL26
+      - Offset:          0x210748
+        Symbol:          main
+        Type:            R_AARCH64_JUMP26
+      - Offset:          0x210778
+        Symbol:          .rodata
+        Type:            R_AARCH64_ADR_PREL_PG_HI21
+        Addend:          8
+      - Offset:          0x21077C
+        Symbol:          .rodata
+        Type:            R_AARCH64_LDST64_ABS_LO12_NC
+        Addend:          8
+      - Offset:          0x2107B8
+        Symbol:          .rodata
+        Type:            R_AARCH64_ADR_PREL_PG_HI21
+        Addend:          16
+      - Offset:          0x2107BC
+        Symbol:          .rodata
+        Type:            R_AARCH64_LDST64_ABS_LO12_NC
+        Addend:          16
+      - Offset:          0x2107DC
+        Symbol:          .bss
+        Type:            R_AARCH64_ADR_PREL_PG_HI21
+      - Offset:          0x2107E0
+        Symbol:          .bss
+        Type:            R_AARCH64_LDST8_ABS_LO12_NC
+      - Offset:          0x2107F0
+        Symbol:          .bss
+        Type:            R_AARCH64_LDST8_ABS_LO12_NC
+      - Offset:          0x21081C
+        Symbol:          dec
+        Type:            R_AARCH64_ADR_PREL_PG_HI21
+      - Offset:          0x210820
+        Symbol:          dec
+        Type:            R_AARCH64_ADD_ABS_LO12_NC
+      - Offset:          0x210834
+        Symbol:          t1
+        Type:            R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21
+      - Offset:          0x210838
+        Symbol:          t1
+        Type:            R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC
+      - Offset:          0x21084C
+        Symbol:          a
+        Type:            R_AARCH64_ADR_PREL_PG_HI21
+      - Offset:          0x210854
+        Symbol:          a
+        Type:            R_AARCH64_LDST32_ABS_LO12_NC
+      - Offset:          0x210858
+        Symbol:          ifuncDec
+        Type:            R_AARCH64_CALL26
+      - Offset:          0x210860
+        Symbol:          a
+        Type:            R_AARCH64_LDST32_ABS_LO12_NC
+      - Offset:          0x210864
+        Symbol:          inc
+        Type:            R_AARCH64_CALL26
+Symbols:
+  - Name:            .text
+    Type:            STT_SECTION
+    Section:         .text
+    Value:           0x210710
+  - Name:            .data
+    Type:            STT_SECTION
+    Section:         .data
+    Value:           0x230B40
+  - Name:            .bss
+    Type:            STT_SECTION
+    Section:         .bss
+    Value:           0x230B90
+  - Name:            .rodata
+    Type:            STT_SECTION
+    Section:         .rodata
+    Value:           0x200560
+  - Name:            .interp
+    Type:            STT_SECTION
+    Section:         .interp
+    Value:           0x2002A8
+  - Name:            _DYNAMIC
+    Section:         .dynamic
+    Value:           0x2209A0
+    Other:           [ STV_HIDDEN ]
+  - Name:            abort
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            _start
+    Type:            STT_FUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x210710
+  - Name:            main
+    Type:            STT_FUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x210828
+    Size:            0x50
+  - Name:            __libc_start_main
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            dec
+    Type:            STT_FUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x210804
+    Size:            0x18
+  - Name:            resolver
+    Type:            STT_FUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x21081C
+    Size:            0xC
+  - Name:            t1
+    Type:            STT_TLS
+    Binding:         STB_GLOBAL
+  - Name:            a
+    Type:            STT_OBJECT
+    Section:         .bss
+    Binding:         STB_GLOBAL
+    Value:           0x230B98
+    Size:            0x4
+  - Name:            ifuncDec
+    Type:            STT_GNU_IFUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x21081C
+    Size:            0xC
+  - Name:            inc
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+DynamicSymbols:
+  - Name:            abort
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            __libc_start_main
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            t1
+    Type:            STT_TLS
+    Binding:         STB_GLOBAL
+  - Name:            inc
+    Type:            STT_FUNC
+    Binding:         STB_GLOBAL
+  - Name:            a
+    Type:            STT_OBJECT
+    Section:         .bss
+    Binding:         STB_GLOBAL
+    Value:           0x230B98
+    Size:            0x4
diff --git a/bolt/test/AArch64/Inputs/rels-so.yaml b/bolt/test/AArch64/Inputs/rels-so.yaml
new file mode 100644 (file)
index 0000000..9ff4295
--- /dev/null
@@ -0,0 +1,306 @@
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_DYN
+  Machine:         EM_AARCH64
+ProgramHeaders:
+  - Type:            PT_PHDR
+    Flags:           [ PF_R ]
+    VAddr:           0x40
+    Align:           0x8
+  - Type:            PT_LOAD
+    Flags:           [ PF_R ]
+    FirstSec:        .dynsym
+    LastSec:         .dynamic
+    Align:           0x10000
+  - Type:            PT_LOAD
+    Flags:           [ PF_X, PF_R ]
+    FirstSec:        .text
+    LastSec:         .tbss
+    VAddr:           0x10658
+    Align:           0x10000
+  - Type:            PT_LOAD
+    Flags:           [ PF_W, PF_R ]
+    FirstSec:        .tbss
+    LastSec:         .got
+    VAddr:           0x207F0
+    Align:           0x10000
+  - Type:            PT_LOAD
+    Flags:           [ PF_W, PF_R ]
+    FirstSec:        .data
+    LastSec:         .bss
+    VAddr:           0x309C8
+    Align:           0x10000
+  - Type:            PT_TLS
+    Flags:           [ PF_R ]
+    FirstSec:        .tbss
+    LastSec:         .tbss
+    VAddr:           0x107F0
+    Align:           0x4
+  - Type:            PT_DYNAMIC
+    Flags:           [ PF_W, PF_R ]
+    FirstSec:        .dynamic
+    LastSec:         .dynamic
+    VAddr:           0x20800
+    Align:           0x8
+  - Type:            PT_GNU_RELRO
+    Flags:           [ PF_R ]
+    FirstSec:        .tbss
+    LastSec:         .got
+    VAddr:           0x207F0
+Sections:
+  - Name:            .dynsym
+    Type:            SHT_DYNSYM
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x270
+    Link:            .dynstr
+    AddressAlign:    0x8
+  - Name:            .dynstr
+    Type:            SHT_STRTAB
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x3AC
+    AddressAlign:    0x1
+  - Name:            .rela.dyn
+    Type:            SHT_RELA
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x428
+    Link:            .dynsym
+    AddressAlign:    0x8
+    Relocations:
+      - Offset:          0x209B0
+        Symbol:          a
+        Type:            R_AARCH64_GLOB_DAT
+      - Offset:          0x309D8
+        Symbol:          a
+        Type:            R_AARCH64_ABS64
+      - Offset:          0x209B8
+        Symbol:          t1
+        Type:            R_AARCH64_TLSDESC
+  - Name:            .rela.plt
+    Type:            SHT_RELA
+    Flags:           [ SHF_ALLOC, SHF_INFO_LINK ]
+    Address:         0x530
+    Link:            .dynsym
+    AddressAlign:    0x8
+    Info:            .got.plt
+    Relocations:
+      - Offset:          0x30A00
+        Symbol:          __gmon_start__
+        Type:            R_AARCH64_JUMP_SLOT
+      - Offset:          0x30A08
+        Symbol:          __cxa_finalize
+        Type:            R_AARCH64_JUMP_SLOT
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x10658
+    AddressAlign:    0x8
+    Content:         8000009000C844F9400000B45B000014C0035FD6000000001F2003D5A01B10101F2003D5611B10103F0000EBC00000548100009021CC44F9610000B4F00301AA00021FD6C0035FD61F2003D5201A10101F2003D5E1191010210000CB22FC7FD3410C818BFF0781EB21FC4193C00000548200009042D044F9620000B4F00302AA00021FD6C0035FD6FD7BBEA9FD030091F30B00F91301009060426839400100358000009000D444F9800000B40001009000E444F935000094D8FFFF972000805260422839F30B40F9FD7BC2A8C0035FD6DEFFFF17FF8300D1FD7B01A9FD430091A0C31FB88900009029D944F9280140B908050011280100B98000009001DC44F900E0269120003FD649D03BD5286960B808050011286920B8A8C35FB800050011FD7B41A9FF830091C0035FD6
+  - Name:            .plt
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x107B0
+    AddressAlign:    0x10
+    Content:         F07BBFA91001009011FE44F910E2279120021FD61F2003D51F2003D51F2003D510010090110245F91002289120021FD610010090110645F91022289120021FD6
+  - Name:            .tbss
+    Type:            SHT_NOBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC, SHF_TLS ]
+    Address:         0x107F0
+    AddressAlign:    0x4
+    Size:            0x4
+  - Name:            .dynamic
+    Type:            SHT_DYNAMIC
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x20800
+    Link:            .dynstr
+    AddressAlign:    0x8
+    Entries:
+      - Tag:             DT_NEEDED
+        Value:           0x60
+      - Tag:             DT_SONAME
+        Value:           0x75
+      - Tag:             DT_RELA
+        Value:           0x428
+      - Tag:             DT_RELASZ
+        Value:           0x48
+      - Tag:             DT_RELAENT
+        Value:           0x18
+      - Tag:             DT_RELACOUNT
+        Value:           0x4
+      - Tag:             DT_JMPREL
+        Value:           0x530
+      - Tag:             DT_PLTRELSZ
+        Value:           0x30
+      - Tag:             DT_PLTGOT
+        Value:           0x309E8
+      - Tag:             DT_PLTREL
+        Value:           0x7
+      - Tag:             DT_SYMTAB
+        Value:           0x270
+      - Tag:             DT_SYMENT
+        Value:           0x18
+      - Tag:             DT_STRTAB
+        Value:           0x3AC
+      - Tag:             DT_STRSZ
+        Value:           0x7C
+      - Tag:             DT_GNU_HASH
+        Value:           0x380
+      - Tag:             DT_NULL
+        Value:           0x0
+  - Name:            .got
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x20990
+    AddressAlign:    0x8
+    Content:         '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
+  - Name:            .data
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x309C8
+    AddressAlign:    0x8
+    Content:         '0000000000000000010000000000000000000000000000000000000000000000'
+  - Name:            .got.plt
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x309E8
+    AddressAlign:    0x8
+    Content:         000000000000000000000000000000000000000000000000B007010000000000B007010000000000
+  - Name:            .bss
+    Type:            SHT_NOBITS
+    Flags:           [ SHF_WRITE, SHF_ALLOC ]
+    Address:         0x30A10
+    AddressAlign:    0x4
+    Size:            0x8
+  - Name:            .rela.text
+    Type:            SHT_RELA
+    Flags:           [ SHF_INFO_LINK ]
+    Link:            .symtab
+    AddressAlign:    0x8
+    Info:            .text
+    Relocations:
+      - Offset:          0x1073C
+        Symbol:          a
+        Type:            R_AARCH64_ADR_GOT_PAGE
+      - Offset:          0x10740
+        Symbol:          a
+        Type:            R_AARCH64_LD64_GOT_LO12_NC
+      - Offset:          0x10750
+        Symbol:          t1
+        Type:            R_AARCH64_TLSDESC_ADR_PAGE21
+      - Offset:          0x10754
+        Symbol:          t1
+        Type:            R_AARCH64_TLSDESC_LD64_LO12
+      - Offset:          0x10758
+        Symbol:          t1
+        Type:            R_AARCH64_TLSDESC_ADD_LO12
+      - Offset:          0x1075C
+        Symbol:          t1
+        Type:            R_AARCH64_TLSDESC_CALL
+  - Name:            .rela.data
+    Type:            SHT_RELA
+    Flags:           [ SHF_INFO_LINK ]
+    Link:            .symtab
+    AddressAlign:    0x8
+    Info:            .data
+    Relocations:
+      - Offset:          0x309C8
+        Symbol:          __dso_handle
+        Type:            R_AARCH64_ABS64
+      - Offset:          0x309D8
+        Symbol:          a
+        Type:            R_AARCH64_ABS64
+      - Offset:          0x309E0
+        Symbol:          .bss
+        Type:            R_AARCH64_ABS64
+        Addend:          4
+Symbols:
+  - Name:            '$x'
+    Section:         .text
+    Value:           0x10658
+  - Name:            call_weak_fn
+    Type:            STT_FUNC
+    Section:         .text
+    Value:           0x10658
+    Size:            0x14
+  - Name:            .text
+    Type:            STT_SECTION
+    Section:         .text
+    Value:           0x10658
+  - Name:            .data
+    Type:            STT_SECTION
+    Section:         .data
+    Value:           0x309C8
+  - Name:            .bss
+    Type:            STT_SECTION
+    Section:         .bss
+    Value:           0x30A10
+  - Name:            frame_dummy
+    Type:            STT_FUNC
+    Section:         .text
+    Value:           0x10728
+  - Name:            __dso_handle
+    Type:            STT_OBJECT
+    Section:         .data
+    Value:           0x309C8
+    Other:           [ STV_HIDDEN ]
+  - Name:            .tbss
+    Type:            STT_SECTION
+    Section:         .tbss
+    Value:           0x107F0
+  - Name:            _DYNAMIC
+    Section:         .dynamic
+    Value:           0x20800
+    Other:           [ STV_HIDDEN ]
+  - Name:            inc
+    Type:            STT_FUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x1072C
+    Size:            0x58
+  - Name:            a
+    Type:            STT_OBJECT
+    Section:         .data
+    Binding:         STB_GLOBAL
+    Value:           0x309D0
+    Size:            0x4
+  - Name:            t1
+    Type:            STT_TLS
+    Section:         .tbss
+    Binding:         STB_GLOBAL
+    Size:            0x4
+  - Name:            b
+    Type:            STT_OBJECT
+    Section:         .data
+    Binding:         STB_GLOBAL
+    Value:           0x309D8
+    Size:            0x8
+DynamicSymbols:
+  - Name:            __gmon_start__
+    Binding:         STB_WEAK
+  - Name:            __cxa_finalize
+    Type:            STT_FUNC
+    Binding:         STB_WEAK
+  - Name:            inc
+    Type:            STT_FUNC
+    Section:         .text
+    Binding:         STB_GLOBAL
+    Value:           0x1072C
+    Size:            0x58
+  - Name:            a
+    Type:            STT_OBJECT
+    Section:         .data
+    Binding:         STB_GLOBAL
+    Value:           0x309D0
+    Size:            0x4
+  - Name:            t1
+    Type:            STT_TLS
+    Section:         .tbss
+    Binding:         STB_GLOBAL
+    Size:            0x4
+  - Name:            b
+    Type:            STT_OBJECT
+    Section:         .data
+    Binding:         STB_GLOBAL
+    Value:           0x309D8
+    Size:            0x8
diff --git a/bolt/test/AArch64/plt-lld.test b/bolt/test/AArch64/plt-lld.test
deleted file mode 100644 (file)
index 0a86a9e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// This test checks that the PLT symbols are properly recognized
-// by the BOLT tool.
-
-// RUN: %clang %cflags %p/../Inputs/stub.c -fuse-ld=lld -fPIC -pie -shared \
-// RUN:   -o %t.so
-// RUN: %clang %cflags %p/../Inputs/plt.c -fuse-ld=lld \
-// RUN:    -o %t.lld.exe -Wl,-q %t.so
-// RUN: llvm-bolt %t.lld.exe -o %t.lld.bolt.exe -use-old-text=0 -lite=0 \
-// RUN:   -print-cfg -print-only=main | FileCheck %s
-
-// CHECK: memcpy@PLT
-// CHECK: memset@PLT
-// CHECK: printf@PLT
diff --git a/bolt/test/AArch64/runtime-relocs.test b/bolt/test/AArch64/runtime-relocs.test
new file mode 100644 (file)
index 0000000..8f73e67
--- /dev/null
@@ -0,0 +1,43 @@
+// This test checks dynamic relocations support for aarch64.
+
+RUN: yaml2obj %p/Inputs/rels-so.yaml &> %t.so
+RUN: yaml2obj %p/Inputs/rels-exe.yaml &> %t.exe
+RUN: llvm-bolt %t.so -o %t.bolt.so -use-old-text=0 -lite=0
+RUN: llvm-bolt %t.exe -o %t.bolt.exe -use-old-text=0 -lite=0
+
+// Check relocations in library:
+
+RUN: llvm-readelf -rW %t.bolt.so | FileCheck %s -check-prefix=CHECKLIB
+
+CHECKLIB: {{.*}} R_AARCH64_GLOB_DAT     {{.*}} a + 0
+CHECKLIB: {{.*}} R_AARCH64_TLSDESC      {{.*}} t1 + 0
+CHECKLIB: {{.*}} R_AARCH64_ABS64        {{.*}} a + 0
+
+// Check relocations in executable:
+
+RUN: llvm-readelf -rW %t.bolt.exe | FileCheck %s -check-prefix=CHECKEXE
+
+CHECKEXE: {{.*}} R_AARCH64_TLS_TPREL64  {{.*}} t1 + 0
+CHECKEXE: {{.*}} R_AARCH64_COPY         {{.*}} a + 0
+CHECKEXE: {{.*}} R_AARCH64_JUMP_SLOT    {{.*}} inc + 0
+
+// Check traditional TLS relocations R_AARCH64_TLS_DTPMOD64 and
+// R_AARCH64_TLS_DTPREL64 emitted correctly after bolt. Since these
+// relocations are obsolete and clang and lld does not support them,
+// the initial binary was built with gcc and ld with -mtls-dialect=trad flag.
+
+RUN: yaml2obj %p/Inputs/tls-trad.yaml &> %t.trad.so
+RUN: llvm-bolt %t.trad.so -o %t.trad.bolt.so -use-old-text=0 -lite=0
+RUN: llvm-readelf -rW %t.trad.so | FileCheck %s -check-prefix=CHECKTRAD
+
+CHECKTRAD: {{.*}} R_AARCH64_TLS_DTPMOD64 {{.*}} t1 + 0
+CHECKTRAD: {{.*}} R_AARCH64_TLS_DTPREL64 {{.*}} t1 + 0
+
+// The ld linker emits R_AARCH64_TLSDESC to .rela.plt section, check that
+// it is emitted correctly.
+
+RUN: yaml2obj %p/Inputs/tls-ld.yaml &> %t.ld.so
+RUN: llvm-bolt %t.ld.so -o %t.ld.bolt.so -use-old-text=0 -lite=0
+RUN: llvm-readelf -rW %t.ld.bolt.so | FileCheck %s -check-prefix=CHECKLD
+
+CHECKLD: {{.*}} R_AARCH64_TLSDESC        {{.*}} t1 + 0
diff --git a/bolt/test/runtime/AArch64/Inputs/runtime_relocs.c b/bolt/test/runtime/AArch64/Inputs/runtime_relocs.c
deleted file mode 100644 (file)
index f60bd27..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-int a = 1;
-__attribute__((used)) int *b = &a; // R_*_ABS64
-
-static int c;
-__attribute__((used)) static int *d = &c; // R_*_RELATIVE
-
-__thread int t1 = 0;
-
-int inc(int var) {
-  ++a;  // R_*_GLOB_DAT
-  ++t1; // R_*_TLSDESC
-  return var + 1;
-}
diff --git a/bolt/test/runtime/AArch64/runtime_relocs.c b/bolt/test/runtime/AArch64/runtime_relocs.c
deleted file mode 100644 (file)
index 28a5791..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-// This test checks dynamic relocations support for aarch64.
-
-// RUN: %clang %cflags -pie -fPIC %S/Inputs/runtime_relocs.c \
-// RUN:    -shared -fuse-ld=lld -o %t.so -Wl,-q -Wl,-soname=rel.so
-// RUN: %clang %cflags -no-pie %s -fuse-ld=lld \
-// RUN:    -o %t.exe -Wl,-q %t.so
-// RUN: llvm-bolt %t.so -o %t.bolt.so -use-old-text=0 -lite=0
-// RUN: llvm-bolt %t.exe -o %t.bolt.exe -use-old-text=0 -lite=0
-// RUN: LD_PRELOAD=%t.bolt.so %t.bolt.exe
-
-// Check relocations in library:
-//
-// RUN: llvm-readelf -r %t.bolt.so | FileCheck %s -check-prefix=CHECKLIB
-//
-// CHECKLIB: 0000000600000401 R_AARCH64_GLOB_DAT     {{.*}} a + 0
-// CHECKLIB: 0000000700000407 R_AARCH64_TLSDESC      {{.*}} t1 + 0
-// CHECKLIB: 0000000600000101 R_AARCH64_ABS64        {{.*}} a + 0
-
-// Check relocations in executable:
-//
-// RUN: llvm-readelf -r %t.bolt.exe | FileCheck %s -check-prefix=CHECKEXE
-//
-// CHECKEXE: 0000000600000406 R_AARCH64_TLS_TPREL64  {{.*}} t1 + 0
-// CHECKEXE: 0000000800000400 R_AARCH64_COPY         {{.*}} a + 0
-// CHECKEXE: 0000000700000402 R_AARCH64_JUMP_SLOT    {{.*}} inc + 0
-
-// Check traditional TLS relocations R_AARCH64_TLS_DTPMOD64 and
-// R_AARCH64_TLS_DTPREL64 emitted correctly after bolt. Since these
-// relocations are obsolete and clang and lld does not support them,
-// the initial binary was built with gcc and ld with -mtls-dialect=trad flag.
-//
-// RUN: yaml2obj %p/Inputs/tls_trad.yaml &> %t.trad.so
-// RUN: llvm-bolt %t.trad.so -o %t.trad.bolt.so -use-old-text=0 -lite=0
-// RUN: llvm-readelf -r %t.trad.so | FileCheck %s -check-prefix=CHECKTRAD
-//
-// CHECKTRAD: 0000000100000404 R_AARCH64_TLS_DTPMOD64 {{.*}} t1 + 0
-// CHECKTRAD: 0000000100000405 R_AARCH64_TLS_DTPREL64 {{.*}} t1 + 0
-
-// The ld linker emits R_AARCH64_TLSDESC to .rela.plt section, check that
-// it is emitted correctly.
-//
-// RUN: yaml2obj %p/Inputs/tls_ld.yaml &> %t.ld.so
-// RUN: llvm-bolt %t.ld.so -o %t.ld.bolt.so -use-old-text=0 -lite=0
-// RUN: llvm-readelf -r %t.ld.bolt.so | FileCheck %s -check-prefix=CHECKLD
-//
-// CHECKLD: 0000000100000407 R_AARCH64_TLSDESC        {{.*}} t1 + 0
-
-extern int a; // R_*_COPY
-
-extern __thread int t1; // R_*_TLS_TPREL64
-
-int inc(int a); // R_*_JUMP_SLOT
-
-int dec(int a) { return a - 1; }
-
-void *resolver() { return dec; }
-
-int ifuncDec(int a) __attribute__((ifunc("resolver"))); // R_*_IRELATIVE
-
-int main() {
-  ++t1;
-  ifuncDec(a);
-  inc(a);
-}