This is an archive of the discontinued LLVM Phabricator instance.

BPF: generate proper BTF for globals with WeakODRLinkage
ClosedPublic

Authored by yonghong-song on Apr 12 2021, 10:59 PM.

Details

Summary

For a global weak symbol defined as below:

char g __attribute__((weak)) = 2;

LLVM generates an allocated global with WeakAnyLinkage,
for which BPF backend generates proper BTF info.

For the above example, if a modifier "const" is added like

const char g __attribute__((weak)) = 2;

LLVM generates an allocated global with WeakODRLinkage,
for which BPF backend didn't generate any BTF as it
didn't handle WeakODRLinkage.

This patch addes support for WeakODRLinkage and proper
BTF info can be generated for weak symbol defined with
"const" modifier.

Diff Detail

Event Timeline

yonghong-song created this revision.Apr 12 2021, 10:59 PM
yonghong-song requested review of this revision.Apr 12 2021, 10:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2021, 10:59 PM
ast accepted this revision.Apr 13 2021, 8:39 AM
This revision is now accepted and ready to land.Apr 13 2021, 8:39 AM