* [PATCH] gdb: make {fill, supply}_{g, fp}regset() as weak functions in gregset.h
@ 2021-11-11 9:21 Tiezhu Yang
2021-11-11 9:45 ` Andrew Burgess
0 siblings, 1 reply; 2+ messages in thread
From: Tiezhu Yang @ 2021-11-11 9:21 UTC (permalink / raw)
To: gdb-patches
I am working on the gdb support for LoongArch (a new RISC Architecture),
when build with gdb/loongarch-tdep.c, there exists the following build
error:
CXXLD gdb
/usr/bin/ld: proc-service.o: in function `.LVL73':
proc-service.c:(.text+0x31c): undefined reference to `fill_gregset(regcache const*, unsigned long (*) [45], int)'
/usr/bin/ld: proc-service.o: in function `.LM151':
proc-service.c:(.text+0x35c): undefined reference to `supply_gregset(regcache*, unsigned long const (*) [45])'
/usr/bin/ld: proc-service.o: in function `.LVL89':
proc-service.c:(.text+0x3bc): undefined reference to `fill_fpregset(regcache const*, elf_fpreg_t (*) [34], int)'
/usr/bin/ld: proc-service.o: in function `.LM179':
proc-service.c:(.text+0x3fc): undefined reference to `supply_fpregset(regcache*, elf_fpreg_t const (*) [34])'
collect2: error: ld returned 1 exit status
I notice that the above undefined references need to be defined in
gdb/loongarch-linux-nat.c in the future work, but it is better to
declare them as weak functions so that it can build successful now.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
gdb/gregset.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/gdb/gregset.h b/gdb/gregset.h
index 4b10692..42d752a 100644
--- a/gdb/gregset.h
+++ b/gdb/gregset.h
@@ -31,6 +31,8 @@
#define GDB_FPREGSET_T fpregset_t
#endif
+#define __weak __attribute__((weak))
+
typedef GDB_GREGSET_T gdb_gregset_t;
typedef GDB_FPREGSET_T gdb_fpregset_t;
@@ -46,18 +48,18 @@ struct regcache;
/* Copy register values from the native target gregset/fpregset
into GDB's internal register cache. */
-extern void supply_gregset (struct regcache *regcache,
+__weak void supply_gregset (struct regcache *regcache,
const gdb_gregset_t *gregs);
-extern void supply_fpregset (struct regcache *regcache,
+__weak void supply_fpregset (struct regcache *regcache,
const gdb_fpregset_t *fpregs);
/* Copy register values from GDB's register cache into
the native target gregset/fpregset. If regno is -1,
copy all the registers. */
-extern void fill_gregset (const struct regcache *regcache,
+__weak void fill_gregset (const struct regcache *regcache,
gdb_gregset_t *gregs, int regno);
-extern void fill_fpregset (const struct regcache *regcache,
+__weak void fill_fpregset (const struct regcache *regcache,
gdb_fpregset_t *fpregs, int regno);
#endif
--
2.1.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gdb: make {fill, supply}_{g, fp}regset() as weak functions in gregset.h
2021-11-11 9:21 [PATCH] gdb: make {fill, supply}_{g, fp}regset() as weak functions in gregset.h Tiezhu Yang
@ 2021-11-11 9:45 ` Andrew Burgess
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Burgess @ 2021-11-11 9:45 UTC (permalink / raw)
To: Tiezhu Yang; +Cc: gdb-patches
* Tiezhu Yang <yangtiezhu@loongson.cn> [2021-11-11 17:21:00 +0800]:
> I am working on the gdb support for LoongArch (a new RISC Architecture),
> when build with gdb/loongarch-tdep.c, there exists the following build
> error:
>
> CXXLD gdb
> /usr/bin/ld: proc-service.o: in function `.LVL73':
> proc-service.c:(.text+0x31c): undefined reference to `fill_gregset(regcache const*, unsigned long (*) [45], int)'
> /usr/bin/ld: proc-service.o: in function `.LM151':
> proc-service.c:(.text+0x35c): undefined reference to `supply_gregset(regcache*, unsigned long const (*) [45])'
> /usr/bin/ld: proc-service.o: in function `.LVL89':
> proc-service.c:(.text+0x3bc): undefined reference to `fill_fpregset(regcache const*, elf_fpreg_t (*) [34], int)'
> /usr/bin/ld: proc-service.o: in function `.LM179':
> proc-service.c:(.text+0x3fc): undefined reference to `supply_fpregset(regcache*, elf_fpreg_t const (*) [34])'
> collect2: error: ld returned 1 exit status
>
> I notice that the above undefined references need to be defined in
> gdb/loongarch-linux-nat.c in the future work, but it is better to
> declare them as weak functions so that it can build successful now.
Not approved.
I suspect you are miss-configuring your target. The proc-service.c
file is added to the build in configure.nat, and this is only done if
your target is configured with "linux" somewhere in its triple.
If your target is (currently) a baremetal target, then don't configure
with "linux" in the triple and proc-service.c will not be built, and
you'll not hit the undefined references.
Obviously, without seeing your full patch set the above is just me
guessing, but there are plenty of non-linux targets in tree, and they
are not running into this same problem, so I'm pretty confident that
this can be fixed without this change.
Thanks,
Andrew
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
> gdb/gregset.h | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/gregset.h b/gdb/gregset.h
> index 4b10692..42d752a 100644
> --- a/gdb/gregset.h
> +++ b/gdb/gregset.h
> @@ -31,6 +31,8 @@
> #define GDB_FPREGSET_T fpregset_t
> #endif
>
> +#define __weak __attribute__((weak))
> +
> typedef GDB_GREGSET_T gdb_gregset_t;
> typedef GDB_FPREGSET_T gdb_fpregset_t;
>
> @@ -46,18 +48,18 @@ struct regcache;
> /* Copy register values from the native target gregset/fpregset
> into GDB's internal register cache. */
>
> -extern void supply_gregset (struct regcache *regcache,
> +__weak void supply_gregset (struct regcache *regcache,
> const gdb_gregset_t *gregs);
> -extern void supply_fpregset (struct regcache *regcache,
> +__weak void supply_fpregset (struct regcache *regcache,
> const gdb_fpregset_t *fpregs);
>
> /* Copy register values from GDB's register cache into
> the native target gregset/fpregset. If regno is -1,
> copy all the registers. */
>
> -extern void fill_gregset (const struct regcache *regcache,
> +__weak void fill_gregset (const struct regcache *regcache,
> gdb_gregset_t *gregs, int regno);
> -extern void fill_fpregset (const struct regcache *regcache,
> +__weak void fill_fpregset (const struct regcache *regcache,
> gdb_fpregset_t *fpregs, int regno);
>
> #endif
> --
> 2.1.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-11 9:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-11 9:21 [PATCH] gdb: make {fill, supply}_{g, fp}regset() as weak functions in gregset.h Tiezhu Yang
2021-11-11 9:45 ` Andrew Burgess
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).