-
Notifications
You must be signed in to change notification settings - Fork 161
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: fix is_import to check st_shndx #436
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,9 +94,9 @@ pub fn st_visibility(other: u8) -> u8 { | |
|
||
/// Is this information defining an import? | ||
#[inline] | ||
pub fn is_import(info: u8, value: u64) -> bool { | ||
pub fn is_import(info: u8, shndx: u64) -> bool { | ||
let bind = st_bind(info); | ||
bind == STB_GLOBAL && value == 0 | ||
(bind == STB_GLOBAL || bind == STB_WEAK) && shndx == SHN_UNDEF as _ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a good catch (the missing STB_WEAK), but changing this function to operate semantically on for example, any clients relying on imho my general thesis that what a dynamic linker can import is how we've defined import, while arguably more nuanced than this, is a good one and has value (no pun intended). using that being said, it seems like people are hitting some issues with this, so we can consider adding something like |
||
} | ||
|
||
/// Convenience function to get the &'static str type from the symbols `st_info`. | ||
|
@@ -170,8 +170,7 @@ macro_rules! elf_sym_std_impl { | |
/// Checks whether this `Sym` has `STB_GLOBAL`/`STB_WEAK` bind and a `st_value` of 0 | ||
#[inline] | ||
pub fn is_import(&self) -> bool { | ||
let bind = self.st_info >> 4; | ||
(bind == STB_GLOBAL || bind == STB_WEAK) && self.st_value == 0 | ||
is_import(self.st_info, self.st_shndx as _) | ||
} | ||
/// Checks whether this `Sym` has type `STT_FUNC` | ||
#[inline] | ||
|
@@ -336,6 +335,8 @@ use core::fmt; | |
use scroll::ctx; | ||
use scroll::ctx::SizeWith; | ||
|
||
use super::section_header::SHN_UNDEF; | ||
|
||
#[derive(Clone, Copy, PartialEq, Default)] | ||
/// A unified Sym definition - convertible to and from 32-bit and 64-bit variants | ||
pub struct Sym { | ||
|
@@ -355,8 +356,7 @@ impl Sym { | |
/// Checks whether this `Sym` has `STB_GLOBAL`/`STB_WEAK` bind and a `st_value` of 0 | ||
#[inline] | ||
pub fn is_import(&self) -> bool { | ||
let bind = self.st_bind(); | ||
(bind == STB_GLOBAL || bind == STB_WEAK) && self.st_value == 0 | ||
is_import(self.st_info, self.st_shndx as _) | ||
} | ||
/// Checks whether this `Sym` has type `STT_FUNC` | ||
#[inline] | ||
|
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.
idly wondering if we should de-pub this along with the other functions; i wonder why they were made
pub
, could have been a historical accident or perhaps someone uses them for whatever reason; i don't see bingrep for example using it anywhere