FreeBSD/libexec/rtld-elf/aarch64/reloc.c
/*
 * LD_BIND_NOW was set - force relocation for all jump slots
 */
LD_BIND_NOW was set - force relocation for all jump slots
LD_BIND_NOW was set - force relocation for all jump slots
int
reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
{
	const Obj_Entry *defobj;
	const Elf_Rela *relalim;
	const Elf_Rela *rela;
	const Elf_Sym *def;
	struct tls_data *tlsdesc;
	relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
	for (rela = obj->pltrela; rela < relalim; rela++) {
		Elf_Addr *where;
		where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
		switch(ELF_R_TYPE(rela->r_info)) {
		case R_AARCH64_JUMP_SLOT:
			def = find_symdef(ELF_R_SYM(rela->r_info), obj,
			    &defobj, SYMLOOK_IN_PLT | flags, NULL, lockstate);
			if (def == NULL) {
				dbg("reloc_jmpslots: sym not found");
				return (-1);
			}
			*where = (Elf_Addr)(defobj->relocbase + def->st_value);
			break;
		case R_AARCH64_TLSDESC:
			if (ELF_R_SYM(rela->r_info) != 0) {
				tlsdesc = (struct tls_data *)where[1];
				if (tlsdesc->index == -1)
					rtld_tlsdesc_handle_locked(tlsdesc,
					    SYMLOOK_IN_PLT | flags, lockstate);
			}
			break;
		default:
			_rtld_error("Unknown relocation type %x in jmpslot",
			    (unsigned int)ELF_R_TYPE(rela->r_info));
			return (-1);
		}
	}
	return (0);
}
int reloc_jmpslots ( Obj_Entry * obj , int flags , RtldLockState * lockstate ) { const Obj_Entry * defobj ; const Elf_Rela * relalim ; const Elf_Rela * rela ; const Elf_Sym * def ; struct tls_data * tlsdesc ; relalim = ( const Elf_Rela * ) ( ( char * ) obj -> pltrela + obj -> pltrelasize ) ; for ( rela = obj -> pltrela ; rela < relalim ; rela ++ ) { Elf_Addr * where ; where = ( Elf_Addr * ) ( obj -> relocbase + rela -> r_offset ) ; switch ( ELF_R_TYPE ( rela -> r_info ) ) { case R_AARCH64_JUMP_SLOT : def = find_symdef ( ELF_R_SYM ( rela -> r_info ) , obj , & defobj , SYMLOOK_IN_PLT | flags , NULL , lockstate ) ; if ( def == NULL ) { dbg ( " " ) ; return ( -1 ) ; } * where = ( Elf_Addr ) ( defobj -> relocbase + def -> st_value ) ; break ; case R_AARCH64_TLSDESC : if ( ELF_R_SYM ( rela -> r_info ) != 0 ) { tlsdesc = ( struct tls_data * ) where [ 1 ] ; if ( tlsdesc -> index == -1 ) rtld_tlsdesc_handle_locked ( tlsdesc , SYMLOOK_IN_PLT | flags , lockstate ) ; } break ; default : _rtld_error ( " " , ( unsigned int ) ELF_R_TYPE ( rela -> r_info ) ) ; return ( -1 ) ; } } return ( 0 ) ; }
LD_BIND_NOW was set - force relocation for all jump slots
LD_BIND_NOW was set - force relocation for all jump slots