From 708e2187a341e9eee46669dbb8c4d6603be5cf40 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 9 Nov 2012 17:00:44 +0000 Subject: [PATCH] 2012-11-09 Nick Clifton * elf32-rx.c (describe_flags): New function. Returns a buffer containing a description of the E_FLAG_RX_... values set. (rx_elf_merge_private_bfd_data): Use it. (rx_elf_print_private_bfd_data): Likewise. (elf32_rx_machine): Skip EF_RX_CPU_RX check. (elf32_rx_special_sections): Define. (elf_backend_special_sections): Define. 2012-11-09 Nick Clifton * readelf.c (get_machine_flags): Add support for E_FLAG_RX_ABI. 2012-11-09 Nick Clifton * config/obj-elf.c (obj_elf_change_section): Allow init array sections to have the SHF_EXECINSTR attribute for the RX target. * config/tc-rx.c (elf_flags): Initialise with E_FLAG_RX_ABI. (enum options): Add OPTION_USES_GCC_ABI and OPTION_USES_RX_ABI. (md_longopts): Add -mgcc-abi and -mrx-abi. (md_parse_option): Add support for OPTION_USES_GCC_ABI and OPTION_USES_RX_ABI. * doc/as.texinfo (RX Options): Add mention of remaining RX options. * doc/c-rx.texi: Document -mgcc-abi and -mrx-abi. 2012-11-09 Nick Clifton * rx.h (EF_RX_CPU_RX): Add comment. (E_FLAG_RX_ABI): Define. 2012-11-09 Nick Clifton * emultempl/rxelf.em (no_flag_mismatch_warnings): Initialise to true. (PARSE_AND_LIST_LONGOPTS): Add flag-mismatch-warnings. (PARSE_AND_LIST_ARG_CASES): Add support for --flag-mismatch-warnings. --- bfd/ChangeLog | 10 ++++++ bfd/elf32-rx.c | 72 ++++++++++++++++++++++++++++++++++++------- binutils/ChangeLog | 4 +++ binutils/readelf.c | 60 +++++++++++++++++++++++++++++++++++- gas/ChangeLog | 13 ++++++++ gas/config/obj-elf.c | 8 +++++ gas/config/tc-rx.c | 14 ++++++++- gas/doc/as.texinfo | 6 ++++ gas/doc/c-rx.texi | 13 ++++++++ include/elf/ChangeLog | 5 +++ include/elf/rx.h | 3 +- ld/ChangeLog | 8 +++++ ld/emultempl/rxelf.em | 10 +++++- 13 files changed, 211 insertions(+), 15 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 2e91b69543f..3a69d7ed317 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,13 @@ +2012-11-09 Nick Clifton + + * elf32-rx.c (describe_flags): New function. Returns a buffer + containing a description of the E_FLAG_RX_... values set. + (rx_elf_merge_private_bfd_data): Use it. + (rx_elf_print_private_bfd_data): Likewise. + (elf32_rx_machine): Skip EF_RX_CPU_RX check. + (elf32_rx_special_sections): Define. + (elf_backend_special_sections): Define. + 2012-11-09 Edgar E. Iglesias * config.bfd: Add microblazeel-*-* diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c index 771867f6318..92c046abfae 100644 --- a/bfd/elf32-rx.c +++ b/bfd/elf32-rx.c @@ -2937,6 +2937,39 @@ bfd_elf32_rx_set_target_flags (bfd_boolean user_no_warn_mismatch, ignore_lma = user_ignore_lma; } +/* Converts FLAGS into a descriptive string. + Returns a static pointer. */ + +static const char * +describe_flags (flagword flags) +{ + static char buf [128]; + + buf[0] = 0; + + if (flags & E_FLAG_RX_64BIT_DOUBLES) + strcat (buf, "64-bit doubles"); + else + strcat (buf, "32-bit doubles"); + + if (flags & E_FLAG_RX_DSP) + strcat (buf, ", dsp"); + else + strcat (buf, ", no dsp"); + + if (flags & E_FLAG_RX_PID) + strcat (buf, ", pid"); + else + strcat (buf, ", no pid"); + + if (flags & E_FLAG_RX_ABI) + strcat (buf, ", RX ABI"); + else + strcat (buf, ", GCC ABI"); + + return buf; +} + /* Merge backend specific data from an object file to the output object file when linking. */ @@ -2958,7 +2991,10 @@ rx_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd) } else if (old_flags != new_flags) { - flagword known_flags = E_FLAG_RX_64BIT_DOUBLES | E_FLAG_RX_DSP | E_FLAG_RX_PID; + flagword known_flags; + + known_flags = E_FLAG_RX_ABI | E_FLAG_RX_64BIT_DOUBLES + | E_FLAG_RX_DSP | E_FLAG_RX_PID; if ((old_flags ^ new_flags) & known_flags) { @@ -2971,9 +3007,12 @@ rx_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd) } else { - (*_bfd_error_handler) - ("ELF header flags mismatch: old_flags = 0x%.8lx, new_flags = 0x%.8lx, filename = %s", - old_flags, new_flags, bfd_get_filename (ibfd)); + _bfd_error_handler ("There is a conflict merging the ELF header flags from %s", + bfd_get_filename (ibfd)); + _bfd_error_handler (" the input file's flags: %s", + describe_flags (new_flags)); + _bfd_error_handler (" the output file's flags: %s", + describe_flags (old_flags)); error = TRUE; } } @@ -3001,21 +3040,20 @@ rx_elf_print_private_bfd_data (bfd * abfd, void * ptr) flags = elf_elfheader (abfd)->e_flags; fprintf (file, _("private flags = 0x%lx:"), (long) flags); - if (flags & E_FLAG_RX_64BIT_DOUBLES) - fprintf (file, _(" [64-bit doubles]")); - if (flags & E_FLAG_RX_DSP) - fprintf (file, _(" [dsp]")); - - fputc ('\n', file); + fprintf (file, describe_flags (flags)); return TRUE; } /* Return the MACH for an e_flags value. */ static int -elf32_rx_machine (bfd * abfd) +elf32_rx_machine (bfd * abfd ATTRIBUTE_UNUSED) { +#if 0 /* FIXME: EF_RX_CPU_MASK collides with E_FLAG_RX_... + Need to sort out how these flag bits are used. + For now we assume that the flags are OK. */ if ((elf_elfheader (abfd)->e_flags & EF_RX_CPU_MASK) == EF_RX_CPU_RX) +#endif return bfd_mach_rx; return 0; @@ -3495,6 +3533,17 @@ elf32_rx_modify_program_headers (bfd * abfd ATTRIBUTE_UNUSED, return TRUE; } + +/* The default literal sections should always be marked as "code" (i.e., + SHF_EXECINSTR). This is particularly important for big-endian mode + when we do not want their contents byte reversed. */ +static const struct bfd_elf_special_section elf32_rx_special_sections[] = +{ + { STRING_COMMA_LEN (".init_array"), 0, SHT_INIT_ARRAY, SHF_ALLOC + SHF_EXECINSTR }, + { STRING_COMMA_LEN (".fini_array"), 0, SHT_FINI_ARRAY, SHF_ALLOC + SHF_EXECINSTR }, + { STRING_COMMA_LEN (".preinit_array"), 0, SHT_PREINIT_ARRAY, SHF_ALLOC + SHF_EXECINSTR }, + { NULL, 0, 0, 0, 0 } +}; #define ELF_ARCH bfd_arch_rx #define ELF_MACHINE_CODE EM_RX @@ -3523,6 +3572,7 @@ elf32_rx_modify_program_headers (bfd * abfd ATTRIBUTE_UNUSED, #define bfd_elf32_set_section_contents rx_set_section_contents #define bfd_elf32_bfd_final_link rx_final_link #define bfd_elf32_bfd_relax_section elf32_rx_relax_section_wrapper +#define elf_backend_special_sections elf32_rx_special_sections #include "elf32-target.h" diff --git a/binutils/ChangeLog b/binutils/ChangeLog index fb31b7322db..0778cb0d28e 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,7 @@ +2012-11-09 Nick Clifton + + * readelf.c (get_machine_flags): Add support for E_FLAG_RX_ABI. + 2012-11-09 H.J. Lu * coffgrok.c (coff_grok): Remove trailing redundant `;'. diff --git a/binutils/readelf.c b/binutils/readelf.c index 63ab14b0958..ee5b607bc26 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -634,6 +634,7 @@ guess_is_rela (unsigned int e_machine) case EM_TI_C6000: case EM_TILEGX: case EM_TILEPRO: + case EM_V800: case EM_V850: case EM_CYGNUS_V850: case EM_VAX: @@ -1058,6 +1059,9 @@ dump_relocations (FILE * file, rtype = elf_spu_reloc_type (type); break; + case EM_V800: + rtype = v800_reloc_type (type); + break; case EM_V850: case EM_CYGNUS_V850: rtype = v850_reloc_type (type); @@ -1885,7 +1889,6 @@ get_machine_name (unsigned e_machine) case EM_960: return "Intel 90860"; case EM_PPC: return "PowerPC"; case EM_PPC64: return "PowerPC64"; - case EM_V800: return "NEC V800"; case EM_FR20: return "Fujitsu FR20"; case EM_RH32: return "TRW RH32"; case EM_MCORE: return "MCORE"; @@ -1910,6 +1913,7 @@ get_machine_name (unsigned e_machine) case EM_CYGNUS_M32R: case EM_M32R: return "Renesas M32R (formerly Mitsubishi M32r)"; case EM_CYGNUS_V850: + case EM_V800: return "Renesas V850 (using RH850 ABI)"; case EM_V850: return "Renesas V850"; case EM_CYGNUS_MN10300: case EM_MN10300: return "mn10300"; @@ -2412,6 +2416,56 @@ get_machine_flags (unsigned e_flags, unsigned e_machine) strcat (buf, _(", relocatable-lib")); break; + case EM_V800: + if ((e_flags & EF_RH850_ABI) == EF_RH850_ABI) + strcat (buf, ", RH850 ABI"); + + if (e_flags & EF_V800_850E3) + strcat (buf, ", V3 architecture"); + + if ((e_flags & (EF_RH850_FPU_DOUBLE | EF_RH850_FPU_SINGLE)) == 0) + strcat (buf, ", FPU not used"); + + if ((e_flags & (EF_RH850_REGMODE22 | EF_RH850_REGMODE32)) == 0) + strcat (buf, ", regmode: COMMON"); + + if ((e_flags & (EF_RH850_GP_FIX | EF_RH850_GP_NOFIX)) == 0) + strcat (buf, ", r4 not used"); + + if ((e_flags & (EF_RH850_EP_FIX | EF_RH850_EP_NOFIX)) == 0) + strcat (buf, ", r30 not used"); + + if ((e_flags & (EF_RH850_TP_FIX | EF_RH850_TP_NOFIX)) == 0) + strcat (buf, ", r5 not used"); + + if ((e_flags & (EF_RH850_REG2_RESERVE | EF_RH850_REG2_NORESERVE)) == 0) + strcat (buf, ", r2 not used"); + + for (e_flags &= 0xFFFF; e_flags; e_flags &= ~ (e_flags & - e_flags)) + { + switch (e_flags & - e_flags) + { + case EF_RH850_FPU_DOUBLE: strcat (buf, ", double precision FPU"); break; + case EF_RH850_FPU_SINGLE: strcat (buf, ", single precision FPU"); break; + case EF_RH850_SIMD: strcat (buf, ", SIMD"); break; + case EF_RH850_CACHE: strcat (buf, ", CACHE"); break; + case EF_RH850_MMU: strcat (buf, ", MMU"); break; + case EF_RH850_REGMODE22: strcat (buf, ", regmode:22"); break; + case EF_RH850_REGMODE32: strcat (buf, ", regmode:23"); break; + case EF_RH850_DATA_ALIGN8: strcat (buf, ", 8-byte alignment"); break; + case EF_RH850_GP_FIX: strcat (buf, ", r4 fixed"); break; + case EF_RH850_GP_NOFIX: strcat (buf, ", r4 free"); break; + case EF_RH850_EP_FIX: strcat (buf, ", r30 fixed"); break; + case EF_RH850_EP_NOFIX: strcat (buf, ", r30 free"); break; + case EF_RH850_TP_FIX: strcat (buf, ", r5 fixed"); break; + case EF_RH850_TP_NOFIX: strcat (buf, ", r5 free"); break; + case EF_RH850_REG2_RESERVE: strcat (buf, ", r2 fixed"); break; + case EF_RH850_REG2_NORESERVE: strcat (buf, ", r2 free"); break; + default: break; + } + } + break; + case EM_V850: case EM_CYGNUS_V850: switch (e_flags & EF_V850_ARCH) @@ -2682,6 +2736,8 @@ get_machine_flags (unsigned e_flags, unsigned e_machine) strcat (buf, ", dsp"); if (e_flags & E_FLAG_RX_PID) strcat (buf, ", pid"); + if (e_flags & E_FLAG_RX_ABI) + strcat (buf, ", RX ABI"); break; case EM_S390: @@ -9998,6 +10054,8 @@ is_32bit_abs_reloc (unsigned int reloc_type) case EM_CYGNUS_V850: case EM_V850: return reloc_type == 6; /* R_V850_ABS32. */ + case EM_V800: + return reloc_type == 0x33; /* R_V810_WORD. */ case EM_VAX: return reloc_type == 1; /* R_VAX_32. */ case EM_X86_64: diff --git a/gas/ChangeLog b/gas/ChangeLog index ddf1a1ed7ad..ce6c114983f 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,16 @@ +2012-11-09 Nick Clifton + + * config/obj-elf.c (obj_elf_change_section): Allow init array + sections to have the SHF_EXECINSTR attribute for the RX target. + * config/tc-rx.c (elf_flags): Initialise with E_FLAG_RX_ABI. + (enum options): Add OPTION_USES_GCC_ABI and OPTION_USES_RX_ABI. + (md_longopts): Add -mgcc-abi and -mrx-abi. + (md_parse_option): Add support for OPTION_USES_GCC_ABI and + OPTION_USES_RX_ABI. + * doc/as.texinfo (RX Options): Add mention of remaining RX + options. + * doc/c-rx.texi: Document -mgcc-abi and -mrx-abi. + 2012-11-09 David Holsgrove * gas/microblaze/endian.exp: New file - endian testcase for microblaze / microblazeel. diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index d7c766513cc..d0fbcfb43ab 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -657,6 +657,14 @@ obj_elf_change_section (const char *name, /* A section on Alpha may have SHF_ALPHA_GPREL. */ else if ((attr & ~ssect->attr) == SHF_ALPHA_GPREL) override = TRUE; +#endif +#ifdef TC_RX + else if (attr == (SHF_EXECINSTR | SHF_WRITE | SHF_ALLOC) + && (ssect->type == SHT_INIT_ARRAY + || ssect->type == SHT_FINI_ARRAY + || ssect->type == SHT_PREINIT_ARRAY)) + /* RX init/fini arrays can and should have the "awx" attributes set. */ + ; #endif else { diff --git a/gas/config/tc-rx.c b/gas/config/tc-rx.c index 3db8fe16e7a..b1d0b20773c 100644 --- a/gas/config/tc-rx.c +++ b/gas/config/tc-rx.c @@ -46,7 +46,7 @@ const char EXP_CHARS[] = "eE"; const char FLT_CHARS[] = "dD"; /* ELF flags to set in the output file header. */ -static int elf_flags = 0; +static int elf_flags = E_FLAG_RX_ABI; bfd_boolean rx_use_conventional_section_names = FALSE; static bfd_boolean rx_use_small_data_limit = FALSE; @@ -70,6 +70,8 @@ enum options OPTION_RELAX, OPTION_PID, OPTION_INT_REGS, + OPTION_USES_GCC_ABI, + OPTION_USES_RX_ABI, }; #define RX_SHORTOPTS "" @@ -94,6 +96,8 @@ struct option md_longopts[] = {"relax", no_argument, NULL, OPTION_RELAX}, {"mpid", no_argument, NULL, OPTION_PID}, {"mint-register", required_argument, NULL, OPTION_INT_REGS}, + {"mgcc-abi", no_argument, NULL, OPTION_USES_GCC_ABI}, + {"mrx-abi", no_argument, NULL, OPTION_USES_RX_ABI}, {NULL, no_argument, NULL, 0} }; size_t md_longopts_size = sizeof (md_longopts); @@ -143,6 +147,14 @@ md_parse_option (int c ATTRIBUTE_UNUSED, char * arg ATTRIBUTE_UNUSED) case OPTION_INT_REGS: rx_num_int_regs = atoi (optarg); return 1; + + case OPTION_USES_GCC_ABI: + elf_flags &= ~ E_FLAG_RX_ABI; + return 1; + + case OPTION_USES_RX_ABI: + elf_flags |= E_FLAG_RX_ABI; + return 1; } return 0; } diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo index 67233f02764..8c439404f35 100644 --- a/gas/doc/as.texinfo +++ b/gas/doc/as.texinfo @@ -459,6 +459,12 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}. @emph{Target RX options:} [@b{-mlittle-endian}|@b{-mbig-endian}] [@b{-m32bit-doubles}|@b{-m64bit-doubles}] + [@b{-muse-conventional-section-names}] + [@b{-msmall-data-limit}] + [@b{-mpid}] + [@b{-mrelax}] + [@b{-mint-register=@var{number}}] + [@b{-mgcc-abi}|@b{-mrx-abi}] @end ifset @ifset S390 diff --git a/gas/doc/c-rx.texi b/gas/doc/c-rx.texi index 5f9239b5ab3..d6390c8bd15 100644 --- a/gas/doc/c-rx.texi +++ b/gas/doc/c-rx.texi @@ -93,6 +93,19 @@ This option tells the assembler how many registers have been reserved for use by interrupt handlers. This is needed in order to compute the correct values for the @code{%gpreg} and @code{%pidreg} meta registers. +@cindex @samp{-mgcc-abi} +@item -mgcc-abi +This option tells the assembler that the old GCC ABI is being used by +the assembled code. With this version of the ABI function arguments +that are passed on the stack are aligned to a 32-bit boundary. + +@cindex @samp{-mrx-abi} +@item -mrx-abi +This option tells the assembler that the official RX ABI is being used +by the assembled code. With this version of the ABI function +arguments that are passed on the stack are aligned to their natural +alignments. This option is the default. + @end table @node RX-Modifiers diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog index 2944bb949cc..e47ac9f3404 100644 --- a/include/elf/ChangeLog +++ b/include/elf/ChangeLog @@ -1,3 +1,8 @@ +2012-11-09 Nick Clifton + + * rx.h (EF_RX_CPU_RX): Add comment. + (E_FLAG_RX_ABI): Define. + 2012-11-08 Maciej W. Rozycki * mips.h (EF_MIPS_32BITMODE): Move next to lower-order bits. diff --git a/include/elf/rx.h b/include/elf/rx.h index baaa1aa9e3c..83980853e7b 100644 --- a/include/elf/rx.h +++ b/include/elf/rx.h @@ -110,7 +110,7 @@ START_RELOC_NUMBERS (elf_rx_reloc_type) END_RELOC_NUMBERS (R_RX_max) -#define EF_RX_CPU_RX 0x00000079 /* FIXME: correct value? */ +#define EF_RX_CPU_RX 0x00000079 /* FIXME: this collides with the E_FLAG_RX_... values below. */ #define EF_RX_CPU_MASK 0x0000007F /* specific cpu bits. */ #define EF_RX_ALL_FLAGS (EF_RX_CPU_MASK) @@ -118,6 +118,7 @@ END_RELOC_NUMBERS (R_RX_max) #define E_FLAG_RX_64BIT_DOUBLES (1 << 0) #define E_FLAG_RX_DSP (1 << 1) /* Defined in the RX CPU Object file specification, but not explained. */ #define E_FLAG_RX_PID (1 << 2) /* Unofficial - DJ */ +#define E_FLAG_RX_ABI (1 << 3) /* Binary passes stacked arguments using natural alignment. Unofficial - NC. */ /* These define the addend field of R_RX_RH_RELAX relocations. */ #define RX_RELAXA_IMM6 0x00000010 /* Imm8/16/24/32 at bit offset 6. */ diff --git a/ld/ChangeLog b/ld/ChangeLog index bba2e84e01e..4da5193d908 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,11 @@ +2012-11-09 Nick Clifton + + * emultempl/rxelf.em (no_flag_mismatch_warnings): Initialise to + true. + (PARSE_AND_LIST_LONGOPTS): Add flag-mismatch-warnings. + (PARSE_AND_LIST_ARG_CASES): Add support for + --flag-mismatch-warnings. + 2012-11-09 Edgar E. Iglesias * Makefile.am: Add eelf32microblazeel.c and eelf32mbel_linux.c. diff --git a/ld/emultempl/rxelf.em b/ld/emultempl/rxelf.em index 159a649f40b..f27e8e6475a 100644 --- a/ld/emultempl/rxelf.em +++ b/ld/emultempl/rxelf.em @@ -25,7 +25,7 @@ test -z "$TARGET2_TYPE" && TARGET2_TYPE="rel" fragment <