-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
std.elf: stronger typing #23600
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
base: master
Are you sure you want to change the base?
std.elf: stronger typing #23600
Conversation
yes i know i still have to update references elsewhere in the codebase :) 2 questions i have:
|
also note that i didn't convert all groups of values to enums/bitfields - for example, |
3f37b69
to
4bf9545
Compare
4bf9545
to
170ac8d
Compare
170ac8d
to
63745ce
Compare
pub fn sectionHeaders( | ||
self: *const Header, | ||
parse_source: anytype, | ||
) SectionHeaders(@TypeOf(parse_source)) { | ||
return .new(self, parse_source); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
header.section_header_iterator(file)
-> header.sectionHeaders(file).iterator()
strtab_header: *const elf64.Shdr, | ||
parse_source: anytype, | ||
) StringTable(@TypeOf(parse_source)) { | ||
_ = self; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feels right to still have this be a method on Header
, even though there's no use for self
in this method... if it's preferred to add method Shdr.asStringTable
instead then i can do that.
8 => Elf64_Relr, | ||
else => @compileError("expected pointer size of 32 or 64"), | ||
|
||
pub const SHF_OSBITS = packed struct(u8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the SHF
os/proc bitflag types are the most awkward api changes. feedback on a better pattern would be appreciated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lately i've been focusing on iterating the API re: my os project so i haven't been working on updating the API usage around the codebase. i'm getting to that soon :)
supercedes #23178
This PR attempts to make
std.elf
a bit easier for API consumers:ELF32_*
andELF64_*
types have been moved/renamed intoelf32
andelf64
namespacespub const x = switch (@sizeOf(usize)) { ... };
declarations have been consolidated into a singlepub const native_elf
which selects eitherelf32
orelf64
note: to optimize the reviewer's experience, i'll keep this PR as 2 commits: the first commit will be the API changes to
std.elf
, and the 2nd commit will be downstream changes