* [rust-dev] Curious about instruction pointer being used to compute string offset
@ 2014-12-10 3:43 C K Kashyap
2014-12-10 3:51 ` Daniel Micay
0 siblings, 1 reply; 3+ messages in thread
From: C K Kashyap @ 2014-12-10 3:43 UTC (permalink / raw)
To: rust-dev
[-- Attachment #1: Type: text/plain, Size: 538 bytes --]
Hi,
Looks like on my ubuntu 64 bit, when I compile
hello("ABCD");
I get
719e: 48 8d 05 e0 68 04 00 lea 0x468e0(%rip),%rax #
4da85 <str1405>
71a5: 48 89 44 24 08 mov %rax,0x8(%rsp)
71aa: 48 c7 44 24 10 04 00 movq $0x4,0x10(%rsp)
71b1: 00 00
71b3: e8 88 f6 ff ff callq 6840
<_ZN5hello20h8ed5f876da0c3862eaaE>
I was wondering why is %rip being used for getting to the string? Or am I
understanding it incorrectly?
Regards,
Kashyap
[-- Attachment #2: Type: text/html, Size: 864 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rust-dev] Curious about instruction pointer being used to compute string offset
2014-12-10 3:43 [rust-dev] Curious about instruction pointer being used to compute string offset C K Kashyap
@ 2014-12-10 3:51 ` Daniel Micay
2014-12-10 4:00 ` C K Kashyap
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Micay @ 2014-12-10 3:51 UTC (permalink / raw)
To: rust-dev
[-- Attachment #1: Type: text/plain, Size: 772 bytes --]
On 09/12/14 10:43 PM, C K Kashyap wrote:
> Hi,
>
> Looks like on my ubuntu 64 bit, when I compile
>
> hello("ABCD");
>
> I get
>
> 719e: 48 8d 05 e0 68 04 00 lea 0x468e0(%rip),%rax
> # 4da85 <str1405>
> 71a5: 48 89 44 24 08 mov %rax,0x8(%rsp)
> 71aa: 48 c7 44 24 10 04 00 movq $0x4,0x10(%rsp)
> 71b1: 00 00
> 71b3: e8 88 f6 ff ff callq 6840
> <_ZN5hello20h8ed5f876da0c3862eaaE>
>
>
> I was wondering why is %rip being used for getting to the string? Or am
> I understanding it incorrectly?
>
> Regards,
> Kashyap
That's what position independent code looks like on x86_64.
https://en.wikipedia.org/wiki/Position-independent_code
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rust-dev] Curious about instruction pointer being used to compute string offset
2014-12-10 3:51 ` Daniel Micay
@ 2014-12-10 4:00 ` C K Kashyap
0 siblings, 0 replies; 3+ messages in thread
From: C K Kashyap @ 2014-12-10 4:00 UTC (permalink / raw)
To: Daniel Micay; +Cc: rust-dev
[-- Attachment #1: Type: text/plain, Size: 1460 bytes --]
oh nice ... In my kernel I am running into an issue where I am looping
though an &str but it does not get the right characters (all zeros
actually) - https://github.com/ckkashyap/unix/blob/master/kernel/uart.rs
While I've used the PIC option several times, I had not realized that rip
relative addressing is how it's done :) Thanks for the pointer.
Now I need to find out what the problem is in my kernel code ...
Thanks Daniel.
Regards,
Kashyap
On Wed, Dec 10, 2014 at 9:21 AM, Daniel Micay <danielmicay@gmail.com> wrote:
> On 09/12/14 10:43 PM, C K Kashyap wrote:
> > Hi,
> >
> > Looks like on my ubuntu 64 bit, when I compile
> >
> > hello("ABCD");
> >
> > I get
> >
> > 719e: 48 8d 05 e0 68 04 00 lea 0x468e0(%rip),%rax
> > # 4da85 <str1405>
> > 71a5: 48 89 44 24 08 mov %rax,0x8(%rsp)
> > 71aa: 48 c7 44 24 10 04 00 movq $0x4,0x10(%rsp)
> > 71b1: 00 00
> > 71b3: e8 88 f6 ff ff callq 6840
> > <_ZN5hello20h8ed5f876da0c3862eaaE>
> >
> >
> > I was wondering why is %rip being used for getting to the string? Or am
> > I understanding it incorrectly?
> >
> > Regards,
> > Kashyap
>
> That's what position independent code looks like on x86_64.
>
> https://en.wikipedia.org/wiki/Position-independent_code
>
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
>
[-- Attachment #2: Type: text/html, Size: 2471 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-12-10 4:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-10 3:43 [rust-dev] Curious about instruction pointer being used to compute string offset C K Kashyap
2014-12-10 3:51 ` Daniel Micay
2014-12-10 4:00 ` C K Kashyap
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox