[llvm] [PAC][ELF] Place AUTH constants in .data.rel.ro for position dependent code (PR #150418)
Daniil Kovalev via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 19 12:32:05 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();
----------------
kovdan01 wrote:
> Would it make sense to move the check for relocation model as well as the `ptrauth` constant detection (without the reloc model check of course) into `needsDynamicRelocation`?
@pcc While I like the idea of simplifying things and making naming less confusing, I'm not sure if such a change would make logic for all the users of `needsDynamicRelocation` simpler. Also, it looks like that some callers do not have easy access to `TargetMachine` object, so they can't easily call `getRelocationModel()` and pass that to new `needsDynamicRelocation` updated accordingly to your suggestion.
We might think of such an improvement, but I guess this is out of scope of this PR and it's better not to combine actual bug fixes and refactoring.
Can we postpone applying your suggestion? And could you please tell if there is any other feedback on this PR or this can be merged? Thanks!
https://github.com/llvm/llvm-project/pull/150418
More information about the llvm-commits
mailing list