Home | History | Annotate | Download | only in llvm2ice_tests
      1 ; Tests that we generate an ELF container correctly when there
      2 ; is no data section.
      3 
      4 ; RUN: %p2i -i %s --filetype=obj --output %t --args -O2 \
      5 ; RUN:   && llvm-readobj -file-headers -sections -section-data \
      6 ; RUN:       -relocations -symbols %t | FileCheck %s
      7 
      8 ; RUN: %if --need=allow_dump --command %p2i -i %s --args -O2 \
      9 ; RUN:   | %if --need=allow_dump --command \
     10 ; RUN:   llvm-mc -triple=i686-nacl -filetype=obj -o - \
     11 ; RUN:   | %if --need=allow_dump --command \
     12 ; RUN:   llvm-readobj -file-headers -sections -section-data \
     13 ; RUN:       -relocations -symbols - \
     14 ; RUN:   | %if --need=allow_dump --command FileCheck %s
     15 
     16 declare void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
     17 
     18 define internal i32 @foo(i32 %x, i32 %len) {
     19   %y = add i32 %x, %x
     20   %dst = inttoptr i32 %y to i8*
     21   %src = inttoptr i32 %x to i8*
     22   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dst, i8* %src,
     23                                        i32 %len, i32 1, i1 false)
     24 
     25   ret i32 %y
     26 }
     27 
     28 ; Test defining a non-internal function.
     29 define void @_start(i32 %x) {
     30   %ignored = call i32 @foo(i32 %x, i32 4)
     31   ret void
     32 }
     33 
     34 ; CHECK:   Section {
     35 ; CHECK:     Index: {{[1-9][0-9]*}}
     36 ; CHECK:     Name: .text
     37 ; CHECK:     Type: SHT_PROGBITS
     38 ; CHECK:     Flags [ (0x6)
     39 ; CHECK:       SHF_ALLOC
     40 ; CHECK:       SHF_EXECINSTR
     41 ; CHECK:     ]
     42 ; CHECK:     Address: 0x0
     43 ; CHECK:     Offset: 0x{{[1-9A-F][0-9A-F]*}}
     44 ; CHECK:     Size: {{[1-9][0-9]*}}
     45 ; CHECK:     Link: 0
     46 ; CHECK:     Info: 0
     47 ; CHECK:     AddressAlignment: 32
     48 ; CHECK:     EntrySize: 0
     49 ; CHECK:     SectionData (
     50 ; CHECK:     )
     51 ; CHECK:   }
     52 ; CHECK:   Section {
     53 ; CHECK:     Index: {{[1-9][0-9]*}}
     54 ; CHECK:     Name: .rel.text
     55 ; CHECK:     Type: SHT_REL
     56 ; CHECK:     Flags [ (0x0)
     57 ; CHECK:     ]
     58 ; CHECK:     Address: 0x0
     59 ; CHECK:     Offset: 0x{{[1-9A-F][0-9A-F]*}}
     60 ; CHECK:     Size: {{[1-9][0-9]*}}
     61 ; CHECK:     Link: [[SYMTAB_INDEX:[1-9][0-9]*]]
     62 ; CHECK:     Info: {{[1-9][0-9]*}}
     63 ; CHECK:     AddressAlignment: 4
     64 ; CHECK:     EntrySize: 8
     65 ; CHECK:     SectionData (
     66 ; CHECK:     )
     67 ; CHECK:   }
     68 ; CHECK:   Section {
     69 ; CHECK:     Index: [[SYMTAB_INDEX]]
     70 ; CHECK-NEXT: Name: .symtab
     71 ; CHECK:     Type: SHT_SYMTAB
     72 ; CHECK:     Flags [ (0x0)
     73 ; CHECK:     ]
     74 ; CHECK:     Address: 0x0
     75 ; CHECK:     Offset: 0x{{[1-9A-F][0-9A-F]*}}
     76 ; CHECK:     Size: {{[1-9][0-9]*}}
     77 ; CHECK:     Link: {{[1-9][0-9]*}}
     78 ; CHECK:     Info: {{[1-9][0-9]*}}
     79 ; CHECK:     AddressAlignment: 4
     80 ; CHECK:     EntrySize: 16
     81 ; CHECK:   }
     82 
     83 
     84 ; CHECK: Relocations [
     85 ; CHECK:   Section ({{[0-9]+}}) .rel.text {
     86 ; CHECK:     0x1E R_386_PC32 memcpy 0x0
     87 ; CHECK:   }
     88 ; CHECK: ]
     89 
     90 
     91 ; CHECK: Symbols [
     92 ; CHECK-NEXT:   Symbol {
     93 ; CHECK-NEXT:     Name: (0)
     94 ; CHECK-NEXT:     Value: 0x0
     95 ; CHECK-NEXT:     Size: 0
     96 ; CHECK-NEXT:     Binding: Local
     97 ; CHECK-NEXT:     Type: None
     98 ; CHECK-NEXT:     Other: 0
     99 ; CHECK-NEXT:     Section: Undefined (0x0)
    100 ; CHECK-NEXT:   }
    101 ; CHECK:        Symbol {
    102 ; CHECK:          Name: foo
    103 ; CHECK-NEXT:     Value: 0x0
    104 ; CHECK-NEXT:     Size: 0
    105 ; CHECK-NEXT:     Binding: Local
    106 ; CHECK-NEXT:     Type: None
    107 ; CHECK-NEXT:     Other: 0
    108 ; CHECK-NEXT:     Section: .text
    109 ; CHECK-NEXT:   }
    110 ; CHECK:        Symbol {
    111 ; CHECK:          Name: _start
    112 ; CHECK-NEXT:     Value: 0x{{[1-9A-F][0-9A-F]*}}
    113 ; CHECK-NEXT:     Size: 0
    114 ; CHECK-NEXT:     Binding: Global
    115 ; CHECK-NEXT:     Type: Function
    116 ; CHECK-NEXT:     Other: 0
    117 ; CHECK-NEXT:     Section: .text
    118 ; CHECK-NEXT:   }
    119 ; CHECK:        Symbol {
    120 ; CHECK:          Name: memcpy
    121 ; CHECK-NEXT:     Value: 0x0
    122 ; CHECK-NEXT:     Size: 0
    123 ; CHECK-NEXT:     Binding: Global
    124 ; CHECK-NEXT:     Type: None
    125 ; CHECK-NEXT:     Other: 0
    126 ; CHECK-NEXT:     Section: Undefined
    127 ; CHECK-NEXT:   }
    128 ; CHECK: ]
    129