From: Christophe Lyon Date: Tue, 20 Mar 2018 09:54:50 +0000 (+0100) Subject: [ARM] Add FDPIC OSABI flag support. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=18a203380502fb3ee75633fd464faa3c83cec710;p=binutils-gdb.git [ARM] Add FDPIC OSABI flag support. ELF files targetting ARM FDPIC use the ELFOSABI_ARM_FDPIC flag. Set it appropriately in file generators (eg. gas), and handle it in readers (eg. readelf). 2018-04-25 Christophe Lyon Mickaël Guêné bfd/ * elf32-arm.c (elf32_arm_print_private_bfd_data): Support EF_ARM_PIC and ELFOSABI_ARM_FDPIC. (elf32_arm_post_process_headers): Support ELFOSABI_ARM_FDPIC. (ELF_OSABI): Define to ELFOSABI_ARM_FDPIC. binutils/ * readelf.c (decode_ARM_machine_flags): Support EF_ARM_PIC. (get_osabi_name): Support ELFOSABI_ARM_FDPIC. gas/ * config/tc-arm.c (arm_fdpic): New. (elf32_arm_target_format): Support FDPIC. (OPTION_FDPIC): New. (md_longopts): Support FDPIC. (md_parse_option): Likewise. (md_show_usage): Likewise. include/ * elf/arm.h (EF_ARM_FDPIC): New. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index ed96fcdda5d..dd28d04fccf 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +2018-04-25 Christophe Lyon + Mickaël Guêné + + * elf32-arm.c (elf32_arm_print_private_bfd_data): Support + EF_ARM_PIC and ELFOSABI_ARM_FDPIC. + (elf32_arm_post_process_headers): Support ELFOSABI_ARM_FDPIC. + (ELF_OSABI): Define to ELFOSABI_ARM_FDPIC. + 2018-04-25 Christophe Lyon Mickaël Guêné diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 565bb404f2c..a0b0be3f160 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -14280,7 +14280,13 @@ elf32_arm_print_private_bfd_data (bfd *abfd, void * ptr) if (flags & EF_ARM_RELEXEC) fprintf (file, _(" [relocatable executable]")); - flags &= ~EF_ARM_RELEXEC; + if (flags & EF_ARM_PIC) + fprintf (file, _(" [position independent]")); + + if (elf_elfheader (abfd)->e_ident[EI_OSABI] == ELFOSABI_ARM_FDPIC) + fprintf (file, _(" [FDPIC ABI supplement]")); + + flags &= ~ (EF_ARM_RELEXEC | EF_ARM_PIC); if (flags) fprintf (file, _("")); @@ -16642,6 +16648,9 @@ elf32_arm_post_process_headers (bfd * abfd, struct bfd_link_info * link_info ATT globals = elf32_arm_hash_table (link_info); if (globals != NULL && globals->byteswap_code) i_ehdrp->e_flags |= EF_ARM_BE8; + + if (globals->fdpic_p) + i_ehdrp->e_ident[EI_OSABI] |= ELFOSABI_ARM_FDPIC; } if (EF_ARM_EABI_VERSION (i_ehdrp->e_flags) == EF_ARM_EABI_VER5 @@ -19427,6 +19436,8 @@ elf32_arm_nacl_plt_sym_val (bfd_vma i, const asection *plt, #define TARGET_BIG_NAME "elf32-bigarm-fdpic" #undef elf_match_priority #define elf_match_priority 128 +#undef ELF_OSABI +#define ELF_OSABI ELFOSABI_ARM_FDPIC /* Like elf32_arm_link_hash_table_create -- but overrides appropriately for FDPIC. */ @@ -19454,6 +19465,7 @@ elf32_arm_fdpic_link_hash_table_create (bfd *abfd) #include "elf32-target.h" #undef elf_match_priority +#undef ELF_OSABI /* VxWorks Targets. */ diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 2b2c709d198..68e5175e938 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2018-04-25 Christophe Lyon + Mickaël Guêné + + * readelf.c (decode_ARM_machine_flags): Support EF_ARM_PIC. + (get_osabi_name): Support ELFOSABI_ARM_FDPIC. + 2018-04-25 Alan Modra * testsuite/binutils-all/arm/objdump.exp: Remove arm-aout and diff --git a/binutils/readelf.c b/binutils/readelf.c index 528954cc6e1..e8e1b9681eb 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -2578,6 +2578,12 @@ decode_ARM_machine_flags (unsigned e_flags, char buf[]) e_flags &= ~ EF_ARM_RELEXEC; } + if (e_flags & EF_ARM_PIC) + { + strcat (buf, ", position independent"); + e_flags &= ~ EF_ARM_PIC; + } + /* Now handle EABI specific flags. */ switch (eabi) { @@ -3718,6 +3724,7 @@ get_osabi_name (Filedata * filedata, unsigned int osabi) switch (osabi) { case ELFOSABI_ARM: return "ARM"; + case ELFOSABI_ARM_FDPIC: return "ARM FDPIC"; default: break; } diff --git a/gas/ChangeLog b/gas/ChangeLog index e8c0f7dbb2e..5db76c97706 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,13 @@ +2018-04-25 Christophe Lyon + Mickaël Guêné + + * config/tc-arm.c (arm_fdpic): New. + (elf32_arm_target_format): Support FDPIC. + (OPTION_FDPIC): New. + (md_longopts): Support FDPIC. + (md_parse_option): Likewise. + (md_show_usage): Likewise. + 2018-04-25 Tamar Christina * testsuite/gas/aarch64/rdma.s: Test for larger register numbers. diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index f7bddd7a6e1..d735609eca5 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -75,6 +75,9 @@ static struct unsigned sp_restored:1; } unwind; +/* Whether --fdpic was given. */ +static int arm_fdpic; + #endif /* OBJ_ELF */ /* Results from operand parsing worker functions. */ @@ -25079,10 +25082,20 @@ elf32_arm_target_format (void) ? "elf32-bigarm-nacl" : "elf32-littlearm-nacl"); #else - if (target_big_endian) - return "elf32-bigarm"; + if (arm_fdpic) + { + if (target_big_endian) + return "elf32-bigarm-fdpic"; + else + return "elf32-littlearm-fdpic"; + } else - return "elf32-littlearm"; + { + if (target_big_endian) + return "elf32-bigarm"; + else + return "elf32-littlearm"; + } #endif } @@ -25602,6 +25615,7 @@ const char * md_shortopts = "m:k"; #endif #endif #define OPTION_FIX_V4BX (OPTION_MD_BASE + 2) +#define OPTION_FDPIC (OPTION_MD_BASE + 3) struct option md_longopts[] = { @@ -25612,6 +25626,9 @@ struct option md_longopts[] = {"EL", no_argument, NULL, OPTION_EL}, #endif {"fix-v4bx", no_argument, NULL, OPTION_FIX_V4BX}, +#ifdef OBJ_ELF + {"fdpic", no_argument, NULL, OPTION_FDPIC}, +#endif {NULL, no_argument, NULL, 0} }; @@ -26783,6 +26800,12 @@ md_parse_option (int c, const char * arg) fix_v4bx = TRUE; break; +#ifdef OBJ_ELF + case OPTION_FDPIC: + arm_fdpic = TRUE; + break; +#endif /* OBJ_ELF */ + case 'a': /* Listing option. Just ignore these, we don't support additional ones. */ @@ -26877,6 +26900,11 @@ md_show_usage (FILE * fp) fprintf (fp, _("\ --fix-v4bx Allow BX in ARMv4 code\n")); + +#ifdef OBJ_ELF + fprintf (fp, _("\ + --fdpic generate an FDPIC object file\n")); +#endif /* OBJ_ELF */ } #ifdef OBJ_ELF diff --git a/include/ChangeLog b/include/ChangeLog index 940136eaf1b..d159a25c056 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,8 @@ +2018-04-25 Christophe Lyon + Mickaël Guêné + + * elf/arm.h (EF_ARM_FDPIC): New. + 2018-04-18 Alan Modra * coff/mipspe.h: Delete. diff --git a/include/elf/common.h b/include/elf/common.h index f4354721bf5..469fe5a9874 100644 --- a/include/elf/common.h +++ b/include/elf/common.h @@ -78,6 +78,7 @@ #define ELFOSABI_C6000_ELFABI 64 /* Bare-metal TMS320C6000 */ #define ELFOSABI_C6000_LINUX 65 /* Linux TMS320C6000 */ +#define ELFOSABI_ARM_FDPIC 65 /* ARM FDPIC */ #define ELFOSABI_ARM 97 /* ARM */ #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */