[PATCH] ARC: support shared crt1

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH] ARC: support shared crt1

Vineet Gupta-5
Signed-off-by: Vineet Gupta <[hidden email]>
---
 libc/sysdeps/linux/arc/crt1.S | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libc/sysdeps/linux/arc/crt1.S b/libc/sysdeps/linux/arc/crt1.S
index 95c41f888850..e38c8e81b2c0 100644
--- a/libc/sysdeps/linux/arc/crt1.S
+++ b/libc/sysdeps/linux/arc/crt1.S
@@ -41,11 +41,15 @@ __start:
 
  mov_s r5, r0 ; rltd_fini
  add_s r2, sp, 4 ; argv
-
+#ifdef L_Scrt1
+ add r0, pcl, @main@pcl
+ add r3, pcl, @_init@pcl
+ add r4, pcl, @_fini@pcl
+#else
  mov_s r0, main
  mov_s r3, _init
  mov r4, _fini
-
+#endif
  and sp, sp, -8
  mov r6, sp
 
--
2.5.0

_______________________________________________
uClibc mailing list
[hidden email]
http://lists.busybox.net/mailman/listinfo/uclibc
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [uclibc-ng-devel] [PATCH] ARC: support shared crt1

Waldemar Brodkorb
Hi Vineet,
Vineet Gupta wrote,

> Signed-off-by: Vineet Gupta <[hidden email]>
> ---
>  libc/sysdeps/linux/arc/crt1.S | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/libc/sysdeps/linux/arc/crt1.S b/libc/sysdeps/linux/arc/crt1.S
> index 95c41f888850..e38c8e81b2c0 100644
> --- a/libc/sysdeps/linux/arc/crt1.S
> +++ b/libc/sysdeps/linux/arc/crt1.S
> @@ -41,11 +41,15 @@ __start:
>  
>   mov_s r5, r0 ; rltd_fini
>   add_s r2, sp, 4 ; argv
> -
> +#ifdef L_Scrt1
> + add r0, pcl, @main@pcl
> + add r3, pcl, @_init@pcl
> + add r4, pcl, @_fini@pcl
> +#else
>   mov_s r0, main
>   mov_s r3, _init
>   mov r4, _fini
> -
> +#endif
>   and sp, sp, -8
>   mov r6, sp

Can you please be a little more descriptive why this patch is
useful? Will ARC support static PIE or is Scrt1.o used in other
code?

best regards
 Waldemar

Sorry, had to resend with correct sender address.
_______________________________________________
uClibc mailing list
[hidden email]
http://lists.busybox.net/mailman/listinfo/uclibc
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [uclibc-ng-devel] [PATCH] ARC: support shared crt1

Vineet Gupta-5
On Wednesday 15 June 2016 08:34 PM, Waldemar Brodkorb wrote:

> Hi Vineet,
> Vineet Gupta wrote,
>
>> Signed-off-by: Vineet Gupta <[hidden email]>
>> ---
>>  libc/sysdeps/linux/arc/crt1.S | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/libc/sysdeps/linux/arc/crt1.S b/libc/sysdeps/linux/arc/crt1.S
>> index 95c41f888850..e38c8e81b2c0 100644
>> --- a/libc/sysdeps/linux/arc/crt1.S
>> +++ b/libc/sysdeps/linux/arc/crt1.S
>> @@ -41,11 +41,15 @@ __start:
>>  
>>   mov_s r5, r0 ; rltd_fini
>>   add_s r2, sp, 4 ; argv
>> -
>> +#ifdef L_Scrt1
>> + add r0, pcl, @main@pcl
>> + add r3, pcl, @_init@pcl
>> + add r4, pcl, @_fini@pcl
>> +#else
>>   mov_s r0, main
>>   mov_s r3, _init
>>   mov r4, _fini
>> -
>> +#endif
>>   and sp, sp, -8
>>   mov r6, sp
> Can you please be a little more descriptive why this patch is
> useful? Will ARC support static PIE or is Scrt1.o used in other
> code?

This is for a dynamically linked PIE - can we have static linked PIE ? Current
approach of taking addresses of functions, in not position independent but still
works for the normal dynamically linked executables (non PIE) since the zero based
addresses are rightly resolved in final link. This is not true for PIE hence we
need a really position independent way (PC relative addr) to pass those function
addresses.

Do u want me to respin with beefed up changelog.

> Sorry, had to resend with correct sender address.

My address was wrong ?


_______________________________________________
uClibc mailing list
[hidden email]
http://lists.busybox.net/mailman/listinfo/uclibc
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [uclibc-ng-devel] [PATCH] ARC: support shared crt1

Waldemar Brodkorb
Hi Vineet,
Vineet Gupta wrote,

> On Wednesday 15 June 2016 08:34 PM, Waldemar Brodkorb wrote:
> > Hi Vineet,
> > Vineet Gupta wrote,
> >
> >> Signed-off-by: Vineet Gupta <[hidden email]>
> >> ---
> >>  libc/sysdeps/linux/arc/crt1.S | 8 ++++++--
> >>  1 file changed, 6 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/libc/sysdeps/linux/arc/crt1.S b/libc/sysdeps/linux/arc/crt1.S
> >> index 95c41f888850..e38c8e81b2c0 100644
> >> --- a/libc/sysdeps/linux/arc/crt1.S
> >> +++ b/libc/sysdeps/linux/arc/crt1.S
> >> @@ -41,11 +41,15 @@ __start:
> >>  
> >>   mov_s r5, r0 ; rltd_fini
> >>   add_s r2, sp, 4 ; argv
> >> -
> >> +#ifdef L_Scrt1
> >> + add r0, pcl, @main@pcl
> >> + add r3, pcl, @_init@pcl
> >> + add r4, pcl, @_fini@pcl
> >> +#else
> >>   mov_s r0, main
> >>   mov_s r3, _init
> >>   mov r4, _fini
> >> -
> >> +#endif
> >>   and sp, sp, -8
> >>   mov r6, sp
> > Can you please be a little more descriptive why this patch is
> > useful? Will ARC support static PIE or is Scrt1.o used in other
> > code?
>
> This is for a dynamically linked PIE - can we have static linked PIE ? Current
> approach of taking addresses of functions, in not position independent but still
> works for the normal dynamically linked executables (non PIE) since the zero based
> addresses are rightly resolved in final link. This is not true for PIE hence we
> need a really position independent way (PC relative addr) to pass those function
> addresses.

You can try static PIE with binutils 2.26 and up with
-Wl,--no-dynamic-linker, but my tests with ARM/MIPS failed.
So I am not sure if crt1.S is the problem or something else.
 
> Do u want me to respin with beefed up changelog.

Yes, please.
 
> > Sorry, had to resend with correct sender address.
>
> My address was wrong ?

No, I use mutt and I am to lazy to configure send-hooks, so I
manually change my mail address before sending e-Mails :/

best regards
 Waldemar
_______________________________________________
uClibc mailing list
[hidden email]
http://lists.busybox.net/mailman/listinfo/uclibc
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [uclibc-ng-devel] [PATCH] ARC: support shared crt1

Rich Felker-2
On Thu, Jun 16, 2016 at 09:49:10PM +0200, Waldemar Brodkorb wrote:

> Hi Vineet,
> Vineet Gupta wrote,
>
> > On Wednesday 15 June 2016 08:34 PM, Waldemar Brodkorb wrote:
> > > Hi Vineet,
> > > Vineet Gupta wrote,
> > >
> > >> Signed-off-by: Vineet Gupta <[hidden email]>
> > >> ---
> > >>  libc/sysdeps/linux/arc/crt1.S | 8 ++++++--
> > >>  1 file changed, 6 insertions(+), 2 deletions(-)
> > >>
> > >> diff --git a/libc/sysdeps/linux/arc/crt1.S b/libc/sysdeps/linux/arc/crt1.S
> > >> index 95c41f888850..e38c8e81b2c0 100644
> > >> --- a/libc/sysdeps/linux/arc/crt1.S
> > >> +++ b/libc/sysdeps/linux/arc/crt1.S
> > >> @@ -41,11 +41,15 @@ __start:
> > >>  
> > >>   mov_s r5, r0 ; rltd_fini
> > >>   add_s r2, sp, 4 ; argv
> > >> -
> > >> +#ifdef L_Scrt1
> > >> + add r0, pcl, @main@pcl
> > >> + add r3, pcl, @_init@pcl
> > >> + add r4, pcl, @_fini@pcl
> > >> +#else
> > >>   mov_s r0, main
> > >>   mov_s r3, _init
> > >>   mov r4, _fini
> > >> -
> > >> +#endif
> > >>   and sp, sp, -8
> > >>   mov r6, sp
> > > Can you please be a little more descriptive why this patch is
> > > useful? Will ARC support static PIE or is Scrt1.o used in other
> > > code?
> >
> > This is for a dynamically linked PIE - can we have static linked PIE ? Current
> > approach of taking addresses of functions, in not position independent but still
> > works for the normal dynamically linked executables (non PIE) since the zero based
> > addresses are rightly resolved in final link. This is not true for PIE hence we
> > need a really position independent way (PC relative addr) to pass those function
> > addresses.
>
> You can try static PIE with binutils 2.26 and up with
> -Wl,--no-dynamic-linker, but my tests with ARM/MIPS failed.
> So I am not sure if crt1.S is the problem or something else.

Static PIE requires an rcrt1.o that's responsible for performing
self-relocation equivalent to what the dynamic linker does to itself.
Scrt1.o is for dynamic-linker PIE (and it's compatible with linking in
non-PIE code whether it's static or dynamic linked, but not necessary
in those cases).

Rich
_______________________________________________
uClibc mailing list
[hidden email]
http://lists.busybox.net/mailman/listinfo/uclibc
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [uclibc-ng-devel] [PATCH] ARC: support shared crt1

Waldemar Brodkorb
In reply to this post by Vineet Gupta-5
Hi Vineet,
Vineet Gupta wrote,

ping?
(resend with better changelog)

> On Wednesday 15 June 2016 08:34 PM, Waldemar Brodkorb wrote:
> > Hi Vineet,
> > Vineet Gupta wrote,
> >
> >> Signed-off-by: Vineet Gupta <[hidden email]>
> >> ---
> >>  libc/sysdeps/linux/arc/crt1.S | 8 ++++++--
> >>  1 file changed, 6 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/libc/sysdeps/linux/arc/crt1.S b/libc/sysdeps/linux/arc/crt1.S
> >> index 95c41f888850..e38c8e81b2c0 100644
> >> --- a/libc/sysdeps/linux/arc/crt1.S
> >> +++ b/libc/sysdeps/linux/arc/crt1.S
> >> @@ -41,11 +41,15 @@ __start:
> >>  
> >>   mov_s r5, r0 ; rltd_fini
> >>   add_s r2, sp, 4 ; argv
> >> -
> >> +#ifdef L_Scrt1
> >> + add r0, pcl, @main@pcl
> >> + add r3, pcl, @_init@pcl
> >> + add r4, pcl, @_fini@pcl
> >> +#else
> >>   mov_s r0, main
> >>   mov_s r3, _init
> >>   mov r4, _fini
> >> -
> >> +#endif
> >>   and sp, sp, -8
> >>   mov r6, sp
> > Can you please be a little more descriptive why this patch is
> > useful? Will ARC support static PIE or is Scrt1.o used in other
> > code?
>
> This is for a dynamically linked PIE - can we have static linked PIE ? Current
> approach of taking addresses of functions, in not position independent but still
> works for the normal dynamically linked executables (non PIE) since the zero based
> addresses are rightly resolved in final link. This is not true for PIE hence we
> need a really position independent way (PC relative addr) to pass those function
> addresses.
>
> Do u want me to respin with beefed up changelog.
>
> > Sorry, had to resend with correct sender address.
>
> My address was wrong ?
>
>
> _______________________________________________
> uClibc mailing list
> [hidden email]
> http://lists.busybox.net/mailman/listinfo/uclibc
>
_______________________________________________
uClibc mailing list
[hidden email]
http://lists.busybox.net/mailman/listinfo/uclibc
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH v2] ARC: Enable shared crt1

Vineet Gupta-5
In reply to this post by Waldemar Brodkorb
Currently crt1 takes address of functions (main,_init,_fini) directly
which doesn't generate truely position independent code, but zero based
values instead. e.g.

|  __start:
|        ...
| add_s   r2,sp,0x4
| mov_s r0, main

generates to

|  000156ec <__start>:
|  ...
|     156f4: add_s r2,sp,0x4
|     156f6: mov_s r0,0x15f7c
|  ...
|  00015f7c <main>:
|     15f7c: push_s blink

This works just fine for the normal (non PIE) dynamic executables since
they are loaded at address 0. However this is not true for PIE
executables. So for Scrt1 we use a true position independent way when
taking function addresses.

Cc: [hidden email] <[hidden email]>
Cc: [hidden email] <[hidden email]>
Cc: Cupertino Miranda <[hidden email]>
Signed-off-by: Vineet Gupta <[hidden email]>
---
 libc/sysdeps/linux/arc/crt1.S | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libc/sysdeps/linux/arc/crt1.S b/libc/sysdeps/linux/arc/crt1.S
index 95c41f888850..e38c8e81b2c0 100644
--- a/libc/sysdeps/linux/arc/crt1.S
+++ b/libc/sysdeps/linux/arc/crt1.S
@@ -41,11 +41,15 @@ __start:
 
  mov_s r5, r0 ; rltd_fini
  add_s r2, sp, 4 ; argv
-
+#ifdef L_Scrt1
+ add r0, pcl, @main@pcl
+ add r3, pcl, @_init@pcl
+ add r4, pcl, @_fini@pcl
+#else
  mov_s r0, main
  mov_s r3, _init
  mov r4, _fini
-
+#endif
  and sp, sp, -8
  mov r6, sp
 
--
2.5.0

_______________________________________________
uClibc mailing list
[hidden email]
http://lists.busybox.net/mailman/listinfo/uclibc
Loading...