public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] i386: Use "movl main@GOT(%ebx), %eax" in start.S
@ 2017-10-03 14:19 H.J. Lu
  2017-10-03 15:37 ` Florian Weimer
  0 siblings, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2017-10-03 14:19 UTC (permalink / raw)
  To: GNU C Library

Don't use "leal main@GOTOFF(%ebx), %eax" since main may be in a
shared object.  Linker will convert "movl main@GOT(%ebx), %eax"
to "leal main@GOTOFF(%ebx), %eax" if main is defined locally.

Any comments?

H.J.
---
	* sysdeps/i386/start.S: Replace "leal main@GOT(%ebx), %eax" with
	"movl main@GOTOFF(%ebx), %eax".
---
 sysdeps/i386/start.S | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sysdeps/i386/start.S b/sysdeps/i386/start.S
index 375a93c15a..916fcd2f9a 100644
--- a/sysdeps/i386/start.S
+++ b/sysdeps/i386/start.S
@@ -99,8 +99,11 @@ _start:
 	pushl main@GOT(%ebx)
 # else
 	/* Avoid relocation in static PIE since _start is called before
-	   it is relocated.  */
-	leal main@GOTOFF(%ebx), %eax
+	   it is relocated.  Don't use "leal main@GOTOFF(%ebx), %eax"
+	   since main may be in a shared object.  Linker will convert
+	   "movl main@GOT(%ebx), %eax" to "leal main@GOTOFF(%ebx), %eax"
+	   if main is defined locally.  */
+	movl main@GOT(%ebx), %eax
 	pushl %eax
 # endif
 
-- 
2.13.6

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i386: Use "movl main@GOT(%ebx), %eax" in start.S
  2017-10-03 14:19 [PATCH] i386: Use "movl main@GOT(%ebx), %eax" in start.S H.J. Lu
@ 2017-10-03 15:37 ` Florian Weimer
  2017-10-03 22:45   ` H.J. Lu
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Weimer @ 2017-10-03 15:37 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library

* H. J. Lu:

> Don't use "leal main@GOTOFF(%ebx), %eax" since main may be in a
> shared object.  Linker will convert "movl main@GOT(%ebx), %eax"
> to "leal main@GOTOFF(%ebx), %eax" if main is defined locally.
>
> Any comments?

Would it be worthwhile to add a test for this which is not
architecture-specific?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i386: Use "movl main@GOT(%ebx), %eax" in start.S
  2017-10-03 15:37 ` Florian Weimer
@ 2017-10-03 22:45   ` H.J. Lu
  2017-10-04  0:44     ` H.J. Lu
  0 siblings, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2017-10-03 22:45 UTC (permalink / raw)
  To: Florian Weimer; +Cc: GNU C Library

On 10/3/17, Florian Weimer <fw@deneb.enyo.de> wrote:
> * H. J. Lu:
>
>> Don't use "leal main@GOTOFF(%ebx), %eax" since main may be in a
>> shared object.  Linker will convert "movl main@GOT(%ebx), %eax"
>> to "leal main@GOTOFF(%ebx), %eax" if main is defined locally.
>>
>> Any comments?
>
> Would it be worthwhile to add a test for this which is not
> architecture-specific?
>

Yes, a patch is here:

https://sourceware.org/ml/libc-alpha/2017-10/msg00104.html


-- 
H.J.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i386: Use "movl main@GOT(%ebx), %eax" in start.S
  2017-10-03 22:45   ` H.J. Lu
@ 2017-10-04  0:44     ` H.J. Lu
  0 siblings, 0 replies; 4+ messages in thread
From: H.J. Lu @ 2017-10-04  0:44 UTC (permalink / raw)
  To: Florian Weimer; +Cc: GNU C Library

On 10/3/17, H.J. Lu <hjl.tools@gmail.com> wrote:
> On 10/3/17, Florian Weimer <fw@deneb.enyo.de> wrote:
>> * H. J. Lu:
>>
>>> Don't use "leal main@GOTOFF(%ebx), %eax" since main may be in a
>>> shared object.  Linker will convert "movl main@GOT(%ebx), %eax"
>>> to "leal main@GOTOFF(%ebx), %eax" if main is defined locally.
>>>
>>> Any comments?
>>
>> Would it be worthwhile to add a test for this which is not
>> architecture-specific?
>>
>
> Yes, a patch is here:
>
> https://sourceware.org/ml/libc-alpha/2017-10/msg00104.html
>
>

I am checking it in.

-- 
H.J.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-10-04  0:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-03 14:19 [PATCH] i386: Use "movl main@GOT(%ebx), %eax" in start.S H.J. Lu
2017-10-03 15:37 ` Florian Weimer
2017-10-03 22:45   ` H.J. Lu
2017-10-04  0:44     ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).