From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 73371 invoked by alias); 5 Jan 2016 16:43:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 72636 invoked by uid 89); 5 Jan 2016 16:43:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=943, 0x10, msp, 2696 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 05 Jan 2016 16:43:37 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 59E338E222; Tue, 5 Jan 2016 16:43:36 +0000 (UTC) Received: from [10.36.4.151] (vpn1-4-151.ams2.redhat.com [10.36.4.151]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u05GhYHc022247 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 5 Jan 2016 11:43:35 -0500 Subject: Re: MSP430 SIM: Add support for hardware multiply To: vapier@gentoo.org References: <87zjislnam.fsf@redhat.com> <20151225002204.GQ25803@vapier.lan> Cc: gdb-patches@sourceware.org, binutils@sourceware.org From: Nick Clifton Message-ID: <568BF2B6.2090201@redhat.com> Date: Tue, 05 Jan 2016 16:43:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <20151225002204.GQ25803@vapier.lan> Content-Type: multipart/mixed; boundary="------------020904000005060606060704" X-SW-Source: 2016-01/txt/msg00058.txt.bz2 This is a multi-part message in MIME format. --------------020904000005060606060704 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1956 Hi Mike, >> I am applying the attached patch to add support for simulating the >> hardware multiply feature found on some MSP430 MCUs. > this broke the testsuite: > FAIL: msp430 add.s (execution) Actually, as far as I can see this test never should have worked in the first place. The problem is that the test harness code (in testutils.inc) assumes that the VMA and LMA addresses of the .data section are the same. This is not the case (at least for the msp430), and without runtime code to copy data from the LMA address to the VMA address all the data addresses in the test executables are wrong. So, I am checking in the following two patches. The first patch updates the linker's built in link script so that it does not place data into the msp430's hardware address range, and so that that it provides a symbol (__romdatastart) with the LMA address of the .data section. [Note - as far as I can see only the sim tests actually use the linker's built in linker script. Everyone else uses scripts explicitly provided on the linker command line]. The second patch updates the testutils.inc file so that it will use the LMA addresses of the strings in the .data section not the VMA addresses. This makes the tests work, although it is a bit of a hack. A proper solution would be to provide start-up code that copies the data from the LMA address to the VMA address before the test proper runs, but this seems like overkill to me. Cheers Nick ld/ChangeLog 2016-01-05 Nick Clifton * emulparams/msp430elf.sh (RAM_START): Move to 0x500 - above the MSP430 hardware multiply address range. * scripttempl/elf32msp430.sc (__romdatastart): Define. (__romdatacopysize): Define. * scripttempl/elf32msp430_3.sc: Likewise. sim/testsuite/sim/msp430/ChangeLog 2016-01-05 Nick Clifton * testutils.inc (__pass): Use the LMA addresses of the _passmsg symbol. (__fail): Likewise. --------------020904000005060606060704 Content-Type: text/x-patch; name="msp430.sim.test.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="msp430.sim.test.patch" Content-length: 1546 diff --git a/sim/testsuite/sim/msp430/testutils.inc b/sim/testsuite/sim/msp430/testutils.inc index 6c540b1..1ddef23 100644 --- a/sim/testsuite/sim/msp430/testutils.inc +++ b/sim/testsuite/sim/msp430/testutils.inc @@ -9,13 +9,43 @@ .global __pass .type __pass, function __pass: - write 1, _passmsg, 5 + # Note - we cannot just invoke: + # + # write 1, _passmsg, 5 + # + # here because _passmsg contains the run-time (VMA) address of + # the pass string (probably 0x500) not the load-time (LMA) + # address (probably 0x804c). Normally using the VMA address + # would be the correct thing to do - *if* there was some start + # up code which copied data from LMA to VMA. But we have no + # start up code, so the data still resides at the LMA + # address. Hence we use __romdatastart instead. + # + # Note - we are cheating because the address that we pass to + # "write" should actually be: + # + # __romdatastart + (_passmsg - __datastart) + # + # but the assembler cannot cope with this expression. So we + # cheat and use the fact that we know that _passmsg is the + # first string in the .data section and so (_passmsg - + # __datastart) evaluates to zero. + + write 1, __romdatastart, 5 exit 0 .global __fail .type __fail, function __fail: - write 1, _failmsg, 5 + # Note - see above. + # + # write 1, _failmsg, 5 + # + # This time we use the fact that _passmsg is aligned to a + # 16 byte boundary to work out that (_failmsg - __datastart) + # evaluates to 0x10. + + write 1, __romdatastart + 0x10, 5 exit 1 .data --------------020904000005060606060704 Content-Type: text/x-patch; name="msp430.ld-scripts.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="msp430.ld-scripts.patch" Content-length: 1240 diff --git a/ld/emulparams/msp430elf.sh b/ld/emulparams/msp430elf.sh index a76e9ee..e9d0237 100644 --- a/ld/emulparams/msp430elf.sh +++ b/ld/emulparams/msp430elf.sh @@ -13,6 +13,6 @@ EMBEDDED=yes ARCH=msp:14 ROM_START=0x8000 ROM_SIZE=0x7fe0 -RAM_START=0x0200 +RAM_START=0x0500 RAM_SIZE=1K STACK=0x600 diff --git a/ld/scripttempl/elf32msp430.sc b/ld/scripttempl/elf32msp430.sc index 78c7c12..50b7ddb 100644 --- a/ld/scripttempl/elf32msp430.sc +++ b/ld/scripttempl/elf32msp430.sc @@ -269,6 +269,9 @@ SECTIONS ${RELOCATING+ _edata = . ; } } ${RELOCATING+ > data ${RELOCATING+AT> text}} + __romdatastart = LOADADDR(.data); + __romdatacopysize = SIZEOF(.data); + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : { ${RELOCATING+. = ALIGN(2);} diff --git a/ld/scripttempl/elf32msp430_3.sc b/ld/scripttempl/elf32msp430_3.sc index 7a13081..7ad04e1 100644 --- a/ld/scripttempl/elf32msp430_3.sc +++ b/ld/scripttempl/elf32msp430_3.sc @@ -147,6 +147,9 @@ SECTIONS ${RELOCATING+ _edata = . ; } } ${RELOCATING+ > data ${RELOCATING+AT> text}} + __romdatastart = LOADADDR(.data); + __romdatacopysize = SIZEOF(.data); + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : { ${RELOCATING+. = ALIGN(2);} --------------020904000005060606060704--