From mboxrd@z Thu Jan 1 00:00:00 1970 From: Toshi Morita To: binutils@sourceware.cygnus.com Subject: Weird relocations Date: Fri, 24 Sep 1999 16:18:00 -0000 Message-id: <199909242316.QAA01124@shell14.ba.best.com> X-SW-Source: 1999-09/msg00166.html I'm still examining the problem whereby an ELF executable is generated with an invalid AT_low_pc, and I think I'm getting further on the problem. Basically, It looks like the linker is applying the relocation against a nonexistent section possibly due to an assembler bug generating a bad object file. When this code in bfd/elf32-sh.c is executed: r_symndx = ELF32_R_SYM (rel->r_info); ... if (r_symndx < symtab_hdr->sh_info) { /* There is nothing to be done for an internal IND12W relocation. FIXME: This is probably wrong, but it's how the COFF relocations work. */ if (r_type == (int) R_SH_IND12W) continue; sym = local_syms + r_symndx; sec = local_sections[r_symndx]; relocation = (sec->output_section->vma + sec->output_offset + sym->st_value); } the pointer "sec" is assigned a null value because r_symndex seems to be invalid (when run in the debugger). When I go dump out the relocations of that object file with sh-elf-objdump --reloc, I see some suspicious relocations: RELOCATION RECORDS FOR [.debug]: OFFSET TYPE VALUE 00000008 R_SH_DIR32 .debug 00000053 R_SH_DIR32 .text 00000059 R_SH_DIR32 .text 0000005f R_SH_DIR32 .line 0000007c R_SH_DIR32 .debug_sfnames 00000082 R_SH_DIR32 .debug_srcinfo 0000008e R_SH_DIR32 .debug 000000b4 R_SH_DIR32 .debug 000000d9 R_SH_DIR32 .debug ... 0000b516 R_SH_DIR32 .debug 0000b51c R_SH_DIR32 .debug 0000b522 R_SH_DIR32 _bSqrt__Ff <- here 0000b528 R_SH_DIR32 .L_f301_e <- here 0000b52e R_SH_DIR32 .L_b301 <- here 0000b534 R_SH_DIR32 .L_b301_e <- here These relocations seems suspicious because all the other entries in the "VALUE" field are names of sections, but these three are label names... and they are also the relocations which are not properly applied. Am I correct in assuming the "VALUE" field of a .debug relocation should always contain a reference to a section, and not a label? And if so, are these relocations clearly incorrect? Toshi