flat assembler
Message board for the users of flat assembler.

Index > Linux > 64bit..?

Author
Thread Post new topic Reply to topic
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
No more giving back...


Last edited by kohlrak on 07 Aug 2008, 14:51; edited 1 time in total
Post 27 Apr 2008, 03:55
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
gunblade



Joined: 19 Feb 2004
Posts: 209
gunblade
I know you mentioned you found some answers to it, but just in case your looking for more, there are some linux 64-bit examples on the example section of the fasm site: http://flatassembler.net/examples/fasm_amd64_linux64_samples.tar.gz
(Ignore the fact that it says "AMD64", its just 64-bit and will run on both intel and amd 64-bit processors)
Very useful examples.
Post 27 Apr 2008, 22:11
View user's profile Send private message Reply with quote
mattst88



Joined: 12 May 2006
Posts: 260
Location: South Carolina
mattst88
I've got some example x86-64 code in my git repo. It uses libc functions also.

http://git.mattst88.com/x86_64-assembly/

Also, check out the x86-64 ABI for calling convention information.


Last edited by mattst88 on 09 Feb 2013, 23:31; edited 1 time in total
Post 28 Apr 2008, 02:10
View user's profile Send private message Visit poster's website Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
No more giving back...


Last edited by kohlrak on 07 Aug 2008, 14:51; edited 1 time in total
Post 28 Apr 2008, 07:39
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 454
Location: Czech republic, Slovak republic
Feryno
this kernel limitation (or bug?) was present in AMD64 kernels few years ago:
ELF64 - last section must be writeable (else you got page faults)
I don't have any serious explanation of this strange fact
Post 28 Apr 2008, 10:39
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Quote:

I don't have any serious explanation of this strange fact

Sorry, I don't have the link but I'm pretty sure I read somewhere that this bug was intruduced because of a fix on a vulnerability with ELFs.

Anyway, this bug was fixed long time ago and surely Ubuntu comes with a newer enough kernel.
Post 28 Apr 2008, 16:18
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
No more giving back...


Last edited by kohlrak on 07 Aug 2008, 14:52; edited 2 times in total
Post 29 Apr 2008, 03:50
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
Endre



Joined: 29 Dec 2003
Posts: 212
Location: Budapest, Hungary
Endre
I changed you libcdemo for 64bit system. It uses strict AMD64 ABI, however gcc would merely use 32 bit registers for passing parameters.
Code:
; fasm example of using the C library in Linux
; compile the source with commands like:
;   fasm libcdemo.asm
;   gcc -s libcdemo.o -o libcdemo

format ELF64

section '.text' executable

public main
extrn printf
extrn getpid

main:
        push    rbp
        mov     rbp, rsp
       call    getpid
        mov     rdi, msg        ; message pointer
        mov     rsi, rax        ; pid
        mov     rax, 0          ; count of sse registers passed
     call    printf
        leave
     ret

section '.data' writeable

msg db "Current process ID is %d.", 0xa, 0
    
Post 29 Apr 2008, 12:06
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
No more giving back...


Last edited by kohlrak on 07 Aug 2008, 14:55; edited 1 time in total
Post 29 Apr 2008, 20:34
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
Endre



Joined: 29 Dec 2003
Posts: 212
Location: Budapest, Hungary
Endre
Oh sorry, now I see what you just want to do. I have checked nocona's code. I like the idea. The executable size is really much smaller.
Have you by the way checked what libraries your program is related to?
I mean:
Code:
ldd ./test.bin    

I guess this is the answer on why you do not have to specify libc for printf or exit - it simply comes with libgtk. If you compiles a C-program with gcc you get libc with libgcc automagically even if you have not particularly specified it for the linker.
Post 30 Apr 2008, 14:06
View user's profile Send private message 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-2020, Tomasz Grysztar.

Powered by rwasa.