Recent Posts

Pages: 1 2 [3] 4
21
Sol_Asm / Re: writing to data or bss section variables
« Last post by mineiro on August 12, 2016, 04:50:08 AM »
Thanks.

You have said on other topic about ideas to be implemented on linux side, well, I have some ideas.
On windows side, sol_asm offers a way to import functions from dinamic libraries (.dll). DLL's are just MZ files being Pe,Pe+, ... , and this type of file depending how it's configured can generate .exe, .dll, .sys, .scr, ... .
On linux side and object file it's an ELF header, an executable it's an ELF header, a dinamic library it's an ELF too, a module (driver) too, just fields change. The only exception is a static library that is just a concatenated of object files. So, I think that sol_asm can have options to generate an executable or a dinamic library.

I have sucessfully created a dinamic library example using sol_asm, appears that 'public' and 'export' have same meanings, I'm still checking.
A suggestion is change lin64 to cdecl, and by checking command line (-elf switch) know if calling convention is to 32 or 64 bits. But it's just a suggestion. Linux have as solid base C language.

Again, 10x
22
Sol_Asm / Re: writing to data or bss section variables
« Last post by bogdanontanu on August 11, 2016, 09:31:02 PM »
Hi mineiro,

I will check this also ;)
23
Sol_Asm / Re: writing to data or bss section variables
« Last post by mineiro on August 09, 2016, 11:43:43 PM »
Hello, it's meeeee   :P
Well, new issues Bogdan.
I'm not on my computer so can't send a source code testcase, but, I was looking for encoding of some instructions, can you check?
mov rax,[r12]
I have tried with others registers too like r13,r14,15 and same problem.

I think this other issue is relocation but on data section I have created 5 variables, like
 one db 'one',0
going to five.
After I create a reference of these variables as pointers, like
pointers dq one,two,three,four,five
The issue appeared like below:
szpointers dq (($-pointers)/8)
It's generating on passes correct value but on execution not.

Oh ye, I remember other think, you know when we are subclasssing on Windows O.S., so we offer as a parameter of a function the procedure that will deal(handle) with that manipulations? Well, this procedure is inside same code ok. I don't have tried this on windows, only on linux, but, if we make a reference to that procedure as being outside source code (like extern) it does not work. An pseudo example can be:
invoke hash_function,mystring1,mystring2,strlen
So, I'm talking about that strlen function as parameter, but not strlen writed by me, instead this, strlen that O.S. offers inside .dll
An other pseudo example
invoke myfunction,MessageBoxExa, ... .
This remove overhead on code. This happens on fastcall calling convention.

Thanks.
24
Sol_Asm / Re: writing to data or bss section variables
« Last post by mineiro on August 04, 2016, 12:24:37 AM »
Thank you sir Bogdan.
Downloading sol_asm now.
Be in peace brother.
25
Sol_Asm / Re: writing to data or bss section variables
« Last post by bogdanontanu on August 01, 2016, 11:12:44 PM »
Hi mineiro,

There is a new version here:
http://www.oby.ro/sol_asm/files/sol_asm_2016_08_01_v36_34.zip

It fixes a lot of relocations issues for ELF64 / Linux
26
Sol_Asm / Re: writing to data or bss section variables
« Last post by bogdanontanu on July 27, 2016, 07:25:06 PM »
Yes, I will check this too ;)
27
Sol_Asm / Re: writing to data or bss section variables
« Last post by mineiro on July 27, 2016, 02:03:18 AM »
Can you check this too, not sure if this is my fault but I'm being unable to write a literal string inside some structure.
I perceived that when using duplicated names some mistakes happen. Like same name on variable and after defined as a literal string.
Code: [Select]
.use64
section "text" class_code alias ".text"
section "data" class_data alias ".data"
section "bss"  class_bss  alias ".bss"

struct person
name rq 1
age rq 1
ends

struc literal
header rb 1   ;dq ?
ends

.entry _start

.data
align 16
tst db "test",0
test db "tst",0 ;<--If I change test to tt works fine

align 16
_name0 person {
name = tst
age = 10
}

align 16
_name1 person {
name = test
age = 20
}

myheader literal {
header = "E" ;<--**Can not take string here: "E", but hexadecimal values are OK
}

.text
_start:
mov rax,_name0
mov rax,_name1
mov rdi,0
mov rax, 60
syscall
 
/*
sol_asm2 struc0.solasm struc0.o -elf64
ld -m elf_x86_64 -o struc0 struc0.o
rm struc0.o
*/
Again, thanks Sir.

----edited---
On code below appears that it's happening an avalanche on structure. Code below needs glib and libc libraries, but if you assembly probably the same error happens to you.
Code: [Select]
.use64
section "text" class_code alias ".text"
section "data" class_data alias ".data"
section "bss"  class_bss  alias ".bss"

struct GSList
data dq ?
next dq ?
ends

struct person
name dq ?
age dq ?
ends

;include g.inc
extern g_list_append lin64
extern g_list_first lin64
extern g_print lin64
extern g_slist_length lin64
extern g_slist_append lin64
extern g_slist_free lin64
extern g_slist_prepend lin64
extern g_slist_remove lin64
extern g_slist_remove_all lin64
extern g_slist_last lin64
extern g_slist_nth lin64
extern g_slist_nth_data lin64
extern g_slist_next lin64

;include c.inc
extern exit lin64

.entry _start

.bss
align 16
list rs GSList,1
;list rq 1

align 16

.data
align 16
one db "one",0
align 16
two db "two",0
align 16
three db "three",0
align 16
now db "The list is now %d items long",10,0
align 16
last db "The last item is '%s'",10,0
align 16
item db "index %d have string %s",10,0

align 16
avatar db "mineiro",0
align 16
pseudo person { avatar , 10 } ;<-comment this line and works fine

.text
_start:
  xor rax,rax
  mov [list.data],rax
  mov [list.next],rax
  invoke g_slist_length,[list.next]
  invoke g_print,now,rax
 
  invoke g_slist_append,[list.next],one
  mov [list.next],rax
  invoke g_slist_prepend,[list.next],three
  mov [list.next],rax
  invoke g_slist_append,[list.next],two
  mov [list.next],rax
  invoke g_slist_prepend,[list.next],three
  mov [list.next],rax
  invoke g_slist_prepend,[list.next],three
  mov [list.next],rax
  invoke g_slist_append,[list.next],two
  mov [list.next],rax
  invoke g_slist_length,[list.next]
  invoke g_print,now,rax

  invoke g_slist_remove,[list.next],two
  mov [list.next],rax
  invoke g_slist_length,[list.next]
  invoke g_print,now,rax
 

  invoke g_slist_remove_all,[list.next],three
  mov [list.next],rax
  invoke g_slist_length,[list.next]
  invoke g_print,now,rax

  invoke g_slist_last,[list.next]
  invoke g_print,last,[rax]

  invoke g_slist_nth,[list.next],1
  invoke g_print,item,1,[rax]

  invoke g_slist_nth_data,[list.next],0
  invoke g_print,item,0,rax

;invoke g_slist_next,[list.next],0
  mov rax,[list.next]
  mov rax,[rax+GSList.next]
  invoke g_print,item,1,[rax]

  invoke g_slist_free,list
  invoke exit,0

/*
sol_asm2 gslist1.solasm gslist1.o -elf64
ld -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -L/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lglib-2.0 -lc -o gslist1 gslist1.o
rm gslist1.o
*/
28
Sol_Asm / Re: writing to data or bss section variables
« Last post by bogdanontanu on July 26, 2016, 11:46:57 PM »
Hi mineiro,

Thanks for testing this.

I will check it out and fix it ;)
29
Sol_Asm / writing to data or bss section variables
« Last post by mineiro on July 26, 2016, 07:04:40 PM »
Hello sir Bogdan, I hope you're fine.
I'm being able to write on variables into data or bss section by using registers but not using direct value.
Code: [Select]
.use64
section "text" class_code alias ".text"
section "data" class_data alias ".data"
section "bss"  class_bss  alias ".bss"

.entry _start

.bss
test dq ?

.data
tst dq 0

.text
_start:
  mov [test], 0  ;<---
  mov [tst], 0   :<---

  mov rdi,0
  mov rax, 60
  syscall
 
/*
sol_asm2 mov0.solasm mov0.o -elf64
ld -m elf_x86_64 -o mov0 mov0.o
rm list.o
*/
I'm able to 'xor eax,eax' or 'xor rax,rax' and after mov zeroed register to tst or test variable. But if I try direct number on that variables, on bss section solasm give me some errors while assembling and on data section assemble fine but when I execute program I'm receiving segmentation fault.
thanks.
30
Sol_Asm / Re: Some questions
« Last post by bogdanontanu on July 12, 2016, 07:45:23 PM »
Hi,

 Thanks for testng sol_asm ;)

Addressing a struct without using a register should work.

Something like this:

Code: [Select]

struc point
x rd 1
y rd 1
z rd 1
ends

.data
my_point rs point,1

.code
mov [my_point.x],eax
mov [my_point.y],2
mov [my_point.z],3


Size of a structure is:

Code: [Select]
    mov eax,size point

I will check the other issues and fix them.
Pages: 1 2 [3] 4