RE: [PATCH RFC v2 68/70] MIPS: kernel: elf: Improve the overall ABI and FPU mode checks

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

 



> +static inline unsigned get_fp_abi(struct elf32_hdr *ehdr, int in_abi)
>  {
>  	/* If the ABI requirement is provided, simply return that */
> -	if (in_abi != -1)
> +	if (in_abi != MIPS_ABI_FP_UNKNOWN)
>  		return in_abi;
> 
>  	/* If the EF_MIPS_FP64 flag was set, return MIPS_ABI_FP_64 */
>  	if (ehdr->e_flags & EF_MIPS_FP64)
> -		return MIPS_ABI_FP_64;
> +		return MIPS_ABI_FP_OLD_64;

Leonid spotting a bug here, the ehdr given to this function can be either elf32
or elf64.

I suggest finding a way to move this check for EF_MIPS_FP64 into arch_elf_pt_proc
where the elf class is known.  The fpabi can be set to MIPS_ABI_FP_OLD_64 if this
holds true and then overridden if a MIPS_ABIFLAGS segment is found so would go
as indicated below:

+	/* Lets see if this is an O32 ELF */
+	if (ehdr32->e_ident[EI_CLASS] == ELFCLASS32) {
+		/* FR = 1 for N32 */
+		if (ehdr32->e_flags & EF_MIPS_ABI2)
+			state->overall_fp_mode = FP_FR1;
+		else
+			/* Set a good default FPU mode for O32*/
+			state->overall_fp_mode = cpu_has_mips_r6 ?
+				FP_FRE : FP_FR0;

<<here>>

+		if (phdr32->p_type != PT_MIPS_ABIFLAGS)
+			return 0;

Thanks,
Matthew





[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux