LLD wasn't previously specifying any specific alignment in the TLS table's Characteristics field so the loader would just assume the default value (16 bytes). This works most of the time except if you have thread locals that want specific higher alignments (e.g. 32 as in the bug) *even* if they specify an alignment on the thread local. This change updates LLD to take the max alignment from tls section.
Thanks for the fix!
If there is already some non-zero alignment, you would have to mask it out, right? Maybe structure this as:
As this setter is currently used, this bug is probably not observable, but it's best to be safe.
Looks good, suggestions optional.
I have some optional nitty suggestions here. You could do something like this to return early and reduce indentation:
Defined *b = dyn_cast_or_null<Defined>(symtab->findUnderscore("_tls_used")); if (!b) return; ...
Also, I'm not sure b is the most descriptive name. sym, tlsSym?