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

Add LoongArch support for ELF #921

Merged
merged 1 commit into from
Jun 4, 2023

Conversation

loongson-zn
Copy link
Contributor

Add LoongArch support for ELF, please review, thanks!

@loongson-zn
Copy link
Contributor Author

Reference Material:binutils-gdb and LoongArch ELF ABI specification

@romainthomas
Copy link
Member

Looks good :) Thank you. Would you have sample(s) for the test-suite?

@loongson-zn
Copy link
Contributor Author

[zhangna@localhost LIEF-2]$ arch
loongarch64
[zhangna@localhost LIEF-2]$ python3
Python 3.9.9 (main, Apr  6 2023, 00:00:00) 
[GCC 10.3.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lief
>>> la=lief.parse("/bin/ls")
>>> print(len(la.segments))
9
>>> print(len(la.sections))
27
>>> ll=lief.parse("/home/zhangna/LIEF-2/build/examples/cpp/elf_reader")
>>> print(len(ll.dynamic_symbols))
248
>>> print(len(ll.segments))
10
>>> print(len(ll.sections))
30

All outputs are correct. Are there any other tests that must be done?

@romainthomas
Copy link
Member

I would like to include the binary you are using in the test suite, could you please point me out to get them?

@loongson-zn
Copy link
Contributor Author

You says ‘/home/zhangna/LIEF-2/build/examples/cpp/elf_reader’ ? This binary generated by LIEF compilation.

[zhangna@localhost LIEF-2]$ pwd      ##git clone xx.LIEF  source
/home/zhangna/LIEF-2
[zhangna@localhost LIEF-2]$ mkdir build && cd build
[zhangna@localhost build]$ cmake ..  && make
[zhangna@localhost c]$ pwd
/home/zhangna/LIEF-2/build/examples/c
[zhangna@localhost c]$ ls
CMakeFiles  cmake_install.cmake  elf_reader  macho_reader  Makefile  pe_reader
[zhangna@localhost c]$ file elf_reader 
elf_reader: ELF 64-bit LSB executable, LoongArch, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-loongarch-lp64d.so.1, BuildID[sha1]=9090e305a462509d2ffc61f468a5dd1e08b083ac, for GNU/Linux 5.10.0, not stripped
[zhangna@localhost cpp]$ pwd
/home/zhangna/LIEF-2/build/examples/cpp
[zhangna@localhost cpp]$ ls
abstract_reader      dex_reader          elf_strip      Makefile               vdex_reader
art_reader           elf_add_section     elf_symbols    oat_reader
benchmark            elf_builder         logging        pe_authenticode_check
CMakeFiles           elf_reader          macho_builder  pe_builder
cmake_install.cmake  elf_section_rename  macho_reader   pe_reader

I upload the compilation directory -- build directory

@romainthomas
Copy link
Member

You says ‘/home/zhangna/LIEF-2/build/examples/cpp/elf_reader’ ? This binary generated by LIEF compilation.

I meant: You introduce the support for a new architecture. Thus, we need a binary with this new architecture for the unit tests. The build directory you pointed you contains such binaries so it's fine. Thank you!

@romainthomas romainthomas merged commit 0daf527 into lief-project:master Jun 4, 2023
3 checks passed
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 this pull request may close these issues.

None yet

2 participants