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

fix(dracut.sh): use dynamically uefi's sections offset #2277

Merged
merged 1 commit into from
Mar 20, 2023

Conversation

keentux
Copy link
Contributor

@keentux keentux commented Mar 13, 2023

Checklist

  • I have tested it locally
  • I have reviewed and updated any documentation if relevant
  • I am providing new code and test(s) for it

Fixes #2275

@keentux keentux force-pushed the uki-section-offsets branch 3 times, most recently from a5a8d9b to c34a839 Compare March 14, 2023 14:16
Copy link
Member

@aafeijoo-suse aafeijoo-suse left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this!

dracut.sh Outdated Show resolved Hide resolved
@keentux keentux changed the title perf(dracut.sh): Use dynamically uefi's sections offset fix(dracut.sh): use dynamically uefi's sections offset Mar 14, 2023
@medhefgo
Copy link

I forgot to mention that the offsets should really be aligned to the PE binary's SectionAlignment header field.

@keentux
Copy link
Contributor Author

keentux commented Mar 15, 2023

I forgot to mention that the offsets should really be aligned to the PE binary's SectionAlignment header field.

Thanks for that clarification. I am going to look on at.

@keentux
Copy link
Contributor Author

keentux commented Mar 16, 2023

On my last changes, during the UEFI generation, it will parse the initial PE file's header (the stub) checking if it is a good PE format and catch the value of sectionAlignment . According to the PE documentation, each section should start on a factor of the value of sectionAlignment.
@medhefgo What do you think about that. Should it be good up to you ?

dracut-functions.sh Outdated Show resolved Hide resolved
@keentux keentux marked this pull request as draft March 16, 2023 14:42
@keentux keentux marked this pull request as ready for review March 16, 2023 15:41
dracut-functions.sh Outdated Show resolved Hide resolved
@keentux keentux force-pushed the uki-section-offsets branch 2 times, most recently from 94252ac to 85ab666 Compare March 16, 2023 16:17
* Uefi section are creating by `objcopy` with hardcoded sections
offset. This commit allow to have the correct offset between
each part of the efi file, needed to create an UKI. Offsets
are simply calculated so no sections overlap, as recommended
in  https://wiki.archlinux.org/title/Unified_kernel_image#Manually
Moreover, efi stub file's header is parsed to apply the correct
offsets according the section alignment factor.
* Remove EFI_SECTION_VMA_INITRD, no need anymore as initrd
section offset dynamically calculated

Fixes dracutdevs#2275

Signed-off-by: Valentin Lefebvre <valentin.lefebvre@suse.com>
Copy link
Collaborator

@johannbg johannbg left a comment

Choose a reason for hiding this comment

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

LGTM

@johannbg johannbg merged commit f32e95b into dracutdevs:master Mar 20, 2023
@keentux keentux deleted the uki-section-offsets branch March 21, 2023 20:40
@LaszloGombos
Copy link
Collaborator

LaszloGombos commented May 8, 2023

Needs confirmation, but I think strtonum does not seem to be available in all awk variants. https://www.gnu.org/software/gawk/manual/html_node/Strtonum-Function.html

Specifically on debian mawk is more popular than gawk, see #2002 (comment)

This PR seems to break UEFI generation if gawk is not installed.

Had we had #2166 landed, we would have seen the failure as part of the PR review.

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.

UKI section offsets are hard-coded
5 participants