* Illegal instruction After base addr alterd
@ 2005-04-08 3:01 Zhenyu Guo
2005-04-08 3:44 ` James E Wilson
0 siblings, 1 reply; 4+ messages in thread
From: Zhenyu Guo @ 2005-04-08 3:01 UTC (permalink / raw)
To: 'Binutils'
Hi there,
I'm trying to change the base addr of an application so that I
can load other usual static linked elf at the specified image base on
Itanium, say 0x400000...
I've done the following changes in my linker script:
/* Read-only sections, merged into text segment: */
. = 0x5000000000000000 + SIZEOF_HEADERS; <<-- used to be
0x4000000000000000
/* Adjust the address for the data segment. We want to adjust
up to
the same address within the page on the next page up. */
. = 0x7000000000000000 + (. & (0x10000 - 1)); << -- used to be
0x6000000000000000
Then I compiled my program and executed it, got "Illegal
instruction" msg.
And gdb told me a bit more:
Program received signal SIGILL, Illegal instruction.
0x2000000000003c80 in ?? ()
And readelf told me:
Elf file type is EXEC (Executable file)
Entry point 0x50000000000004a0
There are 7 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x5000000000000040
0x5000000000000040
0x0000000000000188 0x0000000000000188 R E 8
INTERP 0x00000000000001c8 0x50000000000001c8
0x50000000000001c8
0x0000000000000018 0x0000000000000018 R 1
[Requesting program interpreter: /lib/ld-linux-ia64.so.2]
LOAD 0x0000000000000000 0x5000000000000000
0x5000000000000000
0x0000000000000c48 0x0000000000000c48 R E 10000
LOAD 0x0000000000000c48 0x7000000000000c48
0x7000000000000c48
0x0000000000000298 0x00000000000002a8 RW 10000
DYNAMIC 0x0000000000000c58 0x7000000000000c58
0x7000000000000c58
0x00000000000001c0 0x00000000000001c0 RW 8
NOTE 0x00000000000001e0 0x50000000000001e0
0x50000000000001e0
0x0000000000000020 0x0000000000000020 R 4
IA_64_UNWIND 0x0000000000000bd0 0x5000000000000bd0
0x5000000000000bd0
0x0000000000000078 0x0000000000000078 R 8
BTW, after gdbed this altered program, the itanium machine is
down:(
Anybody tell me what is going on and what I should do?
Thanks,
Zhenyu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Illegal instruction After base addr alterd
2005-04-08 3:01 Illegal instruction After base addr alterd Zhenyu Guo
@ 2005-04-08 3:44 ` James E Wilson
0 siblings, 0 replies; 4+ messages in thread
From: James E Wilson @ 2005-04-08 3:44 UTC (permalink / raw)
To: Zhenyu Guo; +Cc: 'Binutils'
On Thu, 2005-04-07 at 20:03, Zhenyu Guo wrote:
> . = 0x5000000000000000 + SIZEOF_HEADERS; <<-- used to be
> 0x4000000000000000
IA-64 addresses have 4-bits for segment selection, and 60-bits of offset
within a segment. Changing the 0x4 to a 0x5 means you are moving the
code to a different segment. I don't think that is wise. I don't know
offhand exactly how the kernel handles the 16 segments, but something
like 0x48... might be more likely to work than 0x5...
There is an IA-64 linux kernel book written by David Mosberger that
might explain some of this stuff. I don't know for sure though, as I
don't have a copy.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Illegal instruction After base addr alterd
@ 2005-04-08 3:51 Zhenyu Guo
2005-04-08 4:59 ` Ian Wienand
0 siblings, 1 reply; 4+ messages in thread
From: Zhenyu Guo @ 2005-04-08 3:51 UTC (permalink / raw)
To: 'Binutils'
Ok, I've found that the vma bits[51...60] are not implemented on
Itanium, so addr 0x5000000000000000 (0x7000000000000000 ) is invalid.
I've changed to 0x4000100000000000 this time. There is no Illegal
instruction err then.
However, I failed running the ''hello world!" again. The app seemed
asleep.
The stopped addr is 0x2000000000003c80.
Any ideas?
Thanks,
Zhenyu
-----邮件原件-----
发件人: Zhenyu Guo [mailto:guozy03@mails.tsinghua.edu.cn]
发送时间: 2005年4月8日 11:03
收件人: 'Binutils (binutils@sources.redhat.com)'
主题: Illegal instruction After base addr alterd
Hi there,
I'm trying to change the base addr of an application so that I
can load other usual static linked elf at the specified image base on
Itanium, say 0x400000...
I've done the following changes in my linker script:
/* Read-only sections, merged into text segment: */
. = 0x5000000000000000 + SIZEOF_HEADERS; <<-- used to be
0x4000000000000000
/* Adjust the address for the data segment. We want to adjust
up to
the same address within the page on the next page up. */
. = 0x7000000000000000 + (. & (0x10000 - 1)); << -- used to be
0x6000000000000000
Then I compiled my program and executed it, got "Illegal
instruction" msg.
And gdb told me a bit more:
Program received signal SIGILL, Illegal instruction.
0x2000000000003c80 in ?? ()
And readelf told me:
Elf file type is EXEC (Executable file)
Entry point 0x50000000000004a0
There are 7 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x5000000000000040
0x5000000000000040
0x0000000000000188 0x0000000000000188 R E 8
INTERP 0x00000000000001c8 0x50000000000001c8
0x50000000000001c8
0x0000000000000018 0x0000000000000018 R 1
[Requesting program interpreter: /lib/ld-linux-ia64.so.2]
LOAD 0x0000000000000000 0x5000000000000000
0x5000000000000000
0x0000000000000c48 0x0000000000000c48 R E 10000
LOAD 0x0000000000000c48 0x7000000000000c48
0x7000000000000c48
0x0000000000000298 0x00000000000002a8 RW 10000
DYNAMIC 0x0000000000000c58 0x7000000000000c58
0x7000000000000c58
0x00000000000001c0 0x00000000000001c0 RW 8
NOTE 0x00000000000001e0 0x50000000000001e0
0x50000000000001e0
0x0000000000000020 0x0000000000000020 R 4
IA_64_UNWIND 0x0000000000000bd0 0x5000000000000bd0
0x5000000000000bd0
0x0000000000000078 0x0000000000000078 R 8
BTW, after gdbed this altered program, the itanium machine is
down:(
Anybody tell me what is going on and what I should do? Thanks,
Zhenyu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Illegal instruction After base addr alterd
2005-04-08 3:51 Zhenyu Guo
@ 2005-04-08 4:59 ` Ian Wienand
0 siblings, 0 replies; 4+ messages in thread
From: Ian Wienand @ 2005-04-08 4:59 UTC (permalink / raw)
To: Zhenyu Guo; +Cc: 'Binutils'
[-- Attachment #1: Type: text/plain, Size: 1146 bytes --]
On Fri, Apr 08, 2005 at 11:52:56AM +0800, Zhenyu Guo wrote:
> Ok, I've found that the vma bits[51...60] are not implemented on
> Itanium, so addr 0x5000000000000000 (0x7000000000000000 ) is invalid.
> I've changed to 0x4000100000000000 this time. There is no Illegal
> instruction err then.
> However, I failed running the ''hello world!" again. The app seemed
> asleep.
> The stopped addr is 0x2000000000003c80.
> Any ideas?
While that address might be OK in terms of implemented bits (as you
identified, 0x5... isn't) it's still going to be above RGN_MAP_LIMIT
as defined in the kernel (/include/asm-ia64/page.h)
For 16KB pages, your base address will need to be below
0x4000000000000000 + 0xfffffffc000 (calcuated with)
---
#define PAGE_SHIFT 14
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define RGN_MAP_LIMIT ((1UL << (4*PAGE_SHIFT - 12)) - PAGE_SIZE)
int main(void)
{
printf("%lx\n", RGN_MAP_LIMIT);
}
---
If I modify the executable base in the linker script to something
below this address (e.g. 0x4000000020000000) it works OK for hello
world, at least.
-i
ianw@gelato.unsw.edu.au
http://www.gelato.unsw.edu.au
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-04-08 4:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-08 3:01 Illegal instruction After base addr alterd Zhenyu Guo
2005-04-08 3:44 ` James E Wilson
2005-04-08 3:51 Zhenyu Guo
2005-04-08 4:59 ` Ian Wienand
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).