1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-12 23:48:51 +03:00

[ELF] Fix uninitialized ElfSym paddings

Designated initializer doesn't initialize the padding; make sure we memset
them by ourselves.

Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
This commit is contained in:
Tatsuyuki Ishi 2022-10-22 19:37:35 +09:00
parent f18af9e2f4
commit 0b50ebda47
2 changed files with 3 additions and 1 deletions

View File

@ -1535,6 +1535,7 @@ template <typename E>
void SharedFile<E>::populate_symtab(Context<E> &ctx) {
ElfSym<E> *symtab =
(ElfSym<E> *)(ctx.buf + ctx.symtab->shdr.sh_offset) + this->global_symtab_idx;
memset(symtab, 0, sizeof(ElfSym<E>) * this->num_global_symtab);
u8 *strtab = ctx.buf + ctx.strtab->shdr.sh_offset + this->strtab_offset;

View File

@ -508,7 +508,8 @@ static void load_plugin(Context<E> &ctx) {
template <typename E>
static ElfSym<E> to_elf_sym(PluginSymbol &psym) {
ElfSym<E> esym = {};
ElfSym<E> esym;
memset(&esym, 0, sizeof(esym));
switch (psym.def) {
case LDPK_DEF: