From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe31.google.com (mail-vs1-xe31.google.com [IPv6:2607:f8b0:4864:20::e31]) by sourceware.org (Postfix) with ESMTPS id 120273857C58 for ; Sat, 11 Jul 2020 01:35:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 120273857C58 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jimw@sifive.com Received: by mail-vs1-xe31.google.com with SMTP id p25so3956619vsg.4 for ; Fri, 10 Jul 2020 18:35:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PxaLQtEPcTHy9ihBSvRQ4hiGVY7ijT758BcNQwisC7Q=; b=AqI6akeHDT7zAAOP4OJT2daFEmGY6A8ehGVN0b8TrjxmG+JsdoeU2HRvbE8gJo1p1R s/8wD6P7NDE+ejuuC4QNeKLrIV06RSn+axn/Rxh3kOlD2N20tJ7+rs7SdF/4dF9ZmXfW PGX63OOvHVwzpsI+cRPj8x71nC3PDmyVRfEHixInsmsSRePRtB0KLXiekTzNbSI0WjQ2 cvCzRp5mAo4dSqRa6QqD53jw6aQQq8sXwyUL0TKVJcBu2F064EQVa32yQSYmG21ahJmP 1RWDq7umpU5/nYfZML7ctlM4pAOW4WZPTPY5eic0uevsa1yCpX8Fqjv1eG7Vkj2zDy0r A/3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PxaLQtEPcTHy9ihBSvRQ4hiGVY7ijT758BcNQwisC7Q=; b=HyPK3Ni8H03jCG9YyxzJ5z/VWtYCoFy4+KcTVFMqDgYhKHPSKdCuuWd/tRzA+d1Ecp r4ryGEUv4tuDyI+RIjRvr4JQ5ZRgo3g9p8FKWKewBi1XQikBed/iMSWKJiFI6L3Aj8+x kXtFaBqXTsuY3bCkLDyOAbhjhc4DBS5gMXopSwkFzB4pPcYh6kN3OT4ghBJQPCdHH+YG G1HkXu4YDyMZ38ti6qePBQijY8VCCXkftOGGlS1HhvRBiPapfjnjSx9xU/1A9ELV2TEQ XY8fAl2BHw2TrF7UCs+lxhnoUfNefKIHcNGFS1wlLhDeHpSOdR3DurMvJDeaXnutEMWg InyA== X-Gm-Message-State: AOAM5320APAfWG5QHJ+n0lkmLuSIwWxpGqakafszwQtpk/b4cc4j46o1 zQoSEPbHOERD8x8uic0W+vX3xBdTty908aTqSnI4zMpqhlc= X-Google-Smtp-Source: ABdhPJxiJ9zYcjLRE0TIUHngbv+lTXqS/vUZlhZGBeDaHSkZHg11A7NAy3uRGD4WBo775+BCVW13Qerb2rritkTmhOg= X-Received: by 2002:a67:338b:: with SMTP id z133mr20293393vsz.138.1594431349531; Fri, 10 Jul 2020 18:35:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jim Wilson Date: Fri, 10 Jul 2020 18:35:38 -0700 Message-ID: Subject: Re: Compiling gcc fails while trying to link libgcc To: Peter Lamby Cc: gcc-help Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Jul 2020 01:35:51 -0000 On Thu, Jul 9, 2020 at 1:51 AM Peter Lamby via Gcc-help wrote: > export CFLAGS=-pipe -march=native -fstack-protector-strong -fno-plt \ > -pie -fpie You can't use -pie when linking a shared library. So this isn't going to work. Also the -fno-plt is suspicious. Can you compile a shared library without plts? The -fpie is clearly wrong too. You need to do this a different way. Note that gcc has a configure option --enable-default-pie which will produce pie output by default, but won't pass -pie to the linker with -static, -shared, or -r. And won't add -fpie if -fpic was specified. rohan:2242$ gcc -shared -fpic -o tmp.so tmp.c rohan:2243$ gcc -shared -fpic -o tmp.so tmp.c -pie /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start': (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status rohan:2244$ Jim