[ARM,sim] Fix build error and warnings

Message ID 20191126191014.13576-1-luis.machado@linaro.org
State New
Headers show
Series
  • [ARM,sim] Fix build error and warnings
Related show

Commit Message

Luis Machado Nov. 26, 2019, 7:10 p.m.
Newer GCC's have switched to -fno-common by default, and this breaks the build
for the ARM sim, like this:

binutils-gdb.git~gdb-8.3-release/sim/arm/maverick.c:65: multiple definition of `DSPsc'; libsim.a(wrapper.o):binutils-gdb.git~gdb-8.3-release/sim/arm/wrapper.c:134: first defined here
binutils-gdb.git~gdb-8.3-release/sim/arm/maverick.c:64: multiple definition of `DSPacc'; libsim.a(wrapper.o):binutils-gdb.git~gdb-8.3-release/sim/arm/wrapper.c:133: first defined here
binutils-gdb.git~gdb-8.3-release/sim/arm/maverick.c:63: multiple definition of `DSPregs'; libsim.a(wrapper.o):binutils-gdb.git~gdb-8.3-release/sim/arm/wrapper.c:132: first defined here

I also noticed a few warnings due to mismatching types, as follows:

binutils-gdb/sim/arm/wrapper.c:870:31: warning: passing argument 1 of ‘sim_target_parse_arg_array’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  sim_target_parse_arg_array (argv);

binutils-gdb/sim/arm/wrapper.c:775:1: note: expected ‘char **’ but argument is of type ‘char * const*’
  sim_target_parse_arg_array (char ** argv)

The following patch fixes both of the above.

OK for trunk?

sim/arm/ChangeLog:

2019-11-26  Luis Machado  <luis.machado@linaro.org>

	* armemu.c (isize): Move this declaration ...
	* arminit.c (isize): ... here.
	* wrapper.c (DSPregs): Make extern.
	(DSPacc): Likewise.
	(DSPsc): Likewise.
	(sim_create_inferior): Cast variables to proper type.

Signed-off-by: Luis Machado <luis.machado@linaro.org>

Change-Id: I21db699d3b61b2de8c44053e47be4387285af28f
---
 sim/arm/armemu.c  |  4 ----
 sim/arm/arminit.c |  4 ++++
 sim/arm/wrapper.c | 10 +++++-----
 3 files changed, 9 insertions(+), 9 deletions(-)

-- 
2.17.1

Comments

Alan Modra Nov. 27, 2019, 4:26 a.m. | #1
On Tue, Nov 26, 2019 at 04:10:14PM -0300, Luis Machado wrote:
> The following patch fixes both of the above.


Hi Luis, sim is part of gdb.  Patches should go to
gdb-patches@sourceware.org

-- 
Alan Modra
Australia Development Lab, IBM
Luis Machado Nov. 27, 2019, 12:12 p.m. | #2
On 11/27/19 1:26 AM, Alan Modra wrote:
> On Tue, Nov 26, 2019 at 04:10:14PM -0300, Luis Machado wrote:

>> The following patch fixes both of the above.

> 

> Hi Luis, sim is part of gdb.  Patches should go to

> gdb-patches@sourceware.org

> 


Oops. For some reason i thought the simulator was part of binutils. I'll 
send it to the right place. Thanks Alan.

Patch

diff --git a/sim/arm/armemu.c b/sim/arm/armemu.c
index 76f398b3d7..3a72277683 100644
--- a/sim/arm/armemu.c
+++ b/sim/arm/armemu.c
@@ -1140,10 +1140,6 @@  handle_VFP_move (ARMul_State * state, ARMword instr)
 
 /* EMULATION of ARM6.  */
 
-/* The PC pipeline value depends on whether ARM
-   or Thumb instructions are being executed.  */
-ARMword isize;
-
 ARMword
 #ifdef MODE32
 ARMul_Emulate32 (ARMul_State * state)
diff --git a/sim/arm/arminit.c b/sim/arm/arminit.c
index 851d3567e1..3a626c8467 100644
--- a/sim/arm/arminit.c
+++ b/sim/arm/arminit.c
@@ -40,6 +40,10 @@  unsigned ARMul_MultTable[32] =
 ARMword ARMul_ImmedTable[4096];	/* immediate DP LHS values */
 char ARMul_BitList[256];	/* number of bits in a byte table */
 
+/* The PC pipeline value depends on whether ARM
+   or Thumb instructions are being executed.  */
+ARMword isize;
+
 /***************************************************************************\
 *         Call this routine once to set up the emulator's tables.           *
 \***************************************************************************/
diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c
index fde5d8c326..9f86e089a1 100644
--- a/sim/arm/wrapper.c
+++ b/sim/arm/wrapper.c
@@ -129,9 +129,9 @@  union maverick_acc_regs
   long double ld;		/* Acc registers are 72-bits.  */
 };
 
-struct maverick_regs     DSPregs[16];
-union maverick_acc_regs  DSPacc[4];
-ARMword DSPsc;
+extern struct maverick_regs     DSPregs[16];
+extern union maverick_acc_regs  DSPacc[4];
+extern ARMword DSPsc;
 
 static void
 init (void)
@@ -236,7 +236,7 @@  sim_create_inferior (SIM_DESC sd ATTRIBUTE_UNUSED,
 {
   int argvlen = 0;
   int mach;
-  char **arg;
+  char * const *arg;
 
   init ();
 
@@ -867,7 +867,7 @@  sim_open (SIM_OPEN_KIND kind,
 
   sim_callback = cb;
 
-  sim_target_parse_arg_array (argv);
+  sim_target_parse_arg_array ((char **) argv);
 
   if (argv[1] != NULL)
     {