flat assembler
Message board for the users of flat assembler.

Index > Linux > How to make x32 objects and executable?

Author
Thread Post new topic Reply to topic
Jin X



Joined: 06 Mar 2004
Posts: 133
Location: Russia
Jin X 12 Apr 2017, 08:26
"format ELF executable 3" makes x86 executable
"format ELF64 executable 3" makes x64 executable
But how can I make x32 (x64 with 32-bit pointers) execetables?
https://en.wikipedia.org/wiki/X32_ABI

p.s. What does mean "3" after "executable" is these lines?
Post 12 Apr 2017, 08:26
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 12 Apr 2017, 09:58
It should be an ELF file with class ELFCLASS32 and machine EM_X86_64. fasm's "format ELF" is always ELFCLASS32/EM_386 and "format ELF64" is always ELFCLASS64/EM_X86_64. But you can experiment with the ELF formatting macros in fasmg, since they allow to set up these properties freely:
Code:
ELF.Settings.Class = ELFCLASS32
ELF.Settings.Machine = EM_X86_64
ELF.Settings.ABI = ELFOSABI_LINUX
include 'format/elfexe.inc'
include 'x64.inc'
use64    
Note that the value of "ELFOSABI_LINUX" constant is 3 and this is the value in "format ELF executable 3" clause.
Post 12 Apr 2017, 09:58
View user's profile Send private message Visit poster's website Reply with quote
Jin X



Joined: 06 Mar 2004
Posts: 133
Location: Russia
Jin X 13 Apr 2017, 08:30
Thanks!
But why don't you make "format ELFx32" support in original fasm?
Post 13 Apr 2017, 08:30
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 13 Apr 2017, 11:17
With fasmg's macros it is easier to test such things. If we test and make sure that changing these values is enough, I may try to implement it into fasm.
Post 13 Apr 2017, 11:17
View user's profile Send private message Visit poster's website Reply with quote
Jin X



Joined: 06 Mar 2004
Posts: 133
Location: Russia
Jin X 13 Apr 2017, 12:38
You may compare headers of x64 and x32 programs made by 'as'+'ld' or 'nasm' to be sure or to find other differences... Smile
Post 13 Apr 2017, 12:38
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 13 Apr 2017, 15:53
Jin X wrote:
You may compare headers of x64 and x32 programs made by 'as'+'ld' or 'nasm' to be sure or to find other differences... Smile
I may but I cannot say how soon that may happen. Wink
Post 13 Apr 2017, 15:53
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 20 Feb 2019, 09:09
See here for a working example.
Post 20 Feb 2019, 09:09
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.