This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2] Add support for O32 FPXX ABI


Hi Richard,

Attached is a patch that should address all the review comments so
far. I have switched around when the gnu_attribute is added that is
inferred from command-line/module to the start rather than end of
assembly. The error checking remains at the end though to ensure any
user override is still OK.

I realised that the values of isa_ext in objects are largely
irrelevant as they are covered by the bfd_mach so I simple determine
what the correct isa_ext is from bfd_mach irrespective of what was
in the input bfd's .MIPS.abiflags section.

I mentioned doing the FPR_SIZE change next but if it is OK I would
like to do that change after submitting the bulk of this work as it
will be safer to change it afterwards. The option handling rework
in this patch is intricate and I don't want to risk breaking that
by making a significant change to how FPR sizes are tested.

I have split the AFL_ values from the internal gas values so the
patch is both simpler now and the internal values can be (ab)used
and defined any way necessary.

I'd prefer not to split the .module work from the rest of the patch
but do you want the rest of this patch to be broken down further?

If everything is OK (bar nits) then I'll update the FPXX tests.

I do still need to do 'something' for bare metal handling of all
this. My current thought is to specify a special symbol that the
user must define which will lead to the .MIPS.abiflags section
becoming loadable and the symbol point at it. If the special symbol
has not been provided by the user then leave .MIPS.abiflags as not
loadable.
The reasons:

* If the user does not define the symbol then no additional data
  is added to the program. A boot rom or other loader would then
  be responsible for the configuration of hardware with
  information obtained when preparing the system by inspecting the
  .MIPS.abiflags section in the ELF.
* While the FPXX ABI only needs the FR mode requirement to be
  indicated to hardware, we also need to indicate that MSA is
  needed so that it can be enabled too. There then seems little
  point in doing anything other than the whole section.

You may be able to suggest a more appropriate trigger for an end
user (or the standard crt) to include in their source to make the
.MIPS.abiflags loadable. Does that sound vaguely sane?

Regards,
Matthew

include/

	* elf/mips.h (PT_MIPS_ABIFLAGS, SHT_MIPS_ABIFLAGS): Define.
	(Val_GNU_MIPS_ABI_FP_OLD_64): Rename from Val_GNU_MIPS_ABI_FP_64.
	(Val_GNU_MIPS_ABI_FP_64): Redefine.
	(Val_GNU_MIPS_ABI_FP_XX): Define.
	(Elf_External_ABIFlags_v0, Elf_Internal_ABIFlags_v0): New structures.
	(AFL_REG_NONE, AFL_REG_32, AFL_REG_64, AFL_REG_128): Define.
	(AFL_ASE_DSP, AFL_ASE_DSPR2, AFL_ASE_EVA, AFL_ASE_MCU): Likewise.
	(AFL_ASE_MDMX, AFL_ASE_MIPS3D, AFL_ASE_MT, AFL_ASE_SMARTMIPS): Likewise.
	(AFL_ASE_VIRT, AFL_ASE_MSA, AFL_ASE_MIPS16): Likewise.
	(AFL_ASE_MICROMIPS, AFL_ASE_XPA): Likewise.
	(AFL_EXT_XLR, AFL_EXT_OCTEON2, AFL_EXT_OCTEONP): Likewise.
	(AFL_EXT_LOONGSON_3A, AFL_EXT_OCTEON, AFL_EXT_5900): Likewise.
	(AFL_EXT_4650, AFL_EXT_4010, AFL_EXT_4100, AFL_EXT_3900): Likewise.
	(AFL_EXT_10000, AFL_EXT_SB1, AFL_EXT_4111, AFL_EXT_4120): Likewise.
	(AFL_EXT_5400, AFL_EXT_5500, AFL_EXT_LOONGSON_2E): Likewise.
	(AFL_EXT_LOONGSON_2F): Likewise.

bfd/

	* elfxx-mips.c (ABI_O32_P, MIPS_ELF_ABIFLAGS_SECTION_NAME_P): New macro.
	(_bfd_mips_elf_additional_program_headers): Account for new
	PT_MIPS_ABIFLAGS program header.
	(_bfd_mips_elf_modify_segment_map): Create PT_MIPS_ABIFLAGS segment and
	associate with .MIPS.abiflags.
	(mips_elf_merge_obj_attributes, _bfd_mips_fp_abi_string): Error
	checking for Val_GNU_MIPS_ABI_FP_OLD_64 and Val_GNU_MIPS_ABI_FP_XX.
	Check EF_MIPS_FP64 flag consistency.
	(_bfd_mips_elf_merge_private_bfd_data): Restructure and add abiflags
	checks.
	(_bfd_mips_elf_print_private_bfd_data): Display abiflags data.
	(mips_elf_obj_tdata): Add abiflags and abiflags_valid fields.
	(bfd_mips_elf_swap_abiflags_v0_in): New function.
	( bfd_mips_elf_swap_abiflags_v0_out): Likewise.
	(_bfd_mips_elf_section_from_shdr): Handle SHT_MIPS_ABIFLAGS.
	( _bfd_mips_elf_fake_sections): Likewise.
	(_bfd_mips_elf_always_size_sections): Handle .MIPS.abiflags.
	(update_mips_abiflags_isa, infer_mips_abiflags): New static function.
	(bfd_mips_isa_ext, print_mips_ases, print_mips_isa_ext): Likewise.
	( print_mips_fp_abi_value, get_mips_reg_size): Likewise.
	(mips_32bit_flags_p): Moved higher.
	(_bfd_mips_elf_final_link): Handle .MIPS.abiflags

binutils/

	* readelf.c (get_mips_segment_type): Display name for PT_MIPS_ABIFLAGS.
	(get_mips_section_type_name): Display name for SHT_MIPS_ABIFLAGS.
	(display_mips_gnu_attribute): Abstracted fp abi printing to...
	(print_mips_fp_abi_value): New static function. Handle
	Val_GNU_MIPS_ABI_FP_OLD_64 and Val_GNU_MIPS_ABI_FP_XX.
	(print_mips_ases, print_mips_isa_ext, get_mips_reg_size): New static
	functions.
	(process_mips_specific): Display abiflags data.

elfcpp/

	* elfcpp.h (PT_MIPS_ABIFLAGS): New program header type.

gas/

	* config/tc-mips.c (file_mips_opts_checked, mips_flags_frag): New static
	global.
	(s_module): New static function.
	(enum options, md_longopts, md_parse_option): Add -mfpxx option.
	(mips_pseudo_table): Add .module handler.
	(mips_set_ase): Add opts argument and use instead of mips_opts.
	(md_begin): Create .MIPS.abiflags section.
	(md_mips_end): Add consistency checks for command line, .module and
	.gnu_attribute.  Update .gnu_attribute based on command line and .module
	as applicable.
	(md_assemble): Use file_mips_check_options.
	(match_float_constant): Rewrite check regarding FP register width.  Add
	support for generating constants when MXHC1 is present.  Handle fp==0 to
	comply with FPXX ABI.
	(macro): Update M_LI_DD similarly to match_float_constant.  Generate
	MTHC1 when available.  Check that correct code can be generated for FPXX
	and FP64 ABIs.
	(mips_set_architecture): Delete function.  Moved to...
	(mips_after_parse_args): Here.  All logic now applies to file_mips_opts
	first and then copies the final state to mips_opts.  Move error checking
	to...
	(mips_check_options): Here. New static function.  Common option checking
	for command line, .module and .set.  Use general terms in error messages
	instead of refering to command line options.
	(file_mips_check_options): New static function.  A wrapper for
	mips_check_options with file_mips_opts.  Updates BFD arch based on final
	options.
	(s_mipsset): Split into s_mipsset and parse_code_option.  Settings
	supported by both .set and .module are moved to parse_code_option.
	Warnings and errors are kept in s_mipsset because when parse_code_option
	is used with s_module the warnings are deferred until code is generated.
	Any setting supporting 'default' value is kept in s_mipsset as it is not
	applicable to s_module.
	Inferred settings are also kept in s_mipsset as s_module does not infer
	any settings.  Use mips_check_options.
	(parse_code_option): New static function derived from s_mipsset.
	(s_module): New static function that implements .module.  Allows file
	level settings to be changed until code is generated.
	(s_cpload, s_cpsetup, s_cplocal): Use file_mips_check_options.
	(s_cprestore, s_cpreturn, s_cpadd): Likewise.
	(mips_elf_final_processing): Use fpabi == Val_GNU_MIPS_ABI_FP_OLD_64
	to determine when to add the EF_MIPS_FP64 flag.  Populate the
	.MIPS.abiflags section.
	(md_obj_end): Use file_mips_check_options.
	* doc/c-mips.texi: Document -mfpxx, gnu_attribute values and FP ABIs.

ld/

	* emulparams/elf32bmip.sh: Add .MIPS.abiflags_valid.
	* emulparams/elf32bmipn32-defs.sh: Add .MIPS.abiflags_valid.

Attachment: 0001-Implement-O32-FPXX-ABI.patch
Description: 0001-Implement-O32-FPXX-ABI.patch


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]