From patchwork Thu Mar 22 14:38:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 132295 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp930277ljb; Thu, 22 Mar 2018 07:39:53 -0700 (PDT) X-Google-Smtp-Source: AG47ELurwAr4uftJwQyR8ZCQ9xtztFYTvOUsZtzY8/6QQrMofTBUHPGwia06VI5OwlIst0p8hTM+ X-Received: by 10.98.32.89 with SMTP id g86mr20911979pfg.35.1521729593325; Thu, 22 Mar 2018 07:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729593; cv=none; d=google.com; s=arc-20160816; b=KXMOjKYShFoDbFqD6qVOzL5FcP3AvhBdaMm/9Ujoo5+KF9z4u9ng47OWc3rkzk2Iot 6YolHkB8Q0LRRMcZKO1BRoPhCj8q0SiTEh3wZn+7hK0z/qSxLGqENaTXarsvW+1LM9zP raAN7bF50bogZ60EE/+Ou32BA3Ywp1IenOtHF8GyYLC+EVk+vHPvUxexp71w0yHzri7u 5tdSAmB3PrwPp9XIFdBFmGwDX5YkpfBrfbGJISM5CKU1Wp8V4025PijlCb3I/oVPvXFY CkwGRFEn474YiPeARQ44qx67XGFKrT02EmHBmYCn7HgCEbNA2EVKFE74Q77lhj6F3oBd b6Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=LyE4VZvHRovGTJuu3ZE2yoGacMaSNmzOPvULvsU+dWM=; b=erZ8FWy7laYveOsbaM/OlpHfxQLmHSBZww4o+dVILrwxteR+Ce42Dkgaa+yuh/Cb97 NSlIOs/YoJQhIJLge5hrqrAUkTrQNcRTpfSvYNbVy7ucbEctLDvH7aD6P/LMp7EKngfJ cz7FiD5GJE94hs9O0APzU25Ts3PEPw9ZlvRxsu15BY2WfEW6y2fGAj+TPbg8ye2pO3IR /Jr2aKRX/uEKRpjFoZnFr4JcKuXz44sjBAjUUD25sBQzjEZQoTG1SRosFdrpw+pA4zW1 Q6C2n3KVn7mUEFnxvijlXnuhL3YNYh0LwwpDfND+nuSpkBJeyRoJaRojsu5hZ997P3yr Tvkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=UmmHMoNY; spf=pass (google.com: domain of binutils-return-101081-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101081-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g4si4478126pgq.322.2018.03.22.07.39.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:39:53 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-101081-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=UmmHMoNY; spf=pass (google.com: domain of binutils-return-101081-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101081-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=CFxWDQwVg2rqyLFvIiGPvXH0hMfxFq9SDeXxvBPocPy sk1BGvFQjixUQp/QwF926XOl+HjIc0nN3KgIZSaIutbf+XkxVDZk1n3K7tEo3qVx qZ7rDPF+ciurlXOGl4ZraAXrZt9xsCzcurvOZwUxtrbSr+CC9XEjOuGO29PjImf0 = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=4E2OrLzwgGCISrFs1GqOJY4xBnk=; b=UmmHMoNYXWfGuk38s ePLizIY5SyPWXwSn9JWWLhw2AuO2R3gFn28Jv85DpT8D/jfUVzf8jzNuMUsSKe92 obrENuIszz6jXfDzm8SOvy88YNZwiqzpShCifTm30LCQnio80v0BJRe4mQwYwqyP 17zdn07z7wJKPVdPm9N0T12kKE= Received: (qmail 43310 invoked by alias); 22 Mar 2018 14:39:40 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Delivered-To: mailing list binutils@sourceware.org Received: (qmail 42533 invoked by uid 89); 22 Mar 2018 14:39:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx07-00178001.pphosted.com Received: from mx08-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (91.207.212.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 14:39:38 +0000 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2MEdPsu030795 for ; Thu, 22 Mar 2018 15:39:36 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gv69ptjxs-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Mar 2018 15:39:36 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 869F034 for ; Thu, 22 Mar 2018 14:39:35 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6D5822B09 for ; Thu, 22 Mar 2018 14:39:35 +0000 (GMT) Received: from gnx2104.gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 22 Mar 2018 15:39:34 +0100 From: Christophe Lyon To: Subject: [ARM-FDPIC 02/12] [ARM] Add FDPIC OSABI flag support. Date: Thu, 22 Mar 2018 15:38:20 +0100 Message-ID: <20180322143850.1766-3-christophe.lyon@st.com> In-Reply-To: <20180322143850.1766-1-christophe.lyon@st.com> References: <20180322143850.1766-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-22_07:, , signatures=0 X-IsSubscribed: yes 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-XX-XX 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. --- bfd/elf32-arm.c | 14 +++++++++++++- binutils/readelf.c | 7 +++++++ gas/config/tc-arm.c | 34 +++++++++++++++++++++++++++++++--- include/elf/common.h | 1 + 4 files changed, 52 insertions(+), 4 deletions(-) -- 2.6.3 diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 565bb40..a0b0be3 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/readelf.c b/binutils/readelf.c index b85db9f..8f10754 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -2577,6 +2577,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) { @@ -3717,6 +3723,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/config/tc-arm.c b/gas/config/tc-arm.c index eda9890..8a3a282 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. */ @@ -25111,10 +25114,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 } @@ -25634,6 +25647,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[] = { @@ -25644,6 +25658,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} }; @@ -26815,6 +26832,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. */ @@ -26909,6 +26932,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/elf/common.h b/include/elf/common.h index 61a1ca7..a317d83 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 */