From patchwork Mon Mar 30 13:20:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 46507 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D5E6F214C7 for ; Mon, 30 Mar 2015 13:21:00 +0000 (UTC) Received: by pacgg7 with SMTP id gg7sf113747702pac.2 for ; Mon, 30 Mar 2015 06:21:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=+ujoZY6yo9a+zK4ou4JsWHGEe7NDwSu7AbOQst8bA/w=; b=YwziRtOO+XU5bripxqgnpb/81fk3QnZGMaKPHDj1/lcHZOpcXBWYEMA1nVnQWd8Sci sHDkSAN5K2GrSo6m5bzxhIIKTLa1GMMgkeLxMAapBHI/DqmRz0amlG8dggXt5Urk6YvI yEfcvnrCodxfVOYo6gKZtD4hNBu9i1E2+FwOumxbxD+PHOjt2nB/0Xj4C02wP8XHimJr 5g8SO68tWrx5Ac0jXpbdjXMFS44A0Subo9FAT/Dfoayo10uVmq0JDegzAskdpoNK4Fdx RPjgWsR9uVUVKetgMKy0vxU1Ddi622VXKnH2gBHf6zpTUXgC98XNDA6cdl+5r4Ro5XHP Vu/A== X-Gm-Message-State: ALoCoQlbDSw0r6lxSrM8G5YnVnyevcJ3sjerrA9aiI7F6QiOZYg4vlkRFnf5+LT3LEI8VM0VMK9n X-Received: by 10.66.153.6 with SMTP id vc6mr38794445pab.37.1427721660206; Mon, 30 Mar 2015 06:21:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.120 with SMTP id l111ls2194620qga.8.gmail; Mon, 30 Mar 2015 06:21:00 -0700 (PDT) X-Received: by 10.140.150.149 with SMTP id 143mr43392441qhw.4.1427721660093; Mon, 30 Mar 2015 06:21:00 -0700 (PDT) Received: from mail-qg0-f42.google.com (mail-qg0-f42.google.com. [209.85.192.42]) by mx.google.com with ESMTPS id 185si10293817qhs.70.2015.03.30.06.21.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Mar 2015 06:21:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.192.42 as permitted sender) client-ip=209.85.192.42; Received: by qgf60 with SMTP id 60so169153903qgf.3 for ; Mon, 30 Mar 2015 06:21:00 -0700 (PDT) X-Received: by 10.55.51.77 with SMTP id z74mr67755778qkz.84.1427721659708; Mon, 30 Mar 2015 06:20:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.96.155.231 with SMTP id vz7csp1462792qdb; Mon, 30 Mar 2015 06:20:56 -0700 (PDT) X-Received: by 10.68.167.131 with SMTP id zo3mr58049154pbb.123.1427721656030; Mon, 30 Mar 2015 06:20:56 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bn2si14795844pdb.71.2015.03.30.06.20.53; Mon, 30 Mar 2015 06:20:56 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753140AbbC3NUv (ORCPT + 27 others); Mon, 30 Mar 2015 09:20:51 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:32853 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753027AbbC3NUp (ORCPT ); Mon, 30 Mar 2015 09:20:45 -0400 Received: by wixm2 with SMTP id m2so86827272wix.0 for ; Mon, 30 Mar 2015 06:20:43 -0700 (PDT) X-Received: by 10.180.97.66 with SMTP id dy2mr16998917wib.77.1427721643754; Mon, 30 Mar 2015 06:20:43 -0700 (PDT) Received: from ards-macbook-pro.local (129.20.90.92.rev.sfr.net. [92.90.20.129]) by mx.google.com with ESMTPSA id dx11sm15734004wjb.23.2015.03.30.06.20.40 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Mar 2015 06:20:42 -0700 (PDT) From: Ard Biesheuvel To: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, arnd@arndb.de, mmarek@suse.cz, linux@arm.linux.org.uk Cc: Ard Biesheuvel Subject: [PATCH 1/2] Kbuild: kallsyms: ignore veneers emitted by the ARM linker Date: Mon, 30 Mar 2015 15:20:31 +0200 Message-Id: <1427721632-11665-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1427721632-11665-1-git-send-email-ard.biesheuvel@linaro.org> References: <1427721632-11665-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.192.42 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When linking large kernels on ARM, the linker will insert veneers (i.e., PLT like stubs) when function symbols are out of reach for the ordinary relative branch/branch-and-link instructions. However, due to the fact that the kallsyms region sits in .rodata, which is between .text and .init.text, additional veneers may be emitted in the second pass due to the fact that the size of the kallsyms region itself has pushed the .init.text section further apart, requiring even more veneers. So ignore the veneers when generating the symbol table. Veneers have no corresponding source code, and they will not turn up in backtraces anyway. This patch also lightly refactors the symbol_valid() function to use a local 'sym_name' rather than the obfuscated 'sym + 1' and 'sym + offset' Signed-off-by: Ard Biesheuvel --- scripts/kallsyms.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index c6d33bd15b04..f4b016782f0d 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -212,15 +212,23 @@ static int symbol_valid(struct sym_entry *s) "_SDA_BASE_", /* ppc */ "_SDA2_BASE_", /* ppc */ NULL }; + + static char *special_suffixes[] = { + "_compiled.", /* gcc < 3.0: "gcc[0-9]_compiled." */ + "_veneer", /* arm */ + NULL }; + int i; - int offset = 1; + char *sym_name = (char *)s->sym + 1; + if (s->addr < kernel_start_addr) return 0; /* skip prefix char */ - if (symbol_prefix_char && *(s->sym + 1) == symbol_prefix_char) - offset++; + if (symbol_prefix_char && *sym_name == symbol_prefix_char) + sym_name++; + /* if --all-symbols is not specified, then symbols outside the text * and inittext sections are discarded */ @@ -235,22 +243,26 @@ static int symbol_valid(struct sym_entry *s) * rules. */ if ((s->addr == text_range_text->end && - strcmp((char *)s->sym + offset, + strcmp(sym_name, text_range_text->end_sym)) || (s->addr == text_range_inittext->end && - strcmp((char *)s->sym + offset, + strcmp(sym_name, text_range_inittext->end_sym))) return 0; } /* Exclude symbols which vary between passes. */ - if (strstr((char *)s->sym + offset, "_compiled.")) - return 0; - for (i = 0; special_symbols[i]; i++) - if( strcmp((char *)s->sym + offset, special_symbols[i]) == 0 ) + if (strcmp(sym_name, special_symbols[i]) == 0) return 0; + for (i = 0; special_suffixes[i]; i++) { + int l = strlen(sym_name) - strlen(special_suffixes[i]); + + if (l >= 0 && strcmp(sym_name + l, special_suffixes[i]) == 0) + return 0; + } + return 1; }