[BPF] Support external globals
Previously, only types for external variables and globals without
section names are omitted.
This patch emitted types for all non-common-linkage globals.
common “common” linkage is most similar to “weak” linkage, but they are used for tentative definitions in C, such as “int X;” at global scope. ...
It is not clear what are "common"/"weak" semantics for bpf programs,
so omit them for now.
For non-extern global variables without section names,
- a BTF_KIND_VAR will be generated.
- the BTF_KIND_VAR will be put into .bss/.data DataSec based on whether they are zero initialized or not.
For extern globals:
- A BTF_KIND_VAR will be generated.
- if with section name, a DataSec with that section name will be created containing that global variable.
- external globals do not have types in BTF_KIND_VAR since clang does not generate debug info type for external variables.
- the in-section offset for extern variables will be all 0 since these variables are not allocated in current ELF.