Message ID | 54206A25.5060909@redhat.com |
---|---|
State | New |
Headers | show |
I didn't contemplate the substance. > + size_t sizeofrel; > + size_t relcount; Don't predeclare when C99-style mixed decls are fine. > { > errstring = N_("%s: no PLTREL found in object %s\n"); > @@ -279,8 +281,12 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], > l->l_name); > } > > - l->l_reloc_result = calloc (sizeof (l->l_reloc_result[0]), > - l->l_info[DT_PLTRELSZ]->d_un.d_val); > + sizeofrel = l->l_info[DT_PLTREL]->d_un.d_val == DT_RELA > + ? sizeof(ElfW(Rela)) > + : sizeof(ElfW(Rel)); Missing spaces before paren (after sizeof, but not after ElfW).
On 09/22/2014 04:47 PM, Roland McGrath wrote: > I didn't contemplate the substance. > >> + size_t sizeofrel; >> + size_t relcount; > > Don't predeclare when C99-style mixed decls are fine. > >> { >> errstring = N_("%s: no PLTREL found in object %s\n"); >> @@ -279,8 +281,12 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], >> l->l_name); >> } >> >> - l->l_reloc_result = calloc (sizeof (l->l_reloc_result[0]), >> - l->l_info[DT_PLTRELSZ]->d_un.d_val); >> + sizeofrel = l->l_info[DT_PLTREL]->d_un.d_val == DT_RELA >> + ? sizeof(ElfW(Rela)) >> + : sizeof(ElfW(Rel)); > > Missing spaces before paren (after sizeof, but not after ElfW). > Thanks. I'll change that and commit later if nobody else objects. Cheers, Carlos.
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c index d2c6dac..cc8c8eb 100644 --- a/elf/dl-reloc.c +++ b/elf/dl-reloc.c @@ -270,6 +270,8 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], relocations. If the shared object lacks a PLT (for example if it only contains lead function) the l_info[DT_PLTRELSZ] will be NULL. */ + size_t sizeofrel; + size_t relcount; if (l->l_info[DT_PLTRELSZ] == NULL) { errstring = N_("%s: no PLTREL found in object %s\n"); @@ -279,8 +281,12 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], l->l_name); } - l->l_reloc_result = calloc (sizeof (l->l_reloc_result[0]), - l->l_info[DT_PLTRELSZ]->d_un.d_val); + sizeofrel = l->l_info[DT_PLTREL]->d_un.d_val == DT_RELA + ? sizeof(ElfW(Rela)) + : sizeof(ElfW(Rel)); + relcount = l->l_info[DT_PLTRELSZ]->d_un.d_val / sizeofrel; + l->l_reloc_result = calloc (sizeof (l->l_reloc_result[0]), relcount); + if (l->l_reloc_result == NULL) { errstring = N_("\