flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > RAW ELF64, invoke, and syscall (linux)

Author
Thread Post new topic Reply to topic
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 14 Aug 2009, 12:57
Even though some, not all, are maddening enough, no reason some one who could appreciate these cannot. I had some 32bit stuff, but it's kinda outdated and unstable...

Code:
include '/fasminc/easyhead.inc'
include '/fasminc/unistd64.inc'

includes "libgtk-x11-2.0.so", gtk_init,\
        "libc.so.6", printf

hello db "%f", 10, "%f", 10, 0
moo dq 433f
moo2 dd 42f
hello2 db "%i", 10, 0
entrypoint:
 invoke printf, hello, double [moo], float [moo2]
    syscalls sys_exit
endprog:    


Some example code for the uploaded incs. Note that the library files are in quotation marks.

code can be found in the download

I stuck that in unistd64.inc, but i wouldn't want to upload something so incomplete so i just left the syscalls macro itself here in a code tag.


Description: A much, much cleaner update. This has a few bug fixes and the like, however it was more intended for my own personal use. If you're worried about copyrights and stuff, that's why i'm not deleting the older version. The appropriate stuff is there.
Download
Filename: linhead64.inc
Filesize: 16.64 KB
Downloaded: 413 Time(s)

Description:
Download
Filename: raw.tar.gz
Filesize: 6.94 KB
Downloaded: 416 Time(s)



Last edited by kohlrak on 26 Feb 2010, 14:13; edited 5 times in total
Post 14 Aug 2009, 12:57
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 14 Aug 2009, 22:10
current version can be found in the first post.


Last edited by kohlrak on 17 Aug 2009, 04:12; edited 1 time in total
Post 14 Aug 2009, 22:10
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 15 Aug 2009, 08:24
more updates (mere optimization [amd happy, but for the intels i did restrict them to 32bit] update)

current version can be found in the first post.


Last edited by kohlrak on 17 Aug 2009, 04:10; edited 1 time in total
Post 15 Aug 2009, 08:24
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 15 Aug 2009, 15:14
Testing by practical usage makes for lots of updates...

current version can be found in the first post.


Last edited by kohlrak on 17 Aug 2009, 04:09; edited 1 time in total
Post 15 Aug 2009, 15:14
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 16 Aug 2009, 05:34
kohlrak, could you upload the missing includes? (unistd64.inc & gtk.inc)

I have tried your example but this occured:
Code:
loco@athlon64:~/Desktop/fasm/gtk-examples$ ./kohlrak.l64 
./kohlrak.l64: error while loading shared libraries: libgtk-x11-2.0.so: cannot open shared object file: No such file or directory    

Then I've changed includes "libgtk-x11-2.0.so" to includes "libgtk-x11-2.0.so.0" and it worked!
Code:
loco@athlon64:~/Desktop/fasm/gtk-examples$ ./kohlrak.l64 
destroy
Trace/breakpoint trap    
(Ignore the error, I've replaced "syscalls sys_exit" with int3 because it was uncompilable)

I don't know how standard the new name I've chosen for gtklib is, but clearly on my system (Ubuntu 9.04), the original name was not enough.
Code:
loco@athlon64:~/Desktop/fasm/gtk-examples$ ls -l /usr/lib/libgtk-x11-2.0.so*
lrwxrwxrwx 1 root root      26 2009-08-08 17:14 /usr/lib/libgtk-x11-2.0.so.0 -> libgtk-x11-2.0.so.0.1600.1
-rw-r--r-- 1 root root 4169528 2009-04-16 22:12 /usr/lib/libgtk-x11-2.0.so.0.1600.1    


Here the code I've tested:
Code:
include 'includes/easyhead.inc'
;include 'includes/unistd64.inc'
include 'includes/gtk.inc'

includes "libgtk-x11-2.0.so.0", gtk_init, gtk_window_new, gtk_widget_show, gtk_main, gtk_main_quit, g_signal_connect_data, g_type_check_instance_cast,\
        "libc.so.6", printf

strdestroy db "destroy", 0
fmt        db "%s", 10, 0 ; Because if there is no LF the string is not output (because it remains buffered)
entrypoint:
        invoke gtk_init, QWORD [rsp], QWORD [rsp+16]
        invoke gtk_window_new, GTK_WINDOW_TOPLEVEL
        mov r15, rax
        invoke gtk_widget_show, rax
        invoke g_type_check_instance_cast, r15, 50h
        invoke g_signal_connect_data, rax, strdestroy, hakai, 0, 0 ;For some reason it segfaults if this isn't 0ed...
        invoke gtk_main
;        syscalls sys_exit
int3
hakai:  invoke printf, fmt, strdestroy
        invoke gtk_main_quit
        ret
endprog:    
(I've used gtk.inc from bazik's examples)
Post 16 Aug 2009, 05:34
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 16 Aug 2009, 14:13
Quote:
I don't know how standard the new name I've chosen for gtklib is, but clearly on my system (Ubuntu 9.04), the original name was not enough.


Odd, i never placed the link there myself, but i'll keep a note of it for the future, thanks. Though, i must point out that i'm also using Ubuntu 9.04. It might be from an additional package I installed (i couldn't find any gtk sos in my lib folders [apparently i didn't look hard enough the first time] and i went install crazy on anything with "lib" and "gtk" in it).

Quote:
(Ignore the error, I've replaced "syscalls sys_exit" with int3 because it was uncompilable)


uncompilable from some kind of bug in my code or lack of a sys_exit (pretty sure a lack of sys_exit, but i've only ever used this stuff on my machine so i must ask...)?

Quote:
(I've used gtk.inc from bazik's examples)


I guess i should've mentioned that too... Sorry about that, all.

I also have been working more with GTK and found that the type check is just something annoying i've found when disassembling C code. It's unnecessary (though, naturally, switch the rax to r15 if you remove it).
Post 16 Aug 2009, 14:13
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 16 Aug 2009, 17:18
Quote:

Odd, i never placed the link there myself, but i'll keep a note of it for the future, thanks. Though, i must point out that i'm also using Ubuntu 9.04. It might be from an additional package I installed (i couldn't find any gtk sos in my lib folders [apparently i didn't look hard enough the first time] and i went install crazy on anything with "lib" and "gtk" in it).
I'm using a nearly fresh installation (I've not installed anything related to development yet). The link was not created by me. What I meant is that I hope the new lib name I've used (libgtk-x11-2.0.so.0), is standard enough to be available in most distros. Other alternative could be libgtk-x11-2.0.so.0.1600.1 but that one will hardly work everywhere. Is ibgtk-x11-2.0.so.0 present in your installation?

Quote:
uncompilable from some kind of bug in my code or lack of a sys_exit (pretty sure a lack of sys_exit, but i've only ever used this stuff on my machine so i must ask...)?


Because of two reasons, first I forgot to copy from the forum your syscalls macro and second because sys_exit is not defined anywhere (because it is in unistd64.inc?)
Post 16 Aug 2009, 17:18
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 16 Aug 2009, 23:55
Quote:
I'm using a nearly fresh installation (I've not installed anything related to development yet). The link was not created by me. What I meant is that I hope the new lib name I've used (libgtk-x11-2.0.so.0), is standard enough to be available in most distros. Other alternative could be libgtk-x11-2.0.so.0.1600.1 but that one will hardly work everywhere. Is ibgtk-x11-2.0.so.0 present in your installation?


I have 2 links, one without the .0 and one with. I made another link called libgtk earlier but i deleted it (i made it since the "-" was a problem for a previous version of the includes macro. I used the one without the .0 because i was afraid that it would cause my code to break in a year or so if they came out with a major update to the version (like with libc.so.6, as it's not libc.so.0). However, from now on i'll keep in mind to use the .0.

Quote:
Because of two reasons, first I forgot to copy from the forum your syscalls macro and second because sys_exit is not defined anywhere (because it is in unistd64.inc?)


yea, which is where i put my syscalls macro, but since the unistd64.inc was something i copied somewhere (the linux amd64 examples maybe?) i figured that most people would have unistd64.inc and probably wouldn't want to throw a macro in it because it's not in the original file that everyone else already has. However, apparently i'll need to post a more complete set of files. I'll edit my original post with a new upload (that way no one has to search for it if this ends up going over lots of pages).

Note: Brownie points to whomever could possibly explain to me why invoke exit works but sys_exit doesn't terminate the GTK program after one of the button signals are called. And yes, it does exit the main loop and sys_exit did get called, but it wouldn't exit. (And don't tell me thread leak because it already bugs me enough that GTK uses runtime type checking. I'd like to think that GTK is better than trying to use Qt by using the mangled names.)
Post 16 Aug 2009, 23:55
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 17 Aug 2009, 02:23
I've downloaded Firefox from the official site (so distro independent, it was a tar.bz2, not a .deb or distro dependant packages).

Results:
Code:
loco@athlon64:~/Desktop$ readelf firefox-bin -d | grep gtk
 0x00000001 (NEEDED)                     Shared library: [libgtk-x11-2.0.so.0]    
BTW, some extra info could be found here: http://www.linuxfoundation.org/en/Specifications (I completely forgot it before)

In http://refspecs.linux-foundation.org/LSB_3.2.0/LSB-Desktop-AMD64/LSB-Desktop-AMD64.pdf I've found libgtk-x11-2.0.so.0 in page 38 (Table 3-1 Standard Library Names). I think we can be sure that this is the correct name now.
Post 17 Aug 2009, 02:23
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 17 Aug 2009, 04:07
Well they're all correct (i got that file link from somewhere too). I figured then that the one you have is the most proper since, as you've said, your install is pretty fresh. I'm now curious where i got it from.

Also, thanks for that link. The date on it is 2007, so i guess i don't have to panic about versioning anymore then, since this name has therefore then been used for at lease 2 whole years now, which would mean if and when the name does change again, it won't be for an even longer time until the next change (by then gtk might be on version 3 and therefore locking the file name permanent of gtk 2). This means that now i can also start using the correct file names for other libraries, too.

BTW, i'm gonna fix some of my update posts taking up so much space now that the current version is uploaded. All they're going to do is confuse people.
Post 17 Aug 2009, 04:07
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.