Skip to content
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

cxx11 abi issue in 0.12.0 linux-x86_64 release #683

Closed
HyperSine opened this issue Mar 29, 2022 · 2 comments
Closed

cxx11 abi issue in 0.12.0 linux-x86_64 release #683

HyperSine opened this issue Mar 29, 2022 · 2 comments
Assignees

Comments

@HyperSine
Copy link

HyperSine commented Mar 29, 2022

Describe the bug
According to early commit 27a03a6, CXX11 ABI was forced to use in LIEF.

However, I downloaded 0.12.0 linux-x86_64 release and got undefined reference to 'LIEF::PE::Parser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' error, which means the 0.12.0 linux-x86_64 release doesn't use CXX11 ABI at all.

To Reproduce

$ wget 'https://github.com/lief-project/LIEF/releases/download/0.12.0/LIEF-0.12.0-Linux-x86_64.tar.gz'
$ tar -xvf LIEF-0.12.0-Linux-x86_64.tar.gz
$ vim a.cpp

with simple test source code

#include <LIEF/LIEF.hpp>

int main() {
    auto pe = LIEF::PE::Parser::parse("a.exe");
    return 0;
}

then compile

$ g++ -std=c++11 a.cpp -I./LIEF-0.12.0-Linux-x86_64/include/ -L./LIEF-0.12.0-Linux-x86_64/lib64/ -lLIEF
/tmp/ccjARzrH.o: In function `main':
a.cpp:(.text+0x4a): undefined reference to `LIEF::PE::Parser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status

However, if I compile with -D_GLIBCXX_USE_CXX11_ABI=0:

$ g++ -std=c++11 a.cpp -D_GLIBCXX_USE_CXX11_ABI=0 -I./LIEF-0.12.0-Linux-x86_64/include/ -L./LIEF-0.12.0-Linux-x86_64/lib64/ -lLIEF

everything works fine.

And I used nm tool to check the symbols in libLIEF.a:

$ nm -C ./LIEF-0.12.0-Linux-x86_64/lib64/libLIEF.a | grep LIEF::PE::Parser::parse
...
0000000000000000 T LIEF::PE::Parser::parse(std::string const&)
0000000000000000 t LIEF::PE::Parser::parse(std::string const&) [clone .cold]
...

which also shows CXX11 ABI was not used, otherwise there must be std::__cxx11::basic_string...

Expected behavior
The release you published shoud use CXX11 ABI, as the line 465 of your CMakeLists.txt said:

target_compile_definitions(LIB_LIEF PUBLIC -D_GLIBCXX_USE_CXX11_ABI=1)

Environment (please complete the following information):

  • System and Version : Ubuntu 18.04.6 LTS
  • Target format PE
  • LIEF commit version: commit f891891, aka 0.12.0 version

Additional context
None

@romainthomas
Copy link
Member

Hi @HyperSine
Actually and as you pointed, _GLIBCXX_USE_CXX11_ABI is enabled but it looks like CentOS 7 (image used in the CI) disables this ABI even if _GLIBCXX_USE_CXX11_ABI. I'll switch to a more recent image that supports _GLIBCXX_USE_CXX11_ABI

@romainthomas
Copy link
Member

You can test the nightly here: https://lief.s3-website.fr-par.scw.cloud/latest/sdk

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

No branches or pull requests

2 participants