News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Block nesting error

Started by mineiro, January 24, 2023, 11:59:23 AM

Previous topic - Next topic

mineiro

I'm receiving Block nesting error if I try to use invoke inside (.init) segment.
I'm missing something? Linux x86-64.

;Example of constructor, destructor, signal handling.
;uasm -elf64 cd_signal.asm
;gcc cd_signal.o -o cd_signal -no-pie -fno-pie -lc
;rm cd_signal.o

.X64
option casemap:none

exit proto systemv status:dword
printf proto systemv pformat:PTR, arg:VARARG
signal proto s:dword,handler:ptr

SIGINT         equ  2

_fini segment alias(".fini")
mov rax,0
lea rdi,dtor
call printf
_fini ends

_init segment alias(".init")
;invoke printf,CSTR("alo mundo",10)     ;<---this line   ;cd_signal.asm(27) : Error A2080: Block nesting error: _init
;invoke printf,CStr("alo mundo",10)     ;<---or this line
mov rax,0
lea rdi,ctor
call printf
_init ends


_DATA segment public use64 'DATA'
align 16
ctor db "constructor",10,0
align 16
dtor db "destructor",10,0
_DATA ends

.data?
.data
.code

main proc uses rbx r12 r13 r14 r15 _argc:dword,_argv:ptr
local argc:dword
local argv:qword

mov argc,_argc
mov argv,_argv

invoke signal,SIGINT,addr controlc  ;control+c procedure

invoke printf,CStr("main loop, hit control + c",10)

mov rcx,-1
.while rcx != 0
    dec rcx
.endw
ret
main endp

align 16
controlc proc
invoke printf,CStr(13,"Pressed control + c, exiting",10)
invoke exit,1
ret
controlc endp

end main




./cd_signal
constructor
main loop, hit control + c
Pressed control + c, exiting
destructor
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

johnsa

I've not tried using anything but the simplified directives with linux, I will have to investigate this.

johnsa

have you tried setting up the segment without the alias? and possibly try adding some other directives like use64 etc.

mineiro

Thanks for answering sir johnsa.
Yes, I tried that but no luck.

The segment name should start with a dot.
If I use code below, program works, but when I try to use invoke in that segment so the message of Block nesting error appear.

option dotname
.fini segment
.fini ends

I tried the assume directive to set the segment registers, without success. I tried to set the use of segments before their use, but without success.
I tried to not use CStr, and invoke works fine.
So, sounds that it's CStr my problem. It's just for convenience, no need to worry.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything