We will need to set the ssp canary bit in traceback table to communicate
with unwinder about the canary.
Details
- Reviewers
DiggerLin xingxue hubert.reinterpretcast shchenz lkail - Group Reviewers
Restricted Project - Commits
- rG4a89ed373cda: [AIX] Add traceback ssp canary bit support
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | ||
---|---|---|
2199 | A patch like this one would need rather more tests to demonstrate that the insertion of the canary word is in a position that is compatible with where the unwinder and other stack-frame-walking tools would look. |
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | ||
---|---|---|
2199 | I think this is chicken and egg issue: there is no SSP support in current libunwind support on AIX yet. |
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | ||
---|---|---|
2199 | Also, since there is NO *ABI* definition of SSP canary word position, I don't think we should assume that it is the compiler's job to ensure the compatibility of canary word, libunwind can do a better job in ensuring the compatibility with legacy compiler in such case. |
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | ||
---|---|---|
2199 | It is the compiler's responsibility to ensure compatibility of the canary word so that the non-Clang-based IBM XL C++ stack unwinder continues to have whatever ability it did to unwind past C code (that just happens to be compiled with LLVM). Advanced debugging tools may also have an expectation about the positioning of the canary word. As for the ability of libunwind itself to do anything reasonable with this bit, even if the specific positioning is not based on the IBM XL compiler, that there is a concise set of rules for the positioning is necessary. Enabling the bit without identifying such a concise set of rules in prose (that is, improving the documentation of the ABI) seems problematic to me. |
I respectfully disagree with the requirement of mandating the canary word position.
But considering that libunwind hasn't support this,
I think we can guard this feature with an option, and disable it for now.
Doing this will make it easier for libunwind development and further testing.
Is that OK for you?
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | ||
---|---|---|
2199 |
I personally don't agree with this. It doesn't make sense to me to force clang-based compiler to ensure something with legacy unwinder just for mixing linkings -- which is not guarantee to work anyway.
As I mentioned, there was NO mention of canary word position in ABI, the tooling shouldn't have *expectation* of fixed position. Also our new clang based compiler does NOT claim to be backward compatibility with all existing toolings. | |
2199 |
I don't see the benefit justify the effort here. |
Yes, an option control (maybe -mllvm and not a top-level "Clang driver" option) sounds good.
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | ||
---|---|---|
2199 |
My understanding is that there is a design intent for C code to be usable in mixed scenarios. | |
2199 |
Given the additional option control, I'm fine with deferring this to a later patch that enables this functionality by default. |
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | ||
---|---|---|
2198 | Will it cause some issue in unwinder if we set the ssp canary bit in the traceback table but there is no canary word in the stack? Could you please comment @xingxue @DiggerLin @hubert.reinterpretcast |
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | ||
---|---|---|
2198 | The FIXME indicates a problem (as is appropriate for a FIXME). Even if it is possible to recover from this by more complicated logic in the unwinder, the preference should be for it to be resolved by the compiler (pay for it at compile time). The patch does not have to be blocked by the pending FIXME, because the bit is only set when an internal/experimental flag is set. |
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | ||
---|---|---|
2198 | As I mentioned, there is NO unwinder support yet, so this is chicken and egg issue. We can fix this in a following patch if the unwinder will not able to handle it and complain. Also this is a very corner case -- with legacy XL, we set this bit on whenever the options is on, no checking, and we never hit problem -- so legacy unwinder can tolerate this. |
LGTM, thanks.
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | ||
---|---|---|
2198 | OK, LGTM then. We can revisit the impact of the redundant ssp canary bit later when unwinder supports this. And also this flag will not be set by default in the compiler. |
Will it cause some issue in unwinder if we set the ssp canary bit in the traceback table but there is no canary word in the stack?
Could you please comment @xingxue @DiggerLin @hubert.reinterpretcast