From patchwork Mon Apr 27 14:58:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 465062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E7248140082 for ; Tue, 28 Apr 2015 00:58:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=YZvQdfTn; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=tbuGFj4y3CyQbAlWg 3C9y23n/KiN0J9GPeh+0SghCJD9Fez0bKU/s6W1bxo064TU+GPLhZS//PDi8n1s8 05BvXOQ+FqTag6MlXlYowDaD//KVgpNC6rOb6AQYEwlW510OATwYHo2ETXkGQpr2 pyLdam4JuEGrAwepEEhi7FwTOk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=3OjTbsXSY71Re4lZWSySmh5 iQJc=; b=YZvQdfTnbLfwdczg6c+vZZPh9jAbMcdCWRC+il12Fv3cQdeJig0GZc4 nJXJuOvXwJmf217fx0DX5/MvKSddlmWfTZdPMnSVyJ6mi+CopmzCXZYNnSkZQRJM qKEImWo8PYBcXGhFmneyY2nZoSvA0408oBy7JUU+mkUII7ri3kKw= Received: (qmail 107630 invoked by alias); 27 Apr 2015 14:58:15 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 107555 invoked by uid 89); 27 Apr 2015 14:58:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS, UPPERCASE_50_75, WEIRD_QUOTING autolearn=no version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Apr 2015 14:58:08 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by uk-mta-3.uk.mimecast.lan; Mon, 27 Apr 2015 15:58:05 +0100 Received: from [10.2.206.56] ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 27 Apr 2015 15:58:05 +0100 Message-ID: <553E4E7D.2000304@arm.com> Date: Mon, 27 Apr 2015 15:58:05 +0100 From: Szabolcs Nagy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Gregor Richards , Rich Felker , Szabolcs Nagy Subject: Re: [PATCH 7/13] powerpc musl support References: <55354A4A.4060702@arm.com> <55354BAF.7020905@arm.com> In-Reply-To: <55354BAF.7020905@arm.com> X-MC-Unique: QPoNXvsKTWiXy4oXl2Y7vg-1 X-IsSubscribed: yes On 20/04/15 19:55, Szabolcs Nagy wrote: > Set up dynamic linker name for powerpc. Musl only supports powerpc > with secure plt, so appropriate options are passed to the linker by > default. Patch v2. Powerpc does not include the top level linux.h, so I had to repeat the include order fixes from there in rs6000/sysv4.h. I corrected the endianness handling (the "le" suffix should be added correctly now). gcc/Changelog: 2015-04-24 Gregor Richards Szabolcs Nagy * config.gcc (secure_plt): Add *-linux*-musl*. * config/rs6000/linux64.h (MUSL_DYNAMIC_LINKER32): Define. (MUSL_DYNAMIC_LINKER64): Define. (GNU_USER_DYNAMIC_LINKER32): Update. (GNU_USER_DYNAMIC_LINKER64): Update. (CHOOSE_DYNAMIC_LINKER): Update. * config/rs6000/secureplt.h (LINK_SECURE_PLT_DEFAULT_SPEC): Define. * config/rs6000/sysv4.h (GNU_USER_DYNAMIC_LINKER): Update. (MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER_E,) (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,) (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,) (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define. (LINK_SECURE_PLT_DEFAULT_SPEC): Define. (CHOOSE_DYNAMIC_LINKER, LINK_TARGET_SPEC, LINK_OS_LINUX_SPEC): Update. * config/rs6000/sysv4le.h (MUSL_DYNAMIC_LINKER_E): Define. diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h index 0879e7e..a6ad842 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -365,17 +365,21 @@ extern int dot_symbols; #endif #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0" #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E ".so.1" +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E ".so.1" #if DEFAULT_LIBC == LIBC_UCLIBC -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" #elif DEFAULT_LIBC == LIBC_GLIBC -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}" +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}" +#elif DEFAULT_LIBC == LIBC_MUSL +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}" #else #error "Unsupported DEFAULT_LIBC" #endif #define GNU_USER_DYNAMIC_LINKER32 \ - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32) + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32) #define GNU_USER_DYNAMIC_LINKER64 \ - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64) + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64) #undef DEFAULT_ASM_ENDIAN #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN) diff --git a/gcc/config/rs6000/secureplt.h b/gcc/config/rs6000/secureplt.h index b463463..77edf2a 100644 --- a/gcc/config/rs6000/secureplt.h +++ b/gcc/config/rs6000/secureplt.h @@ -18,3 +18,4 @@ along with GCC; see the file COPYING3. If not see . */ #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt" +#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt" diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h index 9917c2f..94c4263 100644 --- a/gcc/config/rs6000/sysv4.h +++ b/gcc/config/rs6000/sysv4.h @@ -537,6 +537,9 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) #ifndef CC1_SECURE_PLT_DEFAULT_SPEC #define CC1_SECURE_PLT_DEFAULT_SPEC "" #endif +#ifndef LINK_SECURE_PLT_DEFAULT_SPEC +#define LINK_SECURE_PLT_DEFAULT_SPEC "" +#endif /* Pass -G xxx to the compiler. */ #undef CC1_SPEC @@ -586,7 +589,8 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) /* Override the default target of the linker. */ #define LINK_TARGET_SPEC \ - ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") + ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \ + "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}" /* Any specific OS flags. */ #define LINK_OS_SPEC "\ @@ -762,17 +766,22 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) #define LINK_START_LINUX_SPEC "" +#define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","") + #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E ".so.1" #if DEFAULT_LIBC == LIBC_UCLIBC -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}" +#elif DEFAULT_LIBC == LIBC_MUSL +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}" #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}" +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}" #else #error "Unsupported DEFAULT_LIBC" #endif #define GNU_USER_DYNAMIC_LINKER \ - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER) + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER) #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \ %{rdynamic:-export-dynamic} \ @@ -895,6 +904,7 @@ ncrtn.o%s" { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \ { "link_os_default", LINK_OS_DEFAULT_SPEC }, \ { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \ + { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \ { "cpp_os_ads", CPP_OS_ADS_SPEC }, \ { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \ { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \ @@ -949,3 +959,72 @@ ncrtn.o%s" /* This target uses the sysv4.opt file. */ #define TARGET_USES_SYSV4_OPT 1 +/* Include order changes for musl, same as in generic linux.h. */ +#if DEFAULT_LIBC == LIBC_MUSL +#define INCLUDE_DEFAULTS_MUSL_GPP \ + { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \ + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \ + { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \ + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \ + { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \ + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, + +#ifdef LOCAL_INCLUDE_DIR +#define INCLUDE_DEFAULTS_MUSL_LOCAL \ + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \ + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 }, +#else +#define INCLUDE_DEFAULTS_MUSL_LOCAL +#endif + +#ifdef PREFIX_INCLUDE_DIR +#define INCLUDE_DEFAULTS_MUSL_PREFIX \ + { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0}, +#else +#define INCLUDE_DEFAULTS_MUSL_PREFIX +#endif + +#ifdef CROSS_INCLUDE_DIR +#define INCLUDE_DEFAULTS_MUSL_CROSS \ + { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0}, +#else +#define INCLUDE_DEFAULTS_MUSL_CROSS +#endif + +#ifdef TOOL_INCLUDE_DIR +#define INCLUDE_DEFAULTS_MUSL_TOOL \ + { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0}, +#else +#define INCLUDE_DEFAULTS_MUSL_TOOL +#endif + +#ifdef NATIVE_SYSTEM_HEADER_DIR +#define INCLUDE_DEFAULTS_MUSL_NATIVE \ + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 }, +#else +#define INCLUDE_DEFAULTS_MUSL_NATIVE +#endif + +#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT) +# undef INCLUDE_DEFAULTS_MUSL_LOCAL +# define INCLUDE_DEFAULTS_MUSL_LOCAL +# undef INCLUDE_DEFAULTS_MUSL_NATIVE +# define INCLUDE_DEFAULTS_MUSL_NATIVE +#else +# undef INCLUDE_DEFAULTS_MUSL_CROSS +# define INCLUDE_DEFAULTS_MUSL_CROSS +#endif + +#undef INCLUDE_DEFAULTS +#define INCLUDE_DEFAULTS \ + { \ + INCLUDE_DEFAULTS_MUSL_GPP \ + INCLUDE_DEFAULTS_MUSL_PREFIX \ + INCLUDE_DEFAULTS_MUSL_CROSS \ + INCLUDE_DEFAULTS_MUSL_TOOL \ + INCLUDE_DEFAULTS_MUSL_NATIVE \ + { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ + { 0, 0, 0, 0, 0, 0 } \ + } +#endif diff --git a/gcc/config/rs6000/sysv4le.h b/gcc/config/rs6000/sysv4le.h index 7b1d6a1..064323c 100644 --- a/gcc/config/rs6000/sysv4le.h +++ b/gcc/config/rs6000/sysv4le.h @@ -35,3 +35,5 @@ /* Little-endian PowerPC64 Linux uses the ELF v2 ABI by default. */ #define LINUX64_DEFAULT_ABI_ELFv2 +#undef MUSL_DYNAMIC_LINKER_E +#define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","le")