From patchwork Sun Nov 6 16:32:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waldemar Brodkorb X-Patchwork-Id: 691654 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 3tBh2X28Vtz9ryv for ; Mon, 7 Nov 2016 03:32:59 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="RIu2n7/g"; 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:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=wgDehQmGIx06F/f1pXi+nnHyLHYzqPGUNXPjG3JpBL9AcyFq+O UGKIxaT9l8Q0X2eqGNRU+cJY3q/4r+iPG7ASmpp+5ik1WMaHyBzUGZGlRX/uao4T 5/er6XfsLUT8knUUpmUmaYM3owDXZZ64LO/jf1e3VGhRmrBDQ7Unos5Ro= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=KSxobMKpY5Z70uQL2dSLmuaMAKE=; b=RIu2n7/gaMUiAuM6ZSwE dh2yekI5kJXyY0HgUJdV532NAxRe9jOspHpinG7V3tYqMV+NEDVF1bGQGJF9rKlH Vpamb2YcHHDSPOzGEPB61tn8qCOc4u3eYyr6G4mJcoZ1Lymv/brX0mu2UyIQpOtx n58uKzjPUZbRFao+YDBJxXg= Received: (qmail 29567 invoked by alias); 6 Nov 2016 16:32:51 -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 29551 invoked by uid 89); 6 Nov 2016 16:32:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=LOCAL, UD:ver, 2016-11-06 X-HELO: helium.openadk.org Received: from helium.openadk.org (HELO helium.openadk.org) (89.238.66.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 06 Nov 2016 16:32:40 +0000 Received: by helium.openadk.org (Postfix, from userid 1000) id 6CE2B1004F; Sun, 6 Nov 2016 17:32:37 +0100 (CET) Date: Sun, 6 Nov 2016 17:32:37 +0100 From: Waldemar Brodkorb To: gcc-patches Cc: thomas.petazzoni@free-electrons.com Subject: [PATCH] libgcc/mkmap-symver: support skip_underscore (PR74748) Message-ID: <20161106163236.GX27313@waldemar-brodkorb.de> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi, Some platforms, such as Blackfin, have a special prefix for assembly symbols as opposed to C symbols. For this reason, a function named "foo()" in C will in fact be visible as a symbol called "_foo" in the ELF binary. The current linker version script logic in libgcc doesn't take into account this situation properly. The Blackfin specific libgcc/config/bfin/libgcc-glibc.ver has an additional "_" in front of every symbol so that it matches the output of "nm" (which gets parsed to produce the final linker version script). But due to this additional "_", ld no longer matches with the symbols since "ld" does the matching with the original symbol name, not the one prefixed with "_". Due to this, none of the symbols in libgcc/config/bfin/libgcc-glibc.ver are actually matched with symbols in libgcc. This causes all libgcc symbols to be left as "LOCAL", which causes lots of "undefined reference" whenever some C or C++ code that calls a function of libgcc is compiled. To address this, this commit introduces a "skip_underscore" variable to the mkmap-symver script. It tells mkmap-symver to ignore the leading underscore from the "nm" output. Note that this new argument is different from the existing "leading_underscore" argument, which *adds* an additional underscore to the generated linker version script. Having this functionality paves the way to using the generic linker version information for Blackfin, instead of using a custom one. Signed-off-by: Thomas Petazzoni Tested-by: Waldemar Brodkorb 2016-11-06 Thomas Petazzoni PR gcc/74748 * libgcc/mkmap-symver.awk: add support for skip_underscore Thanks in advance, Waldemar diff --git a/libgcc/mkmap-symver.awk b/libgcc/mkmap-symver.awk index 266832a..30bb179 100644 --- a/libgcc/mkmap-symver.awk +++ b/libgcc/mkmap-symver.awk @@ -47,7 +47,11 @@ state == "nm" && ($1 == "U" || $2 == "U") { state == "nm" && NF == 3 { split ($3, s, "@") - def[s[1]] = 1; + if (skip_underscore) + symname = substr(s[1], 2); + else + symname = s[1]; + def[symname] = 1; sawsymbol = 1; next; }