I'm now trying to extract source C file name from ELF object which is compiled from following C code by clang.
#include <stdint.h>
uint64_t test(uint64_t a) {
return a + 1;
}
When I specify amd64 as a backend, the clang generates the symtab like below
$ clang-6.0 -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 is there. However, when I specify BPF as a backend, I see output like below.
$ clang-6.0 -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
We can't see the source file name.
Does anyone know why is it and how can I solve the issue?
Working environment is Ubuntu18.04-LTS and clang version is 6.0.0-1ubuntu2 (tags/RELEASE_600/final) which is installed via apt.