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

Address "WARNING :: Failed to get_static_lib_exports(*.a)" #4221

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mbargull
Copy link
Member

@mbargull mbargull commented Apr 19, 2021

Currently, conda-build prints out WARNING :: Failed to get_static_lib_exports(*.a) whenever static libraries are using in the builds.
This is because of a mismatched type of lief.*.parse(raw=...) (explicitly needs List[int] rather than bytes).
When the parameter type is fixed, it fails because lief.Binary.exported_functions gives an iterable of lief.Function objects (or just names, i.e., strs, in older versions) which do not have .exported/.imported members.

I can't say with any confidence, I know what I'm doing here because I did not dig in too deep of LIEF, the surrounding code and everything. Silver lining: If the changed code now raises another exception, the behavior would be identical because the previous one always failed (and the exception is caught and replaced the the mentioned warning). The unknown for me is just in case no exception is raised, IDK what difference a non-empty list of returned "imported by not exported" symbols affects.

@anaconda-issue-bot anaconda-issue-bot added the cla-signed [bot] added once the contributor has signed the CLA label Apr 19, 2021
mbargull added a commit to mbargull/conda-build that referenced this pull request Apr 19, 2021
@@ -701,7 +701,7 @@ def _parse_ar_hdr(content, index):
# syms_b = get_symbols(obj, defined=True, undefined=False)
# print(syms_b)
else:
obj = lief.ELF.parse(raw=content[obj_start:obj_end])
obj = lief.ELF.parse(raw=list(content[obj_start:obj_end]))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lief.parse accepts raw: bytes or raw: List[int], but lief.*.parse only accepts raw: List[int].

mbargull added a commit to mbargull/conda-build that referenced this pull request Apr 19, 2021
@mbargull mbargull force-pushed the failed-to-get_static_lib_exports branch from 0d712d0 to ee24322 Compare April 19, 2021 12:41
if len(binary.exported_functions):
syms = binary.exported_functions
imported_function_names = {s.name for s in binary.imported_functions}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really know if this is the correct thing to do. Just made sense given the names of lief.Binary's members.

@@ -890,8 +890,10 @@ def get_symbols(file, defined=True, undefined=True, notexported=False, arch='nat
except:
pass
res = []
imported_function_names = set()
if len(binary.exported_functions):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: Due to lack of deeper knowledge of LIEF, I have no idea what the implications are in prioritizing binary.exported_functions over binary.symbols over binary.static_symbols. So, IDK if it makes sense to use a (maybe?) smaller set of symbols from .exported_functions rather than just .symbols.

@mbargull mbargull marked this pull request as ready for review April 19, 2021 13:00
@mbargull mbargull closed this Jun 1, 2021
@mbargull mbargull reopened this Jun 1, 2021
mbargull added a commit to mbargull/conda-build that referenced this pull request Jun 1, 2021
@mbargull mbargull force-pushed the failed-to-get_static_lib_exports branch from ee24322 to 0d91589 Compare June 1, 2021 11:18
mbargull added a commit to mbargull/conda-build that referenced this pull request Oct 4, 2021
@mbargull mbargull force-pushed the failed-to-get_static_lib_exports branch from 0d91589 to a964af9 Compare October 4, 2021 09:59
@mbargull
Copy link
Member Author

mbargull commented Oct 4, 2021

@isuruf, @xhochy, apart from Ray, you are the ones that I know of who had a look at LIEF or related code. Could one of you take a look at this?
Of course, this is supposed to be a proper fix if possible. But personally, I'd mainly want to de-clutter conda-build's logs to better see its DSO analysis output :).

@xhochy
Copy link
Contributor

xhochy commented Dec 20, 2022

@isuruf, @xhochy, apart from Ray, you are the ones that I know of who had a look at LIEF or related code. Could one of you take a look at this? Of course, this is supposed to be a proper fix if possible. But personally, I'd mainly want to de-clutter conda-build's logs to better see its DSO analysis output :).

I sadly don't have any expertise either that would go beyond running this code and seeing whether it passes. So I cannot add something on top of what other conda-build reviewers would do here.

Copy link

Hi there, thank you for your contribution!

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further activity occurs.

If you would like this pull request to remain open please:

  1. Rebase and verify the changes still work
  2. Leave a comment with the current status

NOTE: If this pull request was closed prematurely, please leave a comment.

Thanks!

@github-actions github-actions bot added the stale [bot] marked as stale due to inactivity label Dec 21, 2023
Copy link

Hi there, thank you for your contribution!

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further activity occurs.

If you would like this pull request to remain open please:

  1. Rebase and verify the changes still work
  2. Leave a comment with the current status

NOTE: If this pull request was closed prematurely, please leave a comment.

Thanks!

@github-actions github-actions bot added the stale::closed [bot] closed after being marked as stale label Jan 21, 2024
@github-actions github-actions bot closed this Jan 21, 2024
lief.Function from the Python API does not seem to expose flags
directly. Maybe lief.Binary.imported_functions can act as a counterpart
to lief.Binary.exported_functions then?
Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
@mbargull mbargull reopened this Mar 11, 2024
@mbargull mbargull requested a review from a team as a code owner March 11, 2024 16:10
@mbargull mbargull removed stale [bot] marked as stale due to inactivity stale::closed [bot] closed after being marked as stale labels Mar 11, 2024
@mbargull mbargull force-pushed the failed-to-get_static_lib_exports branch from a964af9 to e828b60 Compare March 11, 2024 16:11
@mbargull
Copy link
Member Author

pre-commit.ci autofix

@mbargull
Copy link
Member Author

gh-4850 just disabled this code path by default without any attempted fixes.
Seeing the code in gh-5228 again reminded me of this PR and since I don't believe anything has changed since 2021, I revived it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants