This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Skip gdb.base/func-ptrs.exp in thumb mode


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]