diff options
author | Yonghong Song <yhs@fb.com> | 2019-12-10 11:05:22 -0800 |
---|---|---|
committer | Yonghong Song <yhs@fb.com> | 2019-12-10 11:45:17 -0800 |
commit | 7d0e8930ed08b5f938a317f13d8fc994dd8c551c (patch) | |
tree | dfbf1dd3217f19e1e03fea5e0e7864415a8a85e1 /llvm/lib/Target | |
parent | d0789e6346e489cd84b37ec58964feb0db015de7 (diff) | |
download | bcm5719-llvm-7d0e8930ed08b5f938a317f13d8fc994dd8c551c.tar.gz bcm5719-llvm-7d0e8930ed08b5f938a317f13d8fc994dd8c551c.zip |
[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.
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r-- | llvm/lib/Target/BPF/BTFDebug.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp index 9dce734ea08..bdc7ce71a88 100644 --- a/llvm/lib/Target/BPF/BTFDebug.cpp +++ b/llvm/lib/Target/BPF/BTFDebug.cpp @@ -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); |