diff options
| author | 2026-03-05 19:22:08 +0100 | |
|---|---|---|
| committer | 2026-03-05 19:22:08 +0100 | |
| commit | 25a143d75df857c6b76c67a71a3683d0191c711b (patch) | |
| tree | 99b13013cb9c7f1988cd0aab58c0eebf87e078a0 /c | |
| parent | 4362ce9e9d7defddb2d7965ef1cbf481599f5c81 (diff) | |
c: recognize another static initializer edge case
I think globsym & expr2reloc should be rewritten to be more robust to
this kind of thing. Accumulate offsets whilst recursing into the child
node that might contain a direct global symbol reference kind of thing.
Diffstat (limited to 'c')
| -rw-r--r-- | c/c.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -1410,7 +1410,6 @@ globsym(union ref *psym, const struct expr *ex) return 1; } return 0; - } static vlong /* -> returns addend */ @@ -1432,8 +1431,8 @@ expr2reloc(union ref *psym, const struct expr *ex) } else if (ex->t == EADD) { int swp = ex->sub[0].t == ENUMLIT; struct expr *a = &ex->sub[swp], *b = &ex->sub[swp ^ 1]; - if (globsym(psym, a) && isint(b->ty) && b->t == ENUMLIT) { - return b->i * typesize(typechild(a->ty)); + if (isint(b->ty) && b->t == ENUMLIT) { + return expr2reloc(psym, a) + b->i * typesize(typechild(a->ty)); } } fatal(&ex->span, "internal bug: non static reloc?"); |