This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] ld (bfd) arm32 elf invalid strings offset in .strtab


Patch updated to head and simplified to modify only bfd/elf.c:

On Tue, Aug 20, 2019 at 01:33:22PM +0200, tlaronde@polynum.com wrote:
> Hello Tamar,
> 
> On Tue, Aug 20, 2019 at 09:27:00AM +0000, Tamar Christina wrote:
> >  cauchy.polynum.local id x7KAStGn000625
> > Status: RO
> > Content-Length: 20112
> > Lines: 522
> > 
> > Hi Thierry,
> > 
> > Thanks for the patch, can you make the patch target master instead of the release branch please.
> 
> OK, once you are OK with the modification I will update the patch
> against master.
> 
> > It will be backported once it's accepted.
> > 
> > > ==========================================================
> > > =========
> > > RCS file: /cvsroot/src/external/gpl3/binutils/dist/bfd/elf.c,v
> > > retrieving revision 1.13
> > > diff -u -r1.13 elf.c
> > > --- external/gpl3/binutils/dist/bfd/elf.c	7 Nov 2018 01:13:52 -0000	1.13
> > > +++ external/gpl3/binutils/dist/bfd/elf.c	15 Aug 2019 07:43:15 -0000
> > > @@ -491,7 +491,7 @@
> > >  	   shndx = extshndx_buf;
> > >         isym < isymend;
> > >         esym += extsym_size, isym++, shndx = shndx != NULL ? shndx + 1 : NULL)
> > > -    if (!(*bed->s->swap_symbol_in) (ibfd, esym, shndx, isym))
> > > +    if (!(*bed->s->swap_symbol_in) (ibfd, esym, shndx, isym,
> > > + symtab_hdr))
> > >        {
> > >  	symoffset += (esym - (bfd_byte *) extsym_buf) / extsym_size;
> > >  	/* xgettext:c-format */
> > 
> > Any reason why you can't just update elf_symtab_hdr for ibfd before the call to swap_symbol_in?
> > That way you don't need all the other changes and the symtab comes from there anyway,
> > so updating it I think is OK.
> 
> In elf.c:bfd_elf_get_elf_syms() there is the test:
> 	
> 	 if (symtab_hdr == & elf_symtab_hdr (ibfd))
> 
> hence I infer that the two may not match (it is indeed the case) and
> that is is OK; so changing it here may have effects elsewhere.
> 
> One could also save the current value, update to the here correct one
> before the call (unchanged) and restore after avoiding in this case
> indeed all the other changes.
> 

So please find attached the patch against head, modifying only bfd/elf.c
with baking the private data header information, setting it to
symtab_hdr and restoring (if failure or if success).

Since the procedure is called from misc. points, it is IMHO better to
not temper with the private data if ones doesn't want to audit all the
back ends for the impact of this modification.

Best regards,
-- 
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                     http://www.kergis.com/
                       http://www.sbfa.fr/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

Attachment: head.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]