Skip to content
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

build/elf: handle SHT_RELR sections #744

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/examples/src/readobj/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,7 @@ const FLAGS_SHT: &[Flag<u32>] = &flags!(
SHT_PREINIT_ARRAY,
SHT_GROUP,
SHT_SYMTAB_SHNDX,
SHT_RELR,
SHT_LLVM_DEPENDENT_LIBRARIES,
SHT_GNU_ATTRIBUTES,
SHT_GNU_HASH,
Expand Down
2 changes: 1 addition & 1 deletion src/build/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl<'data> Builder<'data> {
| elf::SHT_LLVM_DEPENDENT_LIBRARIES => {
SectionData::Data(section.data(endian, data)?.into())
}
elf::SHT_REL | elf::SHT_RELA => relocations,
elf::SHT_REL | elf::SHT_RELA | elf::SHT_RELR => relocations,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem correct because we don't currently parse SHT_RELR relocations, so relocations will be empty.

elf::SHT_SYMTAB => {
if index == symbols.section() {
SectionData::Symbol
Expand Down
2 changes: 2 additions & 0 deletions src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,8 @@ pub const SHT_PREINIT_ARRAY: u32 = 16;
pub const SHT_GROUP: u32 = 17;
/// Extended section indices for a symbol table.
pub const SHT_SYMTAB_SHNDX: u32 = 18;
/// Relative Relocation entries (https://maskray.me/blog/2021-10-31-relative-relocations-and-relr)
pub const SHT_RELR: u32 = 19;
/// Start of OS-specific section types.
pub const SHT_LOOS: u32 = 0x6000_0000;
/// LLVM-style dependent libraries.
Expand Down
3 changes: 2 additions & 1 deletion src/read/elf/section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,8 @@ where
| elf::SHT_DYNAMIC
| elf::SHT_REL
| elf::SHT_DYNSYM
| elf::SHT_GROUP => SectionKind::Metadata,
| elf::SHT_GROUP
| elf::SHT_RELR => SectionKind::Metadata,
_ => SectionKind::Elf(sh_type),
}
}
Expand Down
Loading