Better support for linux kernel#62
Merged
flobernd merged 2 commits intozyantific:masterfrom Mar 3, 2023
Merged
Conversation
Add a macro for dividing 64bit numbers. With 32bit linux targets, GCC generates a call to __udivdi3 when dividing 64bit integers, even when compiling in freestanding mode. However, the __udivdi3 implementation resides in libgcc which is not linked-in when building kernel code. Besides, the Linux kernel voluntarily doesn't implement __udivdi3 to force developers to use the do_div macro instead [1]. [1] https://lwn.net/Articles/456689/
Fallback to custom defined types when __*_TYPE__ macros are not defined on GCC. Old versions of GCC such as version 4.4.7 and prior do not define the __*_TYPE__ macros, so provide custom type definition when building without libc headers [1]. Also add custom definition for ZYAN_*_MAX and ZYAN_*_MIN values as __*_MAX__ macros are also missing for the same reason [2]. [1] https://godbolt.org/z/j5Yhs48z9 [2] https://godbolt.org/z/1TvjTd5Ga
Member
|
Thanks for your PR! Will have a detailed look tomorrow. cc @athre0z |
Member
|
Sorry for the delay. LGTM! Thanks again. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
These two commits improve support for building Zydis for the linux kernel in a couple of corner cases:
The first commit introduces the ZYAN_DIV64 macro to fix a failure when linking Zydis on a 32bit linux kernel. The Zydis changes will be submitted in a separate PR.
The second PR adds support for building Zydis in NO_LIBC mode with old versions of GCC.
Thanks,