Skip to content

Build error "‘bfd_get_section_flags’ was not declared in this scope" #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
erksch opened this issue May 21, 2020 · 2 comments · Fixed by #94
Closed

Build error "‘bfd_get_section_flags’ was not declared in this scope" #93

erksch opened this issue May 21, 2020 · 2 comments · Fixed by #94

Comments

@erksch
Copy link

erksch commented May 21, 2020

Hey there.

I tried to build aws-lambda-cpp on my Ubuntu 20.4 machine but got the following errors:

In file included from /home/erik/Projects/tuk/aws-lambda-cpp/src/backward.cpp:26:0:
/home/erik/Projects/tuk/aws-lambda-cpp/src/backward.h: In member function ‘void backward::TraceResolverLinuxImpl<backward::trace_resolver_tag::libbfd>::find_in_section(bfd_vma, bfd_vma, backward::TraceResolverLinuxImpl<backward::trace_resolver_tag::libbfd>::bfd_fileobject&, asection*, backward::TraceResolverLinuxImpl<backward::trace_resolver_tag::libbfd>::find_sym_result&)’:
/home/erik/Projects/tuk/aws-lambda-cpp/src/backward.h:1235:14: error: ‘bfd_get_section_flags’ was not declared in this scope
         if ((bfd_get_section_flags(fobj.handle.get(), section) & SEC_ALLOC) == 0)
              ^~~~~~~~~~~~~~~~~~~~~
/home/erik/Projects/tuk/aws-lambda-cpp/src/backward.h:1235:14: note: suggested alternative: ‘bfd_set_section_flags’
         if ((bfd_get_section_flags(fobj.handle.get(), section) & SEC_ALLOC) == 0)
              ^~~~~~~~~~~~~~~~~~~~~
              bfd_set_section_flags
/home/erik/Projects/tuk/aws-lambda-cpp/src/backward.h:1238:28: error: ‘bfd_get_section_vma’ was not declared in this scope
         bfd_vma sec_addr = bfd_get_section_vma(fobj.handle.get(), section);
                            ^~~~~~~~~~~~~~~~~~~
/home/erik/Projects/tuk/aws-lambda-cpp/src/backward.h:1238:28: note: suggested alternative: ‘bfd_set_section_vma’
         bfd_vma sec_addr = bfd_get_section_vma(fobj.handle.get(), section);
                            ^~~~~~~~~~~~~~~~~~~
                            bfd_set_section_vma
/home/erik/Projects/tuk/aws-lambda-cpp/src/backward.h:1239:30: error: ‘bfd_get_section_size’ was not declared in this scope
         bfd_size_type size = bfd_get_section_size(section);
                              ^~~~~~~~~~~~~~~~~~~~
/home/erik/Projects/tuk/aws-lambda-cpp/src/backward.h:1239:30: note: suggested alternative: ‘bfd_set_section_size’
         bfd_size_type size = bfd_get_section_size(section);
                              ^~~~~~~~~~~~~~~~~~~~
                              bfd_set_section_size
make[2]: *** [CMakeFiles/aws-lambda-runtime.dir/build.make:89: CMakeFiles/aws-lambda-runtime.dir/src/backward.cpp.o] Fehler 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/aws-lambda-runtime.dir/all] Fehler 2
make: *** [Makefile:130: all] Fehler 2

CMake: 3.16.3
GCC: 9.3.0
Distro: Ubuntu 20.4.

As far as I can tell, libbfd exists:

$ locate libbfd
/snap/gnome-3-34-1804/24/usr/lib/x86_64-linux-gnu/libbfd-2.30-system.so
/snap/gnome-3-34-1804/33/usr/lib/x86_64-linux-gnu/libbfd-2.30-system.so
/usr/lib/x86_64-linux-gnu/libbfd-2.34-system.so
/usr/lib/x86_64-linux-gnu/libbfd.a
/usr/lib/x86_64-linux-gnu/libbfd.so
@erksch
Copy link
Author

erksch commented May 21, 2020

Update: a colleague managed to build it. He had the following for locate libbfd:

/snap/gnome-3-34-1804/27/usr/lib/x86_64-linux-gnu/libbfd-2.30-system.so
/snap/gnome-3-34-1804/33/usr/lib/x86_64-linux-gnu/libbfd-2.30-system.so
/usr/lib/x86_64-linux-gnu/libbfd-2.33-system.so

So I am using 2.34 of binutils and he using 2.33.

So I looked into the code of binutils and indeed, the interface has changed between the versions.
Instead of bfd_get_section_size etc., it is now just bfd_section_size. Also for reference this stackoverflow post with answer.

@marcomagdy
Copy link
Contributor

Fortunately, the issue seems to be already fixed in backward. I will update the source here.
Thanks for reporting it.

marcomagdy added a commit that referenced this issue May 21, 2020
binutils 2.34 changed the name of a method and guarded it with a macro.
This backward-lib update makes use of that macro to choose the right
function name.

Fixes #93
marcomagdy added a commit that referenced this issue May 22, 2020
binutils 2.34 changed the name of a function and guarded it with a macro.
This backward-lib update makes use of that macro to choose the right
function name.

Fixes #93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants