export/helpers: only put helpers in special section for B lang
authorDave Marchevsky <davemarchevsky@fb.com>
Mon, 18 Oct 2021 00:25:48 +0000 (20:25 -0400)
committeryonghong-song <ys114321@gmail.com>
Mon, 18 Oct 2021 21:44:07 +0000 (14:44 -0700)
commitbd301e1bcb163fa38b2cdc6793d6681a4fa16ff2
tree1035df6eb01aa37c402e5f5f5950603046290a46
parent1b0eec23cd27cd148c56bf69c756c073dd90c0b9
export/helpers: only put helpers in special section for B lang

B's code generation needs these functions to exist in the object as it
emits some calls to these functions at IR stage, where 'always_inline'
directive results in no symbol for the function being emitted otherwise
as all uses are inlined.

For C, stop putting these helpers in a "helpers" section in object file.
For B, add a `B_WORKAROUND` ifdef check so the "helpers" section is
populated as expected.

There is almost certainly a more elegant way to fix this but would
require digging deep in the b frontend and potentially breaking other
things. Since B frontend hasn't been touched in many years and still
works, let's take the safer but uglier route.
src/cc/bpf_module.cc
src/cc/export/helpers.h