How to detect libbfd when building tools/bpf?

2 messages, 2 authors, 2018-04-23 · open the first message on its own page

How to detect libbfd when building tools/bpf?

From: Wang Sheng-Hui <hidden>
Date: 2018-04-22 07:59:39

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
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

Re: How to detect libbfd when building tools/bpf?

From: Daniel Borkmann <daniel@iogearbox.net>
Date: 2018-04-23 10:05:44

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help