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

elf: add read and write support for GNU properties #541

Merged
merged 5 commits into from
May 5, 2023

Conversation

philipc
Copy link
Contributor

@philipc philipc commented May 2, 2023

No description provided.

@philipc philipc force-pushed the elf-gnu-prop branch 3 times, most recently from 26ded31 to e91df1d Compare May 3, 2023 07:41
@philipc philipc marked this pull request as ready for review May 4, 2023 05:53
@philipc philipc merged commit 69962ee into gimli-rs:master May 5, 2023
@philipc philipc deleted the elf-gnu-prop branch May 5, 2023 04:45
@philipc philipc mentioned this pull request May 9, 2023
let n_name = b"GNU\0";
data.extend_from_slice(pod::bytes_of(&elf::NoteHeader32 {
n_namesz: U32::new(self.endian, n_name.len() as u32),
n_descsz: U32::new(self.endian, util::align(3 * 4, align) as u32),
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It needs to be 12 for 32-bit and 16 for 64-bit. The expression util::align(3 * 4, align) should handle that.

// Value size
data.extend_from_slice(pod::bytes_of(&U32::new(self.endian, 4)));
data.extend_from_slice(pod::bytes_of(&U32::new(self.endian, value)));
util::write_align(&mut data, align);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it typical to not include padding information if it's 0? #learning

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand what you mean. util::write_align(&mut data, align) is the padding, which may be either 0 or 4 bytes.

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