From patchwork Wed Mar 30 12:48:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 842 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:46:21 -0000 Delivered-To: patches@linaro.org Received: by 10.42.161.68 with SMTP id s4cs45295icx; Wed, 30 Mar 2011 05:49:03 -0700 (PDT) Received: by 10.213.4.143 with SMTP id 15mr247184ebr.9.1301489342271; Wed, 30 Mar 2011 05:49:02 -0700 (PDT) Received: from mail-wy0-f178.google.com (mail-wy0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id s8si125680eeh.88.2011.03.30.05.49.00 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 30 Mar 2011 05:49:01 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of dave.martin@linaro.org) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of dave.martin@linaro.org) smtp.mail=dave.martin@linaro.org Received: by wyb33 with SMTP id 33so1240438wyb.37 for ; Wed, 30 Mar 2011 05:49:00 -0700 (PDT) Received: by 10.227.199.68 with SMTP id er4mr1222359wbb.47.1301489339895; Wed, 30 Mar 2011 05:48:59 -0700 (PDT) Received: from e200948.peterhouse.linaro.org (fw-lnat.cambridge.arm.com [217.140.96.63]) by mx.google.com with ESMTPS id b20sm31636wbb.50.2011.03.30.05.48.56 (version=SSLv3 cipher=OTHER); Wed, 30 Mar 2011 05:48:58 -0700 (PDT) From: Dave Martin To: patches@arm.linux.org.uk Cc: patches@linaro.org, Dave Martin Subject: [PATCH] ARM: Thumb-2: Add local symbols to work around gas behaviour Date: Wed, 30 Mar 2011 13:48:49 +0100 Message-Id: <1301489330-4438-1-git-send-email-dave.martin@linaro.org> X-Mailer: git-send-email 1.7.1 All current versions of gas at the time of writing have issues fixing up pc-relative instructions which reference global symbols, due to the potential need to support symbol preemption. Even though symbol preemption is not relevant to the Linux kernel, there is no way to inform the tools of this, so we get the problem. Most pc-relative forms in ARM, and all pc-relative forms in Thumb, will cause the assembler to fail with various fixup error messages when used to reference global symbols. The legacy behaviour is for ADR and plain LDR instructions in ARM which reference global symbols to be fixed up silently with no relocation emitted. This means that building the kernel in ARM currently works without problems, but this behaviour may be a bug. After discussion with Richard Earnshaw, it seems that there is no single obvious remedy for this inconsistent behaviour, so I conclude that there is not likely to be a comprehensive upstream fix for a while. A workaround which should be valid for all past and all foreseeable future versions of gas is to express the need for a local fixup explicitly, by declaring a shadow local symbol for any global symbol which needs to be addressed using ADR or any pc-relative LDR variant. This patch implements this workaround for the one part of the main kernel currently known to be affected. The resulting code builds and works correctly in ARM and Thumb. Similar fixes may be needed in mach-specific assembler. Signed-off-by: Dave Martin Acked-by: Nicolas Pitre --- KernelVersion: v2.6.38 diff --git a/arch/arm/kernel/relocate_kernel.S b/arch/arm/kernel/relocate_kernel.S index 9cf4cbf..302f589 100644 --- a/arch/arm/kernel/relocate_kernel.S +++ b/arch/arm/kernel/relocate_kernel.S @@ -7,8 +7,8 @@ .globl relocate_new_kernel relocate_new_kernel: - ldr r0,kexec_indirection_page - ldr r1,kexec_start_address + ldr r0,.L_kexec_indirection_page + ldr r1,.L_kexec_start_address /* * If there is no indirection page (we are doing crashdumps) @@ -55,27 +55,31 @@ relocate_new_kernel: /* Jump to relocated kernel */ mov lr,r1 mov r0,#0 - ldr r1,kexec_mach_type - ldr r2,kexec_boot_atags + ldr r1,.L_kexec_mach_type + ldr r2,.L_kexec_boot_atags mov pc,lr .align .globl kexec_start_address kexec_start_address: +.L_kexec_start_address: .long 0x0 .globl kexec_indirection_page kexec_indirection_page: +.L_kexec_indirection_page: .long 0x0 .globl kexec_mach_type kexec_mach_type: +.L_kexec_mach_type: .long 0x0 /* phy addr of the atags for the new kernel */ .globl kexec_boot_atags kexec_boot_atags: +.L_kexec_boot_atags: .long 0x0 relocate_new_kernel_end: