[PATCH] Don't include *sol2-tdep.o on Linux/sparc*

Rainer Orth
2020-06-25T08:23:12Z

[-- Attachment #1: Type: text/plain, Size: 2531 bytes --]

Hi Simon,

>>> However, I just discovered that there are two targets that would break
>>> with this patch: both sparc-*-linux* and sparc64-*-linux* include
>>> sparc-sol2-tdep.o and sparc64-sol2-tdep.o in configure.tgt. With the
>>> new call to sol2_init_abi which only lives in sol2-tdep.o, gdb would
>>> fail to link. I have no idea what business they have with
>>> Solaris-specific files: I suspect that's to allow debugging of
>>> Solaris/SPARC binaries (i.e. GDB_OSABI_SOLARIS). What should I do about
>>> this? Maybe I also could include sol2-tdep.o on Linux/SPARC, but is
>>> this TRT? AFAICS those files received only mechanical changes over the
>>> last two years (haven't looked further), and I have no way of testing
>>> changes.
>>
>> Hmm, sparc-*-linux* and sparc64-*-linux* have no business including some
>> Solaris-specific files in the build.
>>
>> When building a GDB on sparc64/Linux, it shouldn't have support for debugging
>> sparc64/Solaris binaries. If you want that, you need to pass
>> --enable-targets=sparc64-solaris-something (I don't know what the actual
>> triplet
>> would be).
>
> sparc{v9,64}-sun-solaris2.11
>
>> So it seems like there is some untangling here, putting the functions on the
>> files that they really belong to, until you can successfully build a
>> sparc64/Linux
>> GDB without including the sol2 tdep files. I haven't looked much at the patch
>
> From a quick check, this should just work today: the functions declared
> in sparc*-sol2-tdep.c are only called in Solaris-specific files already.
> I'll give it a try separately. sparc{32,64}_sol2_init_abi are currently
> declared in common files (sparc*-tdep.h), but they can just be made
> static and the declarations removed.

the following patch does just that: tested on sparc64-unknown-linux-gnu
(build only due to PR tdep/26170) and sparcv9-sun-solaris2.11.

Ok for master?

Rainer

--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

2020-06-24 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>

* configure.tgt <sparc-*-linux*> (gdb_target_obs): Remove
sparc-sol2-tdep.o, sol2-tdep.o, sparc64-sol2-tdep.o.
<sparc64-*-linux*> (gdb_target_obs): Remove sparc64-sol2-tdep.o,
sol2-tdep.o, sparc-sol2-tdep.o.
* sparc-sol2-tdep.c (sparc32_sol2_init_abi): Make static.
* sparc-tdep.h (sparc32_sol2_init_abi): Remove.
* sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Make static.
* sparc64-tdep.h (sparc64_sol2_init_abi): Remove.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sol2-no-sol2-tdep-linux.patch --]
[-- Type: text/x-patch, Size: 2736 bytes --]

# HG changeset patch
# Parent 3a3a48c067f99b6fc95d7b297570b179fd575e9c
Don't include *sol2-tdep.o on Linux/sparc*

diff --git a/gdb/configure.tgt b/gdb/configure.tgt
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -585,20 +585,20 @@ sh*)

sparc-*-linux*)
# Target: GNU/Linux SPARC
- gdb_target_obs="sparc-tdep.o sparc-sol2-tdep.o sol2-tdep.o \
+ gdb_target_obs="sparc-tdep.o \
sparc-linux-tdep.o solib-svr4.o symfile-mem.o \
linux-tdep.o \
ravenscar-thread.o sparc-ravenscar-thread.o"
if test "x$enable_64_bit_bfd" = "xyes"; then
# Target: GNU/Linux UltraSPARC
- gdb_target_obs="sparc64-tdep.o sparc64-sol2-tdep.o \
+ gdb_target_obs="sparc64-tdep.o \
sparc64-linux-tdep.o ${gdb_target_obs}"
fi
;;
sparc64-*-linux*)
# Target: GNU/Linux UltraSPARC
- gdb_target_obs="sparc64-tdep.o sparc64-sol2-tdep.o sol2-tdep.o \
- sparc64-linux-tdep.o sparc-tdep.o sparc-sol2-tdep.o \
+ gdb_target_obs="sparc64-tdep.o \
+ sparc64-linux-tdep.o sparc-tdep.o \
sparc-linux-tdep.o solib-svr4.o linux-tdep.o \
ravenscar-thread.o sparc-ravenscar-thread.o"
;;
diff --git a/gdb/sparc-sol2-tdep.c b/gdb/sparc-sol2-tdep.c
--- a/gdb/sparc-sol2-tdep.c
+++ b/gdb/sparc-sol2-tdep.c
@@ -192,7 +192,7 @@ static const struct frame_unwind sparc32

\f

-void
+static void
sparc32_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
diff --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h
--- a/gdb/sparc-tdep.h
+++ b/gdb/sparc-tdep.h
@@ -245,9 +245,6 @@ extern int sparc_is_annulled_branch_insn
extern const struct sparc_gregmap sparc32_sol2_gregmap;
extern const struct sparc_fpregmap sparc32_sol2_fpregmap;

-extern void sparc32_sol2_init_abi (struct gdbarch_info info,
- struct gdbarch *gdbarch);
-
/* Functions and variables exported from sparcnbsd-tdep.c. */

/* Register offsets for NetBSD. */
diff --git a/gdb/sparc64-sol2-tdep.c b/gdb/sparc64-sol2-tdep.c
--- a/gdb/sparc64-sol2-tdep.c
+++ b/gdb/sparc64-sol2-tdep.c
@@ -195,7 +195,7 @@ static const struct frame_unwind sparc64

\f

-void
+static void
sparc64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
diff --git a/gdb/sparc64-tdep.h b/gdb/sparc64-tdep.h
--- a/gdb/sparc64-tdep.h
+++ b/gdb/sparc64-tdep.h
@@ -119,9 +119,6 @@ extern void sparc64_collect_fpregset (co
extern const struct sparc_gregmap sparc64_sol2_gregmap;
extern const struct sparc_fpregmap sparc64_sol2_fpregmap;

-extern void sparc64_sol2_init_abi (struct gdbarch_info info,
- struct gdbarch *gdbarch);
-
/* Variables exported from sparc64-fbsd-tdep.c. */

/* Register offsets for FreeBSD/sparc64. */