[PATCH] LD/PE: Remove remains of MIPS target support

Richard Earnshaw (lists) Richard.Earnshaw@arm.com
Mon Aug 18 11:40:05 GMT 2025


On 07/08/2025 15:44, Maciej W. Rozycki wrote:
> Support for ECOFF MIPS targets, including `mips*-*-pe*' among others, 
> has been removed from GAS and LD with commit e8044f355dc9 ("Remove gas 
> and ld support for MIPS ECOFF"), 
> <https://inbox.sourceware.org/binutils/8761x65bzx.fsf@talisman.default/>.
> However bits in PEI-format DLL support code have been left behind.
> 
> Remove the relevant pieces then, originally from commit 344a211f9995 
> ("Add support for WinCE based toolchains."), including MIPS architecture 
> parts and HI16/LO16 relocation support in particular.
> ---
> Hi,
> 
>  This has passed my usual verification, including `aarch64-pe', `arm-pe', 
> `arm-wince-pe', `i686-pe', `mcore-pe', `sh-pe', and `x86_64-mingw32' 
> targets among others.  It can't be ruled out however that there are gaps 
> in coverage, so please let me know if you think there's anything I may 
> have overlooked with this change.
> 
>  Otherwise OK to apply?

I'm afraid I know very little about the PE/COFF format, even for Arm, so I can't really comment on the details.  But...
> 
>   Maciej
> ---
>  ld/pe-dll.c |   54 +++---------------------------------------------------
>  1 file changed, 3 insertions(+), 51 deletions(-)
> 
> binutils-ld-mips-pe-remove.diff
> Index: binutils-gdb/ld/pe-dll.c
> ===================================================================
> --- binutils-gdb.orig/ld/pe-dll.c
> +++ binutils-gdb/ld/pe-dll.c
> @@ -247,10 +247,9 @@ static const autofilter_entry_type autof
>  
>  #define PE_ARCH_i386	 1
>  #define PE_ARCH_sh	 2
> -#define PE_ARCH_mips	 3
> -#define PE_ARCH_arm	 4
> -#define PE_ARCH_arm_wince 5
> -#define PE_ARCH_aarch64  6
> +#define PE_ARCH_arm	 3
> +#define PE_ARCH_arm_wince 4
> +#define PE_ARCH_aarch64	 5

If this is purely internal (and it certainly looks like it), perhaps replacing the #defines with an enum would make more sense here, so that next time we don't get more churn here.

R.

>  
>  /* Don't make it constant as underscore mode gets possibly overriden
>     by target or -(no-)leading-underscore option.  */
> @@ -317,16 +316,6 @@ static pe_details_type pe_detail_list[]
>      autofilter_symbollist_generic
>    },
>    {
> -    "pei-mips",
> -    "pe-mips",
> -    34 /* MIPS_R_RVA */,
> -    ~0, 0, ~0, /* none */
> -    PE_ARCH_mips,
> -    bfd_arch_mips,
> -    false,
> -    autofilter_symbollist_generic
> -  },
> -  {
>      "pei-arm-little",
>      "pe-arm-little",
>      11 /* ARM_RVA32 */,
> @@ -1699,19 +1688,6 @@ generate_reloc (bfd *abfd, struct bfd_li
>  		      reloc_data[total_relocs].type = IMAGE_REL_BASED_HIGHLOW;
>  		      total_relocs++;
>  		      break;
> -		    case BITS_AND_SHIFT (16, 0):
> -		      reloc_data[total_relocs].type = IMAGE_REL_BASED_LOW;
> -		      total_relocs++;
> -		      break;
> -		    case BITS_AND_SHIFT (16, 16):
> -		      reloc_data[total_relocs].type = IMAGE_REL_BASED_HIGHADJ;
> -		      /* FIXME: we can't know the symbol's right value
> -			 yet, but we probably can safely assume that
> -			 CE will relocate us in 64k blocks, so leaving
> -			 it zero is safe.  */
> -		      reloc_data[total_relocs].extra = 0;
> -		      total_relocs++;
> -		      break;
>  		    case BITS_AND_SHIFT (26, 2):
>  		      reloc_data[total_relocs].type =
>                          IMAGE_REL_BASED_ARM_MOV32;
> @@ -1765,9 +1741,6 @@ generate_reloc (bfd *abfd, struct bfd_li
>  	}
>  
>        reloc_sz += 2;
> -
> -      if (reloc_data[i].type == IMAGE_REL_BASED_HIGHADJ)
> -	reloc_sz += 2;
>      }
>  
>    reloc_sz = (reloc_sz + 3) & ~3;	/* 4-byte align.  */
> @@ -2314,18 +2287,6 @@ static const unsigned char jmp_sh_bytes[
>    0x01, 0xd0, 0x02, 0x60, 0x2b, 0x40, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00
>  };
>  
> -/* _function:
> -	lui	$t0,<high:__imp_function>
> -	lw	$t0,<low:__imp_function>
> -	jr	$t0
> -	nop                              */
> -
> -static const unsigned char jmp_mips_bytes[] =
> -{
> -  0x00, 0x00, 0x08, 0x3c,  0x00, 0x00, 0x08, 0x8d,
> -  0x08, 0x00, 0x00, 0x01,  0x00, 0x00, 0x00, 0x00
> -};
> -
>  static const unsigned char jmp_arm_bytes[] =
>  {
>    0x00, 0xc0, 0x9f, 0xe5,	/* ldr  ip, [pc] */
> @@ -2388,10 +2349,6 @@ make_one (def_file_export *exp, bfd *par
>  	  jmp_bytes = jmp_sh_bytes;
>  	  jmp_byte_count = sizeof (jmp_sh_bytes);
>  	  break;
> -	case PE_ARCH_mips:
> -	  jmp_bytes = jmp_mips_bytes;
> -	  jmp_byte_count = sizeof (jmp_mips_bytes);
> -	  break;
>  	case PE_ARCH_arm:
>  	case PE_ARCH_arm_wince:
>  	  jmp_bytes = jmp_arm_bytes;
> @@ -2478,11 +2435,6 @@ make_one (def_file_export *exp, bfd *par
>  	case PE_ARCH_sh:
>  	  quick_reloc (abfd, 8, BFD_RELOC_32, 2);
>  	  break;
> -	case PE_ARCH_mips:
> -	  quick_reloc (abfd, 0, BFD_RELOC_HI16_S, 2);
> -	  quick_reloc (abfd, 0, BFD_RELOC_LO16, 0); /* MIPS_R_PAIR */
> -	  quick_reloc (abfd, 4, BFD_RELOC_LO16, 2);
> -	  break;
>  	case PE_ARCH_arm:
>  	case PE_ARCH_arm_wince:
>  	  quick_reloc (abfd, 8, BFD_RELOC_32, 2);



More information about the Binutils mailing list