flat assembler
Message board for the users of flat assembler.
Index
> Main > ELF64 code generation, memory addressing |
Author |
|
UCM 31 May 2005, 00:55
By the way, 64bit code generation, as Privalov has mentioned many times, is not alpha/beta! It is quite stable. However, it still may be a bug, since bugs are not reliably avoidable.
|
|||
31 May 2005, 00:55 |
|
Chewy509 31 May 2005, 01:14
RE: 64bit code generation beta status.
My understanding was, that until v1.64, 64bit code generation (while even in its current state is extremely stable and nearly complete) should be considered beta only. If I'm worng please let me know. Thinking about this more, it does appear to be a bug. This is my take on the issue, and needs Privalov to double check. Since displacements in memory references are still limited to 32bit, (even in 64bit code generation), when FASM assembles ELF as executable it knows the correct offset to generate, and will correctly fit it into 32bits. However when assembling as an object file, it doesn't know the correct offset and wants to insert a 64bit space (which will get filled in by the linker), but since a displacement is limited to 32bit, you can't fit a 64bit value into a 32bit hole, and thus FASM generates an error. If I'm wrong, then please let me know. I also have another question, but in regards to uses pointers. Say I have: Code: mov r10, _My_string movzx r11, byte [r10] movzx r12, byte [r10+1] Will FASM load the absolute address of _My_String into r10, and the following loads use RIP relative or absolute addresses? (I'm still a little vague on where RIP addressing is used and not used). |
|||
31 May 2005, 01:14 |
|
Tomasz Grysztar 01 Jun 2005, 10:23
The features that are implemented in the stable releases (like 1.60, which implements the ELF64 output) are considered complete. The 1.64 release is planned as a "final" release for x86-64, because there are still Win64 formats left to be added (the COFF objects are already implemented for the coming 1.62), also maybe some Win64 includes, etc.
As for displacements, your explanation is correct - in case of object file fasm doesn't know whether the relocated address would fill in 32 bits and therefore doesn't allow absolute 32-bit addressing. The RIP-relative addressing is used by default, but since there is only RIP+imm32 addressing in x86-64 architecture, it cannot be used when there is any other register used in address. This is the limitation of x86-64 architecture and you have to take it into consideration when writing any code for the long mode. |
|||
01 Jun 2005, 10:23 |
|
Chewy509 01 Jun 2005, 23:28
Hi Privalov,
Thanks for clarifing the state of the 64bit code generation. You indicated that all x86-64 address generation uses RIP addressing, Quote: The RIP-relative addressing is used by default Code: movzx r10, byte [_my_byte] ;Uses RIP addressing movzx r10, byte [r0] ;Uses absolute addressing becuase of register. |
|||
01 Jun 2005, 23:28 |
|
Tomasz Grysztar 02 Jun 2005, 06:05
The answer is already in my post above:
Quote: (...) since there is only RIP+imm32 addressing in x86-64 architecture, it cannot be used when there is any other register used in address. |
|||
02 Jun 2005, 06:05 |
|
Chewy509 05 Jun 2005, 23:51
Thanks! (Sorry, misread the post, and got a little confused )
|
|||
05 Jun 2005, 23:51 |
|
fly 06 Jun 2005, 14:26
i have a question regarding global variable addressing. the code below works fine if the "format ELF64 executable" is used, but produces a segfault if an elf object is generated and linked by using ld. i believe the relocation is responsible for that, but i do not know how that i can write to the variable in a other way...
please, can anybody help me? Code: format ELF64 public _start section '.data' writeable times 1951 db 0 variable dq 0 section '.text' executable _start: mov [variable], rax int 3 ret ;eof |
|||
06 Jun 2005, 14:26 |
|
scientica 06 Jun 2005, 14:44
hmmm.. segevs for me too:
Code: frekla@zeus /tmp $ fasm test.asm test.o flat assembler version 1.61.1 1 passes, 2485 bytes. frekla@zeus /tmp $ ld test.o -o test frekla@zeus /tmp $ file test test: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), statically linked, not stripped frekla@zeus /tmp $ ./test Segmenteringsfel gdb says this: Code: (gdb) run Program received signal SIGSEGV, Segmentation fault. 0x00000000004000e8 in _start () ---------------- Dump of assembler code for function _start: 0x00000000004000e8 <_start+0>: mov ds:0x798,rax 0x00000000004000ef <_start+7>: int 0x3 0x00000000004000f1 <_start+9>: ret End of assembler dump. I have set gdb to use intel syntax, but I begin to wonder... (gdb is a bitch (im!ho)) |
|||
06 Jun 2005, 14:44 |
|
Tomasz Grysztar 06 Jun 2005, 20:25
OK, finally found the bug that caused all those problems with ELF64 object - look out for 1.61.10 release, it's going to have it fixed.
|
|||
06 Jun 2005, 20:25 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.