ldso: correct condition for local symbol handling in do_relocs
authorRich Felker <dalias@aerifal.cx>
Mon, 12 Aug 2019 22:19:38 +0000 (18:19 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 12 Aug 2019 22:19:38 +0000 (18:19 -0400)
commit 7a9669e977e5f750cf72ccbd2614f8b72ce02c4c added use of the
symbol reference as the definition, in place of performing a lookup,
for STT_SECTION symbol references that were first found used in FDPIC.
such references may happen in certain other cases, such as
local-dynamic TLS and with relocation types that require a symbol but
that are being used for non-symbolic purposes, like the powerpc
unaligned address relocations.

in all such cases I'm aware of, the symbol referenced is a section
symbol (STT_SECTION); however, the important semantic property is not
its being a section, but rather its binding local (STB_LOCAL). check
the latter instead of the former for greater generality and semantic
correctness.

ldso/dynlink.c

index edd91acde257f6b185d35e28855b903d6cd50098..b9b2e96c89e6ff027bc9fbb0d5efd9acb01be3f5 100644 (file)
@@ -363,7 +363,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
                        sym = syms + sym_index;
                        name = strings + sym->st_name;
                        ctx = type==REL_COPY ? head->syms_next : head;
-                       def = (sym->st_info&0xf) == STT_SECTION
+                       def = (sym->st_info>>4) == STB_LOCAL
                                ? (struct symdef){ .dso = dso, .sym = sym }
                                : find_sym(ctx, name, type==REL_PLT);
                        if (!def.sym && (sym->st_shndx != SHN_UNDEF