Re: how to realize long jump instruction in ia 64 assebly language?
"ChenMingChun" <[email protected]> Wed, 1 Mar 2006 11:10:58 +0800
| Newsgroups | gmane.linux.redhat.ia64.general |
|---|---|
| Message-ID | <012301c63cdd$c3899310$8004a8c0@liangjianhua> |
hello Mr.wilson.
=20
Thank u for your help .I have succeeded in accomplishing my job:).
Many differences were found between IA64 and x86_64:
1,the stack point register in x86_64 is rsp,while it is r12 in IA64. stil=
l,we must minus 16 when set the stack in IA64.
2,the Auxiliary vectors must be set,and AT_NULL,AT_PAGESZ, AT_PHDR, AT_P=
HDR, AT_PHNUM,AT_BASE, AT_FLAGS,AT_ENTRY are absolutely necessary.
3.when checking /proc/self/maps ,we could know that the dynamic liner is =
mapped to the memory from 0x2000000000000000
,so i mmap()ed that to the exact address.
4,and i also modified the ld script so that the data segment and text seg=
ment myld.so was mmap()ed at the address of 0x4000000000000000 and 0x6000=
000000000000 respectively.=20
thank you for your selfless help:-)
=20
----- Original Message -----=20
From: "James E Wilson" <[email protected]>
To: "Discussion of Linux on the Intel IA-64 processor" <ia64-list@redhat.=
com>
Sent: Saturday, February 18, 2006 5:20 AM
Subject: Re: how to realize long jump instruction in ia 64 assebly langua=
ge?
> On Thu, 2006-02-16 at 20:04, ChenMingChun wrote:
>> 1. mmap the ld-linux-ia64.so.2 to the memory .
>> For each PT_LOAD segment in the program header table,
>> the loader ensures that the ELF image from p_offset for p_filesz
>> bytes is copied into a memory buffer (with p_flags permissions)
>> at p_vaddr of p_memsz (aligned to p_align) bytes.
>=20
> I don't think this is sufficient. If you are loading segments with
> run-time relocations, then you have to perform the relocations after
> loading the segments.
>=20
> Also, some segments are special, like the .got section. You need to se=
t
> the gp pointer to point to this section before branching to the new
> code. Otherwise, all gp-relative references will fail.
>=20
>> in IA32 or x86_64 it prints "this is test".it's ok.
>> but in IA64 ,i think several differences between IA32 and IA64.
>=20
> Another important difference that you didn't list, is that on IA-64,
> code is always PIC, even when compiled with -static. I think this is
> the main source of your problems.
>=20
>> 1.the space of memory is divided into 8 regions. we must modify
>> ld script to compile myld.c so that the data
>> segment and text segment are loaded into region 1 0x2000000000000000
>> -0x4000000000000000,otherwise it might be
>> handing up when myld.so was as the dynamic linker.
>=20
> You didn't include this linker script.
>=20
> I did manage to produce a segfault when I tried your testcase. Trying
> to debug it by adding "return 0;" statements, I discovered it died
> inside the fstat call. Looking at the disassembled code, I figured out
> that it died inside the glibc routine __syscall_error. This is a short
> sequence of assembly code, so the only reason why it could have failed
> is because either gp (global pointer) or tp (thread pointer) was set
> wrong.
>=20
> I tried compiling myld.c with -mno-pic, and it got farther, to the read
> call, and then it died the same way.
>=20
> I think what you are trying to do here is very complicated, and it just
> happened to work on x86 because it uses a rather simple ABI. The IA-64
> ABI is much more complicated, and there are many more things that can g=
o
> wrong. You will need to spend some time reading IA-64 ABI documents,
> and you will probably need to spend some time learning how some low
> level aspects of glibc work, and you will have to spend more time
> debugging your code.
>=20
>=20
>=20
>