59 lines · plain
1; RUN: llc -mtriple=bpfel -filetype=obj < %s | llvm-objdump -r - | FileCheck --check-prefix=CHECK-RELOC %s2; RUN: llc -mtriple=bpfeb -filetype=obj < %s | llvm-objdump -r - | FileCheck --check-prefix=CHECK-RELOC %s3 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.c12 13@g = dso_local local_unnamed_addr global i32 4, section "ids", align 4, !dbg !014@s = internal global i32 0, align 4, !dbg !615 16; Function Attrs: norecurse nounwind17define dso_local i32 @test() local_unnamed_addr !dbg !14 {18 %1 = load i32, ptr @g, align 4, !dbg !17, !tbaa !1819 %2 = load volatile i32, ptr @s, align 4, !dbg !22, !tbaa !1820 %3 = add nsw i32 %2, %1, !dbg !2321 ret i32 %3, !dbg !2422}23 24; CHECK-RELOC: file format elf64-bpf25; CHECK-RELOC: RELOCATION RECORDS FOR [.BTF]:26; CHECK-RELOC: R_BPF_64_NODYLD32 .bss27; CHECK-RELOC: R_BPF_64_NODYLD32 g28; CHECK-RELOC: RELOCATION RECORDS FOR [.BTF.ext]:29 30!llvm.dbg.cu = !{!2}31!llvm.module.flags = !{!10, !11, !12}32!llvm.ident = !{!13}33 34!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())35!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 1, type: !9, isLocal: false, isDefinition: true)36!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)37!3 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/llvm/relocation")38!4 = !{}39!5 = !{!0, !6}40!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())41!7 = distinct !DIGlobalVariable(name: "s", scope: !2, file: !3, line: 2, type: !8, isLocal: true, isDefinition: true)42!8 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !9)43!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)44!10 = !{i32 2, !"Dwarf Version", i32 4}45!11 = !{i32 2, !"Debug Info Version", i32 3}46!12 = !{i32 1, !"wchar_size", i32 4}47!13 = !{!"clang version 9.0.0 (trunk 360739) (llvm/trunk 360747)"}48!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)49!15 = !DISubroutineType(types: !16)50!16 = !{!9}51!17 = !DILocation(line: 4, column: 10, scope: !14)52!18 = !{!19, !19, i64 0}53!19 = !{!"int", !20, i64 0}54!20 = !{!"omnipotent char", !21, i64 0}55!21 = !{!"Simple C/C++ TBAA"}56!22 = !DILocation(line: 4, column: 14, scope: !14)57!23 = !DILocation(line: 4, column: 12, scope: !14)58!24 = !DILocation(line: 4, column: 3, scope: !14)59