1; RUN: llc -march=bpfel -filetype=obj < %s | llvm-objdump -r - | FileCheck --check-prefix=CHECK-RELOC %s 2; RUN: llc -march=bpfeb -filetype=obj < %s | llvm-objdump -r - | FileCheck --check-prefix=CHECK-RELOC %s 3 4; source code: 5; int g __attribute__((section("ids"))) = 4; 6; static volatile int s = 0; 7; int test() { 8; return g + s; 9; } 10; compilation flag: 11; clang -target bpf -g -O2 -emit-llvm -S test.c 12 13@g = dso_local local_unnamed_addr global i32 4, section "ids", align 4, !dbg !0 14@s = internal global i32 0, align 4, !dbg !6 15 16; Function Attrs: norecurse nounwind 17define dso_local i32 @test() local_unnamed_addr #0 !dbg !14 { 18 %1 = load i32, i32* @g, align 4, !dbg !17, !tbaa !18 19 %2 = load volatile i32, i32* @s, align 4, !dbg !22, !tbaa !18 20 %3 = add nsw i32 %2, %1, !dbg !23 21 ret i32 %3, !dbg !24 22} 23 24; CHECK-RELOC: file format elf64-bpf 25; CHECK-RELOC: RELOCATION RECORDS FOR [.BTF]: 26; CHECK-RELOC: R_BPF_NONE .bss 27; CHECK-RELOC: R_BPF_NONE g 28; CHECK-RELOC: RELOCATION RECORDS FOR [.BTF.ext]: 29 30attributes #0 = { norecurse nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "frame-pointer"="all" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 31 32!llvm.dbg.cu = !{!2} 33!llvm.module.flags = !{!10, !11, !12} 34!llvm.ident = !{!13} 35 36!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 37!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 1, type: !9, isLocal: false, isDefinition: true) 38!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 9.0.0 (trunk 360739) (llvm/trunk 360747)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None) 39!3 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/llvm/relocation") 40!4 = !{} 41!5 = !{!0, !6} 42!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) 43!7 = distinct !DIGlobalVariable(name: "s", scope: !2, file: !3, line: 2, type: !8, isLocal: true, isDefinition: true) 44!8 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !9) 45!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 46!10 = !{i32 2, !"Dwarf Version", i32 4} 47!11 = !{i32 2, !"Debug Info Version", i32 3} 48!12 = !{i32 1, !"wchar_size", i32 4} 49!13 = !{!"clang version 9.0.0 (trunk 360739) (llvm/trunk 360747)"} 50!14 = distinct !DISubprogram(name: "test", scope: !3, file: !3, line: 3, type: !15, scopeLine: 3, isLocal: false, isDefinition: true, isOptimized: true, unit: !2, retainedNodes: !4) 51!15 = !DISubroutineType(types: !16) 52!16 = !{!9} 53!17 = !DILocation(line: 4, column: 10, scope: !14) 54!18 = !{!19, !19, i64 0} 55!19 = !{!"int", !20, i64 0} 56!20 = !{!"omnipotent char", !21, i64 0} 57!21 = !{!"Simple C/C++ TBAA"} 58!22 = !DILocation(line: 4, column: 14, scope: !14) 59!23 = !DILocation(line: 4, column: 12, scope: !14) 60!24 = !DILocation(line: 4, column: 3, scope: !14) 61