From 92e397469d49e5d6dd053b061ec2a138a3dd1ef0 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 20 Apr 2024 01:40:00 -0700 Subject: qbe: Disallow address of TLS variables in static initializers The address of an object with thread storage duration is not an address constant. --- qbe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qbe.c b/qbe.c index 571cfaf..a360d03 100644 --- a/qbe.c +++ b/qbe.c @@ -1277,8 +1277,8 @@ dataitem(struct expr *expr, unsigned long long size) if (expr->kind != EXPRIDENT) error(&tok.loc, "initializer is not a constant expression"); decl = expr->u.ident.decl; - if (decl->value->kind != VALUE_GLOBAL) - fatal("not a global"); + if (decl->kind == DECLOBJECT && decl->u.obj.storage != SDSTATIC) + error(&tok.loc, "initializer is not a constant expression"); emitvalue(decl->value); break; case EXPRBINARY: -- cgit v1.2.3