aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/ELF.cpp
diff options
context:
space:
mode:
authorAiden Grossman <aidengrossman@google.com>2025-02-10 10:57:19 -0800
committerGitHub <noreply@github.com>2025-02-10 10:57:19 -0800
commit808b1c11a26ba986a4148e10f30a5ba995766f83 (patch)
tree761f87b6cb51598d9a980a36963da638109e2e6f /llvm/lib/Object/ELF.cpp
parent196a1acc7d277d05d4b94ad7745c18bf13ea991f (diff)
downloadllvm-808b1c11a26ba986a4148e10f30a5ba995766f83.zip
llvm-808b1c11a26ba986a4148e10f30a5ba995766f83.tar.gz
llvm-808b1c11a26ba986a4148e10f30a5ba995766f83.tar.bz2
[ELF] Add support for CREL to getSectionAndRelocations
This patch updates the getSectionAndRelocations function to also support CREL relocation sections. Unit tests have been added. This patch also updates consumers to say they explicitly do not support CREL format relocations. Subsequent patches will make the consumers work with CREL format relocations and also add in testing support. Reviewers: red1bluelost, MaskRay, rlavaee Reviewed By: MaskRay Pull Request: https://github.com/llvm/llvm-project/pull/126445
Diffstat (limited to 'llvm/lib/Object/ELF.cpp')
-rw-r--r--llvm/lib/Object/ELF.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Object/ELF.cpp b/llvm/lib/Object/ELF.cpp
index b6d0699..8cb3d7e 100644
--- a/llvm/lib/Object/ELF.cpp
+++ b/llvm/lib/Object/ELF.cpp
@@ -747,6 +747,13 @@ decodeBBAddrMapImpl(const ELFFile<ELFT> &EF,
assert(RelaSec &&
"Can't read a SHT_LLVM_BB_ADDR_MAP section in a relocatable "
"object file without providing a relocation section.");
+ // We might end up with relocations in CREL here. If we do, return an
+ // error since we do not currently support them.
+ if (RelaSec->sh_type == ELF::SHT_CREL)
+ return createError("unable to read relocations for section " +
+ describe(EF, Sec) +
+ " as the corresponding relocation section format is "
+ "CREL, which is not currently supported.");
Expected<typename ELFFile<ELFT>::Elf_Rela_Range> Relas = EF.relas(*RelaSec);
if (!Relas)
return createError("unable to read relocations for section " +
@@ -958,7 +965,8 @@ ELFFile<ELFT>::getSectionAndRelocations(
continue;
}
- if (Sec.sh_type != ELF::SHT_RELA && Sec.sh_type != ELF::SHT_REL)
+ if (Sec.sh_type != ELF::SHT_RELA && Sec.sh_type != ELF::SHT_REL &&
+ Sec.sh_type != ELF::SHT_CREL)
continue;
Expected<const Elf_Shdr *> RelSecOrErr = this->getSection(Sec.sh_info);