This is an archive of the discontinued LLVM Phabricator instance.

BPF: remove default .extern data section
ClosedPublic

Authored by yonghong-song on Apr 13 2021, 9:30 AM.

Details

Summary

Currently, for any extern variable, if it doesn't have
section attribution, it will be put into a default ".extern"
btf DataSec. The initial design is to put every extern
variable in a DataSec so libbpf can use it.

But later on, libbpf actually requires extern variables
to put into special sections, e.g., ".kconfig", ".ksyms", etc.
so they can be used properly based on section name.

Andrii mentioned since ".extern" variables are
not actually used, it makes sense to remove it from
the compiler so libbpf does not need to deal with it,
esp. for static linking. The BTF for these extern variables
is still generated.

With this patch, I tested kernel selftests/bpf and all tests
passed. Indeed, removing ".extern" DataSec seems having no
impact.

Diff Detail

Event Timeline

yonghong-song created this revision.Apr 13 2021, 9:30 AM
yonghong-song requested review of this revision.Apr 13 2021, 9:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2021, 9:30 AM
ast accepted this revision.Apr 13 2021, 9:54 AM
This revision is now accepted and ready to land.Apr 13 2021, 9:54 AM
anakryiko accepted this revision.Apr 13 2021, 10:36 AM

LGTM, thanks!

This revision was landed with ongoing or failed builds.Apr 13 2021, 11:38 AM
This revision was automatically updated to reflect the committed changes.