This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Skip gdb.base/func-ptrs.exp in thumb mode
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>, "Maciej W. Rozycki" <macro at imgtec dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Wed, 29 Jun 2016 12:55:52 +0100
- Subject: Re: [PATCH] Skip gdb.base/func-ptrs.exp in thumb mode
- Authentication-results: sourceware.org; auth=none
- References: <1465812702-22061-1-git-send-email-yao dot qi at linaro dot org> <alpine dot DEB dot 2 dot 00 dot 1606210234110 dot 7182 at tp dot orcam dot me dot uk> <CAH=s-PP26yTpNGU46T-J9kvFrg0UK7A=6h9-bJZyOPjE6SJFdg at mail dot gmail dot com>
On 06/29/2016 09:39 AM, Yao Qi wrote:
> On Wed, Jun 22, 2016 at 8:04 PM, Maciej W. Rozycki <macro@imgtec.com> wrote:
>>
>> So how does this work for indirect calls, such as ones made via function
>> pointers, with the ARM target? With dynamic reassignment such a pointer
>> can change at the run time and with mixed code it can point to regular ARM
>> code sometimes and at other times it can point to Thumb code, still within
>> the same execution of a program. Can't GDB reproduce the same actions?
>> What do GCC/GAS/LD do with function pointer assignments that GDB can't?
>
> On ARM target, instruction "blx rm" is generated for indirect call, and "rm" has
> the target address, plus ISA bit if needed. If the target function is ARM code,
> "rm" has the target function address, otherwise, it has the thumb
> target function
> address with LSB set. I want to make it clear that, although thumb function
> symbol value has LSB set, which only indicates this is a thumb function, the
> function address is still 2-byte aligned. All these ISA bit set/clear
> is managed
> by LD.
I think the question is what happens at run time, when a function
pointer is set to a thumb function. Say, with something like this:
typedef void (func_ptr) (void);
void arm_function (void);
void thumb_function (void); // add whatever __attribute__ necessary
// for thumb.
func_ptr *ptr;
void foo (void)
{
ptr = thumb_function;
ptr (); // stop here
}
Does "ptr" hold an address with the LSB set at run time, somehow?
I assume it does.
Then, doesn't this in gdb:
(gdb) print ptr = thumb_function
end up with the same value (LSB set)? If not, seems like that's a bug.
Note that from the original commit log, one can't tell what
exactly goes wrong in the test that requires skipping it. It talks
in terms of Maciej's patch, and how some prototype based on that
behaves, and not in terms of what is wrong with the current support, or
if there's something the test is doing that is fundamentally impossible
to do on arm.
Thanks,
Pedro Alves