public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/2] gdb/testsuite: allow gdb.base/overlays.exp to compile for m32r
Date: Fri, 18 Sep 2020 19:17:34 +0100	[thread overview]
Message-ID: <c1117e74bd4b53037abf0ea680dbab82b990ae34.1600452947.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1600452947.git.andrew.burgess@embecosm.com>

The gdb.base/overlays.exp test is only currently supported on m32r
baremetal targets, however, when I configure a toolchain for m32r-elf
the test does not compile.

This commit updates the linker script, fixes some TCL errors in the
exp file, and adds some missing includes to the source file so that
the test does compile.

With this test, when run against an m32r-elf toolchain the test mostly
passes, but there are a couple of failures, these are GDB issues and
will be addressed in a later commit.

gdb/testsuite/ChangeLog:

	* gdb.base/m32r.ld: Remove SEARCH_DIR line.  Add MEMORY regions,
	make use of regions throughout.
	* gdb.base/overlays.exp: Enclose string with variableds in "..",
	not {...}.
	* gdb.base/ovlymgr.c: Add 'string.h' and 'stdlib.h' includes.
---
 gdb/testsuite/ChangeLog             |  8 +++
 gdb/testsuite/gdb.base/m32r.ld      | 84 ++++++++++++++++-------------
 gdb/testsuite/gdb.base/overlays.exp |  2 +-
 gdb/testsuite/gdb.base/ovlymgr.c    |  2 +
 4 files changed, 58 insertions(+), 38 deletions(-)

diff --git a/gdb/testsuite/gdb.base/m32r.ld b/gdb/testsuite/gdb.base/m32r.ld
index b96077adb6a..3358f4ce7fa 100644
--- a/gdb/testsuite/gdb.base/m32r.ld
+++ b/gdb/testsuite/gdb.base/m32r.ld
@@ -2,34 +2,43 @@ OUTPUT_FORMAT("elf32-m32r", "elf32-m32r",
 	      "elf32-m32r")
 OUTPUT_ARCH(m32r)
 ENTRY(_start)
- SEARCH_DIR(/usr/cygnus/m32r-961018/H-sparc-sun-sunos4.1//lib);
+
+MEMORY
+{
+  RAM : ORIGIN = 0x208000, LENGTH = 0x100000
+  OVLY_1 : ORIGIN = 0x300000, LENGTH = 0x40000
+  OVLY_2 : ORIGIN = 0x340000, LENGTH = 0x40000
+  OVLY_3 : ORIGIN = 0x380000, LENGTH = 0x40000
+  OVLY_4 : ORIGIN = 0x3c0000, LENGTH = 0x40000
+  OVLY_STORAGE : ORIGIN = 0x400000, LENGTH = 0x100000
+}
+
 /* Do we need any of these for elf?
    __DYNAMIC = 0;    */
 SECTIONS
 {
-     OVERLAY 0x300000 : AT (0x400000)
-        {
-          .ovly0 { foo.o(.text) }
-          .ovly1 { bar.o(.text) }
-        }
-     OVERLAY 0x380000 : AT (0x480000)
-        {
-          .ovly2 { baz.o(.text) }
-          .ovly3 { grbx.o(.text) }
-        }
-     OVERLAY 0x340000 : AT (0x440000)
-        {
-          .data00 { foo.o(.data) }
-          .data01 { bar.o(.data) }
-        }
-     OVERLAY 0x3C0000 : AT (0x4C0000)
-        {
-          .data02 { baz.o(.data) }
-          .data03 { grbx.o(.data) }
-        }
+   OVERLAY :
+      {
+        .ovly0 { */overlays2.o(.text) }
+        .ovly1 { */overlays3.o(.text) }
+      } >OVLY_1 AT>OVLY_STORAGE
+   OVERLAY :
+      {
+        .ovly2 { */overlays4.o(.text) }
+        .ovly3 { */overlays5.o(.text) }
+      } >OVLY_3 AT>OVLY_STORAGE
+   OVERLAY :
+      {
+        .data00 { */overlays2.o(.data) }
+        .data01 { */overlays3.o(.data) }
+      } >OVLY_2 AT>OVLY_STORAGE
+   OVERLAY :
+      {
+        .data02 { */overlays4.o(.data) }
+        .data03 { */overlays5.o(.data) }
+      } >OVLY_4 AT>OVLY_STORAGE
 
   /* Read-only sections, merged into text segment: */
-  . = 0x208000;
   .interp        : { *(.interp) 	}
   .hash          : { *(.hash)		}
   .dynsym        : { *(.dynsym)		}
@@ -54,20 +63,21 @@ SECTIONS
   .rela.bss      : { *(.rela.bss)	}
   .rel.plt       : { *(.rel.plt)	}
   .rela.plt      : { *(.rela.plt)	}
-  .init          : { *(.init)		} =0
-  .plt           : { *(.plt)		}
+  .init          : { *(.init)		} >RAM AT>RAM =0
+  .plt           : { *(.plt)		} >RAM AT>RAM
+
   .text          :
   {
     *(.text)
     /* .gnu.warning sections are handled specially by elf32.em.  */
     *(.gnu.warning)
     *(.gnu.linkonce.t*)
-  } =0
+  } >RAM AT>RAM =0
   _etext = .;
   PROVIDE (etext = .);
-  .fini          : { *(.fini)		} =0
-  .rodata        : { *(.rodata) *(.gnu.linkonce.r*) }
-  .rodata1       : { *(.rodata1)	}
+  .fini          : { *(.fini)		} >RAM AT>RAM =0
+  .rodata        : { *(.rodata) *(.gnu.linkonce.r*) } >RAM AT>RAM
+  .rodata1       : { *(.rodata1)	} >RAM AT>RAM
   /* Adjust the address for the data segment.  We want to adjust up to
      the same address within the page on the next page up.  */
   . = ALIGN(32) + (ALIGN(8) & (32 - 1));
@@ -120,21 +130,21 @@ SECTIONS
 	LONG((_novlys - _ovly_table) / 16);
 
     CONSTRUCTORS
-  }
-  .data1         : { *(.data1)		}
-  .ctors         : { *(.ctors)		}
-  .dtors         : { *(.dtors)		}
-  .got           : { *(.got.plt) *(.got)}
-  .dynamic       : { *(.dynamic)	}
+  } >RAM AT>RAM
+  .data1         : { *(.data1)		} >RAM AT>RAM
+  .ctors         : { *(.ctors)		} >RAM AT>RAM
+  .dtors         : { *(.dtors)		} >RAM AT>RAM
+  .got           : { *(.got.plt) *(.got)} >RAM AT>RAM
+  .dynamic       : { *(.dynamic)	} >RAM AT>RAM
   /* We want the small data sections together, so single-instruction offsets
      can access them all, and initialized data all before uninitialized, so
      we can shorten the on-disk segment size.  */
-  .sdata         : { *(.sdata)		}
+  .sdata         : { *(.sdata)		} >RAM AT>RAM
   _edata  =  .;
   PROVIDE (edata = .);
   __bss_start = .;
-  .sbss          : { *(.sbss) *(.scommon) }
-  .bss           : { *(.dynbss) *(.bss) *(COMMON) }
+  .sbss          : { *(.sbss) *(.scommon) } >RAM AT>RAM
+  .bss           : { *(.dynbss) *(.bss) *(COMMON) } >RAM AT>RAM
   _end = . ;
   PROVIDE (end = .);
   /* Stabs debugging sections.  */
diff --git a/gdb/testsuite/gdb.base/overlays.exp b/gdb/testsuite/gdb.base/overlays.exp
index 7ebb77695b3..248379e25eb 100644
--- a/gdb/testsuite/gdb.base/overlays.exp
+++ b/gdb/testsuite/gdb.base/overlays.exp
@@ -38,7 +38,7 @@ standard_testfile overlays.c ovlymgr.c foo.c bar.c baz.c grbx.c
 
 if {[build_executable $testfile.exp $testfile \
 	 [list $srcfile $srcfile2 $srcfile3 $srcfile4 $srcfile5 $srcfile6] \
-	 {debug ldscript=-Wl,-T$linker_script}] == -1} {
+	 "debug ldscript=-Wl,-T$linker_script"] == -1} {
      untested "failed to compile"
      return -1
 }
diff --git a/gdb/testsuite/gdb.base/ovlymgr.c b/gdb/testsuite/gdb.base/ovlymgr.c
index 5d087ad90a2..262c2a61f02 100644
--- a/gdb/testsuite/gdb.base/ovlymgr.c
+++ b/gdb/testsuite/gdb.base/ovlymgr.c
@@ -4,6 +4,8 @@
  */
 
 #include "ovlymgr.h"
+#include <string.h>
+#include <stdlib.h>
 
 /* Local functions and data: */
 
-- 
2.25.4


  reply	other threads:[~2020-09-18 18:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-18 18:17 [PATCH 0/2] Get gdb.base/overlays.exp passing on m32r Andrew Burgess
2020-09-18 18:17 ` Andrew Burgess [this message]
2020-09-18 18:17 ` [PATCH 2/2] gdb: handle unmapped overlays in find_pc_line Andrew Burgess
2020-09-20 21:08   ` Simon Marchi
2020-09-21  8:47     ` Andrew Burgess
2020-10-06 10:25 ` [PATCH 0/2] Get gdb.base/overlays.exp passing on m32r Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c1117e74bd4b53037abf0ea680dbab82b990ae34.1600452947.git.andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).