flat assembler
Message board for the users of flat assembler.
Index
> Linux > IS there will be support for x86_x32 |
Author |
|
gens 03 Feb 2014, 16:22
afaik x32 is just an ABI
http://lwn.net/Articles/456731/ and the project site https://sites.google.com/site/x32abi/ didnt look much at it, but it seems like its just 32bit pointers (and structs and connected things) in 64bit mode i also looked at my local kernel source... well just checked quick and cant find x32 syscall list, but it should be there somewhere (again, didnt look hard) ofc, you can use 32bit calls to the kernel no problem and to shared lib's, with a little problem (linking) so as i understand it should not be a problem (thinking about it maybe general memory access is bit different, but i know only to do 64bit so:)) |
|||
03 Feb 2014, 16:22 |
|
Melissa 04 Feb 2014, 23:02
No it's not just an aBI. It's distinct elf file type,
and wont link with 64 bit elfs. Also there are versions of libraries specific to this format which are linked when used -mx32 flag. File type is recognized as : ELF 32-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.4.0, |
|||
04 Feb 2014, 23:02 |
|
gens 05 Feb 2014, 21:10
my bad
edit: http://www.linuxplumbersconf.org/2011/ocw/system/presentations/531/original/x32-LPC-2011-0906.pptx yes, plenty of things diferent |
|||
05 Feb 2014, 21:10 |
|
HaHaAnonymous 22 Mar 2015, 20:02
Quote:
I do not know what is the point... because: 1.32bit only machines will not run 64bit code. 2.If this is to be run on 32bit OS and the machine supports 64bit then it does not make sense to install a 32bit OS to run 64bit code. Seems confusing for now. But it works if you want to run 32bit code in 64bit mode, you can alternate between 32/64bit code as you wish: Code: format ELF64 executable 3 entry woof use32 align 16 woof: mov eax,$04 mov ebx,$01 mov ecx,str0 mov edx,_str0 int $80 use64 and edi,$00 mov eax,$3C syscall ; force exception on modified kernels that returns after exit (i.e. fake exit) ud2 segment readable align 8 str0: db 'Woof, woof! :D',$0A _str0 = $-str0 |
|||
22 Mar 2015, 20:02 |
|
revolution 20 Feb 2019, 09:08
A working example of x32
Code: USE_LIBC = 1 IS_DYNAMIC = 1 if IS_DYNAMIC format ELF dynamic 3 at 1 shl 32 - 0x10000 else format ELF executable 3 at 1 shl 32 - 0x10000 end if entry start segment gnustack segment executable use64 start: lea edi,[maps] mov esi,O_RDONLY xor edx,edx if USE_LIBC call [open] else mov eax,SYS_OPEN syscall end if mov edx,0x1000 sub esp,edx mov edi,eax mov eax,SYS_READ mov esi,esp syscall mov edx,eax mov eax,SYS_WRITE mov edi,STD_OUTPUT mov esi,esp syscall mov eax,SYS_EXIT xor edi,edi syscall SYS_x32 = 0x40000000 SYS_READ = SYS_x32 or 0 SYS_WRITE = SYS_x32 or 1 SYS_OPEN = SYS_x32 or 2 SYS_EXIT = SYS_x32 or 60 STD_INPUT = 0 STD_OUTPUT = 1 O_RDONLY = 0 PROT_READ = 0x1 DT_NULL = 0 DT_NEEDED = 1 DT_STRTAB = 5 DT_SYMTAB = 6 DT_RELA = 7 DT_RELASZ = 8 DT_RELAENT = 9 DT_STRSZ = 10 DT_SYMENT = 11 DT_BIND_NOW = 24 DT_FLAGS = 30 DT_FLAGS_1 = 0x6ffffffb STB_GLOBAL = 1 STT_FUNC = 2 R_386_32 = 1 DF_BIND_NOW = 0x00000008 DF_1_NOW = 0x00000001 DF_1_PIE = 0x08000000 macro Elf32_Sym name,value,size,bind,type,other,shndx { dd name+0 dd value+0 dd size+0 db (bind+0) shl 4 + (type+0) db other+0 dw shndx+0 } macro Elf32_Rela offset,symbol,type,addend { dd offset+0 dd (symbol+0) shl 8 + (type+0) dd addend+0 } virtual at 0 Elf32_Sym sizeof.Elf32_Sym = $ Elf32_Rela sizeof.Elf32_Rela = $ - sizeof.Elf32_Sym end virtual if USE_LIBC segment interpreter readable db '/libx32/ld-linux-x32.so.2' strtab: db 0 _libc db 'libc.so.6',0 _open db 'open',0 strsz = $ - strtab maps: db '/proc/self/maps',0 segment dynamic readable dd DT_NEEDED,_libc - strtab dd DT_STRTAB,rva strtab dd DT_STRSZ,strsz dd DT_SYMTAB,rva symtab dd DT_SYMENT,sizeof.Elf32_Sym dd DT_RELA,rva rela dd DT_RELASZ,relasz dd DT_RELAENT,sizeof.Elf32_Rela dd DT_BIND_NOW,1 dd DT_FLAGS,DF_BIND_NOW dd DT_FLAGS_1,DF_1_NOW or DF_1_PIE dd DT_NULL,0 symtab: Elf32_Sym Elf32_Sym _open - strtab,0,0,STB_GLOBAL,STT_FUNC,0,0 rela: Elf32_Rela open,1,R_386_32,0 relasz = $ - rela open dq 0 segment readable writeable else segment readable maps: db '/proc/self/maps',0 end if Code: printf "\x3e" | dd of=<filename> obs=1 seek=18 count=1 conv=notrunc Last edited by revolution on 20 Feb 2019, 21:55; edited 2 times in total |
|||
20 Feb 2019, 09:08 |
|
Tomasz Grysztar 20 Feb 2019, 09:55
Note that my official x32 examples (fasmg only) are here: https://github.com/tgrysztar/fasmg/tree/master/packages/x86/examples/linux/x32
|
|||
20 Feb 2019, 09:55 |
|
revolution 20 Feb 2019, 11:34
HaHaAnonymous wrote: I do not know what is the point... because: According to WP Quote: Though the x32 ABI limits the program to a virtual address space of 4 GiB, it also decreases the memory footprint of the program by making pointers smaller. This can allow it to run faster by fitting more data into cache. The best results during testing were with the 181.mcf SPEC CPU 2000 benchmark, in which the x32 ABI version was 40% faster than the x86-64 version. On average, x32 is 5–8% faster on the SPEC CPU integer benchmarks compared to x86-64. There is no speed advantage over x86-64 in the SPEC CPU floating-point benchmarks. |
|||
20 Feb 2019, 11:34 |
|
guignol 20 Feb 2019, 21:43
And the tests on power usage?
|
|||
20 Feb 2019, 21:43 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.