[PATCH] PR 28447: implement multiple parameters for .file on XCOFF

CHIGOT, CLEMENT clement.chigot@atos.net
Tue Nov 30 07:57:41 GMT 2021


> On Fri, Nov 26, 2021 at 12:47:32PM -0500, Mike Frysinger via Binutils wrote:
> > On 18 Oct 2021 11:37, CHIGOT, CLEMENT via Binutils wrote:
> > > On XCOFF, ".file" pseudo-op allows 3 extras parameters to provide
> > > additional information to AIX linker, or its debugger. These are
> > > stored in auxiliary entries of the C_FILE symbol.
> > >
> > > --- a/bfd/coffgen.c
> > > +++ b/bfd/coffgen.c
> > > @@ -2135,6 +2203,12 @@ coff_print_symbol (bfd *abfd,
> > >              {
> > >              case C_FILE:
> > >                fprintf (file, "File ");
> > > +             /* Add additional information if this isn't the filename
> > > +                auxiliary entry.  */
> > > +             if (aux)
> > > +               fprintf (file, "ftype %d fname \"%s\"",
> > > +                        auxp->u.auxent.x_file.x_ftype,
> > > +                        (char *) auxp->u.auxent.x_file.x_n.x_n.x_offset);
> >
> > x_offset is a long and is not safe to directly cast to a pointer.  on LLP64
> > sytems where sizeof(long) == 4 and sizeof(char*) == 8, this fails, and it's
> > causing a build failure as a result:
> >
> > bfd/coffgen.c: In function ‘coff_print_symbol’:
> > bfd/coffgen.c:2221:30: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
> >  2221 |                              (char *) auxp->u.auxent.x_file.x_n.x_n.x_offset);
> >       |                              ^
> > -mike
>
> Also reported as PR28630.

Thanks to Pekka, it seems that a fix would be to replace the
type of x_offset from "long" to "bfd_hostptr_t".
I've tried quickly on AIX and with some cross-compilation and it
looks good. However, I'm not mastering enough bfd to ensure that
this is the right fix.
Alan does it look good to you or it might trigger some unwanted
behaviors in some COFF targets ?
Note that this trick is already used by "internal_syment" structure
to store its name.

Thanks,
Clément



More information about the Binutils mailing list