Re: [PATCH RFC] bpf: Symbol sizes and types in object file

Yonghong Song

On Wed, Sep 19, 2018 at 1:20 AM Paul Chaignon <paul.chaignon@...> wrote:

On Wed, Sept 19, 2018 at 8:17 AM, Yonghong Song wrote:
On 9/18/18 12:18 AM, Yutaro Hayakawa wrote:

Paul, thank you for your help. I’m Yutaro a reporter of this issue.

On Mon, Sep 17, 2018 at 3:46 PM Alexei Starovoitov
<alexei.starovoitov@... <mailto:alexei.starovoitov@...>>

On Mon, Sep 17, 2018 at 11:29:13PM +0200, Paul Chaignon wrote:
I am sending here as an RFC instead of LLVM's mailing list as I'm
not sure
this is the intended behavior, and the "fix" may therefore not be

Clang-compiled object files currently don't include the symbol sizes and
types. Some tools however need that information. For example,
uses that information to generate FreeBSD's CTF representation from ELF
With this patch, that information is included in object files.

Signed-off-by: Paul Chaignon <paul.chaignon@...
Reported-by: Yutaro Hayakawa <yhayakawa3720@...
Index: lib/Target/BPF/MCTargetDesc/BPFMCAsmInfo.h
--- lib/Target/BPF/MCTargetDesc/BPFMCAsmInfo.h (revision 341679)
+++ lib/Target/BPF/MCTargetDesc/BPFMCAsmInfo.h (working copy)
@@ -30,8 +30,8 @@
WeakRefDirective = "\t.weak\t";

UsesELFSectionDirectiveForBSS = true;
- HasSingleParameterDotFile = false;
- HasDotTypeDotSizeDirective = false;
+ HasSingleParameterDotFile = true;
+ HasDotTypeDotSizeDirective = true;

SupportsDebugInformation = true;
ExceptionsType = ExceptionHandling::DwarfCFI;
make sense to me, but I wonder why pahole's dwarf->btf converter
doesn't have this issue.
Could you describe what exactly are you trying to do with llvm
generated elf file?
Currently, BTF does not deal with symbols, so that is why it is okay.
llvm-objdump does not need symbol size either. It only needs symbol
that is why we did not have issues so far.

In my future proposed func support in BTF, I also need offset only.

In your use case, the size is merely to satisfy conversion to CTF or there
are some other needs? What did you do with CTF?
Describing the background, I’m trying to port eBPF to FreeBSD

What I want to do with CTF is very similar to that of BTF, but I
currently focusing on assisting verification. Since FreeBSD
already has library to deal with CTF, we prefer to use CTF instead of BTF.

In FreeBSD, we usually use tool called ctfconvert
to generate CTF.

And the problem is ctfconvert is aware of symbol type and size. It
cannot generate correct CTF if they were missing.

To solve this issue I need the change.

Thanks for explanation. Now I understand your use case.
The change looks good to me. Please send me and Alexei a formal patch
through standard "git send-email" or just an email with
all necessary patch information, and I will apply
to llvm trunk.
Don't we need to cc llvm-commits? I can also send via Phabricator if
that's fine with you.
You can also cc llvm-commits.



Join to automatically receive all group messages.