• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1;; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -O3 -code-model=small  \
2;; RUN:  -filetype=obj %s -o - | \
3;; RUN: elf-dump --dump-section-data | FileCheck %s
4
5;; FIXME: this file need to be in .s form, change when asm parse is done.
6
7@number64 = global i64 10, align 8
8
9define i64 @access_int64(i64 %a) nounwind readonly {
10entry:
11  %0 = load i64* @number64, align 8
12  %cmp = icmp eq i64 %0, %a
13  %conv1 = zext i1 %cmp to i64
14  ret i64 %conv1
15}
16
17declare double @sin(double) nounwind
18
19define double @test_branch24 (double %x) nounwind readonly {
20entry:
21  %add = call double @sin(double %x) nounwind
22  ret double %add
23}
24
25;; The relocations in .rela.text are the 'number64' load using a
26;; R_PPC64_TOC16_DS against the .toc and the 'sin' external function
27;; address using a R_PPC64_REL24
28;; CHECK:       '.rela.text'
29;; CHECK:       Relocation 0
30;; CHECK-NEXT:  'r_offset',
31;; CHECK-NEXT:  'r_sym', 0x00000006
32;; CHECK-NEXT:  'r_type', 0x0000003f
33;; CHECK:       Relocation 1
34;; CHECK-NEXT:  'r_offset',
35;; CHECK-NEXT:  'r_sym', 0x0000000a
36;; CHECK-NEXT:  'r_type', 0x0000000a
37
38;; The .opd entry for the 'access_int64' function creates 2 relocations:
39;; 1. A R_PPC64_ADDR64 against the .text segment plus addend (the function
40;    address itself);
41;; 2. And a R_PPC64_TOC against no symbol (the linker will replace for the
42;;    module's TOC base).
43;; CHECK:       '.rela.opd'
44;; CHECK:       Relocation 0
45;; CHECK-NEXT:  'r_offset',
46;; CHECK-NEXT:  'r_sym', 0x00000002
47;; CHECK-NEXT:  'r_type', 0x00000026
48;; CHECK:       Relocation 1
49;; CHECK-NEXT:  'r_offset',
50;; CHECK-NEXT:  'r_sym', 0x00000000
51;; CHECK-NEXT:  'r_type', 0x00000033
52
53;; Finally the TOC creates the relocation for the 'number64'.
54;; CHECK:       '.rela.toc'
55;; CHECK:       Relocation 0
56;; CHECK-NEXT:  'r_offset',
57;; CHECK-NEXT:  'r_sym', 0x00000008
58;; CHECK-NEXT:  'r_type', 0x00000026
59
60;; Check if the relocation references are for correct symbols.
61;; CHECK:       Symbol 7
62;; CHECK-NEXT:  'access_int64'
63;; CHECK:       Symbol 8
64;; CHECK-NEXT:  'number64'
65;; CHECK:       Symbol 10
66;; CHECK-NEXT:  'sin'
67