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

internal/pe1.14: support arm64 and riscv64 #204

Merged
merged 1 commit into from
Aug 15, 2022

Conversation

alfonsosanchezbeato
Copy link
Member

No description provided.

@alfonsosanchezbeato
Copy link
Member Author

alfonsosanchezbeato commented Apr 28, 2022

There is still the problem of shimaa64.efi not having a .vendor_cert section.

Copy link
Collaborator

@chrisccoulson chrisccoulson left a comment

Choose a reason for hiding this comment

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

This looks ok, although I've left one comment

var pe64 bool
switch f.Machine {
case IMAGE_FILE_MACHINE_AMD64, IMAGE_FILE_MACHINE_ARM64, IMAGE_FILE_MACHINE_RISCV64:
pe64 = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was wondering what defines whether a machine types uses the PE32 or PE32+ optional header, and then I realised that this check is probably wrong. The type of the optional header (PE32 vs PE32+) is determined by the first uint16 value in the header, which is checked already when the header is decoded in readOptionalHeader. The code here probably shouldn't check the machine type but instead just check whether the underlying type of f.OptionalHeader is *OptionalHeader32 or *OptionalHeader64.

This is probably ok for now because this code is inherited from the upstream go repo, but it might be worth reporting a bug there.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I hadn't noticed this was actually a copy of a go package. FWIW, very similar changes to what I did were performed in golang/go@0ca0551. Unfortunately that change is in go 1.17 and we still must support go 1.13 afaiu.

You are right in that the way PE32+ is detected is not fully right, and might fail in some corner case. I have opened an issue for this: golang/go#54250.

I have also opened golang/go#54251 to ask for RISCV64 support, that is still not in upstream.

@alfonsosanchezbeato
Copy link
Member Author

alfonsosanchezbeato commented Aug 1, 2022

@chrisccoulson thanks for the review. I also have an identical change in canonical/go-efilib#9 - that is being pulled as a dependency too by snapd, even though it looks like it is duplicated code. So we would need that change too, unless the code duplication is removed in some way.

@chrisccoulson chrisccoulson merged commit f112d72 into canonical:master Aug 15, 2022
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.

2 participants