================ @@ -1355,6 +1355,36 @@ unsigned RelocationScanner::handleTlsRelocation(RelExpr expr, RelType type, return 1; } + auto fatalBothAuthAndNonAuth = [&sym]() { + fatal("both AUTH and non-AUTH TLSDESC entries for '" + sym.getName() + + "' requested, but only one type of TLSDESC entry per symbol is " + "supported"); + }; + + // Do not optimize signed TLSDESC as described in pauthabielf64 to LE/IE. + // https://github.com/ARM-software/abi-aa/blob/main/pauthabielf64/pauthabielf64.rst#general-restrictions + // > PAUTHELF64 only supports the descriptor based TLS (TLSDESC). + if (oneof<R_AARCH64_AUTH_TLSDESC_PAGE, RelExpr::R_AARCH64_AUTH_TLSDESC>( + expr)) { + assert(ctx.arg.emachine == EM_AARCH64); + if (!sym.hasFlag(NEEDS_TLSDESC)) + sym.setFlags(NEEDS_TLSDESC | NEEDS_TLSDESC_AUTH); + else if (!sym.hasFlag(NEEDS_TLSDESC_AUTH)) + fatalBothAuthAndNonAuth(); + sec->addReloc({expr, type, offset, addend, &sym}); + return 1; + } + + if (sym.hasFlag(NEEDS_TLSDESC_AUTH)) { + assert(ctx.arg.emachine == EM_AARCH64); + // TLSDESC_CALL hint relocation probably should not be emitted by compiler + // with signed TLSDESC enabled since it does not give any value, but leave a + // check against that just in case someone uses it. + if (expr != R_TLSDESC_CALL) + fatalBothAuthAndNonAuth(); ---------------- kovdan01 wrote:
The logic of this code and code above is the following. We check rel expr against AUTH variants. 1. If yes, the symbol should either already have both `NEEDS_TLSDESC` and `NEEDS_TLSDESC_AUTH` or have none of them. The symbol having only `NEEDS_TLSDESC` means that a non-auth entry was requested previously, and now we are requesting an auth one - which is currently not supported. 2. If no, but `NEEDS_TLSDESC_AUTH` flag was already set previously, it means that auth entry was requested previously, and non-auth one is requested now, which is currently not supported. The only case when we don't emit an error is expr equal to `R_TLSDESC_CALL` - this is a hint reloc which does not result in a non-auth entry by itself. See comment right above this if statement. https://github.com/llvm/llvm-project/pull/113817 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits