1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[BPF] put not-section-attribute externs into BTF ".extern" data section

Currently for extern variables with section attribute, those
BTF_KIND_VARs will not be placed in any DataSec. This is
inconvenient as any other generated BTF_KIND_VAR belongs to
one DataSec. This patch put these extern variables into
".extern" section so bpf loader can have a consistent
processing mechanism for all data sections and variables.
This commit is contained in:
Yonghong Song 2019-12-10 11:05:22 -08:00
parent 0b4c2010ff
commit 36b96dd940
5 changed files with 50 additions and 15 deletions

View File

@ -1065,6 +1065,10 @@ void BTFDebug::processGlobals(bool ProcessingMapDef) {
SecName = ".rodata";
else
SecName = Global.getInitializer()->isZeroValue() ? ".bss" : ".data";
} else {
// extern variables without explicit section,
// put them into ".extern" section.
SecName = ".extern";
}
if (ProcessingMapDef != SecName.startswith(".maps"))
@ -1113,8 +1117,7 @@ void BTFDebug::processGlobals(bool ProcessingMapDef) {
std::make_unique<BTFKindVar>(Global.getName(), GVTypeId, GVarInfo);
uint32_t VarId = addType(std::move(VarEntry));
if (SecName.empty())
continue;
assert(!SecName.empty());
// Find or create a DataSec
if (DataSecEntries.find(SecName) == DataSecEntries.end()) {
@ -1167,7 +1170,7 @@ void BTFDebug::processFuncPrototypes() {
StringRef SecName = F.getSection();
if (SecName.empty())
continue;
SecName = ".extern";
if (DataSecEntries.find(SecName) == DataSecEntries.end()) {
DataSecEntries[SecName] = std::make_unique<BTFKindDataSec>(Asm, SecName);

View File

@ -23,9 +23,9 @@ declare !dbg !4 extern_weak dso_local i32 @global_func(i8 signext) local_unnamed
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .long 24
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 92
; CHECK-NEXT: .long 92
; CHECK-NEXT: .long 72
; CHECK-NEXT: .long 116
; CHECK-NEXT: .long 116
; CHECK-NEXT: .long 80
; CHECK-NEXT: .long 0 # BTF_KIND_FUNC_PROTO(id = 1)
; CHECK-NEXT: .long 218103808 # 0xd000000
; CHECK-NEXT: .long 2
@ -49,6 +49,12 @@ declare !dbg !4 extern_weak dso_local i32 @global_func(i8 signext) local_unnamed
; CHECK-NEXT: .long 234881024 # 0xe000000
; CHECK-NEXT: .long 4
; CHECK-NEXT: .long 2
; CHECK-NEXT: .long 72 # BTF_KIND_DATASEC(id = 7)
; CHECK-NEXT: .long 251658241 # 0xf000001
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 6
; CHECK-NEXT: .long global_func
; CHECK-NEXT: .long 8
; CHECK-NEXT: .byte 0 # string offset=0
; CHECK-NEXT: .ascii "int" # string offset=1
; CHECK-NEXT: .byte 0
@ -62,6 +68,8 @@ declare !dbg !4 extern_weak dso_local i32 @global_func(i8 signext) local_unnamed
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .ascii "global_func" # string offset=60
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .ascii ".extern" # string offset=72
; CHECK-NEXT: .byte 0
attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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" }
attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="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" }

View File

@ -22,9 +22,9 @@ entry:
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .long 24
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 92
; CHECK-NEXT: .long 92
; CHECK-NEXT: .long 72
; CHECK-NEXT: .long 116
; CHECK-NEXT: .long 116
; CHECK-NEXT: .long 80
; CHECK-NEXT: .long 0 # BTF_KIND_FUNC_PROTO(id = 1)
; CHECK-NEXT: .long 218103808 # 0xd000000
; CHECK-NEXT: .long 2
@ -48,6 +48,12 @@ entry:
; CHECK-NEXT: .long 234881024 # 0xe000000
; CHECK-NEXT: .long 4
; CHECK-NEXT: .long 2
; CHECK-NEXT: .long 72 # BTF_KIND_DATASEC(id = 7)
; CHECK-NEXT: .long 251658241 # 0xf000001
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 6
; CHECK-NEXT: .long global_func
; CHECK-NEXT: .long 8
; CHECK-NEXT: .byte 0 # string offset=0
; CHECK-NEXT: .ascii "int" # string offset=1
; CHECK-NEXT: .byte 0
@ -61,6 +67,8 @@ entry:
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .ascii "global_func" # string offset=60
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .ascii ".extern" # string offset=72
; CHECK-NEXT: .byte 0
declare !dbg !4 dso_local i32 @global_func(i8 signext) local_unnamed_addr #1

View File

@ -24,9 +24,9 @@ entry:
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .long 24
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 92
; CHECK-NEXT: .long 92
; CHECK-NEXT: .long 73
; CHECK-NEXT: .long 116
; CHECK-NEXT: .long 116
; CHECK-NEXT: .long 81
; CHECK-NEXT: .long 0 # BTF_KIND_FUNC_PROTO(id = 1)
; CHECK-NEXT: .long 218103808 # 0xd000000
; CHECK-NEXT: .long 2
@ -50,6 +50,12 @@ entry:
; CHECK-NEXT: .long 234881024 # 0xe000000
; CHECK-NEXT: .long 4
; CHECK-NEXT: .long 2
; CHECK-NEXT: .long 73 # BTF_KIND_DATASEC(id = 7)
; CHECK-NEXT: .long 251658241 # 0xf000001
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 6
; CHECK-NEXT: .long global
; CHECK-NEXT: .long 4
; CHECK-NEXT: .byte 0 # string offset=0
; CHECK-NEXT: .ascii "int" # string offset=1
; CHECK-NEXT: .byte 0
@ -67,6 +73,8 @@ entry:
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .ascii "global" # string offset=66
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .ascii ".extern" # string offset=73
; CHECK-NEXT: .byte 0
attributes #0 = { norecurse nounwind readonly "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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" }

View File

@ -25,9 +25,9 @@ entry:
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .long 24
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 92
; CHECK-NEXT: .long 92
; CHECK-NEXT: .long 73
; CHECK-NEXT: .long 116
; CHECK-NEXT: .long 116
; CHECK-NEXT: .long 81
; CHECK-NEXT: .long 0 # BTF_KIND_FUNC_PROTO(id = 1)
; CHECK-NEXT: .long 218103808 # 0xd000000
; CHECK-NEXT: .long 2
@ -51,6 +51,12 @@ entry:
; CHECK-NEXT: .long 234881024 # 0xe000000
; CHECK-NEXT: .long 4
; CHECK-NEXT: .long 2
; CHECK-NEXT: .long 73 # BTF_KIND_DATASEC(id = 7)
; CHECK-NEXT: .long 251658241 # 0xf000001
; CHECK-NEXT: .long 0
; CHECK-NEXT: .long 6
; CHECK-NEXT: .long global
; CHECK-NEXT: .long 4
; CHECK-NEXT: .byte 0 # string offset=0
; CHECK-NEXT: .ascii "int" # string offset=1
; CHECK-NEXT: .byte 0
@ -68,6 +74,8 @@ entry:
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .ascii "global" # string offset=66
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .ascii ".extern" # string offset=73
; CHECK-NEXT: .byte 0
attributes #0 = { norecurse nounwind readonly "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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" }