RISC-V problem with weak function references and -mcmodel=medany

Jim Wilson jimw@sifive.com
Tue May 29 18:27:00 GMT 2018


On 05/28/2018 06:32 AM, Sebastian Huber wrote:
> I guess, that the resolution of the weak reference to the undefined 
> symbol __deregister_frame_info somehow sets __deregister_frame_info to 
> the absolute address 0 which is illegal in the following "call 
> __deregister_frame_info"? Is this construct with weak references and a 
> -mcmodel=medany supported on RISC-V at all?

Yes.  It works for me.  Given a simple testcase

extern void *__deregister_frame_info (const void *)
          __attribute__ ((weak));
void * foo;
int
main (void)
{
   if (__deregister_frame_info)
     __deregister_frame_info (foo);
   return 0;
}

and compiling with -mcmodel=medany -O -Ttext=0x80000000, I get

80000158:       80000097                auipc   ra,0x80000
8000015c:       ea8080e7                jalr    -344(ra) # 0 
<_start-0x80000000>

for the weak call.  It isn't clear what you are doing differently.

Jim



More information about the Gcc mailing list