From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752135AbbGJVs6 (ORCPT ); Fri, 10 Jul 2015 17:48:58 -0400 Received: from blu004-omc1s13.hotmail.com ([65.55.116.24]:50691 "EHLO BLU004-OMC1S13.hotmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751307AbbGJVsw (ORCPT ); Fri, 10 Jul 2015 17:48:52 -0400 X-TMN: [u04e6mdcijjmUvRBelLLMUA50HYVWcyi] X-Originating-Email: [xili_gchen_5257@hotmail.com] Message-ID: Date: Sat, 11 Jul 2015 05:50:07 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: starvik@axis.com, jesper.nilsson@axis.com CC: "linux-cris-kernel@axis.com" , "linux-kernel@vger.kernel.org" , Hans-Peter Nilsson Subject: [PATCH v2] cris: arch-v10: kgdb: Add volatile for static variable is_dyn_brkp Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 10 Jul 2015 21:48:50.0171 (UTC) FILETIME=[34D724B0:01D0BB5A] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Within one C file, current gcc can optimize the global static variables according to the C code, but it will skip assembly code -- it will pass them to gas directly. if the static variable is used between C code and assembly code in one C file (e.g. is_dyn_brkp in kgdb.c), it needs volatile to let gcc know it should not be optimized, or it may cause issue. The related error in this case: LD init/built-in.o arch/cris/arch-v10/kernel/built-in.o: In function `kgdb_handle_breakpoint': (.text+0x2aca): undefined reference to `is_dyn_brkp' arch/cris/arch-v10/kernel/built-in.o: In function `is_static': kgdb.c:(.text+0x2ada): undefined reference to `is_dyn_brkp' Signed-off-by: Chen Gang --- arch/cris/arch-v10/kernel/kgdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c index 5b61335..8faddd3 100644 --- a/arch/cris/arch-v10/kernel/kgdb.c +++ b/arch/cris/arch-v10/kernel/kgdb.c @@ -351,7 +351,7 @@ char internal_stack[INTERNAL_STACK_SIZE]; breakpoint to be handled. A static breakpoint uses the content of register BRP as it is whereas a dynamic breakpoint requires subtraction with 2 in order to execute the instruction. The first breakpoint is static. */ -static unsigned char is_dyn_brkp = 0; +static volatile unsigned char is_dyn_brkp; /********************************* String library ****************************/ /* Single-step over library functions creates trap loops. */ -- 1.9.3