[PATCH v6 02/13] ARC: startup and dynamic linking code

Vineet Gupta Vineet.Gupta1@synopsys.com
Thu May 28 01:14:53 GMT 2020


On 5/27/20 12:05 PM, Adhemerval Zanella via Libc-alpha wrote:
> 
> 
> On 22/04/2020 22:41, Vineet Gupta via Libc-alpha wrote:
>> Code for C runtime startup and dynamic loading including PLT layout.
>>
>> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
> 
> As prior patch we do not use DCO, but rather copyright assignment.
> 
> Looks ok in general, with some comments below.
> 
> 

>> +
>> +
>> +/* Return the run-time load address of the shared object.  */
>> +static inline ElfW(Addr)
>> +elf_machine_load_address (void)
>> +{
>> +  ElfW(Addr) build_addr, run_addr;
>> +
>> +  /* For build address, below generates
>> +     ld  r0, [pcl, _GLOBAL_OFFSET_TABLE_@pcl].  */
>> +  build_addr = elf_machine_dynamic ();
>> +  __asm__ ("add %0, pcl, _DYNAMIC@pcl	\n" : "=r" (run_addr));
>> +
>> +  return run_addr - build_addr;
>> +}
> 
> Why does it need an inline asm here?

PCL is a pseudo register and we use the @pcl assembler syntax to get runtime
address of DYNAMIC section. Last I checked the aarch64 style reference to _DYNAMIC
in "C" was not generating the right code.

>> +auto inline void
> 
> Do we still need to use 'auto' keyword here? Same for other uses.
Copy-paste thinko, I'll remove it.


>> diff --git a/sysdeps/arc/entry.h b/sysdeps/arc/entry.h
>> new file mode 100644
>> index 000000000000..adb01d981afd
>> --- /dev/null
>> +++ b/sysdeps/arc/entry.h
>> @@ -0,0 +1,5 @@
>> +#ifndef __ASSEMBLY__
>> +extern void __start (void) attribute_hidden;
>> +#endif
>> +
>> +#define ENTRY_POINT __start
> 
> Ok.  Why ARC has decided to use double underscore start btw?

Historically the linker scripts have had __start as entry point. Do note that we
use the same linker scripts for other libs etc so changing them would be very painful.


More information about the Libc-alpha mailing list