[llvm] [Bolt] Fix issue 110407 (Support CREL) (PR #119150)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 8 14:50:20 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-bolt
Author: 2:5030/1559 (0xfk0)
<details>
<summary>Changes</summary>
This commit fixes issue #<!-- -->110407 in Bolt subproject: BOLT programs not support CREL-type relocations.
---
Full diff: https://github.com/llvm/llvm-project/pull/119150.diff
1 Files Affected:
- (modified) bolt/lib/Rewrite/RewriteInstance.cpp (+10-2)
``````````diff
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 76e1f0156f828d..f1ef97888a26ce 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -1938,8 +1938,11 @@ Error RewriteInstance::readSpecialSections() {
"Use -update-debug-sections to keep it.\n";
}
- HasTextRelocations = (bool)BC->getUniqueSectionByName(
- ".rela" + std::string(BC->getMainCodeSectionName()));
+ const char *code_sec = BC->getMainCodeSectionName();
+ HasTextRelocations = !!BC->getUniqueSectionByName(std::string{".rela"} + code_sec);
+ if (!HasTextRelocations)
+ HasTextRelocations = !!BC->getUniqueSectionByName(std::string{".crel"} + code_sec);
+
HasSymbolTable = (bool)BC->getUniqueSectionByName(".symtab");
EHFrameSection = BC->getUniqueSectionByName(".eh_frame");
@@ -2127,6 +2130,11 @@ int64_t getRelocationAddend(const ELFObjectFile<ELFT> *Obj,
llvm_unreachable("unexpected relocation section type");
case ELF::SHT_REL:
break;
+ case ELF::SHT_CREL: {
+ auto ERela = Obj->getCrel(Rel);
+ Addend = ERela.r_addend;
+ break;
+ }
case ELF::SHT_RELA: {
const Elf_Rela *RelA = Obj->getRela(Rel);
Addend = RelA->r_addend;
``````````
</details>
https://github.com/llvm/llvm-project/pull/119150
More information about the llvm-commits
mailing list