From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754656AbcAXSCa (ORCPT ); Sun, 24 Jan 2016 13:02:30 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:38096 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754492AbcAXSBm (ORCPT ); Sun, 24 Jan 2016 13:01:42 -0500 Subject: Re: Problems with commit 'kallsyms: add support for relative offsets in kallsyms address table' (in mmotm) To: Ard Biesheuvel References: <56A431B5.8010505@roeck-us.net> <56A43882.50308@roeck-us.net> <56A477E1.50509@roeck-us.net> <56A50462.50501@roeck-us.net> Cc: Heiko Carstens , Michael Ellerman , Kees Cook , Andrew Morton , "linux-kernel@vger.kernel.org" From: Guenter Roeck Message-ID: <56A51182.9040105@roeck-us.net> Date: Sun, 24 Jan 2016 10:01:38 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/24/2016 09:20 AM, Ard Biesheuvel wrote: [ ... ] >>> OK, there's an additional issue in my latest version: the >>> kallsyms_relative_base value itself is not relocated. >>> >>> If you have more time to burn on this, could you try the following on >>> top? (If not, that is also fine, I will look into it myself on Monday) >>> >>> diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c >>> index 5ab13394dfd9..0f43f0751d47 100644 >>> --- a/scripts/kallsyms.c >>> +++ b/scripts/kallsyms.c >>> @@ -137,8 +137,10 @@ static int read_symbol(FILE *in, struct sym_entry *s) >>> sym++; >>> >>> /* Ignore most absolute/undefined (?) symbols. */ >>> - if (strcmp(sym, "_text") == 0) >>> + if (strcmp(sym, "_text") == 0) { >>> _text = s->addr; >>> + stype = 'T'; >>> + } >>> else if (check_symbol_range(sym, s->addr, text_ranges, >>> ARRAY_SIZE(text_ranges)) == 0) >>> /* nothing to do */; >>> @@ -406,7 +408,7 @@ static void write_src(void) >>> >>> if (base_relative) { >>> output_label("kallsyms_relative_base"); >>> - printf("\tPTR\t%#llx\n", relative_base); >>> + printf("\tPTR\t_text - %#llx\n", _text - relative_base); >>> printf("\n"); >>> } >> >> Does not help. >> > > For x86? Or none of them? > I tested sparc32 and x86_64/nosmp. Doesn't help for any of them. sparc32 has the following absolute symbols. f035a420 A _etext f03d9000 A _sdata f03de8c4 A jiffies f03f8860 A _edata f03fc000 A __init_begin f041bdc8 A __init_text_end f0423000 A __bss_start f0423000 A __init_end f044457d A __bss_stop f044457d A _end This results in: kallsyms failure: absolute symbol value 0xf035a420 out of range in relative mode This is with binutils 2.22. I didn't test with binutils 2.25 for sparc, or re-test mips. Looks like I'll need to add more test cases with binutils 2.22 vs. 2.25 for various architectures, as well as more SMP vs. !SMP builds. Guenter