This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] Fix gdb.asm/asm-source.exp for recent NetBSD/ELF targets
- From: Mark Kettenis <kettenis at chello dot nl>
- To: bje at wasabisystems dot com, gdb-patches at sources dot redhat dot com
- Date: Sat, 29 Nov 2003 14:55:29 +0100 (CET)
- Subject: [PATCH] Fix gdb.asm/asm-source.exp for recent NetBSD/ELF targets
Ben,
Recent NetBSD/ELF targets need a special .note section in their
executables, otherwise the kernel refuses to excute them. The
attached patch does this, but only for targets that are explicitly
marked as "ELF" (*-*-netbsdelf*) and NetBSD/amd64 (x86_64-*-netbsd*).
It might be necessary to tweak this a bit for NetBSD/ELF targets that
aren't explicitly marked as such by config.guess.
Anyway, I committed the attached.
Tested on x86_64-unknown-netbsd1.6ZF and i386-unknown-netbsdelf1.6.1.
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* gdb.asm/asm-source.exp: Initialize asm-note to "empty". Set
asm-note to "netbsd" for *-*-netbsdelf* and x86_64-*-netbsd*. Use
it to create the appropriate note.inc.
* gdb.asm/asmsrc1.s: Include "note.inc".
* gdb.asm/netbsd.inc: New file.
* gdb.asm/empty.inc: New file.
Index: gdb.asm/asm-source.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/asm-source.exp,v
retrieving revision 1.44
diff -u -p -r1.44 asm-source.exp
--- gdb.asm/asm-source.exp 26 Nov 2003 01:17:16 -0000 1.44
+++ gdb.asm/asm-source.exp 29 Nov 2003 13:48:34 -0000
@@ -32,6 +32,7 @@ set prms_id 0
set bug_id 0
set asm-arch ""
+set asm-note "empty"
set asm-flags ""
set link-flags "--entry _start"
@@ -124,6 +125,12 @@ if {[istarget "*-*-freebsd*"] || [istarg
append link-flags " -static"
}
+# On NetBSD/ELF we need a special NetBSD-identifying note section.
+if { [istarget "*-*-netbsdelf*"]
+ || [istarget "x86_64-*-netbsd*"] } then {
+ set asm-note "netbsd"
+}
+
# Watch out, we are invoking the assembler, but the testsuite sets multilib
# switches according to compiler syntax. If we pass these options straight
# to the assembler, they won't always make sense. If we don't pass them to
@@ -146,6 +153,8 @@ set srcfile2 asmsrc2.s
remote_exec build "rm -f ${subdir}/arch.inc"
remote_download host ${srcdir}/${subdir}/${asm-arch}.inc ${subdir}/arch.inc
+remote_exec build "rm -f ${subdir}/note.inc"
+remote_download host ${srcdir}/${subdir}/${asm-note}.inc ${subdir}/note.inc
if { "${asm-flags}" == "" } {
#set asm-flags "-Wa,-gstabs,-I${srcdir}/${subdir},-I${objdir}/${subdir}"
@@ -359,3 +368,4 @@ gdb_test "disassem foostatic" ".*<foosta
"look at static function"
remote_exec build "rm -f ${subdir}/arch.inc"
+remote_exec build "rm -f ${subdir}/note.inc"
Index: gdb.asm/asmsrc1.s
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/asmsrc1.s,v
retrieving revision 1.5
diff -u -p -r1.5 asmsrc1.s
--- gdb.asm/asmsrc1.s 22 Oct 2002 01:43:37 -0000 1.5
+++ gdb.asm/asmsrc1.s 29 Nov 2003 13:48:34 -0000
@@ -65,3 +65,5 @@ gdbasm_datavar globalvar 11
comment "A static variable"
gdbasm_datavar staticvar 5
+
+ .include "note.inc"
Index: gdb.asm/empty.inc
===================================================================
RCS file: gdb.asm/empty.inc
diff -N gdb.asm/empty.inc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb.asm/empty.inc 29 Nov 2003 13:48:34 -0000
@@ -0,0 +1 @@
+ comment "empty"
Index: gdb.asm/netbsd.inc
===================================================================
RCS file: gdb.asm/netbsd.inc
diff -N gdb.asm/netbsd.inc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gdb.asm/netbsd.inc 29 Nov 2003 13:48:34 -0000
@@ -0,0 +1,12 @@
+ comment "netbsd .note"
+
+.section ".note.netbsd.ident", "a"
+ .p2align 2
+
+ .long 7
+ .long 4
+ .long 1
+ .ascii "NetBSD\0\0"
+ .long 105010000
+
+ .p2align 2