-
Notifications
You must be signed in to change notification settings - Fork 158
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: The strtab in the section header is wrong. #300
Comments
This is expected because strings can be any suffix. That is, |
Yes, sir. That's right. However, I don't think StrTab::parse takes this into account.
For example, there is no way in current goblin to correctly parse the Also, I would like to fix the parsing of |
The equivalent of Edit: like this let elf = Elf::parse(&buf)?;
for section in elf.section_headers {
println!("{}", elf.shdr_strtab.get_at(section.sh_name).unwrap());
}
What needs fixing? |
Wow I was not aware of this method. |
It's a small thing, but how about specify in the documentation that " |
When I first saw your issue I was puzzled at first too; perhaps a documentation blurb on |
How about this? #[cfg(feature = "alloc")]
/// Converts the string table to a vector of parsed strings.
///
/// Note: If you want to get the correct `Vec` of shdr_strtab, don't use this method but use `get_at` to get it sequentially.
///
/// Requires `feature = "alloc"`
pub fn to_vec(&self) -> error::Result<Vec<&'a str>> { |
Yea something like that sounds good to me; or even pasting philipc's code snippet as a ```rust block? |
anyway, PR's welcome :) |
This problem isn't specific to |
There is no way to access the contents of the parsed string table without E.g., I use it right here: https://github.com//m4b/bingrep/blob/7a2e2a157ada79afe51b46396347ac706d78a029/src/format_elf.rs#L380 🤷 |
It might be better to remove/deprecate it and just return an |
haha, funny enough, in the link i gave, that's actually the to_vec method of Symtab ;) so i guess i don't use it in bingrep, at least, but the point still remains, there's no way to access the parsed strings inside the string table without such a method. |
How about creating an appropriate impl<'a> Elf<'a> {
pub fn shdr_strtab_to_vec(&self) -> Vec<&str> {
let mut ret = Vec::new();
for shdr in &self.section_headers {
ret.push(self.shdr_strtab.get_at(shdr.sh_name).unwrap_or(""));
}
ret
} |
Why would you want to do that instead of using
You very rarely want a list of section header names that are disassociated from the section headers. Typically you only want to process the name in conjunction with other information from the section header. Additionally, nothing says that |
Closing this as I think this is resolved, please re-open if not the case |
example
.plt
doesn't appear in shdr_strtab.The text was updated successfully, but these errors were encountered: