[llvm-dev] BPF backend doesn't generate some of the symtab informations

Hayakawa Yutaro via llvm-dev llvm-dev at lists.llvm.org
Fri Aug 31 06:46:04 PDT 2018


Hello,

I'm now trying to extract some .symtab information such as source C file name (STT_FILE) from BPF ELF
object which is compiled from following C code by clang, but it seems the generated information is different depends
on the target.

=== test.c ====
#include <stdint.h>

uint64_t test(uint64_t a) {
 return a + 1;
}
============

For example, when I specify amd64 as a backend, the clang generates the symtab like below

$ clang -target amd64 -c test.c
$ readelf -s test.o

Symbol table '.symtab' contains 4 entries:
  Num:    Value          Size Type    Bind   Vis      Ndx Name
    0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
    1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS test.c
    2: 0000000000000000     0 SECTION LOCAL  DEFAULT    2
    3: 0000000000000000    21 FUNC    GLOBAL DEFAULT    2 test

We can see the source file name or type of the symbol “test”. However, when I specify BPF as
a backend, I see output like below.

$ clang -target bpf -c test.c
$ readelf -s test.o

Symbol table '.symtab' contains 2 entries:
  Num:    Value          Size Type    Bind   Vis      Ndx Name
    0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
    1: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT    2 test

Some of the information which was generated on amd64 platform like file name or size or type of the symbol
are missing in this case.

Working environment is Ubuntu18.04-LTS and clang version is 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
which is installed via apt.

I am just a beginner for LLVM, so this question might be silly, but could you give me an idea for solving
this problem or tell me what makes difference?

Regards,
Yutaro


More information about the llvm-dev mailing list