Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@mips.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: gdb-patches@sourceware.org, "Maciej W. Rozycki" <macro@linux-mips.org>
Subject: Re: MIPS: Handle manual calls of MIPS16 functions with a call stub
Date: Fri, 08 Feb 2008 14:23:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.61.0802041642480.28589@perivale.mips.com> (raw)
In-Reply-To: <20080204163929.GA6642@caradoc.them.org>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 3418 bytes --]

On Mon, 4 Feb 2008, Daniel Jacobowitz wrote:

> This is not how any other target that I know of handles extra PC bits.
> I think it's going to cause a whole lot of other similar problems.  I
> am reluctant to add new hooks to support storing additional bits in
> addresses, when at the same time we have hooks that other targets use
> - called from overlapping places - to remove extra bits from addresses.

 Well, it is certainly the smallest change that fits the way the MIPS 
target is currently handled throughout the toolchain.  Not necessarily the 
best.

> Honestly, I'm not just trying to be difficult.  But having two targets

 Of course -- I would not have doubted.  I have been around for long 
enough.

> solve the same problem in opposite ways makes the core of GDB a mess.
> "Do line table entries include extra non-address bits" is not a
> question that should have different answers on different targets.
> Similarly for function block addresses.

 Your proposal sounds clean enough for me to investigate it further.  In 
fact I have done so to some extent already.

> I think that using mips_pc_is_mips16 can be made to work, by analogy
> to ARM.  I'd look at this myself, but I don't think I'm set up to run

 It is much more than that, but I think it can be done with some 
adjustments to pointer_to_address(), address_to_pointer() and 
integer_to_address() methods.  If DWARF-2 records could be treated as 
pointers (which they are given how the linker processes them) rather than 
addresses then such a setup should work.  That should be done above the 
level of the DWARF-2 interpreter, as losing the LSB from relative data 
often contained in records would result in an accumulative error.

 Of course further adjustments might be needed to methods like read_pc(), 
write_pc() and unwind_pc() (I am not absolutely sure at this point yet) 
and perhaps elsewhere.  Just as a proof of concept, with some hacks to the 
DWARF-2 parser and elsewhere, including but not limited to functions 
mentioned, I got down to just three regressions compared to results with 
my proposal.  Now the question is whether a similar result may be achieved 
using properly architected code.  I'll have a look at it soon.

> mips16 tests (yet).  Should I be able to do this with just the GDB
> simulator and a board file?

 I have attached the "mips-sim-sde32" board description file I use and the 
necessary linker script.  You should be able to use it, though there may 
be pitfalls.  When running tests you need -Wa,-O0 to disable branch 
swapping as it makes MIPS16 code inconsistent with DWARF-2 information in 
a fatal way.

> I don't understand.  The stub is not annotated with debug information
> in the example you posted earlier in the thread.  It's only "inside
> the block" physically in the assembly file and for the purposes of
> confusing gas (it probably puts the symbol and first instruction in
> different frags, the first of which is zero length, breaking whatever
> gas uses to annotate the symbol value).  It's not covered by the range
> [.LFB20, .LEB20] because those labels are in the text section.

 It is still covered by the .loc directive and therefore recognised to be 
a part of the code corresponding to the first line of the function.  It 
makes single-stepping through it possible -- including correct frame 
discovery as required by `nexti'/`step'/`next' (not `stepi' though).

  Maciej

[-- Attachment #2: Type: TEXT/PLAIN, Size: 10844 bytes --]

2005-03-17  Nigel Stephens  <nigel@mips.com>

	[mti-libgloss-linkonce]
	* mips/mdi32.ld: Append appending final '.' to .gnu.linkonce.x
	input section names, and add missing .gnu.linkonce.b. section.
	* mips/mdi64.ld: Similarly. 
	* mips/sde32.ld: Similarly. 
	* mips/sde64.ld: Similarly. 

2004-11-26  Nigel Stephens  <nigel@mips.com>

	* mips/sde32.ld: New linker script for SDE newlib configurations,
	which uses elf32-trad*mips.

	* mips/sde64.ld: Change object formats from elf32-n*mips to elf32-ntrad*mips.

	* mips/mdi32.ld: Change object formats from elf32-*mips to elf32-trad*mips.
	
	* mips/mdi64.ld: Change object formats from elf32-n*mips to elf32-ntrad*mips.

	* mips/configure.in (mips*-sde-elf*): Change "idt32" in script_list
	to "sde32". 

	* mips/configure: Rebuilt.

2004-10-04  Nigel Stephens  <nigel@mips.com>

	* mips/idt32.ld (.sdeosabi): Added this new section to the script,
	so that we can tell gdb that whether this program uses "SDE"
	exception handling or not. 
	* mips/sde64.ld: Similarly.

2004-08-24  Nigel Stephens  <nigel@mips.com>

	* mips/mdi32.ld: MDI/MIPSsim link script for 32-bit ABIs.
	* mips/mdi64.ld: MDI/MIPSsim link script for N32 ABI.


Index: binutils/src/libgloss/mips/sde32.ld
===================================================================
--- /dev/null
+++ binutils/src/libgloss/mips/sde32.ld
@@ -0,0 +1,175 @@
+/* The following TEXT start address leaves space for the monitor
+   workspace.  This linker script links isa32 programs for use with the
+   simulator.  */
+
+ENTRY(_start)
+OUTPUT_ARCH("mips:isa32")
+OUTPUT_FORMAT("elf32-tradlittlemips", "elf32-tradbigmips", "elf32-tradlittlemips")
+GROUP(-lc -lidt -lgcc)
+SEARCH_DIR(.)
+__DYNAMIC  =  0;
+STARTUP(crt0.o)
+
+/*
+ * Allocate the stack to be at the top of memory, since the stack
+ * grows down
+ */
+PROVIDE (__stack = 0);
+/* PROVIDE (__global = 0); */
+
+/*
+ * Initalize some symbols to be zero so we can reference them in the
+ * crt0 without core dumping. These functions are all optional, but
+ * we do this so we can have our crt0 always use them if they exist.
+ * This is so BSPs work better when using the crt0 installed with gcc.
+ * We have to initalize them twice, so we multiple object file
+ * formats, as some prepend an underscore.
+ */
+PROVIDE (hardware_exit_hook = 0);
+PROVIDE (hardware_hazard_hook = 0);
+PROVIDE (hardware_init_hook = 0);
+PROVIDE (software_init_hook = 0);
+
+SECTIONS
+{
+  . = 0x80020000;
+  .text : {
+     _ftext = . ;
+    PROVIDE (eprol  =  .);
+    *(.text)
+    *(.text.*)
+    *(.gnu.linkonce.t.*)
+    *(.mips16.fn.*)
+    *(.mips16.call.*)
+  }
+  .init : {
+    KEEP(*(.init))
+  }
+  .fini : {
+    KEEP(*(.fini))
+  }
+  .rel.sdata : {
+    PROVIDE (__runtime_reloc_start = .);
+    *(.rel.sdata)
+    PROVIDE (__runtime_reloc_stop = .);
+  }
+  PROVIDE (etext  =  .);
+  _etext  =  .;
+
+  .eh_frame_hdr : { *(.eh_frame_hdr) }
+  .eh_frame : { KEEP (*(.eh_frame)) }
+  .gcc_except_table : { *(.gcc_except_table) }
+  .jcr : { KEEP (*(.jcr)) }
+
+  .ctors    :
+  {
+    /* gcc uses crtbegin.o to find the start of
+       the constructors, so we make sure it is
+       first.  Because this is a wildcard, it
+       doesn't matter if the user does not
+       actually link against crtbegin.o; the
+       linker won't look for a file to match a
+       wildcard.  The wildcard also means that it
+       doesn't matter which directory crtbegin.o
+       is in.  */
+
+    KEEP (*crtbegin.o(.ctors))
+
+    /* We don't want to include the .ctor section from
+       from the crtend.o file until after the sorted ctors.
+       The .ctor section from the crtend file contains the
+       end of ctors marker and it must be last */
+
+    KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+    KEEP (*(SORT(.ctors.*)))
+    KEEP (*(.ctors))
+  }
+
+  .dtors    :
+  {
+    KEEP (*crtbegin.o(.dtors))
+    KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+    KEEP (*(SORT(.dtors.*)))
+    KEEP (*(.dtors))
+  }
+
+  . = .;
+  .rodata : {
+    *(.rdata)
+    *(.rodata)
+    *(.rodata.*)
+    *(.gnu.linkonce.r.*)
+  }
+  .sdeosabi : {
+     /* SDE OSABI indication for GDB */
+     *(.sdeosabi)
+  }
+   _fdata = ALIGN(16);
+  .data : {
+    *(.data)
+    *(.data.*)
+    *(.data1)
+    *(.gnu.linkonce.d.*)
+  }
+  . = ALIGN(8);
+  _gp = . + 0x8000;
+  __global = _gp;
+  .lit8 : {
+    *(.lit8)
+  }
+  .lit4 : {
+    *(.lit4)
+  }
+  .sdata : {
+    *(.sdata)
+    *(.sdata.*)
+    *(.gnu.linkonce.s.*)
+  }
+  . = ALIGN(4);
+  PROVIDE (edata  =  .);
+  _edata  =  .;
+  _fbss = .;
+  .sbss : {
+    *(.sbss .sbss.* .gnu.linkonce.sb.*)
+    *(.scommon)
+  }
+  .bss : {
+    _bss_start = . ;
+    *(.bss .bss.* .gnu.linkonce.b.*)
+    *(COMMON)
+  }
+
+   PROVIDE (end = .);
+   _end = .;
+
+  /* DWARF debug sections.
+     Symbols in the DWARF debugging sections are relative to
+     the beginning of the section so we begin them at 0.  */
+
+  /* DWARF 1 */
+  .debug          0 : { *(.debug) }
+  .line           0 : { *(.line) }
+
+  /* GNU DWARF 1 extensions */
+  .debug_srcinfo  0 : { *(.debug_srcinfo) }
+  .debug_sfnames  0 : { *(.debug_sfnames) }
+
+  /* DWARF 1.1 and DWARF 2 */
+  .debug_aranges  0 : { *(.debug_aranges) }
+  .debug_pubnames 0 : { *(.debug_pubnames) }
+
+  /* DWARF 2 */
+  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
+  .debug_abbrev   0 : { *(.debug_abbrev) }
+  .debug_line     0 : { *(.debug_line) }
+  .debug_frame    0 : { *(.debug_frame) }
+  .debug_str      0 : { *(.debug_str) }
+  .debug_loc      0 : { *(.debug_loc) }
+  .debug_macinfo  0 : { *(.debug_macinfo) }
+
+  /* SGI/MIPS DWARF 2 extensions */
+  .debug_weaknames 0 : { *(.debug_weaknames) }
+  .debug_funcnames 0 : { *(.debug_funcnames) }
+  .debug_typenames 0 : { *(.debug_typenames) }
+  .debug_varnames  0 : { *(.debug_varnames) }
+}
Index: binutils/src/libgloss/mips/sde64.ld
===================================================================
--- /dev/null
+++ binutils/src/libgloss/mips/sde64.ld
@@ -0,0 +1,176 @@
+/* The following TEXT start address leaves space for the monitor
+   workspace.  This linker script links isa32 programs for use with the
+   simulator.  */
+
+ENTRY(_start)
+OUTPUT_ARCH("mips:isa64")
+OUTPUT_FORMAT("elf32-ntradlittlemips", "elf32-ntradbigmips", "elf32-ntradlittlemips")
+GROUP(-lc -lidt -lgcc)
+SEARCH_DIR(.)
+__DYNAMIC  =  0;
+STARTUP(crt0.o)
+
+/*
+ * Allocate the stack to be at the top of memory, since the stack
+ * grows down
+ */
+PROVIDE (__stack = 0);
+/* PROVIDE (__global = 0); */
+
+/*
+ * Initalize some symbols to be zero so we can reference them in the
+ * crt0 without core dumping. These functions are all optional, but
+ * we do this so we can have our crt0 always use them if they exist.
+ * This is so BSPs work better when using the crt0 installed with gcc.
+ * We have to initalize them twice, so we multiple object file
+ * formats, as some prepend an underscore.
+ */
+PROVIDE (hardware_exit_hook = 0);
+PROVIDE (hardware_hazard_hook = 0);
+PROVIDE (hardware_init_hook = 0);
+PROVIDE (software_init_hook = 0);
+
+SECTIONS
+{
+  . = 0x80020000;
+  .text : {
+     _ftext = . ;
+    PROVIDE (eprol  =  .);
+    *(.text)
+    *(.text.*)
+    *(.gnu.linkonce.t.*)
+    *(.mips16.fn.*)
+    *(.mips16.call.*)
+  }
+  .init : {
+    KEEP(*(.init))
+  }
+  .fini : {
+    KEEP(*(.fini))
+  }
+  .rel.sdata : {
+    PROVIDE (__runtime_reloc_start = .);
+    *(.rel.sdata)
+    PROVIDE (__runtime_reloc_stop = .);
+  }
+  PROVIDE (etext  =  .);
+  _etext  =  .;
+
+
+  .eh_frame_hdr : { *(.eh_frame_hdr) }
+  .eh_frame : { KEEP (*(.eh_frame)) }
+  .gcc_except_table : { *(.gcc_except_table) }
+  .jcr : { KEEP (*(.jcr)) }
+
+  .ctors    :
+  {
+    /* gcc uses crtbegin.o to find the start of
+       the constructors, so we make sure it is
+       first.  Because this is a wildcard, it
+       doesn't matter if the user does not
+       actually link against crtbegin.o; the
+       linker won't look for a file to match a
+       wildcard.  The wildcard also means that it
+       doesn't matter which directory crtbegin.o
+       is in.  */
+
+    KEEP (*crtbegin.o(.ctors))
+
+    /* We don't want to include the .ctor section from
+       from the crtend.o file until after the sorted ctors.
+       The .ctor section from the crtend file contains the
+       end of ctors marker and it must be last */
+
+    KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+    KEEP (*(SORT(.ctors.*)))
+    KEEP (*(.ctors))
+  }
+
+  .dtors    :
+  {
+    KEEP (*crtbegin.o(.dtors))
+    KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+    KEEP (*(SORT(.dtors.*)))
+    KEEP (*(.dtors))
+  }
+
+  . = .;
+  .rodata : {
+    *(.rdata)
+    *(.rodata)
+    *(.rodata.*)
+    *(.gnu.linkonce.r.*)
+  }
+  .sdeosabi : {
+     /* SDE OSABI indication for GDB */
+     *(.sdeosabi)
+  }
+   _fdata = ALIGN(16);
+  .data : {
+    *(.data)
+    *(.data.*)
+    *(.data1)
+    *(.gnu.linkonce.d.*)
+  }
+  . = ALIGN(8);
+  _gp = . + 0x8000;
+  __global = _gp;
+  .lit8 : {
+    *(.lit8)
+  }
+  .lit4 : {
+    *(.lit4)
+  }
+  .sdata : {
+    *(.sdata)
+    *(.sdata.*)
+    *(.gnu.linkonce.s.*)
+  }
+  . = ALIGN(4);
+  PROVIDE (edata  =  .);
+  _edata  =  .;
+  _fbss = .;
+  .sbss : {
+    *(.sbss .sbss.* .gnu.linkonce.sb.*)
+    *(.scommon)
+  }
+  .bss : {
+    _bss_start = . ;
+    *(.bss .bss.* .gnu.linkonce.b.*)
+    *(COMMON)
+  }
+
+  PROVIDE (end = .);
+  _end = .;
+
+  /* DWARF debug sections.
+     Symbols in the DWARF debugging sections are relative to
+     the beginning of the section so we begin them at 0.  */
+
+  /* DWARF 1 */
+  .debug          0 : { *(.debug) }
+  .line           0 : { *(.line) }
+
+  /* GNU DWARF 1 extensions */
+  .debug_srcinfo  0 : { *(.debug_srcinfo) }
+  .debug_sfnames  0 : { *(.debug_sfnames) }
+
+  /* DWARF 1.1 and DWARF 2 */
+  .debug_aranges  0 : { *(.debug_aranges) }
+  .debug_pubnames 0 : { *(.debug_pubnames) }
+
+  /* DWARF 2 */
+  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
+  .debug_abbrev   0 : { *(.debug_abbrev) }
+  .debug_line     0 : { *(.debug_line) }
+  .debug_frame    0 : { *(.debug_frame) }
+  .debug_str      0 : { *(.debug_str) }
+  .debug_loc      0 : { *(.debug_loc) }
+  .debug_macinfo  0 : { *(.debug_macinfo) }
+
+  /* SGI/MIPS DWARF 2 extensions */
+  .debug_weaknames 0 : { *(.debug_weaknames) }
+  .debug_funcnames 0 : { *(.debug_funcnames) }
+  .debug_typenames 0 : { *(.debug_typenames) }
+  .debug_varnames  0 : { *(.debug_varnames) }
+}

[-- Attachment #3: Type: TEXT/PLAIN, Size: 3047 bytes --]

Index: dejagnu-quilt/dejagnu/baseboards/mips-sim-sde32.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ dejagnu-quilt/dejagnu/baseboards/mips-sim-sde32.exp	2007-05-24 16:25:43.000000000 +0100
@@ -0,0 +1,60 @@
+# Load the generic configuration for this board. This will define a basic
+# set of routines needed by the tool to communicate with the board.
+load_generic_config "sim";
+
+# basic-sim.exp is a basic description for the standard Cygnus simulator.
+load_base_board_description "basic-sim";
+
+# This tells it which directory to look in for the simulator.
+setup_sim mips;
+
+# No multilib flags are set by default.
+process_multilib_options "";
+
+# The compiler used to build for this board. This has *nothing* to do
+# with what compiler is tested if we're testing gcc.
+set_board_info compiler "[find_gcc]";
+#set_board_info needs_status_wrapper 1
+set_board_info gdb,nofileio 1
+
+set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]";
+set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags]";
+set_board_info ldscript "-Tsde32.ld";
+
+# And, it can't do arguments, and doesn't have real signals.
+set_board_info noargs 1;
+set_board_info gdb,nosignals 1;
+
+# For some big C++ benchmarks...
+set_board_info sim,options "--memory-size=0x1000000"
+
+# Skip huge test. The MIPS simulator reports only 
+# 2MB of memory.
+set_board_info gdb,skip_huge_test 1
+
+# Tell gdb to assume no fpu for -msoft-float compilation
+if {[string match "*soft-float*" [board_info $board multilib_flags]]} {
+  add_board_info gdb_load_commands "set mipsfpu none"
+}
+
+# Tell gdb to assume no fpu for -msoft-float compilation
+if {[string match "*mno-data-in-code*" [board_info $board multilib_flags]]} {
+  add_board_info sim,options "--spram=on"
+}
+
+#
+# Kludge g++_link_flags routine to explicitly add -lstdc++ to link flags
+# so that we can make sure the it comes *before* newlib and the libgloss
+# target libraries 
+#
+proc msim_g++_link_flags { args } {
+  set flags [ msim_orig_g++_link_flags "$args" ]
+  append flags "-lstdc++ "
+  return "$flags"
+}
+
+if { [info procs msim_orig_g++_link_flags ] == "" } {
+  verbose "installing msim_g++_link_flags" 1;
+  rename g++_link_flags msim_orig_g++_link_flags
+  rename msim_g++_link_flags g++_link_flags
+}
Index: dejagnu-quilt/dejagnu/lib/targetdb.exp
===================================================================
--- dejagnu-quilt.orig/dejagnu/lib/targetdb.exp	2007-05-24 16:25:04.000000000 +0100
+++ dejagnu-quilt/dejagnu/lib/targetdb.exp	2007-05-24 16:25:12.000000000 +0100
@@ -73,6 +73,15 @@
     }
 }
 
+#
+# Add VALUE to ENTRY for the current board being defined.
+#
+proc add_board_info { entry value } {
+    global board_info board;
+
+    lappend board_info($board,$entry) $value;
+}
+
 # Fill in ENTRY with VALUE for the current target.
 #
 proc set_currtarget_info { entry value } {

  reply	other threads:[~2008-02-08 14:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-31 18:14 Maciej W. Rozycki
2008-01-31 22:08 ` Daniel Jacobowitz
2008-02-01 10:27   ` Maciej W. Rozycki
2008-02-01 14:19     ` Daniel Jacobowitz
2008-02-01 15:34       ` Maciej W. Rozycki
2008-02-01 16:58         ` Daniel Jacobowitz
2008-02-01 17:07           ` Maciej W. Rozycki
2008-02-01 17:15             ` Daniel Jacobowitz
2008-02-04 16:14     ` Maciej W. Rozycki
2008-02-04 16:39       ` Daniel Jacobowitz
2008-02-08 14:23         ` Maciej W. Rozycki [this message]
2008-02-08 14:57           ` Daniel Jacobowitz
2008-02-08 18:06           ` Jim Blandy
2008-02-08 18:08           ` Jim Blandy
2008-02-13 18:28             ` Maciej W. Rozycki
2008-02-13 20:54               ` Jim Blandy
2008-02-15 11:36                 ` Maciej W. Rozycki
2008-02-18 13:32                   ` Nigel Stephens
2008-02-18 16:28                     ` Maciej W. Rozycki
2008-02-19 19:48                       ` Michael Snyder
2008-02-22 16:38                     ` Jim Blandy

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=Pine.LNX.4.61.0802041642480.28589@perivale.mips.com \
    --to=macro@mips.com \
    --cc=drow@false.org \
    --cc=gdb-patches@sourceware.org \
    --cc=macro@linux-mips.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