Update dl_phdr_info definition to more closely match header files
Also, update tests to skip conflicts
This commit is contained in:
parent
970fec9245
commit
ab1472eb08
|
@ -1471,6 +1471,7 @@ fn test_android(target: &str) {
|
|||
"asm/mman.h",
|
||||
"linux/auxvec.h",
|
||||
"linux/dccp.h",
|
||||
"linux/elf.h",
|
||||
"linux/errqueue.h",
|
||||
"linux/falloc.h",
|
||||
"linux/futex.h",
|
||||
|
@ -1612,7 +1613,12 @@ fn test_android(target: &str) {
|
|||
// This is a weird union, don't check the type.
|
||||
(struct_ == "ifaddrs" && field == "ifa_ifu") ||
|
||||
// sigval is actually a union, but we pretend it's a struct
|
||||
(struct_ == "sigevent" && field == "sigev_value")
|
||||
(struct_ == "sigevent" && field == "sigev_value") ||
|
||||
// FIXME: `sa_sigaction` has type `sighandler_t` but that type is
|
||||
// incorrect, see: https://github.com/rust-lang/libc/issues/1359
|
||||
(struct_ == "sigaction" && field == "sa_sigaction") ||
|
||||
// signalfd had SIGSYS fields added in Android 4.19, but CI does not have that version yet.
|
||||
(struct_ == "signalfd_siginfo" && field == "ssi_call_addr")
|
||||
});
|
||||
|
||||
cfg.skip_field(move |struct_, field| {
|
||||
|
@ -1630,6 +1636,20 @@ fn test_android(target: &str) {
|
|||
field == "ssi_arch"))
|
||||
});
|
||||
|
||||
cfg.skip_field(|struct_, field| {
|
||||
match (struct_, field) {
|
||||
// conflicting with `p_type` macro from <resolve.h>.
|
||||
("Elf32_Phdr", "p_type") => true,
|
||||
("Elf64_Phdr", "p_type") => true,
|
||||
|
||||
// this is actually a union on linux, so we can't represent it well and
|
||||
// just insert some padding.
|
||||
("siginfo_t", "_pad") => true,
|
||||
|
||||
_ => false,
|
||||
}
|
||||
});
|
||||
|
||||
cfg.generate("../src/lib.rs", "main.rs");
|
||||
|
||||
test_linux_like_apis(target);
|
||||
|
|
|
@ -26,36 +26,19 @@ pub type loff_t = ::c_longlong;
|
|||
pub type __kernel_loff_t = ::c_longlong;
|
||||
pub type __kernel_pid_t = ::c_int;
|
||||
|
||||
// elf.h
|
||||
// linux/elf.h
|
||||
|
||||
pub type Elf32_Addr = u32;
|
||||
pub type Elf32_Half = u16;
|
||||
pub type Elf32_Lword = u64;
|
||||
pub type Elf32_Off = u32;
|
||||
pub type Elf32_Sword = i32;
|
||||
pub type Elf32_Word = u32;
|
||||
|
||||
pub type Elf64_Addr = u64;
|
||||
pub type Elf64_Half = u16;
|
||||
pub type Elf64_Lword = u64;
|
||||
pub type Elf64_Off = u64;
|
||||
pub type Elf64_Sword = i32;
|
||||
pub type Elf64_Sxword = i64;
|
||||
pub type Elf64_Word = u32;
|
||||
pub type Elf64_Xword = u64;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(target_pointer_width = "64")] {
|
||||
type Elf_Addr = Elf64_Addr;
|
||||
type Elf_Half = Elf64_Half;
|
||||
type Elf_Phdr = Elf64_Phdr;
|
||||
} else if #[cfg(target_pointer_width = "32")] {
|
||||
type Elf_Addr = Elf32_Addr;
|
||||
type Elf_Half = Elf32_Half;
|
||||
type Elf_Phdr = Elf32_Phdr;
|
||||
}
|
||||
}
|
||||
|
||||
s! {
|
||||
pub struct stack_t {
|
||||
pub ss_sp: *mut ::c_void,
|
||||
|
@ -275,7 +258,7 @@ s! {
|
|||
pub svm_zero: [u8; 4]
|
||||
}
|
||||
|
||||
// elf.h
|
||||
// linux/elf.h
|
||||
|
||||
pub struct Elf32_Phdr {
|
||||
pub p_type: Elf32_Word,
|
||||
|
@ -302,13 +285,27 @@ s! {
|
|||
// link.h
|
||||
|
||||
pub struct dl_phdr_info {
|
||||
pub dlpi_addr: Elf_Addr,
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
pub dlpi_addr: Elf64_Addr,
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
pub dlpi_addr: Elf32_Addr,
|
||||
|
||||
pub dlpi_name: *const ::c_char,
|
||||
pub dlpi_phdr: *const Elf_Phdr,
|
||||
pub dlpi_phnum: Elf_Half,
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
pub dlpi_phdr: *const Elf64_Phdr,
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
pub dlpi_phdr: *const Elf32_Phdr,
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
pub dlpi_phnum: Elf64_Half,
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
pub dlpi_phnum: Elf32_Half,
|
||||
|
||||
// These fields were added in Android R
|
||||
pub dlpi_adds: ::c_ulonglong,
|
||||
pub dlpi_subs: ::c_ulonglong,
|
||||
pub dlpi_tls_modid: usize,
|
||||
pub dlpi_tls_modid: ::size_t,
|
||||
pub dlpi_tls_data: *mut ::c_void,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue