Skip to content

Commit

Permalink
readobj/elf: delete duplicated field (#683)
Browse files Browse the repository at this point in the history
Also fix a typo.
  • Loading branch information
philipc committed May 9, 2024
1 parent 0643b61 commit a739147
Show file tree
Hide file tree
Showing 14 changed files with 1 addition and 24 deletions.
1 change: 0 additions & 1 deletion crates/examples/src/readobj/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ fn print_file_header<Elf: FileHeader>(p: &mut Printer<'_>, endian: Elf::Endian,
} else {
p.field_hex("Version", version);
}
p.field_enum("Type", elf.e_type(endian), FLAGS_ET);
p.field_hex("Entry", elf.e_entry(endian).into());
p.field_hex("ProgramHeaderOffset", elf.e_phoff(endian).into());
p.field_hex("SectionHeaderOffset", elf.e_shoff(endian).into());
Expand Down
6 changes: 0 additions & 6 deletions crates/examples/testfiles/archive/bsd.a.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x228
Expand Down Expand Up @@ -281,7 +280,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x228
Expand Down Expand Up @@ -547,7 +545,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x230
Expand Down Expand Up @@ -813,7 +810,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x228
Expand Down Expand Up @@ -1079,7 +1075,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x228
Expand Down Expand Up @@ -1345,7 +1340,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x228
Expand Down
6 changes: 0 additions & 6 deletions crates/examples/testfiles/archive/gnu.a.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x228
Expand Down Expand Up @@ -281,7 +280,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x228
Expand Down Expand Up @@ -547,7 +545,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x230
Expand Down Expand Up @@ -813,7 +810,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x228
Expand Down Expand Up @@ -1079,7 +1075,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x228
Expand Down Expand Up @@ -1345,7 +1340,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x228
Expand Down
1 change: 0 additions & 1 deletion crates/examples/testfiles/elf/base-aarch64.o.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_AARCH64 (0xB7)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x280
Expand Down
1 change: 0 additions & 1 deletion crates/examples/testfiles/elf/base-aarch64.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ FileHeader {
Type: ET_DYN (0x3)
Machine: EM_AARCH64 (0xB7)
Version: EV_CURRENT (0x1)
Type: ET_DYN (0x3)
Entry: 0x620
ProgramHeaderOffset: 0x40
SectionHeaderOffset: 0x1CB8
Expand Down
1 change: 0 additions & 1 deletion crates/examples/testfiles/elf/base-mips64el.o.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_MIPS (0x8)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x3E8
Expand Down
1 change: 0 additions & 1 deletion crates/examples/testfiles/elf/base-mips64el.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ FileHeader {
Type: ET_EXEC (0x2)
Machine: EM_MIPS (0x8)
Version: EV_CURRENT (0x1)
Type: ET_EXEC (0x2)
Entry: 0x120000900
ProgramHeaderOffset: 0x40
SectionHeaderOffset: 0x1C50
Expand Down
1 change: 0 additions & 1 deletion crates/examples/testfiles/elf/base-strip.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ FileHeader {
Type: ET_DYN (0x3)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_DYN (0x3)
Entry: 0x570
ProgramHeaderOffset: 0x40
SectionHeaderOffset: 0x0
Expand Down
1 change: 0 additions & 1 deletion crates/examples/testfiles/elf/base.o.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x2D0
Expand Down
1 change: 0 additions & 1 deletion crates/examples/testfiles/elf/base.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ FileHeader {
Type: ET_DYN (0x3)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_DYN (0x3)
Entry: 0x570
ProgramHeaderOffset: 0x40
SectionHeaderOffset: 0x1948
Expand Down
1 change: 0 additions & 1 deletion crates/examples/testfiles/elf/nostd-mipsel.o.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ FileHeader {
Type: ET_REL (0x1)
Machine: EM_MIPS (0x8)
Version: EV_CURRENT (0x1)
Type: ET_REL (0x1)
Entry: 0x0
ProgramHeaderOffset: 0x0
SectionHeaderOffset: 0x1A0
Expand Down
1 change: 0 additions & 1 deletion crates/examples/testfiles/elf/nostd-mipsel.readobj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ FileHeader {
Type: ET_EXEC (0x2)
Machine: EM_MIPS (0x8)
Version: EV_CURRENT (0x1)
Type: ET_EXEC (0x2)
Entry: 0x0
ProgramHeaderOffset: 0x34
SectionHeaderOffset: 0x123C
Expand Down
1 change: 0 additions & 1 deletion crates/rewrite/testfiles/elf/base.noop
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ FileHeader {
Type: ET_DYN (0x3)
Machine: EM_X86_64 (0x3E)
Version: EV_CURRENT (0x1)
Type: ET_DYN (0x3)
Entry: 0x570
ProgramHeaderOffset: 0x40
SectionHeaderOffset: 0x1948
Expand Down
2 changes: 1 addition & 1 deletion src/read/elf/section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'data, Elf: FileHeader, R: ReadRef<'data>> SectionTable<'data, Elf, R> {
/// Returns an error for the null section at index 0.
pub fn section(&self, index: SectionIndex) -> read::Result<&'data Elf::SectionHeader> {
if index.0 == 0 {
return Err(read::Error("Invalid ELF symbol index"));
return Err(read::Error("Invalid ELF section index"));
}
self.sections
.get(index.0)
Expand Down

0 comments on commit a739147

Please sign in to comment.