From patchwork Tue Jul 1 09:46:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 1832 Received: (qmail 13868 invoked by alias); 1 Jul 2014 09:46:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 13820 invoked by uid 89); 1 Jul 2014 09:46:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Jul 2014 09:46:20 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1X1udl-0005bN-4L from Luis_Gustavo@mentor.com for gdb-patches@sourceware.org; Tue, 01 Jul 2014 02:46:17 -0700 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 1 Jul 2014 02:46:16 -0700 Received: from [172.30.72.106] (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.2.247.3; Tue, 1 Jul 2014 02:46:12 -0700 Message-ID: <53B28365.1010508@codesourcery.com> Date: Tue, 1 Jul 2014 11:46:13 +0200 From: Luis Machado Reply-To: User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "'gdb-patches@sourceware.org'" Subject: [PATCH] Fix gdb.base/code_elim.exp failures for PowerPC 32-bit X-IsSubscribed: yes Hi, Another case of slight variations between targets and compiler options. gdb.base/code_elim.exp assumes the linker generates the same sections for all architectures. For x86, this works fine and the testcase binary code_elim2 contains the .data section to hold our initialized global int variable. For PowerPC 32-bit though, the small initialized global int variable is sent to the .sdata section as an optimization. Since there is no more data to store, the .data section doesn't get created. GDB complains about the lack of such a section and expect doesn't like seeing that warning, which results in a couple failures for powerpc. One of them: [snip] add-symbol-file gdb.base/code_elim2 0x200000 -s .data 0x210000 -s .bss 0x220000^M add symbol table from file "gdb.d/gdb.base/code_elim2" at^M .text_addr = 0x200000^M .data_addr = 0x210000^M .bss_addr = 0x220000^M (y or n) y^M Reading symbols from gdb.base/code_elim2...warning: section .data not found in gdb.base/code_elim2^M done.^M (gdb) FAIL: gdb.base/code_elim.exp: order1: add-symbol-file code_elim2 0x200000 I have tweaked the testcase sources a little to hold a bigger initialized global variable, forcing the linker to create a regular .data section in order to prevent GDB's warning. The testcase still runs fine, but now PowerPC 32-bit sees full passes on this one. I thought about tweaking the optimization options, but that would need to be target-specific, which is more cumbersome. Luis 2014-07-01 Luis Machado * gdb.base/code_elim2.c (my_global_array): New global variable. (my_global_func): Use global variable. diff --git a/gdb/testsuite/gdb.base/code_elim2.c b/gdb/testsuite/gdb.base/code_elim2.c index 64ecc04..3eb8d5c 100644 --- a/gdb/testsuite/gdb.base/code_elim2.c +++ b/gdb/testsuite/gdb.base/code_elim2.c @@ -15,6 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +/* Declare a global variable of reasonable size to make sure the .data section + is created, preventing a warning from GDB when manually loading symbols. */ +int my_global_array[6] = {4, 8, 15, 16, 23, 42}; int my_global_symbol = 42; static int my_static_symbol; @@ -28,7 +31,7 @@ main () int my_global_func () { - my_static_symbol = my_global_symbol; - my_global_symbol = my_static_symbol + my_global_symbol; + my_static_symbol = my_global_symbol + my_global_array[6]; + my_global_symbol = my_static_symbol + my_global_symbol + my_global_array[3]; return my_global_symbol; }