News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

BSS

Started by mabdelouahab, September 10, 2020, 09:35:24 PM

Previous topic - Next topic

mabdelouahab


.data?
data01 db 1073741824 dup(?)
data02 db 1073741824 dup(?)
.code
main PROC SYSTEMV      _argc:DWORD, _argv:QWORD
xor rax,rax
ret
main ENDP
end

linux: 6963 Segmentation fault   
.data?
data01 db 1073741824 dup(?)
data02 db 1073741824 dup(?)
.code
entry_point proc
XOR RAX,RAX
ret
entry_point endp
end

windows: 00000005

Are there limits to BSS, How can I use 4 GB?

Vortex

Hi mabdelouahab,

Why not to use dynamic memory allocation functions?

BugCatcher

.data?
data01 QWORD ?

invoke   GlobalAlloc,GMEM_ZEROINIT,1073741824
mov data01,rax

mabdelouahab

Thank you Vortex, I know the allocation dynamically , But my question is about the limits of BSS
invoke g_malloc,16032385536
mov view,rax
mov rcx,16032385536-32
add rax,rcx
mov dword ptr [rax],"DCBA"
mov dword ptr [rax+4],"HGFE"
mov qword ptr [rax+8],0
invoke printf,str$(<13,10,"0%Xh='%s' ">),rax   ,rax

Quote07D5C69F0h='ABCDEFGH'
16GB

BugCatcher

Its been my experience that large amount bss can be compiled, but it takes forever for the assembler to do it.

jj2007

Quote from: BugCatcher on September 11, 2020, 12:38:11 AM
Its been my experience that large amount bss can be compiled, but it takes forever for the assembler to do it.

This was true for older versions of MASM.

Vortex


Hi mabdelouahab,

No any error messages in my test :

.data?
data01 db 1073741824 dup(?)
data02 db 1073741824 dup(?)
.code
entry_point proc
XOR RAX,RAX
ret
entry_point endp
end


uasm64.exe -win64 test.asm
UASM v2.49, Jun 21 2019, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

test.asm: 9 lines, 2 passes, 2 ms, 0 warnings, 0 errors

mabdelouahab

Vortex ,
After running: 00000005 (windows) or 6963 Segmentation fault  (linux)

mineiro

hello sir mabdelouahab, these are my tests in linux 64
test2.uasm

;uasm -elf64 -pie test2.uasm
;ld test2.o -o test2
;./test2 ; echo $?

.X64
option casemap:none

.data?
data01 db 7FFFFFFFh dup(?)
data02 db 7FFFFFFFh dup(?)

.code

_start:
mov rdi,0   ;return code
mov rax,60  ;sysexit
syscall

end _start



;---first try
; data01 db 80000000h dup(?)       ;Error A2209: Count must be positive or zero

;---second try
; data01 db 7FFFFFFFh dup(?)       ;OK to assemble, link and execute

;---third try
; data01 db 7FFFFFFFh dup(?)       ;pseudo OK to assemble, link and execute
; data02 db 7FFFFFFFh dup(?)       
;readelf -S test2.o
; [ 3] .bss              NOBITS           0000000000000000  00000210
;      fffffffffffffffe  0000000000000000  WA       0     0     16
;readelf -S test2
;   No bss section created in executable
;size test2
;   text    data     bss     dec     hex filename
;     16       0       0      16      10 test2
;size test2.o
;   text    data     bss     dec     hex filename
;     16       0 18446744073709551614         14       e test2.o


;fourth try, using previous test.o and changing with hexadecimal editor fffffffffffffffeh at offset 120h
;to FF FF FF FF │ 00 00 00 00
;link OK, execute OK
; [ 3] .bss              NOBITS           0000000000000000  00000210            object file
;       00000000ffffffff  0000000000000000  WA       0     0     16
;[ 2] .bss              NOBITS           0000000000402000  00002000             executable
;       0000000100000000  0000000000000000  WA       0     0     16


;fifth try, using previous test.o and changing with hexadecimal editor FF FF FF FF │ 00 00 00 00 at offset 120h
;to 00 00 00 00 │ 10 00 00 00
;link OK, execute return 139 segmentation fault
;[ 3] .bss              NOBITS           0000000000000000  00000210
;       0000001000000000  0000000000000000  WA       0     0     16
;strace ./test2 ; echo $?
;execve("./test2", ["./test2"], 0x7ffc150b9e40 /* 65 vars */) = -1 ENOMEM (Not possible to alloc memory)
;+++ killed by SIGSEGV +++


So I try with as assembler same tests and increasing allocation data:
test3.s

#as test3.s -o test3.o
#ld -e _start test3.o -o test3
#./test3 ; echo$?

.code64
.intel_syntax noprefix
.bss
data01: .space  0x40fffffff

.text
.global _start
_start:
mov rdi,0
mov rax,60
syscall


I was thinking in elf64 field but thats 64 bits, so not a problem. After I think in 48 bits addressing of some machines or hardware limitation of some machines. After I think in some link switches but was not able to find anything; so I check ld loader, ... . But when I tried with as assembler I see that can be done.
Maybe some field in object file.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything