tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Changes to do rtld debug build in mips



Hi,

I had some problems with mips n64 dynamic code. to debug them I wanted
to do a debug build, and I needed these (somewhat brute force) changes.

Otherwise after uncommenting:

CPPFLAGS+=      -DDEBUG
CPPFLAGS+=      -DRTLD_DEBUG
CPPFLAGS+=      -DRTLD_DEBUG_RELOC

I got:

/usr/src/libexec/ld.elf_so/arch/mips/mips_reloc.c: In function '_rtld_relocate_nonplt_objects':
/usr/src/libexec/ld.elf_so/arch/mips/mips_reloc.c:476:34: error: 'r_symndx' undeclared (first use in this function)
        obj->strtab + obj->symtab[r_symndx].st_name));
                                  ^
Needed these changes to do a debug build


Index: ld.elf_so/arch/mips/mips_reloc.c
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/arch/mips/mips_reloc.c,v
retrieving revision 1.69
diff -U 15 -r1.69 mips_reloc.c
--- ld.elf_so/arch/mips/mips_reloc.c	10 Aug 2017 19:03:26 -0000	1.69
+++ ld.elf_so/arch/mips/mips_reloc.c	23 Dec 2017 22:40:18 -0000
@@ -397,94 +397,101 @@
 				    obj->strtab + def2->st_name, obj->path));
 			}
 			store_ptr(where, val, rlen);
 			break;
 		}
 
 #if ELFSIZE == 64
 		case R_TYPE(TLS_DTPMOD64):
 #else
 		case R_TYPE(TLS_DTPMOD32): 
 #endif
 		{
 			Elf_Addr old = load_ptr(where, ELFSIZE / 8);
 			Elf_Addr val = old;
 
+			Elf_Word r_symndx = ELF_R_SYM(rel->r_info);
+
 			val += (Elf_Addr)defobj->tlsindex;
 
 			store_ptr(where, val, ELFSIZE / 8);
 			rdbg(("DTPMOD %s in %s --> %p in %s",
 			    obj->strtab + obj->symtab[r_symndx].st_name,
 			    obj->path, (void *)old, defobj->path));
 			break;
 		}
 
 #if ELFSIZE == 64
 		case R_TYPE(TLS_DTPREL64):
 #else
 		case R_TYPE(TLS_DTPREL32):
 #endif
 		{
 			Elf_Addr old = load_ptr(where, ELFSIZE / 8);
 			Elf_Addr val = old;
+			Elf_Word r_symndx = ELF_R_SYM(rel->r_info);
 
 			if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
 				return -1;
 
 			val += (Elf_Addr)def->st_value - TLS_DTV_OFFSET;
 			store_ptr(where, val, ELFSIZE / 8);
 
 			rdbg(("DTPREL %s in %s --> %p in %s",
 			    obj->strtab + obj->symtab[r_symndx].st_name,
 			    obj->path, (void *)old, defobj->path));
 			break;
 		}
 
 #if ELFSIZE == 64
 		case R_TYPE(TLS_TPREL64):
 #else
 		case R_TYPE(TLS_TPREL32):
 #endif
 		{
 			Elf_Addr old = load_ptr(where, ELFSIZE / 8);
 			Elf_Addr val = old;
+			Elf_Word r_symndx = ELF_R_SYM(rel->r_info);
 
 			if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
 				return -1;
 
 			val += (Elf_Addr)(def->st_value + defobj->tlsoffset
 			    - TLS_TP_OFFSET);
 			store_ptr(where, val, ELFSIZE / 8);
 
 			rdbg(("TPREL %s in %s --> %p in %s",
 			    obj->strtab + obj->symtab[r_symndx].st_name,
 			    obj->path, where, defobj->path));
 			break;
 		}
 
 		default:
+			{
+			Elf_Word r_symndx = ELF_R_SYM(rel->r_info);
 			rdbg(("sym = %lu, type = %lu, offset = %p, "
 			    "contents = %p, symbol = %s",
 			    (u_long)ELF_R_SYM(rel->r_info),
 			    (u_long)ELF_R_TYPE(rel->r_info),
 			    (void *)rel->r_offset,
 			    (void *)load_ptr(where, sizeof(Elf_Sword)),
 			    obj->strtab + obj->symtab[r_symndx].st_name));
 			_rtld_error("%s: Unsupported relocation type %ld "
 			    "in non-PLT relocations",
 			    obj->path, (u_long) ELF_R_TYPE(rel->r_info));
 			return -1;
+			}
 		}
 	}
 
 	return 0;
 }
 
 int
 _rtld_relocate_plt_lazy(Obj_Entry *obj)
 {
 	/* PLT fixups were done above in the GOT relocation. */
 	return 0;
 }
 
 static inline int
 _rtld_relocate_plt_object(const Obj_Entry *obj, Elf_Word sym, Elf_Addr *tp)


Home | Main Index | Thread Index | Old Index