public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/31851] New: GDB ignores absolute function symbols
@ 2024-06-06 12:35 marian.buschsieweke at posteo dot net
  2024-06-06 13:50 ` [Bug gdb/31851] " marian.buschsieweke at posteo dot net
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: marian.buschsieweke at posteo dot net @ 2024-06-06 12:35 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31851

            Bug ID: 31851
           Summary: GDB ignores absolute function symbols
           Product: gdb
           Version: 14.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: marian.buschsieweke at posteo dot net
  Target Milestone: ---

Hi,

for xtensa-esp32-elf targets some functions end up being absolute symbols.

I created a simple proof of concept that does not require exotic targets (e.g.
I used this on x86_64 / Linux):

main.c:

    extern void func(void);

    int main(void)
    {
        func();
        return 0;
    }

func.c:

    #include <stdio.h>

    void func_impl(void)
    {
        puts("Hello from func");
    }

And I used a custom linker script that is based on the default linker script,
but I added the following line:

    PROVIDE(func = ABSOLUTE(func_impl));

With nm I can confirm that func_impl is a regular function symbol (section
.text) and func is an absolute symbol (section *ABS*) at the same address. When
I try to create a break point I get

    Function "func" not defined.

When I change the linker script to use

    PROVIDE(func = func_impl);

I get a regular symbol for func (section .text) and setting the break point
just works:

    (gdb) break func
    Breakpoint 1 at 0x1199: file func.c, line 5.

To my understanding this is a bug, as GDB should not ignore absolute function
symbols.

(Context: There is no special handling of functions that end up as absolute
symbols in either the C code or the linker script, so there is no obvious
reason why those functions do end up being absolute. My wild guess is that
those functions are being called from functions that get placed in flash as
well as from functions that are placed in instruction RAM. I would happily
apply any change that would prevent functions from becoming absolute symbols,
if someone knows what could cause this. I do however believe that there is a
valid use case for function symbols being explicitly absolute symbols: E.g. on
the RP2040 MCU there are functions in Mask ROM. So even if I could fix this on
my side by not having functions as absolute symbols, I do think that GDB should
be prepared to handle functions that are absolute symbols.)

Kind regards,
Marian

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-06-12 12:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-06 12:35 [Bug gdb/31851] New: GDB ignores absolute function symbols marian.buschsieweke at posteo dot net
2024-06-06 13:50 ` [Bug gdb/31851] " marian.buschsieweke at posteo dot net
2024-06-06 13:51 ` marian.buschsieweke at posteo dot net
2024-06-11 21:38 ` marian.buschsieweke at posteo dot net
2024-06-11 21:45 ` marian.buschsieweke at posteo dot net
2024-06-12 11:11 ` marian.buschsieweke at posteo dot net
2024-06-12 12:40 ` tromey at sourceware dot org

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).