[clang 5 generates R_PPC_PLTREL24 in the .o files
for global symbols in places gcc 4.2.1 generates
R_PPC_ADDR16_HA / R_PPC_ADDR16_LO pairs.]

On 2017-Aug-10, at 7:22 PM, Mark Millard <markmi at dsl-only.net> wrote:

> [A top post about the failing R_PPC_PLTREL24 since
> the material does not flow well as a sequential
> read from prior material. I found that the .kld
> does not match the contributing .o for GLOBAL
> status for routines and the LOCAL in the .kld is
> rejected by ld in ppc_elf_check_relocs.]
> 
> There is something consistent between the two example
> failures. (The examples here are from a more recent
> head version for a buildkernel attempt.)
> 
> (I inserted some lines not matched by the shown grep.)
> 
> # readelf -a 
> /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/aha/aha.kld
>  | grep aha_alloc
> 00002b8c 00003e12 R_PPC_PLTREL24      00000000 aha_alloc + 0
> 000031a8 00003e12 R_PPC_PLTREL24      00000000 aha_alloc + 0
> Symbol table (.symtab) contains 180 entries:
>   Num:    Value          Size Type    Bind   Vis      Ndx Name
>    62: 0000000000000000    96 FUNC    LOCAL  DEFAULT    1 aha_alloc
> 
> but in aha.o :
> 
>    44: 0000000000000000    96 FUNC    GLOBAL DEFAULT    2 aha_alloc
> 
> # readelf -a 
> /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/agp/agp.kld
>  | grep agp_find_caps
> 00002e08 00004912 R_PPC_PLTREL24      00000000 agp_find_caps + 0
> Symbol table (.symtab) contains 180 entries:
>   Num:    Value          Size Type    Bind   Vis      Ndx Name
>    73: 0000000000000000   172 FUNC    LOCAL  DEFAULT    1 agp_find_caps
> 
> but in agp.o :
> 
>    58: 0000000000000000   172 FUNC    GLOBAL DEFAULT    2 agp_find_caps
> 
> building the .kld's is turning GLOBAL into LOCAL -- and the LOCAL
> is being rejected by:
> 
> /usr/src/contrib/binutils/bfd/elf32-ppc.c
> 
> in its routine:
> 
> /* Look through the relocs for a section during the first phase, and
>   allocate space in the global offset table or procedure linkage
>   table.  */
> 
> static bfd_boolean
> ppc_elf_check_relocs (bfd *abfd,
>                      struct bfd_link_info *info,
>                      asection *sec,
>                      const Elf_Internal_Rela *relocs)
> 
> via:
> 
> 
>      r_symndx = ELF32_R_SYM (rel->r_info);
>      if (r_symndx < symtab_hdr->sh_info)
>        h = NULL;
>      else  
> 
> . . .
>      tls_type = 0;
>      r_type = ELF32_R_TYPE (rel->r_info);
> . . .              
>      switch (r_type)
>        {
> . . .
>        case R_PPC_PLT32:
>        case R_PPC_PLTREL24:
>        case R_PPC_PLTREL32:
>        case R_PPC_PLT16_LO:
>        case R_PPC_PLT16_HI:
>        case R_PPC_PLT16_HA:
> #ifdef DEBUG
>          fprintf (stderr, "Reloc requires a PLT entry\n");
> #endif
>          /* This symbol requires a procedure linkage table entry.  We
>             actually build the entry in finish_dynamic_symbol,
>             because this might be a case of linking PIC code without
>             linking in any dynamic objects, in which case we don't
>             need to generate a procedure linkage table after all.  */
> 
>          if (h == NULL)
>            {
>              /* It does not make sense to have a procedure linkage
>                 table entry for a local symbol.  */
>              (*_bfd_error_handler) (_("%B(%A+0x%lx): %s reloc against "
>                                       "local symbol"),
>                                     abfd,
>                                     sec,
>                                     (long) rel->r_offset,
>                                     ppc_elf_howto_table[r_type]->name);
>              bfd_set_error (bfd_error_bad_value);
>              return FALSE;
>            }
>          else
> . . .

clang 5 and gcc 4.2.1 do not match for what
goes in aha*.o and agp*.o files for the
problem symbols in clang 5's output:

gcc 4.2.1 ( R_PPC_ADDR16_HA / R_PPC_ADDR16_LO ):

# readelf -at 
/usr/obj/powerpcvtsc_gcc421/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/aha/aha*.o
 | grep aha_alloc
    50: 0000000000000514   112 FUNC    GLOBAL DEFAULT    1 aha_alloc
00000032 00003206 R_PPC_ADDR16_HA     00000000 aha_alloc + 0
0000003e 00003204 R_PPC_ADDR16_LO     00000000 aha_alloc + 0
0000052a 00003206 R_PPC_ADDR16_HA     00000000 aha_alloc + 0
0000052e 00003204 R_PPC_ADDR16_LO     00000000 aha_alloc + 0
    50: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND aha_alloc

# readelf -at 
/usr/obj/powerpcvtsc_gcc421/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/agp/agp*.o
 | grep caps
0000204a 00003a06 R_PPC_ADDR16_HA     00000434 agp_find_caps + 0
0000204e 00003a04 R_PPC_ADDR16_LO     00000434 agp_find_caps + 0
00002312 00003a06 R_PPC_ADDR16_HA     00000434 agp_find_caps + 0
0000231a 00003a04 R_PPC_ADDR16_LO     00000434 agp_find_caps + 0
00000000 00003a01 R_PPC_ADDR32        00000434 agp_find_caps + 0
    58: 0000000000000434   192 FUNC    GLOBAL DEFAULT    1 agp_find_caps
000002be 00003906 R_PPC_ADDR16_HA     00000000 agp_find_caps + 0
000002c6 00003904 R_PPC_ADDR16_LO     00000000 agp_find_caps + 0
    57: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND agp_find_caps


clang 5 ( R_PPC_PLTREL24 ):

# readelf -at 
/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/aha/aha*.o
 | grep aha_alloc
    44: 0000000000000000    96 FUNC    GLOBAL DEFAULT    2 aha_alloc
000000f0 00002e12 R_PPC_PLTREL24      00000000 aha_alloc + 0
0000070c 00002e12 R_PPC_PLTREL24      00000000 aha_alloc + 0
    46: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND aha_alloc

# readelf -at 
/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/agp/agp*.o
 | grep caps
    58: 0000000000000000   172 FUNC    GLOBAL DEFAULT    2 agp_find_caps
00000138 00003512 R_PPC_PLTREL24      00000000 agp_find_caps + 0
    53: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND agp_find_caps

(Turning some R_PPC_PLTREL24 into LOCAL for *.kld files
is a no-no as far as powerpc (32-bit) ld is concerned.)

===
Mark Millard
markmi at dsl-only.net

_______________________________________________
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to