On 04/22/2018 09:51 AM, Wang Sheng-Hui wrote:
> Sorry to trouble you !
> 
> I run debian and installed binutils-dev beforehand.
> Then I copied tools/build/feature/test-libbfd.c to t.c and run:
> ------------------------------------------------------------------------
> root@lazyfintech:~# cat t.c 
> #include <bfd.h>
> 
> extern int printf(const char *format, ...);
> 
> int main(void)
> {
>       char symbol[4096] = "FieldName__9ClassNameFd";
>       char *tmp;
> 
>       tmp = bfd_demangle(0, symbol, 0);
> 
>       printf("demangled symbol: {%s}\n", tmp);
> 
>       return 0;
> }
> root@lazyfintech:~# gcc t.c -lbfd

Can you run with 'gcc t.c -lbfd -lz -liberty -ldl' since this is
what the Makefile for the feature test is doing:

  $(OUTPUT)test-libbfd.bin:
        $(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl

Seems most likely that you're missing some of the remaining libs
to have the feature test properly detect it?

> root@lazyfintech:~# ./a.out 
> demangled symbol: {ClassName::FieldName}
> 
> 
> I thought libbfd can be reached from above. 
> But when I built tools/bpf, libbfd cannot be detected: 
> -------------------------------------------------------------------------
> /linux# make O=../buildkernel/ tools/bpf
> make[1]: Entering directory '/root/buildkernel'
>   DESCEND  bpf
> 
> Auto-detecting system features:
> ...                        libbfd: [ OFF ]
> ...        disassembler-four-args: [ on  ]
> 
>   DESCEND  bpftool
> 
> Auto-detecting system features:
> ...                        libbfd: [ OFF ]
> ...        disassembler-four-args: [ on  ]
> 
> make[1]: Leaving directory '/root/buildkernel'
> 
> 
> I wonder how should I do to get libbfd auto detected when  building bpf tool?
> 
> Regards,
> shenghui


Reply via email to