]> granicus.if.org Git - musl/commitdiff
fix inefficient choice of tlsdesc function due to off-by-one
authorRich Felker <dalias@aerifal.cx>
Mon, 16 Jul 2018 16:29:14 +0000 (12:29 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 16 Jul 2018 16:29:14 +0000 (12:29 -0400)
tls_id is one-based, whereas [static_]tls_cnt is a count, so
comparison for checking that a given tls_id is dynamic rather than
static needs to use strict inequality.

ldso/dynlink.c

index 41534e90e4680b88e7d6a623c1632b014600e547..8242a1d1aba7f3005a46b5401954bedae7a10864 100644 (file)
@@ -438,7 +438,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
 #endif
                case REL_TLSDESC:
                        if (stride<3) addend = reloc_addr[1];
-                       if (runtime && def.dso->tls_id >= static_tls_cnt) {
+                       if (runtime && def.dso->tls_id > static_tls_cnt) {
                                struct td_index *new = malloc(sizeof *new);
                                if (!new) {
                                        error(