From nobody Sun Feb 8 15:59:18 2026 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75BED3570AE for ; Fri, 16 Jan 2026 09:34:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768556064; cv=none; b=fKgTVi84ykfqX/qLISQPF657OoutIT37+OYDVPcOfzTqpsIyaqvj9p31Op1vFD7nOvOWdZEcNEqdvB2g3iIRJ3ngTesz/yEfeQ88UlPynxEUvrNfJ6eqjmycVz7Nw2oUmgPDRuP5XT6xJ5bsoryJIVHn+DLs76Og+FUFGMw3qZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768556064; c=relaxed/simple; bh=Y/JLcurrP7hYPL4AV5l4OWDyDh1zMqiBUjyu5CelejU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lFKh+uhh1zDBhKuEfIB6FFr1q1n8lAcH1wkbRGo/yUkNiUK5mh+AkT+znkNxElP4fKVkpO79yq6TGlDKXk+QcDzJLLLTFSScupFhEwCeiiOLpFaM5FtmrJozWCpXI3Tq23ha3O6RHpL4Rndsaup/K3jC4EjsO99Lk9qdlcGrsig= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=cwbF2N2n; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cwbF2N2n" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-47ee8808ffbso12650675e9.2 for ; Fri, 16 Jan 2026 01:34:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768556061; x=1769160861; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=dobnQlzcQXndjhDiBs5Er5oWRxsPFXQMWQBLT95H/Xg=; b=cwbF2N2nDY8tR+eEvbhvqkJuzQjXY83InFdk9YN8fBeltVuhZAE/fqemHhsvFKcMXY eHWV0F7BadYCh3VZkmP86mWHiTesWY6igyAPHYqgK2AF2hYLJ0hu7dPw9jFTU15/i5T4 xPlVNP3MD9DAOPMQqut5hnT7AwQ4aP3b2HpFLtHOQISZ0IIYA5e7ty9pOQCVvf7cCFdi 1Wm9cOR8ddBWzkNFPfB/GW4krT3INKieFtZvsRGsWMsWQnIEDYJKw4YVN5NXYyAsZXRi NpXt1GIJOs8A9PulUT0c8bC08SOm2m5roNAtWTs7XmvoYm9gQdJz/AdDERvKczlzC7qn 3HYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768556061; x=1769160861; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dobnQlzcQXndjhDiBs5Er5oWRxsPFXQMWQBLT95H/Xg=; b=odb0YzCar8flQg3hy23Slr+rKg5Byj9JFJDcXq7PidCsmQDqyaqXxH4Kjb66ylu+Ik dy9Yv16yqPJyzBhM6LgVbilDtpC1JR7HhrwSJ72ZT3sFpLUX+j0Ewejwd9oafnciQpGj 6rN6aXHoOL0QO5QLLJN7S7QSKPvumZvjFxsK9Ifz1Z7ppJopYmNz5MJpWqtOj6E6v5xX 8pzinLaf1AwMnb1yc7nKxHxAwjyFw4Fu+z/uH703GyTREJRWsdaLJuWy/EyrX2XoxHWA nUVGlcgtUAmD3WeGt2qp7TfTnLfkEEgu8cW3p7/3WL3eylW2ed+dM0MJ2OkqAdZKf2Pv knRw== X-Gm-Message-State: AOJu0YxB9Ni0svDr4HFVOwgBuRl59oRTFD62Tzo6dqFthlqWxRKcuWzv QCKFUfUwg17cg8mKsY+KXiTfrHYQEDNFCiKS/GUdMsmmGn6d4iuCXzO6sp5Y08XQIhnS00YmE4G jS1cpi9nlZPZKejqYIK/Vfw/Ifcomwp5DvWxg1n8noYvxzP1jUZHh8RfEdLELCtC44C5voBxyQX Xmz1yCRMN98v4vbdFqyWjTzSlVyNU+zvZFPw== X-Received: from wmco13.prod.google.com ([2002:a05:600c:a30d:b0:475:decb:4c4d]) (user=ardb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:5248:b0:477:b642:9dc9 with SMTP id 5b1f17b1804b1-4801e3459d3mr25659335e9.28.1768556060718; Fri, 16 Jan 2026 01:34:20 -0800 (PST) Date: Fri, 16 Jan 2026 10:34:01 +0100 In-Reply-To: <20260116093359.2442297-4-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260116093359.2442297-4-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1741; i=ardb@kernel.org; h=from:subject; bh=DUkB/GIoROOowZ3yMGbRxpDeWaywIuqMepfO7ycB2TA=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JITOLjeO/9crlrv6HHGMT1oTLXg3eZzZ7nocCV6f7nuPX/ H9kFH/pKGVhEONikBVTZBGY/ffdztMTpWqdZ8nCzGFlAhnCwMUpABOZvJThn2Lwjg8vrmw/smH9 xV9lbhIhKZINZ+5MZ7adumSKbY3FIyeG/3WHvRslAtJvO5p8KszUeGCoFxvEUeDP7nDx6+0uS5W J3AA= X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260116093359.2442297-5-ardb+git@google.com> Subject: [PATCH v2 1/2] mips: Add support for PC32 relocations in vmlinux From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , Nathan Chancellor , Nicolas Schier , Kees Cook , Thomas Bogendoerfer , linux-kbuild@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mips@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ard Biesheuvel MIPS supports PC32 relocations like most other architectures, which will be used by kallsyms to make its symbol references visible to the linker. Given that these are place-relative, they can be ignored by the 'relocs' tool, just like other PC type relocations. Cc: Thomas Bogendoerfer Signed-off-by: Ard Biesheuvel --- arch/mips/boot/tools/relocs.c | 2 ++ arch/mips/include/asm/elf.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/mips/boot/tools/relocs.c b/arch/mips/boot/tools/relocs.c index 9863e1d5c62e..30809f47415a 100644 --- a/arch/mips/boot/tools/relocs.c +++ b/arch/mips/boot/tools/relocs.c @@ -79,6 +79,7 @@ static const char *rel_type(unsigned type) REL_TYPE(R_MIPS_HIGHEST), REL_TYPE(R_MIPS_PC21_S2), REL_TYPE(R_MIPS_PC26_S2), + REL_TYPE(R_MIPS_PC32), #undef REL_TYPE }; const char *name =3D "unknown type rel type name"; @@ -522,6 +523,7 @@ static int do_reloc(struct section *sec, Elf_Rel *rel, = Elf_Sym *sym, case R_MIPS_PC16: case R_MIPS_PC21_S2: case R_MIPS_PC26_S2: + case R_MIPS_PC32: /* * NONE can be ignored and PC relative relocations don't * need to be adjusted. diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h index dc8d2863752c..aaef0eaa68d5 100644 --- a/arch/mips/include/asm/elf.h +++ b/arch/mips/include/asm/elf.h @@ -123,6 +123,8 @@ #define R_MIPS_LOVENDOR 100 #define R_MIPS_HIVENDOR 127 =20 +#define R_MIPS_PC32 248 + #define SHN_MIPS_ACCOMON 0xff00 /* Allocated common symbols */ #define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */ #define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */ --=20 2.52.0.457.g6b5491de43-goog From nobody Sun Feb 8 15:59:18 2026 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57B153570DF for ; Fri, 16 Jan 2026 09:34:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768556065; cv=none; b=V5sLITOy062q18B8muA8wGZb26JS1P2iIAgNy2vavJgplwPJFqzQf+Sdl89mRW/HYkt+KDCR91tq9f0wzvctQv4IBWG8VTnV5xyNd/VDLgrTUaIzY6V+MGmPzeYcJEWni7VohudKMoeFldQFsukz8hToKVf14Y9TMlRM0fKPo1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768556065; c=relaxed/simple; bh=NM6q4F+2pfcBZpE6P1Uc+XKD9LINZOumvQNalN1oIgQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=fWJBAUQTfbxtcN6Mj5mCOvnK+QTz8t0Bi/VSVf2+wRgIA78a6za3djGBphtlgY+FdROj8A0eHUWYemBLCUSJ3sg9Q6CPaLvWXdIL2FDeER+F6WecUTPm+l7zcwd7yvpy7WjYATh4q09fny9oVzq80bN4kTdxCe6DHEtX+V1m8bY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lzFJui4M; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lzFJui4M" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-43101a351c7so1588836f8f.2 for ; Fri, 16 Jan 2026 01:34:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768556062; x=1769160862; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Xv9mZehuSWKkpgnhRisn4d35nxKH/bJdH2uCguWaEG0=; b=lzFJui4Mw5H/414z3TduY3YIUTKQTjGP1MIH86qtIX8kBcxMG3ZtPJzSqEbb0/TnZM 8eaeRI5qnaGyzLdtLUCBh2wy1A47sq+86+zAA8JCJmASHBTM6U8STCGAV9YfUqKbA8pe G4WzjJ3GRqMBEMBRGAFxJFmLmCroWM6PvUHR1mwcAmZpir627OAr33azTM+Av2YIauV+ 9WPc/T+JNPm18A709Elnk2ZZcZcEx9eA0oXCGCVpuNdfTGBYq1wUYfo4HBibp0sBBf2/ uC3Mrbhcjhy+YUCHEWZkX+PnlMPAU+1SusqegcscqRvMMNQMu5Hgh0eiV2eXGIfVudzE 1I/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768556062; x=1769160862; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Xv9mZehuSWKkpgnhRisn4d35nxKH/bJdH2uCguWaEG0=; b=glk9IMnFjROM2bpaiTSb43i2ckdmscgePe/GPEuR9kFExCtTk5h7sTVOj5amrzlrUk MmrGnQNfRr+Y7Jse8LYKvPhVlLiRkfggNCpl1dXIdw7pUrJDcPv098SdM9sivFE1veWq HvVtMBaCw1jLZiCMs2sR0yy2/SFyYkNb/ZppVTy76DUumLQpxClzCowiVv9pkX6TBUKY cH2VghHNglLpZrGD9SI2yg+boaOj2+6fVOTh0BgGSeYoaqr0SuDVmPIVP/vQTMRc772T VHJ9ORR3riRy5/JMvjW0R4foJYxyu1WsCcAwwFHAxadUUriCdfB4DfnouiaaO2U5Du1l MfyQ== X-Gm-Message-State: AOJu0YzDf7yrjBZPzXG842a94GK6UJV4o1YVKlmHQ/d+J6P+NGkkQpRV qffvt+7FhR4qpN45AbKGQthQNbkCN9OK6ScCOUddroWIKXtNPKDL0qkAGJRbBGm6t9AGiAkiitJ WKPm+yGJNQVytLWSpU2vOrilu5Cxqa+bl4YUd13IaUkQ0c6XkJn14qs/En69JcgJuFCBsR5bIPl 17E0l70ked1C9zJRdm+JwSttGaCEJiI1dAtA== X-Received: from wrbcp41.prod.google.com ([2002:a05:6000:4029:b0:432:c0b9:b553]) (user=ardb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:238a:b0:432:e00b:8680 with SMTP id ffacd0b85a97d-43569bc54a2mr2781711f8f.31.1768556061745; Fri, 16 Jan 2026 01:34:21 -0800 (PST) Date: Fri, 16 Jan 2026 10:34:02 +0100 In-Reply-To: <20260116093359.2442297-4-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260116093359.2442297-4-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=8138; i=ardb@kernel.org; h=from:subject; bh=IzuRsXHQD94wcxsjT6y4DYYcBMPmDTwaoDoXh1QUfu4=; b=owGbwMvMwCVmkMcZplerG8N4Wi2JITOLjSPiQMaxrCMB6Uu8GkoEGs2PnZy9uGy2Zrt466nW3 Vs5J63rKGVhEONikBVTZBGY/ffdztMTpWqdZ8nCzGFlAhnCwMUpABMxOMvwTyVgneejezK/z7x+ FnKp9NvhrAAVm13sqauL5c9tYp8r5sXI0Jx//8dFnsUpV7l0r/nqf0kTf1Iz31bc13/5vMJnrA/ 5GAA= X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260116093359.2442297-6-ardb+git@google.com> Subject: [PATCH v2 2/2] kallsyms: Get rid of kallsyms relative base From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , Nathan Chancellor , Nicolas Schier , Kees Cook , Thomas Bogendoerfer , linux-kbuild@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mips@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ard Biesheuvel When the kallsyms relative base was introduced, per-CPU variable references on x86_64 SMP were implemented as offsets into the respective per-CPU region, rather than offsets relative to the location of the variable's template in the kernel image, which is how other architectures implement it. This required kallsyms to reason about the difference between the two, and the sign of the value in the kallsyms_offsets[] array was used to distinguish them. This meant that negative offsets were not permitted for ordinary variables, and so it was crucial that the relative base was chosen such that all offsets were positive numbers. This is no longer needed: instead, the offsets can simply be encoded as values in the range -/+ 2 GiB, which is precisely what PC32 relocations provide on most architectures. So it is possible to simplify the logic, and just use _text as the anchor directly, and let the linker calculate the final value based on the location of the entry itself. Some architectures (nios2, extensa) do not support place-relative relocations at all, but these are all 32-bit and non-relocatable, and so there is no need for place-relative relocations in the first place, and the actual symbol values can just be stored directly. This makes all entries in the kallsyms_offsets[] array visible as place-relative references in the ELF metadata, which will be important when implementing ELF-based fg-kaslr. Reviewed-by: Kees Cook Signed-off-by: Ard Biesheuvel --- kernel/kallsyms.c | 6 +- kernel/kallsyms_internal.h | 1 - kernel/vmcore_info.c | 1 - scripts/kallsyms.c | 64 ++++++-------------- scripts/link-vmlinux.sh | 4 ++ tools/perf/tests/vmlinux-kallsyms.c | 1 - 6 files changed, 25 insertions(+), 52 deletions(-) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 049e296f586c..6125724aadb1 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -151,8 +151,10 @@ static unsigned int get_symbol_offset(unsigned long po= s) =20 unsigned long kallsyms_sym_address(int idx) { - /* values are unsigned offsets */ - return kallsyms_relative_base + (u32)kallsyms_offsets[idx]; + /* non-relocatable 32-bit kernels just embed the value directly */ + if (!IS_ENABLED(CONFIG_64BIT) && !IS_ENABLED(CONFIG_RELOCATABLE)) + return (u32)kallsyms_offsets[idx]; + return (unsigned long)offset_to_ptr(kallsyms_offsets + idx); } =20 static unsigned int get_symbol_seq(int index) diff --git a/kernel/kallsyms_internal.h b/kernel/kallsyms_internal.h index 9633782f8250..81a867dbe57d 100644 --- a/kernel/kallsyms_internal.h +++ b/kernel/kallsyms_internal.h @@ -8,7 +8,6 @@ extern const int kallsyms_offsets[]; extern const u8 kallsyms_names[]; =20 extern const unsigned int kallsyms_num_syms; -extern const unsigned long kallsyms_relative_base; =20 extern const char kallsyms_token_table[]; extern const u16 kallsyms_token_index[]; diff --git a/kernel/vmcore_info.c b/kernel/vmcore_info.c index fe9bf8db1922..f114719f6cb5 100644 --- a/kernel/vmcore_info.c +++ b/kernel/vmcore_info.c @@ -238,7 +238,6 @@ static int __init crash_save_vmcoreinfo_init(void) VMCOREINFO_SYMBOL(kallsyms_token_table); VMCOREINFO_SYMBOL(kallsyms_token_index); VMCOREINFO_SYMBOL(kallsyms_offsets); - VMCOREINFO_SYMBOL(kallsyms_relative_base); #endif /* CONFIG_KALLSYMS */ =20 arch_crash_save_vmcoreinfo(); diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 4b0234e4b12f..37d5c095ad22 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -46,7 +46,6 @@ struct addr_range { }; =20 static unsigned long long _text; -static unsigned long long relative_base; static struct addr_range text_ranges[] =3D { { "_stext", "_etext" }, { "_sinittext", "_einittext" }, @@ -57,6 +56,7 @@ static struct addr_range text_ranges[] =3D { static struct sym_entry **table; static unsigned int table_size, table_cnt; static int all_symbols; +static int pc_relative; =20 static int token_profit[0x10000]; =20 @@ -280,7 +280,7 @@ static void read_map(const char *in) static void output_label(const char *label) { printf(".globl %s\n", label); - printf("\tALGN\n"); + printf("\t.balign 4\n"); printf("%s:\n", label); } =20 @@ -343,15 +343,6 @@ static void write_src(void) unsigned int *markers, markers_cnt; char buf[KSYM_NAME_LEN]; =20 - printf("#include \n"); - printf("#if BITS_PER_LONG =3D=3D 64\n"); - printf("#define PTR .quad\n"); - printf("#define ALGN .balign 8\n"); - printf("#else\n"); - printf("#define PTR .long\n"); - printf("#define ALGN .balign 4\n"); - printf("#endif\n"); - printf("\t.section .rodata, \"a\"\n"); =20 output_label("kallsyms_num_syms"); @@ -434,34 +425,24 @@ static void write_src(void) output_label("kallsyms_offsets"); =20 for (i =3D 0; i < table_cnt; i++) { - /* - * Use the offset relative to the lowest value - * encountered of all relative symbols, and emit - * non-relocatable fixed offsets that will be fixed - * up at runtime. - */ - - long long offset; - - offset =3D table[i]->addr - relative_base; - if (offset < 0 || offset > UINT_MAX) { - fprintf(stderr, "kallsyms failure: " - "relative symbol value %#llx out of range\n", - table[i]->addr); - exit(EXIT_FAILURE); + if (pc_relative) { + long long offset =3D table[i]->addr - _text; + + if (offset < INT_MIN || offset > INT_MAX) { + fprintf(stderr, "kallsyms failure: " + "relative symbol value %#llx out of range\n", + table[i]->addr); + exit(EXIT_FAILURE); + } + printf("\t.long\t_text - . + (%d)\t/* %s */\n", + (int)offset, table[i]->sym); + } else { + printf("\t.long\t%#x\t/* %s */\n", + (unsigned int)table[i]->addr, table[i]->sym); } - printf("\t.long\t%#x\t/* %s */\n", (int)offset, table[i]->sym); } printf("\n"); =20 - output_label("kallsyms_relative_base"); - /* Provide proper symbols relocatability by their '_text' relativeness. */ - if (_text <=3D relative_base) - printf("\tPTR\t_text + %#llx\n", relative_base - _text); - else - printf("\tPTR\t_text - %#llx\n", _text - relative_base); - printf("\n"); - sort_symbols_by_name(); output_label("kallsyms_seqs_of_names"); for (i =3D 0; i < table_cnt; i++) @@ -701,22 +682,12 @@ static void sort_symbols(void) qsort(table, table_cnt, sizeof(table[0]), compare_symbols); } =20 -/* find the minimum non-absolute symbol address */ -static void record_relative_base(void) -{ - /* - * The table is sorted by address. - * Take the first symbol value. - */ - if (table_cnt) - relative_base =3D table[0]->addr; -} - int main(int argc, char **argv) { while (1) { static const struct option long_options[] =3D { {"all-symbols", no_argument, &all_symbols, 1}, + {"pc-relative", no_argument, &pc_relative, 1}, {}, }; =20 @@ -734,7 +705,6 @@ int main(int argc, char **argv) read_map(argv[optind]); shrink_table(); sort_symbols(); - record_relative_base(); optimize_token_table(); write_src(); =20 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 4ab44c73da4d..73531cb63efc 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -143,6 +143,10 @@ kallsyms() kallsymopt=3D"${kallsymopt} --all-symbols" fi =20 + if is_enabled CONFIG_64BIT || is_enabled CONFIG_RELOCATABLE; then + kallsymopt=3D"${kallsymopt} --pc-relative" + fi + info KSYMS "${2}.S" scripts/kallsyms ${kallsymopt} "${1}" > "${2}.S" =20 diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux= -kallsyms.c index 74cdbd2ce9d0..524d46478364 100644 --- a/tools/perf/tests/vmlinux-kallsyms.c +++ b/tools/perf/tests/vmlinux-kallsyms.c @@ -27,7 +27,6 @@ static bool is_ignored_symbol(const char *name, char type) * stable symbol list. */ "kallsyms_offsets", - "kallsyms_relative_base", "kallsyms_num_syms", "kallsyms_names", "kallsyms_markers", --=20 2.52.0.457.g6b5491de43-goog