On Fri, Mar 19, 2021 at 10:12:59AM -0500, Josh Poimboeuf wrote:

> > -void elf_add_reloc(struct elf *elf, struct reloc *reloc)
> > +int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long 
> > offset,
> > +             unsigned int type, struct symbol *sym, int addend)
> >  {
> > -   struct section *sec = reloc->sec;
> > +   struct reloc *reloc;
> > +
> > +   reloc = malloc(sizeof(*reloc));
> > +   if (!reloc) {
> > +           perror("malloc");
> > +           return -1;
> > +   }
> > +   memset(reloc, 0, sizeof(*reloc));
> > +
> > +   reloc->sec = sec->reloc;
> 
> Maybe elf_add_reloc() could create the reloc section if it doesn't
> already exist, that would help remove the multiple calls to
> elf_create_reloc_section().

I'll do that as yet another patch ;-)

> > +   reloc->offset = offset;
> > +   reloc->type = type;
> > +   reloc->sym = sym;
> > +   reloc->addend = addend;
> >  
> >     list_add_tail(&reloc->list, &sec->reloc_list);
> 
> This should be sec->reloc->reloc_list?

Absolutely, there were a few other 'funnies' as well that I just fixed
whilst trying to make the whole new stack work again :-)

Reply via email to