Skip to content

Commit 267375e

Browse files
committed
Auto merge of #1072 - sfackler:more-elf, r=alexcrichton
Add some more elf types
2 parents b9a0e23 + 063c721 commit 267375e

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

libc-test/build.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,11 @@ fn main() {
358358
"Dl_info" |
359359
"DIR" |
360360
"Elf32_Phdr" |
361-
"Elf64_Phdr" => ty.to_string(),
361+
"Elf64_Phdr" |
362+
"Elf32_Shdr" |
363+
"Elf64_Shdr" |
364+
"Elf32_Sym" |
365+
"Elf64_Sym" => ty.to_string(),
362366

363367
// Fixup a few types on windows that don't actually exist.
364368
"time64_t" if windows => "__time64_t".to_string(),

src/unix/notbsd/linux/mod.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ pub type Elf64_Word = u32;
3333
pub type Elf64_Off = u64;
3434
pub type Elf64_Addr = u64;
3535
pub type Elf64_Xword = u64;
36+
pub type Elf64_Sxword = i64;
37+
38+
pub type Elf32_Section = u16;
39+
pub type Elf64_Section = u16;
3640

3741
pub enum fpos64_t {} // TODO: fill this out with a struct
3842

@@ -479,6 +483,24 @@ s! {
479483
pub dlpi_tls_data: *mut ::c_void,
480484
}
481485

486+
pub struct Elf32_Sym {
487+
pub st_name: Elf32_Word,
488+
pub st_value: Elf32_Addr,
489+
pub st_size: Elf32_Word,
490+
pub st_info: ::c_uchar,
491+
pub st_other: ::c_uchar,
492+
pub st_shndx: Elf32_Section,
493+
}
494+
495+
pub struct Elf64_Sym {
496+
pub st_name: Elf64_Word,
497+
pub st_info: ::c_uchar,
498+
pub st_other: ::c_uchar,
499+
pub st_shndx: Elf64_Section,
500+
pub st_value: Elf64_Addr,
501+
pub st_size: Elf64_Xword,
502+
}
503+
482504
pub struct Elf32_Phdr {
483505
pub p_type: Elf32_Word,
484506
pub p_offset: Elf32_Off,
@@ -501,6 +523,32 @@ s! {
501523
pub p_align: Elf64_Xword,
502524
}
503525

526+
pub struct Elf32_Shdr {
527+
pub sh_name: Elf32_Word,
528+
pub sh_type: Elf32_Word,
529+
pub sh_flags: Elf32_Word,
530+
pub sh_addr: Elf32_Addr,
531+
pub sh_offset: Elf32_Off,
532+
pub sh_size: Elf32_Word,
533+
pub sh_link: Elf32_Word,
534+
pub sh_info: Elf32_Word,
535+
pub sh_addralign: Elf32_Word,
536+
pub sh_entsize: Elf32_Word,
537+
}
538+
539+
pub struct Elf64_Shdr {
540+
pub sh_name: Elf64_Word,
541+
pub sh_type: Elf64_Word,
542+
pub sh_flags: Elf64_Xword,
543+
pub sh_addr: Elf64_Addr,
544+
pub sh_offset: Elf64_Off,
545+
pub sh_size: Elf64_Xword,
546+
pub sh_link: Elf64_Word,
547+
pub sh_info: Elf64_Word,
548+
pub sh_addralign: Elf64_Xword,
549+
pub sh_entsize: Elf64_Xword,
550+
}
551+
504552
pub struct ucred {
505553
pub pid: ::pid_t,
506554
pub uid: ::uid_t,

0 commit comments

Comments
 (0)