Summary: | -r322109 and -r322210 (so clang 5) TARGET_ARCH=powerpc agp.kld or agp.kld gets: R_PPC_PLTREL24 reloc against local symbol; could not read symbols: Bad value | ||
---|---|---|---|
Product: | Base System | Reporter: | Mark Millard <marklmi26-fbsd> |
Component: | kern | Assignee: | freebsd-bugs (Nobody) <bugs> |
Status: | Closed FIXED | ||
Severity: | Affects Only Me | ||
Priority: | --- | ||
Version: | CURRENT | ||
Hardware: | powerpc | ||
OS: | Any |
Description
Mark Millard
2017-07-30 19:58:15 UTC
objdump reports that the .text+0x2b94 is in aha_isa_probe and is a reference to aha_alloc: (sorted objdump -x output:) 00002b78 R_PPC_PLTREL24 bus_alloc_resource 00002b88 R_PPC_PLTREL24 rman_get_start 00002b94 R_PPC_PLTREL24 aha_alloc 00002b96 R_PPC_ADDR32 .debug_str+0x0000266c 00002b9c R_PPC_PLTREL24 aha_probe 00002b9f R_PPC_ADDR32 .debug_str+0x00001904 (objdump -d --prefix-addresses output:) 00002aa4 <aha_isa_probe> mflr r0 . . . 00002b7c <aha_isa_probe+0xd8> cmplwi r3,0 00002b80 <aha_isa_probe+0xdc> stw r3,188(r28) 00002b84 <aha_isa_probe+0xe0> beq 00002c1c <aha_isa_probe+0x178> 00002b88 <aha_isa_probe+0xe4> bl 00002b88 <aha_isa_probe+0xe4> 00002b8c <aha_isa_probe+0xe8> mr r3,r28 00002b90 <aha_isa_probe+0xec> mr r27,r4 00002b94 <aha_isa_probe+0xf0> bl 00002b94 <aha_isa_probe+0xf0> 00002b98 <aha_isa_probe+0xf4> mr r3,r28 00002b9c <aha_isa_probe+0xf8> bl 00002b9c <aha_isa_probe+0xf8> 00002ba0 <aha_isa_probe+0xfc> cmplwi r3,0 My -r322109 update got the same type of error in a different place: --- all_subdir_agp --- Building /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/agp/agp.ko.full . . . --- all_subdir_agp --- --- agp.ko.full --- ld: agp.kld(.text+0x2e08): R_PPC_PLTREL24 reloc against local symbol agp.kld: could not read symbols: Bad value *** [agp.ko.full] Error code 1 make[4]: stopped in /usr/src/sys/modules/agp .ERROR_TARGET='agp.ko.full' .ERROR_META_FILE='/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/agp/agp.ko.full.meta' .MAKE.LEVEL='4' MAKEFILE='' .MAKE.MODE='meta missing-filemon=yes missing-meta=yes silent=yes verbose' _ERROR_CMD='ld -m elf32ppc_fbsd -Bshareable -znotext -d -warn-common -o agp.ko.full agp.kld;' .CURDIR='/usr/src/sys/modules/agp' .MAKE='make' .OBJDIR='/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/agp' .TARGETS='all' DESTDIR='' LD_LIBRARY_PATH='' MACHINE='powerpc' MACHINE_ARCH='powerpc' MAKEOBJDIRPREFIX='/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules' MAKESYSPATH='/usr/src/share/mk' MAKE_VERSION='20170720' PATH='/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/tmp/legacy/usr/sbin:/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/tmp/legacy/usr/bin:/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/tmp/legacy/bin:/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/tmp/usr/sbin:/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/tmp/usr/bin:/sbin:/bin:/usr/sbin:/usr/bin' SRCTOP='/usr/src' OBJTOP='/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src' .MAKE.MAKEFILES='/usr/src/share/mk/sys.mk /usr/src/share/mk/local.sys.env.mk /usr/src/share/mk/src.sys.env.mk /root/src.configs/src.conf.powerpc-clang-bootstrap.amd64-host /usr/src/share/mk/bsd.mkopt.mk /usr/src/share/mk/bsd.suffixes.mk /root/src.configs/make.conf /usr/src/share/mk/local.sys.mk /usr/src/share/mk/src.sys.mk /dev/null /usr/src/sys/modules/agp/Makefile /usr/src/share/mk/bsd.kmod.mk /usr/src/sys/conf/kmod.mk /usr/src/share/mk/bsd.init.mk /usr/src/share/mk/bsd.opts.mk /usr/src/share/mk/bsd.cpu.mk /usr/src/share/mk/local.init.mk /usr/src/share/mk/src.init.mk /usr/src/sys/modules/agp/../Makefile.inc /usr/src/share/mk/bsd.own.mk /usr/src/share/mk/bsd.compiler.mk /usr/src/share/mk/bsd.linker.mk /usr/src/sys/conf/kern.opts.mk /usr/src/sys/conf/config.mk /usr/src/share/mk/bsd.links.mk /usr/src/share/mk/bsd.dep.mk /usr/src/share/mk/bsd.clang-analyze.mk /usr/src/share/mk/bsd.obj.mk /usr/src/share/mk/bsd.subdir.mk /usr/src/sys/conf/kern.mk' .PATH='. /usr/src/sys/modules/agp /usr/src/sys/dev/agp /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG' 1 error --- all_subdir_aha --- A failure has been detected in another branch of the parallel make make[4]: stopped in /usr/src/sys/modules/aha .ERROR_TARGET='' .ERROR_META_FILE='' .MAKE.LEVEL='4' MAKEFILE='' .MAKE.MODE='meta missing-filemon=yes missing-meta=yes silent=yes verbose' _ERROR_CMD='.PHONY' .CURDIR='/usr/src/sys/modules/aha' .MAKE='make' .OBJDIR='/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/aha' .TARGETS='all' DESTDIR='' LD_LIBRARY_PATH='' MACHINE='powerpc' MACHINE_ARCH='powerpc' MAKEOBJDIRPREFIX='/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules' MAKESYSPATH='/usr/src/share/mk' MAKE_VERSION='20170720' PATH='/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/tmp/legacy/usr/sbin:/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/tmp/legacy/usr/bin:/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/tmp/legacy/bin:/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/tmp/usr/sbin:/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/tmp/usr/bin:/sbin:/bin:/usr/sbin:/usr/bin' SRCTOP='/usr/src' OBJTOP='/usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src' .MAKE.MAKEFILES='/usr/src/share/mk/sys.mk /usr/src/share/mk/local.sys.env.mk /usr/src/share/mk/src.sys.env.mk /root/src.configs/src.conf.powerpc-clang-bootstrap.amd64-host /usr/src/share/mk/bsd.mkopt.mk /usr/src/share/mk/bsd.suffixes.mk /root/src.configs/make.conf /usr/src/share/mk/local.sys.mk /usr/src/share/mk/src.sys.mk /dev/null /usr/src/sys/modules/aha/Makefile /usr/src/share/mk/bsd.kmod.mk /usr/src/sys/conf/kmod.mk /usr/src/share/mk/bsd.init.mk /usr/src/share/mk/bsd.opts.mk /usr/src/share/mk/bsd.cpu.mk /usr/src/share/mk/local.init.mk /usr/src/share/mk/src.init.mk /usr/src/sys/modules/aha/../Makefile.inc /usr/src/share/mk/bsd.own.mk /usr/src/share/mk/bsd.compiler.mk /usr/src/share/mk/bsd.linker.mk /usr/src/sys/conf/kern.opts.mk /usr/src/sys/conf/config.mk /usr/src/share/mk/bsd.links.mk /usr/src/share/mk/bsd.dep.mk /usr/src/share/mk/bsd.clang-analyze.mk /usr/src/share/mk/bsd.obj.mk /usr/src/share/mk/bsd.subdir.mk /usr/src/sys/conf/kern.mk' .PATH='. /usr/src/sys/modules/aha /usr/src/sys/dev/aha /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG' *** [all_subdir_aha] Error code 2 (In reply to Mark Millard from comment #2) Building under/for -r322210 got the R_PPC_PLTREL24 report for aha.kld instead of agp.aha : --- aha.ko.full --- ld: aha.kld(.text+0x2b8c): R_PPC_PLTREL24 reloc against local symbol aha.kld: could not read symbols: Bad value --- all_subdir_agp --- Building /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/agp/agp.ko.full --- all_subdir_aha --- *** [aha.ko.full] Error code 1 Looks like a race as two which occurs first but both fail. The "reloc against local symbol" text is omitted by code from: /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: 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 { bfd_vma addend = 0; if (r_type == R_PPC_PLTREL24) { ppc_elf_tdata (abfd)->makes_plt_call = 1; addend = rel->r_addend; } h->needs_plt = 1; if (!update_plt_info (abfd, h, got2, addend)) return FALSE; } break; where the earlier code for finding the h value is: r_symndx = ELF32_R_SYM (rel->r_info); if (r_symndx < symtab_hdr->sh_info) h = NULL; else { h = sym_hashes[r_symndx - symtab_hdr->sh_info]; while (h->root.type == bfd_link_hash_indirect || h->root.type == bfd_link_hash_warning) h = (struct elf_link_hash_entry *) h->root.u.i.link; } There is something consistent between the two example failures. Even across builds of different versions that have moved the .text offset of one of the routines the same routines fail. (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 (2b8c is different than reported before: newer head version used) # 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 The "Value" is zero for "FUNC LOCCAL DEFAULT" in the failing references. Using the agp example: Section Headers: [Nr] Name Type Addr Off Size ES Lk Inf Al Flags . . . [35] .symtab SYMTAB 00000000 025418 000b40 10 36 108 4 [00000000]: is related to: r_symndx = ELF32_R_SYM (rel->r_info); if (r_symndx < symtab_hdr->sh_info) h = NULL; else where for the agp example: r_symndx == 0x49 (73 decimal) for agp_find_caps. So r_symndx < 108 (if 108 is the sh_info field value). Note that in agp.o : 58: 0000000000000000 172 FUNC GLOBAL DEFAULT 2 agp_find_caps but in agp.kld : 73: 0000000000000000 172 FUNC LOCAL DEFAULT 1 agp_find_caps For the aha example: [34] .symtab SYMTAB 00000000 020a54 000930 10 35 70 4 [00000000]: So 0x3e == 62 for aha_alloc and 62 < 70. Note that in aha.o : 44: 0000000000000000 96 FUNC GLOBAL DEFAULT 2 aha_alloc but in aha.kld : 62: 0000000000000000 96 FUNC LOCAL DEFAULT 1 aha_alloc For reference for how aha.kld and agp.kld are produced: # Meta data file /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/aha/aha.kld.meta CMD ld -m elf32ppc_fbsd -d -warn-common -r -d -o aha.kld aha.o aha_isa.o CMD ctfmerge -L VERSION -g -o aha.kld aha.o aha_isa.o CMD :> export_syms CMD awk -f /usr/src/sys/conf/kmod_syms.awk aha.kld export_syms | xargs -J% objcopy % aha.kld CWD /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/aha TARGET aha.kld # Meta data file /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/agp/agp.kld.meta CMD ld -m elf32ppc_fbsd -d -warn-common -r -d -o agp.kld agp.o agp_if.o agp_apple.o CMD ctfmerge -L VERSION -g -o agp.kld agp.o agp_if.o agp_apple.o CMD echo agp_find_device agp_state agp_acquire agp_release agp_enable agp_alloc_memory agp_free_memory agp_bin d_memory agp_unbind_memory agp_memory_info > export_syms CMD awk -f /usr/src/sys/conf/kmod_syms.awk agp.kld export_syms | xargs -J% objcopy % agp.kld CWD /usr/obj/powerpcvtsc_clang/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/modules/usr/src/sys/modules/agp TARGET agp.kld It looks like (via kmod_syms.awk) objcopy is explicitly turning various R_PPC_PLTREL24 examples into LOCAL symbols. May be before clang 5 these were not R_PPC_PLTREL24 ? They are now and the conversion to LOCAL while keeping R_PPC_PLTREL24 is rejected by: ppc_elf_check_relocs which in turn stops ld from producing the matching .full files. And that in turn stops the buildkernel . clang 5 and gcc 4.2.1 do not match for what goes in aha*.o and agp*.o files for the problem symbols: 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 With head's switching to system clang 9 even for 32-bit powerpc, this is not a problem. No official FreeBSD variation based on clang is a problem. The effort to get to that point fixed things. |