[llvm] [PAC][ELF] Place AUTH constants in .data.rel.ro for position dependent code (PR #150418)
Anatoly Trosinenko via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 6 08:10:37 PDT 2025
================
@@ -333,9 +348,10 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalObject *GO,
// mergable section, because the linker doesn't take relocations into
// consideration when it tries to merge entries in the section.
Reloc::Model ReloModel = TM.getRelocationModel();
- if (ReloModel == Reloc::Static || ReloModel == Reloc::ROPI ||
- ReloModel == Reloc::RWPI || ReloModel == Reloc::ROPI_RWPI ||
- !C->needsDynamicRelocation())
+ if ((ReloModel == Reloc::Static || ReloModel == Reloc::ROPI ||
+ ReloModel == Reloc::RWPI || ReloModel == Reloc::ROPI_RWPI ||
+ !C->needsDynamicRelocation()) &&
+ !containsConstantPtrAuth(C))
return SectionKind::getReadOnly();
----------------
atrosinenko wrote:
[nit] Maybe it would be more readable to organize the checks along the lines
```cpp
// ...
} else {
// First of all, the dynamic linker always needs to fix PtrAuth relocations up.
if (containsPtrAuth(C))
return SectionKind::getReadOnlyWithRel();
// In static, ROPI and RWPI relocation models, the linker will resolve
// ...
if (ReloModel == ...)
return SectionKind::getReadOnly();
// Otherwise, the dynamic linker needs to fix it up, put it in the
// writable data.rel section.
return SectionKind::getReadOnlyWithRel();
```
https://github.com/llvm/llvm-project/pull/150418
More information about the llvm-commits
mailing list