-
-
Notifications
You must be signed in to change notification settings - Fork 624
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
Segmentation fault while build an ELF #659
Comments
Currently the new builder does still not enable to create an ELF from scratch. It assumes that the underlying ELF file is already setup with a minimum layout. I updated the documentation for your second point :) |
Hello, Thanks for your reply. I think there are two issues, which could be discussed separately:
For the second issue, it can be helpful that I describe my use-case more precisely. In my work, I am often encountering firmware in exotic formats. For example a few years ago, I encountered the firmware used by HP iLO 4 Baseboard Management Controller. This firmware defined for each process their sections, named in a way similar as in an ELF file ( Back to the present, I saw your blog post titled "New ELF Builder" and I thought that LIEF now enabled building ELF from scratch. However it requires "a minimum layout" which does not seem to be documented (and the fact that LIEF supports creating PE files from scratch also gave me false hope, https://lief-project.github.io/doc/latest/tutorials/02_pe_from_scratch.html). What do you think of a feature which would enable building an ELF file from scratch, using defined sections which are for example extracted from a firmware? If I understand correctly, the approach of building a bare ELF and adding the sections one by one is hard to support, because the ELF program header could need to be moved around. Nevertheless if LIEF provided a way to create an ELF directly with given sections (and if it was then possible to define symbols), it would be great :) |
Yes I completely agree and I removed the ELF Binary constructor as it actually does not
It was a similar request feature that @wisk had. He worked on it a while ago and his experimentation are here. They are based on the old ELF builder but they are worth reading.
Yes the title is a bit confusing but it was more about the performances.
I thought about that for a while and my approach would be to initialize a Binary from a predefined set of section (or segments). It would be something like: import lief
section1 = lief.ELF.Section(".test1")
...
section2 = lief.ELF.Section(".test2")
crafted = lief.ELF.Binary.create("test", lief.ELF.ELF_CLASS.CLASS64
[section1, section2], symbol_table=True)
if crafted is None:
print("Crafting failed")
return
# ... continue the modification I'll try to make a new PoC to get a better picture of this feature with the new ELF builder 😊 Currently I'm focus on cleaning the code base of LIEF to prepare the next release |
FYI, it already exists an issue for this request: #213 |
Describe the bug
Building an ELF file with the new ELF builder (https://lief-project.github.io/blog/2022-01-23-new-elf-builder/) triggers a segmentation fault in LIEF.
To Reproduce
Steps to reproduce the behavior:
master
(commit 2ae5327e86f50fe87733d8641d4e7bc3774e3087)elf.add(segment)
is executed).Expected behavior
I expected the program to successfully build a
test.elf
file.Environment (please complete the following information):
docker.io/library/python:3.9-slim
container (with Debian 11)python -c "import lief;print(lief.__version__)"
gives0.12.0-bb7faf3
Additional context
I tried to follow instruction from https://lief-project.github.io/blog/2022-01-23-new-elf-builder/ to build an ELF file. Getting a segmentation fault issue instead of a clean Python exception is frustrating.
To debug the issue by myself, I launched
gdb
and got the following stack trace:To get more information about the functions, I tried to build LIEF with debugging:
Unfortunately the second command did not work (
install
does not know--debug
) and usingsetup.py install
without--debug
made everything to be recompiled without debug symbols. How is it possible to build LIEF and the Python bindings with debugging? (It would be nice to have such instructions on https://lief-project.github.io/doc/latest/compilation.html ).Anyway, thanks for your great blog post! It was nice, even though LIEF does not work for my use-case.
The text was updated successfully, but these errors were encountered: